From: Dr. Stephen Henson Date: Wed, 28 Jul 2010 16:53:28 +0000 (+0000) Subject: Fix ctr mode properly this time.... X-Git-Tag: OpenSSL-fips-2_0-rc1~1014 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2948fbab3acf853e0f61c559009dce7e0f876b62;p=openssl Fix ctr mode properly this time.... --- diff --git a/crypto/evp/evp_enc.c b/crypto/evp/evp_enc.c index a35621a2ec..99e6b200c2 100644 --- a/crypto/evp/evp_enc.c +++ b/crypto/evp/evp_enc.c @@ -206,14 +206,17 @@ skip_to_init: ctx->num = 0; case EVP_CIPH_CBC_MODE: - case EVP_CIPH_CTR_MODE: OPENSSL_assert(EVP_CIPHER_CTX_iv_length(ctx) <= (int)sizeof(ctx->iv)); if(iv) memcpy(ctx->oiv, iv, EVP_CIPHER_CTX_iv_length(ctx)); + memcpy(ctx->iv, ctx->oiv, EVP_CIPHER_CTX_iv_length(ctx)); + break; + + case EVP_CIPH_CTR_MODE: /* Don't reuse IV for CTR mode */ - if (EVP_CIPHER_CTX_mode(ctx) != EVP_CIPH_CTR_MODE) - memcpy(ctx->iv, ctx->oiv, EVP_CIPHER_CTX_iv_length(ctx)); + if(iv) + memcpy(ctx->iv, iv, EVP_CIPHER_CTX_iv_length(ctx)); break; default: