diff options
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/libcrypto/evp/evp_enc.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/src/lib/libcrypto/evp/evp_enc.c b/src/lib/libcrypto/evp/evp_enc.c index 1bde05f493..7c25b59dce 100644 --- a/src/lib/libcrypto/evp/evp_enc.c +++ b/src/lib/libcrypto/evp/evp_enc.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: evp_enc.c,v 1.79 2023/12/23 13:05:06 tb Exp $ */ | 1 | /* $OpenBSD: evp_enc.c,v 1.80 2023/12/26 08:39:28 tb Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -93,23 +93,18 @@ EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *engine, | |||
93 | } | 93 | } |
94 | 94 | ||
95 | /* | 95 | /* |
96 | * If the ctx is reused and a cipher is passed in, reset the ctx but | 96 | * Set up cipher and context. Allocate cipher data and initialize ctx. |
97 | * remember enc and whether key wrap was enabled. | 97 | * On ctx reuse only retain encryption direction and key wrap flag. |
98 | */ | 98 | */ |
99 | if (cipher != NULL && ctx->cipher != NULL) { | 99 | if (cipher != NULL) { |
100 | unsigned long flags = ctx->flags; | 100 | unsigned long flags = ctx->flags; |
101 | 101 | ||
102 | EVP_CIPHER_CTX_cleanup(ctx); | 102 | EVP_CIPHER_CTX_cleanup(ctx); |
103 | |||
104 | ctx->encrypt = enc; | 103 | ctx->encrypt = enc; |
105 | ctx->flags = flags & EVP_CIPHER_CTX_FLAG_WRAP_ALLOW; | 104 | ctx->flags = flags & EVP_CIPHER_CTX_FLAG_WRAP_ALLOW; |
106 | } | ||
107 | 105 | ||
108 | /* Set up cipher. Allocate cipher data and initialize if necessary. */ | ||
109 | if (cipher != NULL) { | ||
110 | ctx->cipher = cipher; | 106 | ctx->cipher = cipher; |
111 | ctx->key_len = cipher->key_len; | 107 | ctx->key_len = cipher->key_len; |
112 | ctx->flags &= EVP_CIPHER_CTX_FLAG_WRAP_ALLOW; | ||
113 | 108 | ||
114 | if (ctx->cipher->ctx_size != 0) { | 109 | if (ctx->cipher->ctx_size != 0) { |
115 | ctx->cipher_data = calloc(1, ctx->cipher->ctx_size); | 110 | ctx->cipher_data = calloc(1, ctx->cipher->ctx_size); |