diff options
author | tb <> | 2019-03-17 18:07:41 +0000 |
---|---|---|
committer | tb <> | 2019-03-17 18:07:41 +0000 |
commit | fb0b540c39c782c9152081c2021f54363e04307c (patch) | |
tree | dd2e39bee98dd971a0881b58b8d9c80b4aed5bb3 /src/lib/libcrypto/evp/evp_enc.c | |
parent | 373c84ef2291a7b228066cf92fe5b23e39cd35aa (diff) | |
download | openbsd-fb0b540c39c782c9152081c2021f54363e04307c.tar.gz openbsd-fb0b540c39c782c9152081c2021f54363e04307c.tar.bz2 openbsd-fb0b540c39c782c9152081c2021f54363e04307c.zip |
Provide EVP_aes_{128,192,256}_wrap(). This is a compatible
implementation based on the one in OpenSSL 1.0.2r which is
still freely licensed.
The functions are undocumented in OpenSSL. To use them, one
needs to set the undocumented EVP_CIPHER_CTX_FLAG_WRAP_ALLOW
flag on the EVP_CIPHER_CTX.
resolves #505
ok jsing
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 | ||