From: Richard Levitte Date: Wed, 2 Dec 2015 21:49:24 +0000 (+0100) Subject: Cleanup: fix all sources that used HMAC_CTX_init X-Git-Tag: OpenSSL_1_1_0-pre1~101 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=a87a0a6e5eb7993ae7a4d2eb13e605d8b5428073;p=oweals%2Fopenssl.git Cleanup: fix all sources that used HMAC_CTX_init Reviewed-by: Rich Salz --- diff --git a/crypto/evp/p5_crpt2.c b/crypto/evp/p5_crpt2.c index 9df07d67d0..0f5b82b1aa 100644 --- a/crypto/evp/p5_crpt2.c +++ b/crypto/evp/p5_crpt2.c @@ -134,7 +134,7 @@ int PKCS5_PBKDF2_HMAC(const char *pass, int passlen, 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)) { @@ -148,7 +148,7 @@ int PKCS5_PBKDF2_HMAC(const char *pass, int passlen, 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]; } diff --git a/crypto/hmac/hmac.c b/crypto/hmac/hmac.c index c0f45131fa..3bc93a8841 100644 --- a/crypto/hmac/hmac.c +++ b/crypto/hmac/hmac.c @@ -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) - HMAC_CTX_init(ctx); + HMAC_CTX_reset(ctx); 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) { - 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; diff --git a/test/hmactest.c b/test/hmactest.c index fc168de581..9fb12ad3da 100644 --- a/test/hmactest.c +++ b/test/hmactest.c @@ -193,7 +193,7 @@ int main(int argc, char *argv[]) } 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++; @@ -282,7 +282,7 @@ test5: 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");