diff options
Diffstat (limited to 'src/lib/libcrypto/evp/evp_enc.c')
-rw-r--r-- | src/lib/libcrypto/evp/evp_enc.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/lib/libcrypto/evp/evp_enc.c b/src/lib/libcrypto/evp/evp_enc.c index db2deb6905..a229901956 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.39 2018/04/14 07:09:21 tb Exp $ */ | 1 | /* $OpenBSD: evp_enc.c,v 1.40 2019/03/17 18:07:41 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 | * |
@@ -153,7 +153,7 @@ EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *impl, | |||
153 | ctx->cipher_data = NULL; | 153 | ctx->cipher_data = NULL; |
154 | } | 154 | } |
155 | ctx->key_len = cipher->key_len; | 155 | ctx->key_len = cipher->key_len; |
156 | ctx->flags = 0; | 156 | ctx->flags &= EVP_CIPHER_CTX_FLAG_WRAP_ALLOW; |
157 | if (ctx->cipher->flags & EVP_CIPH_CTRL_INIT) { | 157 | if (ctx->cipher->flags & EVP_CIPH_CTRL_INIT) { |
158 | if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_INIT, 0, NULL)) { | 158 | if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_INIT, 0, NULL)) { |
159 | EVPerror(EVP_R_INITIALIZATION_ERROR); | 159 | EVPerror(EVP_R_INITIALIZATION_ERROR); |
@@ -175,6 +175,12 @@ skip_to_init: | |||
175 | return 0; | 175 | return 0; |
176 | } | 176 | } |
177 | 177 | ||
178 | if (!(ctx->flags & EVP_CIPHER_CTX_FLAG_WRAP_ALLOW) && | ||
179 | EVP_CIPHER_CTX_mode(ctx) == EVP_CIPH_WRAP_MODE) { | ||
180 | EVPerror(EVP_R_WRAP_MODE_NOT_ALLOWED); | ||
181 | return 0; | ||
182 | } | ||
183 | |||
178 | if (!(EVP_CIPHER_CTX_flags(ctx) & EVP_CIPH_CUSTOM_IV)) { | 184 | if (!(EVP_CIPHER_CTX_flags(ctx) & EVP_CIPH_CUSTOM_IV)) { |
179 | switch (EVP_CIPHER_CTX_mode(ctx)) { | 185 | switch (EVP_CIPHER_CTX_mode(ctx)) { |
180 | 186 | ||