Fix a horrible BN bug in bn_expand2 which caused BN_add_word() et al to fail

when they cause the destination to expand.

To see how evil this is try this:

#include <pem.h>
main()
{
	BIGNUM *bn = NULL;
        int i;
	bn = BN_new();
	BN_hex2bn(&bn, "FFFFFFFF");
	BN_add_word(bn, 1);
	printf("Value %s\n", BN_bn2hex(bn));
}

This would typically fail before the patch.

It also screws up if you comment out the BN_hex2bn line above or in any
situation where BN_add_word() causes the number of BN_ULONGs in the result
to change (try doubling the number of FFs).
This commit is contained in:
Dr. Stephen Henson
1999-04-15 23:07:00 +00:00
parent abed0b8a1f
commit 953937bdc6
2 changed files with 30 additions and 17 deletions

View File

@@ -5,6 +5,10 @@
Changes between 0.9.2b and 0.9.3
*) Fix an evil bug in bn_expand2() which caused various BN functions to
fail when they extended the size of a BIGNUM.
[Steve Henson]
*) Various utility functions to handle SXNet extension. Modify mkdef.pl to
support typesafe stack.
[Steve Henson]