memset, memcpy, sizeof consistency fixes
[openssl.git] / engines / e_ubsec.c
index 2d6331d690e27a366ff7934a6efd39d6fead2a75..a44b0b2b4ac2085c49a9e1852ed34c808f2d9342 100644 (file)
@@ -339,8 +339,7 @@ static const char *get_UBSEC_LIBNAME(void)
 
 static void free_UBSEC_LIBNAME(void)
 {
-    if (UBSEC_LIBNAME)
-        OPENSSL_free((void *)UBSEC_LIBNAME);
+    OPENSSL_free(UBSEC_LIBNAME);
     UBSEC_LIBNAME = NULL;
 }
 
@@ -482,8 +481,7 @@ static int ubsec_init(ENGINE *e)
     }
 
  err:
-    if (ubsec_dso)
-        DSO_free(ubsec_dso);
+    DSO_free(ubsec_dso);
     ubsec_dso = NULL;
     p_UBSEC_ubsec_bytes_to_bits = NULL;
     p_UBSEC_ubsec_bits_to_bytes = NULL;
@@ -680,40 +678,6 @@ static int ubsec_mod_exp_crt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
 }
 #  endif
 
-#  ifndef OPENSSL_NO_DSA
-#   ifdef NOT_USED
-static int ubsec_dsa_mod_exp(DSA *dsa, BIGNUM *rr, BIGNUM *a1,
-                             BIGNUM *p1, BIGNUM *a2, BIGNUM *p2, BIGNUM *m,
-                             BN_CTX *ctx, BN_MONT_CTX *in_mont)
-{
-    BIGNUM t;
-    int to_return = 0;
-
-    BN_init(&t);
-    /* let rr = a1 ^ p1 mod m */
-    if (!ubsec_mod_exp(rr, a1, p1, m, ctx))
-        goto end;
-    /* let t = a2 ^ p2 mod m */
-    if (!ubsec_mod_exp(&t, a2, p2, m, ctx))
-        goto end;
-    /* let rr = rr * t mod m */
-    if (!BN_mod_mul(rr, rr, &t, m, ctx))
-        goto end;
-    to_return = 1;
- end:
-    BN_free(&t);
-    return to_return;
-}
-
-static int ubsec_mod_exp_dsa(DSA *dsa, BIGNUM *r, BIGNUM *a,
-                             const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
-                             BN_MONT_CTX *m_ctx)
-{
-    return ubsec_mod_exp(r, a, p, m, ctx);
-}
-#   endif
-#  endif
-
 #  ifndef OPENSSL_NO_RSA
 
 /*
@@ -825,10 +789,8 @@ static DSA_SIG *ubsec_dsa_do_sign(const unsigned char *dgst, int dlen,
 
  err:
     if (!to_return) {
-        if (r)
-            BN_free(r);
-        if (s)
-            BN_free(s);
+        BN_free(r);
+        BN_free(s);
     }
     BN_clear_free(&m);
     return to_return;
@@ -967,11 +929,11 @@ static int ubsec_dh_generate_key(DH *dh)
 
     if (dh->pub_key == NULL) {
         pub_key = BN_new();
+        if (pub_key == NULL)
+            goto err;
         pub_key_len = BN_num_bits(dh->p);
         if (bn_wexpand(pub_key, dh->p->top) == NULL)
             goto err;
-        if (pub_key == NULL)
-            goto err;
     } else {
         pub_key = dh->pub_key;
     }