diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2010-07-28 16:53:28 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2010-07-28 16:53:28 +0000 |
commit | 2948fbab3acf853e0f61c559009dce7e0f876b62 (patch) | |
tree | d027f431075c4d9f755af211f5cb401fc68f45d8 /crypto/evp/evp_enc.c | |
parent | 081464fa142ce908d0606417e5f576263cb29584 (diff) |
Fix ctr mode properly this time....
Diffstat (limited to 'crypto/evp/evp_enc.c')
-rw-r--r-- | crypto/evp/evp_enc.c | 9 |
1 files changed, 6 insertions, 3 deletions
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: |