diff options
author | miod <> | 2015-02-10 09:52:35 +0000 |
---|---|---|
committer | miod <> | 2015-02-10 09:52:35 +0000 |
commit | d2f68f95d95ff1ca4370b66eb67e8add10d9d079 (patch) | |
tree | 58f7f299c05557099d7278079e061aed0f4a9f23 /src/lib/libcrypto/evp/p5_crpt.c | |
parent | 9c8f4b278d0fe6c5ae67ecea60905c57ccf4c4e1 (diff) | |
download | openbsd-d2f68f95d95ff1ca4370b66eb67e8add10d9d079.tar.gz openbsd-d2f68f95d95ff1ca4370b66eb67e8add10d9d079.tar.bz2 openbsd-d2f68f95d95ff1ca4370b66eb67e8add10d9d079.zip |
Replace assert() and OPENSSL_assert() calls with proper error return paths.
Careful review, feedback & ok doug@ jsing@
Diffstat (limited to 'src/lib/libcrypto/evp/p5_crpt.c')
-rw-r--r-- | src/lib/libcrypto/evp/p5_crpt.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/lib/libcrypto/evp/p5_crpt.c b/src/lib/libcrypto/evp/p5_crpt.c index 3b1419b545..112a69114c 100644 --- a/src/lib/libcrypto/evp/p5_crpt.c +++ b/src/lib/libcrypto/evp/p5_crpt.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: p5_crpt.c,v 1.14 2014/07/13 12:46:44 miod Exp $ */ | 1 | /* $OpenBSD: p5_crpt.c,v 1.15 2015/02/10 09:52:35 miod Exp $ */ |
2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
3 | * project 1999. | 3 | * project 1999. |
4 | */ | 4 | */ |
@@ -134,9 +134,15 @@ PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *cctx, const char *pass, int passlen, | |||
134 | if (!EVP_DigestFinal_ex (&ctx, md_tmp, NULL)) | 134 | if (!EVP_DigestFinal_ex (&ctx, md_tmp, NULL)) |
135 | goto err; | 135 | goto err; |
136 | } | 136 | } |
137 | OPENSSL_assert(EVP_CIPHER_key_length(cipher) <= (int)sizeof(md_tmp)); | 137 | if ((size_t)EVP_CIPHER_key_length(cipher) > sizeof(md_tmp)) { |
138 | EVPerr(EVP_F_PKCS5_PBE_KEYIVGEN, EVP_R_BAD_KEY_LENGTH); | ||
139 | goto err; | ||
140 | } | ||
138 | memcpy(key, md_tmp, EVP_CIPHER_key_length(cipher)); | 141 | memcpy(key, md_tmp, EVP_CIPHER_key_length(cipher)); |
139 | OPENSSL_assert(EVP_CIPHER_iv_length(cipher) <= 16); | 142 | if ((size_t)EVP_CIPHER_iv_length(cipher) > 16) { |
143 | EVPerr(EVP_F_PKCS5_PBE_KEYIVGEN, EVP_R_IV_TOO_LARGE); | ||
144 | goto err; | ||
145 | } | ||
140 | memcpy(iv, md_tmp + (16 - EVP_CIPHER_iv_length(cipher)), | 146 | memcpy(iv, md_tmp + (16 - EVP_CIPHER_iv_length(cipher)), |
141 | EVP_CIPHER_iv_length(cipher)); | 147 | EVP_CIPHER_iv_length(cipher)); |
142 | if (!EVP_CipherInit_ex(cctx, cipher, NULL, key, iv, en_de)) | 148 | if (!EVP_CipherInit_ex(cctx, cipher, NULL, key, iv, en_de)) |