Cleanup: fix all sources that used HMAC_CTX_init
authorRichard Levitte <levitte@openssl.org>
Wed, 2 Dec 2015 21:49:24 +0000 (22:49 +0100)
committerRichard Levitte <levitte@openssl.org>
Mon, 7 Dec 2015 16:40:20 +0000 (17:40 +0100)
Reviewed-by: Rich Salz <rsalz@openssl.org>
crypto/evp/p5_crpt2.c
crypto/hmac/hmac.c
test/hmactest.c

index 9df07d67d0b5b32aefee70c777312da8e905c671..0f5b82b1aa7f4680c495f34a7c4a0f104d2b719d 100644 (file)
@@ -134,7 +134,7 @@ int PKCS5_PBKDF2_HMAC(const char *pass, int passlen,
             HMAC_CTX_free(hctx_tpl);
             return 0;
         }
             HMAC_CTX_free(hctx_tpl);
             return 0;
         }
-        HMAC_CTX_init(hctx);
+        HMAC_CTX_reset(hctx);
         memcpy(p, digtmp, cplen);
         for (j = 1; j < iter; j++) {
             if (!HMAC_CTX_copy(hctx, hctx_tpl)) {
         memcpy(p, digtmp, cplen);
         for (j = 1; j < iter; j++) {
             if (!HMAC_CTX_copy(hctx, hctx_tpl)) {
@@ -148,7 +148,7 @@ int PKCS5_PBKDF2_HMAC(const char *pass, int passlen,
                 HMAC_CTX_free(hctx_tpl);
                 return 0;
             }
                 HMAC_CTX_free(hctx_tpl);
                 return 0;
             }
-            HMAC_CTX_init(hctx);
+            HMAC_CTX_reset(hctx);
             for (k = 0; k < cplen; k++)
                 p[k] ^= digtmp[k];
         }
             for (k = 0; k < cplen; k++)
                 p[k] ^= digtmp[k];
         }
index c0f45131fa7626dac2498d7c881367d460e00f02..3bc93a8841cfc7a7348866b806720e37d04ee7ee 100644 (file)
@@ -131,7 +131,7 @@ int HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len,
 int HMAC_Init(HMAC_CTX *ctx, const void *key, int len, const EVP_MD *md)
 {
     if (key && md)
 int HMAC_Init(HMAC_CTX *ctx, const void *key, int len, const EVP_MD *md)
 {
     if (key && md)
-        HMAC_CTX_init(ctx);
+        HMAC_CTX_reset(ctx);
     return HMAC_Init_ex(ctx, key, len, md, NULL);
 }
 #endif
     return HMAC_Init_ex(ctx, key, len, md, NULL);
 }
 #endif
@@ -225,7 +225,7 @@ int HMAC_CTX_reset(HMAC_CTX *ctx)
 
 int HMAC_CTX_copy(HMAC_CTX *dctx, HMAC_CTX *sctx)
 {
 
 int HMAC_CTX_copy(HMAC_CTX *dctx, HMAC_CTX *sctx)
 {
-    if (!HMAC_CTX_init(dctx))
+    if (!HMAC_CTX_reset(dctx))
         goto err;
     if (!EVP_MD_CTX_copy_ex(dctx->i_ctx, sctx->i_ctx))
         goto err;
         goto err;
     if (!EVP_MD_CTX_copy_ex(dctx->i_ctx, sctx->i_ctx))
         goto err;
index fc168de581622c575656be4281c3edfce73954b3..9fb12ad3da146e38fd96163ba0d33145aa4f65c2 100644 (file)
@@ -193,7 +193,7 @@ int main(int argc, char *argv[])
     }
     printf("test 4 ok\n");
 test5:
     }
     printf("test 4 ok\n");
 test5:
-    HMAC_CTX_init(ctx);
+    HMAC_CTX_reset(ctx);
     if (HMAC_Init_ex(ctx, test[4].key, test[4].key_len, NULL, NULL)) {
         printf("Should fail to initialise HMAC with empty MD (test 5)\n");
         err++;
     if (HMAC_Init_ex(ctx, test[4].key, test[4].key_len, NULL, NULL)) {
         printf("Should fail to initialise HMAC with empty MD (test 5)\n");
         err++;
@@ -282,7 +282,7 @@ test5:
         printf("test 5 ok\n");
     }
 test6:
         printf("test 5 ok\n");
     }
 test6:
-    HMAC_CTX_init(ctx);
+    HMAC_CTX_reset(ctx);
     ctx2 = HMAC_CTX_new();
     if (ctx2 == NULL) {
         printf("HMAC malloc failure (test 6)\n");
     ctx2 = HMAC_CTX_new();
     if (ctx2 == NULL) {
         printf("HMAC malloc failure (test 6)\n");