Very minor BN fixes.

Fixes one comment that mentioned the wrong function name. Also causes
two BN random functions to fail when the output is NULL. Previously they
would silently do nothing.

Change-Id: I89796ab855ea32787765c301a478352287e61190
This commit is contained in:
Adam Langley
2014-06-30 14:22:32 -07:00
parent 389110ae89
commit 5d17dd64cc
2 changed files with 9 additions and 1 deletions
+1 -1
View File
@@ -712,7 +712,7 @@ int BN_mod_mul_montgomery(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
* zero otherwise. */
int BN_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
/* BN_exp sets |r| equal to |a|^{|p|} mod |m|. It does so with the best
/* BN_mod_exp sets |r| equal to |a|^{|p|} mod |m|. It does so with the best
* algorithm for the values provided and can run in constant time if
* |BN_FLG_CONSTTIME| is set for |p|. It returns one on success or zero
* otherwise. */
+8
View File
@@ -117,6 +117,10 @@ int BN_rand(BIGNUM *rnd, int bits, int top, int bottom) {
uint8_t *buf = NULL;
int ret = 0, bit, bytes, mask;
if (rnd == NULL) {
return 0;
}
if (bits == 0) {
BN_zero(rnd);
return 1;
@@ -252,6 +256,10 @@ int BN_generate_dsa_nonce(BIGNUM *out, const BIGNUM *range, const BIGNUM *priv,
uint8_t *k_bytes = NULL;
int ret = 0;
if (out == NULL) {
return 0;
}
if (BN_is_zero(range)) {
OPENSSL_PUT_ERROR(BN, BN_generate_dsa_nonce, BN_R_DIV_BY_ZERO);
goto err;