Misc BN fixes
authorRich Salz <rsalz@openssl.org>
Mon, 5 Sep 2016 22:08:43 +0000 (18:08 -0400)
committerRich Salz <rsalz@openssl.org>
Tue, 6 Sep 2016 14:42:28 +0000 (10:42 -0400)
commite9590d00fc7c269f3e90b93cf6ac17238f0ca2c6
treeb437dc4c773addf2fc7cb391ee80b3ed452e98f2
parentf52d16ac1d0f0bc3a13e32cc62dcbd4fed4ac649
Misc BN fixes

Never output -0; make "negative zero" an impossibility.
Do better checking on BN_rand top/bottom requirements and #bits.
Update doc.
Ignoring trailing garbage in BN_asc2bn.

Port this commit from boringSSL: https://boringssl.googlesource.com/boringssl/+/899b9b19a4cd3fe526aaf5047ab9234cdca19f7d%5E!/
        Ensure |BN_div| never gives negative zero in the no_branch code.

        Have |bn_correct_top| fix |bn->neg| if the input is zero so that we
        don't have negative zeros lying around.

        Thanks to Brian Smith for noticing.

Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit 01c09f9fde5793e0b3712d602b02e2aed4908e8d)
crypto/bn/bn_lib.c
crypto/bn/bn_print.c
crypto/bn/bn_rand.c
doc/crypto/BN_bn2bin.pod
doc/crypto/BN_rand.pod