summaryrefslogtreecommitdiffstats
path: root/crypto/evp/evp_enc.c
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2010-07-28 11:03:09 +0000
committerDr. Stephen Henson <steve@openssl.org>2010-07-28 11:03:09 +0000
commit081464fa142ce908d0606417e5f576263cb29584 (patch)
tree5dac87db3bb52cb4869bf0c55f5358ceb8d531a3 /crypto/evp/evp_enc.c
parentee2ffc279417f15fef3b1073c7dc81a908991516 (diff)
Make ctr mode behaviour consistent with other modes.
Diffstat (limited to 'crypto/evp/evp_enc.c')
-rw-r--r--crypto/evp/evp_enc.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/crypto/evp/evp_enc.c b/crypto/evp/evp_enc.c
index bead6a2170..a35621a2ec 100644
--- a/crypto/evp/evp_enc.c
+++ b/crypto/evp/evp_enc.c
@@ -206,11 +206,14 @@ 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));
+ /* 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));
break;
default: