diff options
author | tb <> | 2023-09-28 11:35:10 +0000 |
---|---|---|
committer | tb <> | 2023-09-28 11:35:10 +0000 |
commit | 1eae5e17d399f969dd174d2f35c9a4d5bf50948b (patch) | |
tree | e20e5d4ae02e4f5fb3dd9911d3b81ddaf03ba3a5 /src | |
parent | 92da04b3fa82724d71f293483fb9284e6da2fa37 (diff) | |
download | openbsd-1eae5e17d399f969dd174d2f35c9a4d5bf50948b.tar.gz openbsd-1eae5e17d399f969dd174d2f35c9a4d5bf50948b.tar.bz2 openbsd-1eae5e17d399f969dd174d2f35c9a4d5bf50948b.zip |
Check that EVP_CIPHER_CTX_iv_length() matches what was set
This really only covers AES-GCM.
From beck
Diffstat (limited to 'src')
-rw-r--r-- | src/regress/lib/libcrypto/aead/aeadtest.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/regress/lib/libcrypto/aead/aeadtest.c b/src/regress/lib/libcrypto/aead/aeadtest.c index 4d24a81768..7144cb98d6 100644 --- a/src/regress/lib/libcrypto/aead/aeadtest.c +++ b/src/regress/lib/libcrypto/aead/aeadtest.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: aeadtest.c,v 1.24 2023/07/07 07:44:59 bcook Exp $ */ | 1 | /* $OpenBSD: aeadtest.c,v 1.25 2023/09/28 11:35:10 tb Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2022 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2022 Joel Sing <jsing@openbsd.org> |
4 | * Copyright (c) 2014, Google Inc. | 4 | * Copyright (c) 2014, Google Inc. |
@@ -203,6 +203,7 @@ run_cipher_aead_encrypt_test(const EVP_CIPHER *cipher, | |||
203 | EVP_CIPHER_CTX *ctx; | 203 | EVP_CIPHER_CTX *ctx; |
204 | size_t out_len; | 204 | size_t out_len; |
205 | int len; | 205 | int len; |
206 | int ivlen; | ||
206 | int ret = 0; | 207 | int ret = 0; |
207 | 208 | ||
208 | if ((ctx = EVP_CIPHER_CTX_new()) == NULL) { | 209 | if ((ctx = EVP_CIPHER_CTX_new()) == NULL) { |
@@ -220,6 +221,13 @@ run_cipher_aead_encrypt_test(const EVP_CIPHER *cipher, | |||
220 | goto err; | 221 | goto err; |
221 | } | 222 | } |
222 | 223 | ||
224 | ivlen = EVP_CIPHER_CTX_iv_length(ctx); | ||
225 | if (ivlen != (int)lengths[NONCE]) { | ||
226 | fprintf(stderr, "FAIL = ivlen %d != nonce length %d\n", ivlen, | ||
227 | (int)lengths[NONCE]); | ||
228 | goto err; | ||
229 | } | ||
230 | |||
223 | if (!EVP_EncryptInit_ex(ctx, NULL, NULL, bufs[KEY], NULL)) { | 231 | if (!EVP_EncryptInit_ex(ctx, NULL, NULL, bufs[KEY], NULL)) { |
224 | fprintf(stderr, "FAIL: EVP_EncryptInit_ex with key\n"); | 232 | fprintf(stderr, "FAIL: EVP_EncryptInit_ex with key\n"); |
225 | goto err; | 233 | goto err; |