Check if test_rehash is run as root
[openssl.git] / engines / e_sureware.c
index 3c7b2b26bf85d3fd6ba56fc0168a8a889deed797..fb5e55c930a8e1b4fa26c16315390bf7cf46faf9 100644 (file)
@@ -404,10 +404,8 @@ static int surewarehk_ctrl(ENGINE *e, int cmd, long i, void *p,
         {
             BIO *bio = (BIO *)p;
             CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
-            if (logstream) {
-                BIO_free(logstream);
-                logstream = NULL;
-            }
+            BIO_free(logstream);
+            logstream = NULL;
             if (CRYPTO_add(&bio->references, 1, CRYPTO_LOCK_BIO) > 1)
                 logstream = bio;
             else
@@ -562,8 +560,7 @@ static int surewarehk_init(ENGINE *e)
 
     return 1;
  err:
-    if (surewarehk_dso)
-        DSO_free(surewarehk_dso);
+    DSO_free(surewarehk_dso);
     surewarehk_dso = NULL;
     p_surewarehk_Init = NULL;
     p_surewarehk_Finish = NULL;
@@ -596,8 +593,7 @@ static int surewarehk_finish(ENGINE *e)
         goto err;
     }
  err:
-    if (logstream)
-        BIO_free(logstream);
+    BIO_free(logstream);
     surewarehk_dso = NULL;
     p_surewarehk_Init = NULL;
     p_surewarehk_Finish = NULL;
@@ -713,7 +709,7 @@ static EVP_PKEY *sureware_load_public(ENGINE *e, const char *key_id,
         /* set public big nums */
         rsatmp->e = BN_new();
         rsatmp->n = BN_new();
-        if(!rsatmp->e || !rsatmp->n)
+        if (!rsatmp->e || !rsatmp->n)
             goto err;
         bn_expand2(rsatmp->e, el / sizeof(BN_ULONG));
         bn_expand2(rsatmp->n, el / sizeof(BN_ULONG));
@@ -755,7 +751,7 @@ static EVP_PKEY *sureware_load_public(ENGINE *e, const char *key_id,
         dsatmp->p = BN_new();
         dsatmp->q = BN_new();
         dsatmp->g = BN_new();
-        if(!dsatmp->pub_key || !dsatmp->p || !dsatmp->q || !dsatmp->g)
+        if (!dsatmp->pub_key || !dsatmp->p || !dsatmp->q || !dsatmp->g)
             goto err;
         bn_expand2(dsatmp->pub_key, el / sizeof(BN_ULONG));
         bn_expand2(dsatmp->p, el / sizeof(BN_ULONG));
@@ -893,7 +889,7 @@ static int surewarehk_rsa_priv_dec(int flen, const unsigned char *from,
                     ENGINE_R_NOT_INITIALISED);
     }
     /* extract ref to private key */
-    else if (!(hptr = RSA_get_ex_data(rsa, rsaHndidx))) {
+    else if ((hptr = RSA_get_ex_data(rsa, rsaHndidx)) == NULL) {
         SUREWAREerr(SUREWARE_F_SUREWAREHK_RSA_PRIV_DEC,
                     SUREWARE_R_MISSING_KEY_COMPONENTS);
         goto err;
@@ -951,10 +947,7 @@ static int surewarehk_rsa_priv_dec(int flen, const unsigned char *from,
                         SUREWARE_R_PADDING_CHECK_FAILED);
     }
  err:
-    if (buf) {
-        OPENSSL_cleanse(buf, tlen);
-        OPENSSL_free(buf);
-    }
+    OPENSSL_clear_free(buf, tlen);
     return ret;
 }
 
@@ -971,7 +964,7 @@ static int surewarehk_rsa_sign(int flen, const unsigned char *from,
         SUREWAREerr(SUREWARE_F_SUREWAREHK_RSA_SIGN, ENGINE_R_NOT_INITIALISED);
     }
     /* extract ref to private key */
-    else if (!(hptr = RSA_get_ex_data(rsa, rsaHndidx))) {
+    else if ((hptr = RSA_get_ex_data(rsa, rsaHndidx)) == NULL) {
         SUREWAREerr(SUREWARE_F_SUREWAREHK_RSA_SIGN,
                     SUREWARE_R_MISSING_KEY_COMPONENTS);
     } else {
@@ -1009,7 +1002,7 @@ static DSA_SIG *surewarehk_dsa_do_sign(const unsigned char *from, int flen,
         goto err;
     }
     /* extract ref to private key */
-    else if (!(hptr = DSA_get_ex_data(dsa, dsaHndidx))) {
+    else if ((hptr = DSA_get_ex_data(dsa, dsaHndidx)) == NULL) {
         SUREWAREerr(SUREWARE_F_SUREWAREHK_DSA_DO_SIGN,
                     SUREWARE_R_MISSING_KEY_COMPONENTS);
         goto err;
@@ -1021,7 +1014,7 @@ static DSA_SIG *surewarehk_dsa_do_sign(const unsigned char *from, int flen,
         }
         psign->r = BN_new();
         psign->s = BN_new();
-        if(!psign->r || !psign->s)
+        if (!psign->r || !psign->s)
             goto err;
         bn_expand2(psign->r, 20 / sizeof(BN_ULONG));
         bn_expand2(psign->s, 20 / sizeof(BN_ULONG));