[openssl-commits] [openssl] master update

Richard Levitte levitte at openssl.org
Tue Mar 24 11:22:14 UTC 2015


The branch master has been updated
       via  2383a74be14d26d57bf7e56a2f2688705577d5e7 (commit)
       via  912d7c75d41a36bac2371f4e3a440eca86b6489b (commit)
      from  77b1f87214224689a84db21d2eb54e9497186d93 (commit)


- Log -----------------------------------------------------------------
commit 2383a74be14d26d57bf7e56a2f2688705577d5e7
Author: Richard Levitte <levitte at openssl.org>
Date:   Tue Mar 24 12:16:31 2015 +0100

    Use OPENSSL_malloc rather than malloc/calloc
    
    Reviewed-by: Matt Caswell <matt at openssl.org>

commit 912d7c75d41a36bac2371f4e3a440eca86b6489b
Author: Richard Levitte <levitte at openssl.org>
Date:   Tue Mar 24 08:38:22 2015 +0100

    Fix eng_cryptodev to not depend on BN internals.
    
    Reviewed-by: Matt Caswell <matt at openssl.org>

-----------------------------------------------------------------------

Summary of changes:
 crypto/engine/eng_cryptodev.c | 27 +++++++++------------------
 1 file changed, 9 insertions(+), 18 deletions(-)

diff --git a/crypto/engine/eng_cryptodev.c b/crypto/engine/eng_cryptodev.c
index 65efc81..d005e01 100644
--- a/crypto/engine/eng_cryptodev.c
+++ b/crypto/engine/eng_cryptodev.c
@@ -30,7 +30,6 @@
 #include <openssl/engine.h>
 #include <openssl/evp.h>
 #include <openssl/bn.h>
-#include "../bn/bn_lcl.h"
 
 #if (defined(__unix__) || defined(unix)) && !defined(USG) && \
         (defined(OpenBSD) || defined(__FreeBSD__))
@@ -1014,7 +1013,6 @@ cryptodev_engine_digests(ENGINE *e, const EVP_MD **digest,
  */
 static int bn2crparam(const BIGNUM *a, struct crparam *crp)
 {
-    int i, j, k;
     ssize_t bytes, bits;
     u_char *b;
 
@@ -1022,9 +1020,9 @@ static int bn2crparam(const BIGNUM *a, struct crparam *crp)
     crp->crp_nbits = 0;
 
     bits = BN_num_bits(a);
-    bytes = (bits + 7) / 8;
+    bytes = BN_num_bytes(a);
 
-    b = malloc(bytes);
+    b = OPENSSL_malloc(bytes);
     if (b == NULL)
         return (1);
     memset(b, 0, bytes);
@@ -1032,14 +1030,7 @@ static int bn2crparam(const BIGNUM *a, struct crparam *crp)
     crp->crp_p = (caddr_t) b;
     crp->crp_nbits = bits;
 
-    for (i = 0, j = 0; i < a->top; i++) {
-        for (k = 0; k < BN_BITS2 / 8; k++) {
-            if ((j + k) >= bytes)
-                return (0);
-            b[j + k] = a->d[i] >> (k * 8);
-        }
-        j += BN_BITS2 / 8;
-    }
+    BN_bn2bin(a, b);
     return (0);
 }
 
@@ -1054,7 +1045,7 @@ static int crparam2bn(struct crparam *crp, BIGNUM *a)
     if (bytes == 0)
         return (-1);
 
-    if ((pd = (u_int8_t *) malloc(bytes)) == NULL)
+    if ((pd = (u_int8_t *) OPENSSL_malloc(bytes)) == NULL)
         return (-1);
 
     for (i = 0; i < bytes; i++)
@@ -1239,10 +1230,10 @@ cryptodev_dsa_dsa_mod_exp(DSA *dsa, BIGNUM *t1, BIGNUM *g,
                           BIGNUM *u1, BIGNUM *pub_key, BIGNUM *u2, BIGNUM *p,
                           BN_CTX *ctx, BN_MONT_CTX *mont)
 {
-    BIGNUM t2;
+    BIGNUM *t2;
     int ret = 0;
 
-    BN_init(&t2);
+    t2 = BN_new();
 
     /* v = ( g^u1 * y^u2 mod p ) mod q */
     /* let t1 = g ^ u1 mod p */
@@ -1252,17 +1243,17 @@ cryptodev_dsa_dsa_mod_exp(DSA *dsa, BIGNUM *t1, BIGNUM *g,
         goto err;
 
     /* let t2 = y ^ u2 mod p */
-    if (!dsa->meth->bn_mod_exp(dsa, &t2, dsa->pub_key, u2, dsa->p, ctx, mont))
+    if (!dsa->meth->bn_mod_exp(dsa, t2, dsa->pub_key, u2, dsa->p, ctx, mont))
         goto err;
     /* let u1 = t1 * t2 mod p */
-    if (!BN_mod_mul(u1, t1, &t2, dsa->p, ctx))
+    if (!BN_mod_mul(u1, t1, t2, dsa->p, ctx))
         goto err;
 
     BN_copy(t1, u1);
 
     ret = 1;
  err:
-    BN_free(&t2);
+    BN_free(t2);
     return (ret);
 }
 


More information about the openssl-commits mailing list