diff options
author | David Benjamin <davidben@chromium.org> | 2014-12-16 07:48:10 -0500 |
---|---|---|
committer | Adam Langley <agl@google.com> | 2014-12-16 19:15:59 +0000 |
commit | a6d81018f8fd5647d88a49923633f29dd77c2365 (patch) | |
tree | a2182160a477558c1919642629a684046938c42b /crypto/rsa | |
parent | 263eac02f5c27ad91c1514c93246b84980f73c97 (diff) | |
download | boringssl-a6d81018f8fd5647d88a49923633f29dd77c2365.zip boringssl-a6d81018f8fd5647d88a49923633f29dd77c2365.tar.gz boringssl-a6d81018f8fd5647d88a49923633f29dd77c2365.tar.bz2 |
Consistently use RAND_bytes and check for failure.
RAND_pseudo_bytes just calls RAND_bytes now and only returns 0 or 1. Switch all
callers within the library call the new one and use the simpler failure check.
This fixes a few error checks that no longer work (< 0) and some missing ones.
Change-Id: Id51c79deec80075949f73fa1fbd7b76aac5570c6
Reviewed-on: https://boringssl-review.googlesource.com/2621
Reviewed-by: Adam Langley <agl@google.com>
Diffstat (limited to 'crypto/rsa')
-rw-r--r-- | crypto/rsa/padding.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/crypto/rsa/padding.c b/crypto/rsa/padding.c index 4d29b07..70dafb2 100644 --- a/crypto/rsa/padding.c +++ b/crypto/rsa/padding.c @@ -181,13 +181,13 @@ int RSA_padding_add_PKCS1_type_2(uint8_t *to, unsigned tlen, /* pad out with non-zero random data */ j = tlen - 3 - flen; - if (RAND_pseudo_bytes(p, j) <= 0) { + if (!RAND_bytes(p, j)) { return 0; } for (i = 0; i < j; i++) { while (*p == 0) { - if (RAND_pseudo_bytes(p, 1) <= 0) { + if (!RAND_bytes(p, 1)) { return 0; } } @@ -411,7 +411,7 @@ int RSA_padding_add_PKCS1_OAEP_mgf1(uint8_t *to, unsigned tlen, memset(db + mdlen, 0, emlen - flen - 2 * mdlen - 1); db[emlen - flen - mdlen - 1] = 0x01; memcpy(db + emlen - flen - mdlen, from, flen); - if (RAND_pseudo_bytes(seed, mdlen) <= 0) { + if (!RAND_bytes(seed, mdlen)) { return 0; } @@ -718,7 +718,7 @@ int RSA_padding_add_PKCS1_PSS_mgf1(RSA *rsa, unsigned char *EM, ERR_R_MALLOC_FAILURE); goto err; } - if (RAND_pseudo_bytes(salt, sLen) <= 0) { + if (!RAND_bytes(salt, sLen)) { goto err; } } |