diff options
Diffstat (limited to '')
-rw-r--r-- | src/lib/libcrypto/evp/p_seal.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/lib/libcrypto/evp/p_seal.c b/src/lib/libcrypto/evp/p_seal.c index b98da94360..7f29ea0ca2 100644 --- a/src/lib/libcrypto/evp/p_seal.c +++ b/src/lib/libcrypto/evp/p_seal.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: p_seal.c,v 1.16 2023/07/07 19:37:54 beck Exp $ */ | 1 | /* $OpenBSD: p_seal.c,v 1.17 2023/11/18 09:37:15 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 | * |
@@ -74,7 +74,7 @@ EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, unsigned char **ek, | |||
74 | int *ekl, unsigned char *iv, EVP_PKEY **pubk, int npubk) | 74 | int *ekl, unsigned char *iv, EVP_PKEY **pubk, int npubk) |
75 | { | 75 | { |
76 | unsigned char key[EVP_MAX_KEY_LENGTH]; | 76 | unsigned char key[EVP_MAX_KEY_LENGTH]; |
77 | int i; | 77 | int i, iv_len; |
78 | 78 | ||
79 | if (type) { | 79 | if (type) { |
80 | EVP_CIPHER_CTX_init(ctx); | 80 | EVP_CIPHER_CTX_init(ctx); |
@@ -85,8 +85,11 @@ EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, unsigned char **ek, | |||
85 | return 1; | 85 | return 1; |
86 | if (EVP_CIPHER_CTX_rand_key(ctx, key) <= 0) | 86 | if (EVP_CIPHER_CTX_rand_key(ctx, key) <= 0) |
87 | return 0; | 87 | return 0; |
88 | if (EVP_CIPHER_CTX_iv_length(ctx)) | 88 | /* XXX - upper bound? */ |
89 | arc4random_buf(iv, EVP_CIPHER_CTX_iv_length(ctx)); | 89 | if ((iv_len = EVP_CIPHER_CTX_iv_length(ctx)) < 0) |
90 | return 0; | ||
91 | if (iv_len > 0) | ||
92 | arc4random_buf(iv, iv_len); | ||
90 | 93 | ||
91 | if (!EVP_EncryptInit_ex(ctx, NULL, NULL, key, iv)) | 94 | if (!EVP_EncryptInit_ex(ctx, NULL, NULL, key, iv)) |
92 | return 0; | 95 | return 0; |