diff options
author | jsing <> | 2019-08-11 10:54:11 +0000 |
---|---|---|
committer | jsing <> | 2019-08-11 10:54:11 +0000 |
commit | 8e1a02b0b1470213ac669256827ac9f393aaa8a7 (patch) | |
tree | c73fadde9a753ff4d6f1dd186c6ec1b247d8543f /src/lib/libcrypto/cms/cms_pwri.c | |
parent | 026ecb9dcf81edc5f262b0e7822f6d05f6581573 (diff) | |
download | openbsd-8e1a02b0b1470213ac669256827ac9f393aaa8a7.tar.gz openbsd-8e1a02b0b1470213ac669256827ac9f393aaa8a7.tar.bz2 openbsd-8e1a02b0b1470213ac669256827ac9f393aaa8a7.zip |
Use arc4random_buf() instead of RAND_bytes().
This also removes return checks since arc4random_buf() does not fail.
Diffstat (limited to 'src/lib/libcrypto/cms/cms_pwri.c')
-rw-r--r-- | src/lib/libcrypto/cms/cms_pwri.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/lib/libcrypto/cms/cms_pwri.c b/src/lib/libcrypto/cms/cms_pwri.c index 6120cee4c9..6423ddeaf9 100644 --- a/src/lib/libcrypto/cms/cms_pwri.c +++ b/src/lib/libcrypto/cms/cms_pwri.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: cms_pwri.c,v 1.23 2019/08/11 10:50:23 jsing Exp $ */ | 1 | /* $OpenBSD: cms_pwri.c,v 1.24 2019/08/11 10:54:11 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 3 | * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
4 | * project. | 4 | * project. |
@@ -136,8 +136,7 @@ CMS_add0_recipient_password(CMS_ContentInfo *cms, int iter, int wrap_nid, | |||
136 | ivlen = EVP_CIPHER_CTX_iv_length(ctx); | 136 | ivlen = EVP_CIPHER_CTX_iv_length(ctx); |
137 | 137 | ||
138 | if (ivlen > 0) { | 138 | if (ivlen > 0) { |
139 | if (RAND_bytes(iv, ivlen) <= 0) | 139 | arc4random_buf(iv, ivlen); |
140 | goto err; | ||
141 | if (EVP_EncryptInit_ex(ctx, NULL, NULL, NULL, iv) <= 0) { | 140 | if (EVP_EncryptInit_ex(ctx, NULL, NULL, NULL, iv) <= 0) { |
142 | CMSerror(ERR_R_EVP_LIB); | 141 | CMSerror(ERR_R_EVP_LIB); |
143 | goto err; | 142 | goto err; |
@@ -305,9 +304,8 @@ kek_wrap_key(unsigned char *out, size_t *outlen, const unsigned char *in, | |||
305 | out[3] = in[2] ^ 0xFF; | 304 | out[3] = in[2] ^ 0xFF; |
306 | memcpy(out + 4, in, inlen); | 305 | memcpy(out + 4, in, inlen); |
307 | /* Add random padding to end */ | 306 | /* Add random padding to end */ |
308 | if (olen > inlen + 4 && | 307 | if (olen > inlen + 4) |
309 | RAND_bytes(out + 4 + inlen, olen - 4 - inlen) <= 0) | 308 | arc4random_buf(out + 4 + inlen, olen - 4 - inlen); |
310 | return 0; | ||
311 | /* Encrypt twice */ | 309 | /* Encrypt twice */ |
312 | if (!EVP_EncryptUpdate(ctx, out, &dummy, out, olen) || | 310 | if (!EVP_EncryptUpdate(ctx, out, &dummy, out, olen) || |
313 | !EVP_EncryptUpdate(ctx, out, &dummy, out, olen)) | 311 | !EVP_EncryptUpdate(ctx, out, &dummy, out, olen)) |