[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openssl-cvs
Subject:    cvs commit: openssl/crypto/bn bn.h bn_rand.c bntest.c
From:       ulf () openssl ! org
Date:       2001-02-27 23:00:55
[Download RAW message or body]

ulf         28-Feb-2001 00:00:53

  Modified:    .        Tag: OpenSSL_0_9_6-stable CHANGES
               crypto/bn Tag: OpenSSL_0_9_6-stable bn.h bn_rand.c bntest.c
  Log:
  improved bignum test as in 0.9.7.
  We need this to find out if the bignum failures on Irix and Alpha are
  caused by new 0.9.7 code or just aren't triggered in the 0.9.6 test suite.
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.618.2.43 +3 -0      openssl/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /e/openssl/cvs/openssl/CHANGES,v
  retrieving revision 1.618.2.42
  retrieving revision 1.618.2.43
  diff -u -r1.618.2.42 -r1.618.2.43
  --- CHANGES	2001/02/24 17:32:20	1.618.2.42
  +++ CHANGES	2001/02/27 23:00:13	1.618.2.43
  @@ -4,6 +4,9 @@
   
    Changes between 0.9.6 and 0.9.6a  [xx XXX 2001]
   
  +  *) Use better test patterns in bntest.
  +     [Ulf Möller]
  +
     *) Initialise "ex_data" member of RSA/DSA/DH structures prior to calling
        the method-specific "init()" handler. Also clean up ex_data after
        calling the method-specific "finish()" handler. Previously, this was
  
  
  No                   revision
  No                   revision
  1.41.2.7  +2 -0      openssl/crypto/bn/bn.h
  1.9.2.9   +28 -0     openssl/crypto/bn/bn_rand.c
  1.27.4.2  +30 -32    openssl/crypto/bn/bntest.c
  
  Index: bn.h
  ===================================================================
  RCS file: /e/openssl/cvs/openssl/crypto/bn/bn.h,v
  retrieving revision 1.41.2.6
  retrieving revision 1.41.2.7
  diff -u -r1.41.2.6 -r1.41.2.7
  --- bn.h	2001/02/10 00:34:10	1.41.2.6
  +++ bn.h	2001/02/27 23:00:40	1.41.2.7
  @@ -468,6 +468,8 @@
   # define bn_dump(a,b)
   #endif
   
  +int BN_bntest_rand(BIGNUM *rnd, int bits, int top,int bottom);
  +
   /* BEGIN ERROR CODES */
   /* The following lines are auto generated by the script mkerr.pl. Any changes
    * made after this point may be overwritten when the script is next run.
  
  Index: bn_rand.c
  ===================================================================
  RCS file: /e/openssl/cvs/openssl/crypto/bn/bn_rand.c,v
  retrieving revision 1.9.2.8
  retrieving revision 1.9.2.9
  diff -u -r1.9.2.8 -r1.9.2.9
  --- bn_rand.c	2001/02/20 08:22:25	1.9.2.8
  +++ bn_rand.c	2001/02/27 23:00:41	1.9.2.9
  @@ -100,6 +100,27 @@
   			goto err;
   		}
   
  +#if 1
  +	if (pseudorand == 2)
  +		{
  +		/* generate patterns that are more likely to trigger BN
  +		   library bugs */
  +		int i;
  +		unsigned char c;
  +
  +		for (i = 0; i < bytes; i++)
  +			{
  +			RAND_pseudo_bytes(&c, 1);
  +			if (c >= 128 && i > 0)
  +				buf[i] = buf[i-1];
  +			else if (c < 42)
  +				buf[i] = 0;
  +			else if (c < 84)
  +				buf[i] = 255;
  +			}
  +		}
  +#endif
  +
   	if (top != -1)
   		{
   		if (top)
  @@ -142,6 +163,13 @@
   	{
   	return bnrand(1, rnd, bits, top, bottom);
   	}
  +
  +#if 1
  +int     BN_bntest_rand(BIGNUM *rnd, int bits, int top, int bottom)
  +	{
  +	return bnrand(2, rnd, bits, top, bottom);
  +	}
  +#endif
   
   /* random number r:  0 <= r < range */
   int	BN_rand_range(BIGNUM *r, BIGNUM *range)
  
  Index: bntest.c
  ===================================================================
  RCS file: /e/openssl/cvs/openssl/crypto/bn/bntest.c,v
  retrieving revision 1.27.4.1
  retrieving revision 1.27.4.2
  diff -u -r1.27.4.1 -r1.27.4.2
  --- bntest.c	2001/01/18 12:41:25	1.27.4.1
  +++ bntest.c	2001/02/27 23:00:42	1.27.4.2
  @@ -120,9 +120,7 @@
   
   	results = 0;
   
  -	RAND_seed(rnd_seed, sizeof rnd_seed); /* or BN_rand may fail, and we don't
  -	                                       * even check its return value
  -	                                       * (which we should) */
  +	RAND_seed(rnd_seed, sizeof rnd_seed); /* or BN_generate_prime may fail */
   
   	argc--;
   	argv++;
  @@ -251,10 +249,10 @@
   	BN_init(&b);
   	BN_init(&c);
   
  -	BN_rand(&a,512,0,0);
  +	BN_bntest_rand(&a,512,0,0);
   	for (i=0; i<num0; i++)
   		{
  -		BN_rand(&b,450+i,0,0);
  +		BN_bntest_rand(&b,450+i,0,0);
   		a.neg=rand_neg();
   		b.neg=rand_neg();
   		if (bp == NULL)
  @@ -303,14 +301,14 @@
   		{
   		if (i < num1)
   			{
  -			BN_rand(&a,512,0,0);
  +			BN_bntest_rand(&a,512,0,0);
   			BN_copy(&b,&a);
   			if (BN_set_bit(&a,i)==0) return(0);
   			BN_add_word(&b,i);
   			}
   		else
   			{
  -			BN_rand(&b,400+i-num1,0,0);
  +			BN_bntest_rand(&b,400+i-num1,0,0);
   			a.neg=rand_neg();
   			b.neg=rand_neg();
   			}
  @@ -360,13 +358,13 @@
   		{
   		if (i < num1)
   			{
  -			BN_rand(&a,400,0,0);
  +			BN_bntest_rand(&a,400,0,0);
   			BN_copy(&b,&a);
   			BN_lshift(&a,&a,i);
   			BN_add_word(&a,i);
   			}
   		else
  -			BN_rand(&b,50+3*(i-num1),0,0);
  +			BN_bntest_rand(&b,50+3*(i-num1),0,0);
   		a.neg=rand_neg();
   		b.neg=rand_neg();
   		if (bp == NULL)
  @@ -430,13 +428,13 @@
   		{
   		if (i < num1)
   			{
  -			BN_rand(&a,400,0,0);
  +			BN_bntest_rand(&a,400,0,0);
   			BN_copy(&b,&a);
   			BN_lshift(&a,&a,i);
   			BN_add_word(&a,i);
   			}
   		else
  -			BN_rand(&b,50+3*(i-num1),0,0);
  +			BN_bntest_rand(&b,50+3*(i-num1),0,0);
   		a.neg=rand_neg();
   		b.neg=rand_neg();
   		BN_RECP_CTX_set(&recp,&b,ctx);
  @@ -507,11 +505,11 @@
   		{
   		if (i <= num1)
   			{
  -			BN_rand(&a,100,0,0);
  -			BN_rand(&b,100,0,0);
  +			BN_bntest_rand(&a,100,0,0);
  +			BN_bntest_rand(&b,100,0,0);
   			}
   		else
  -			BN_rand(&b,i-num1,0,0);
  +			BN_bntest_rand(&b,i-num1,0,0);
   		a.neg=rand_neg();
   		b.neg=rand_neg();
   		if (bp == NULL)
  @@ -560,7 +558,7 @@
   
   	for (i=0; i<num0; i++)
   		{
  -		BN_rand(&a,40+i*10,0,0);
  +		BN_bntest_rand(&a,40+i*10,0,0);
   		a.neg=rand_neg();
   		if (bp == NULL)
   			for (j=0; j<100; j++)
  @@ -611,15 +609,15 @@
   
   	mont=BN_MONT_CTX_new();
   
  -	BN_rand(&a,100,0,0); /**/
  -	BN_rand(&b,100,0,0); /**/
  +	BN_bntest_rand(&a,100,0,0); /**/
  +	BN_bntest_rand(&b,100,0,0); /**/
   	for (i=0; i<num2; i++)
   		{
   		int bits = (200*(i+1))/num2;
   
   		if (bits == 0)
   			continue;
  -		BN_rand(&n,bits,0,1);
  +		BN_bntest_rand(&n,bits,0,1);
   		BN_MONT_CTX_set(mont,&n,ctx);
   
   		BN_to_montgomery(&A,&a,mont,ctx);
  @@ -681,10 +679,10 @@
   	d=BN_new();
   	e=BN_new();
   
  -	BN_rand(a,1024,0,0); /**/
  +	BN_bntest_rand(a,1024,0,0); /**/
   	for (i=0; i<num0; i++)
   		{
  -		BN_rand(b,450+i*10,0,0); /**/
  +		BN_bntest_rand(b,450+i*10,0,0); /**/
   		a->neg=rand_neg();
   		b->neg=rand_neg();
   		if (bp == NULL)
  @@ -730,11 +728,11 @@
   	d=BN_new();
   	e=BN_new();
   
  -	BN_rand(c,1024,0,0); /**/
  +	BN_bntest_rand(c,1024,0,0); /**/
   	for (i=0; i<num0; i++)
   		{
  -		BN_rand(a,475+i*10,0,0); /**/
  -		BN_rand(b,425+i*11,0,0); /**/
  +		BN_bntest_rand(a,475+i*10,0,0); /**/
  +		BN_bntest_rand(b,425+i*11,0,0); /**/
   		a->neg=rand_neg();
   		b->neg=rand_neg();
   	/*	if (bp == NULL)
  @@ -792,11 +790,11 @@
   	d=BN_new();
   	e=BN_new();
   
  -	BN_rand(c,30,0,1); /* must be odd for montgomery */
  +	BN_bntest_rand(c,30,0,1); /* must be odd for montgomery */
   	for (i=0; i<num2; i++)
   		{
  -		BN_rand(a,20+i*5,0,0); /**/
  -		BN_rand(b,2+i,0,0); /**/
  +		BN_bntest_rand(a,20+i*5,0,0); /**/
  +		BN_bntest_rand(b,2+i,0,0); /**/
   
   		if (!BN_mod_exp(d,a,b,c,ctx))
   			return(00);
  @@ -846,8 +844,8 @@
   
   	for (i=0; i<num2; i++)
   		{
  -		BN_rand(a,20+i*5,0,0); /**/
  -		BN_rand(b,2+i,0,0); /**/
  +		BN_bntest_rand(a,20+i*5,0,0); /**/
  +		BN_bntest_rand(b,2+i,0,0); /**/
   
   		if (!BN_exp(d,a,b,ctx))
   			return(00);
  @@ -897,7 +895,7 @@
   	else
   	    {
   	    a=BN_new();
  -	    BN_rand(a,200,0,0); /**/
  +	    BN_bntest_rand(a,200,0,0); /**/
   	    a->neg=rand_neg();
   	    }
   	for (i=0; i<num0; i++)
  @@ -949,7 +947,7 @@
   	b=BN_new();
   	c=BN_new();
   
  -	BN_rand(a,200,0,0); /**/
  +	BN_bntest_rand(a,200,0,0); /**/
   	a->neg=rand_neg();
   	for (i=0; i<num0; i++)
   		{
  @@ -993,7 +991,7 @@
   	e=BN_new();
   	BN_one(c);
   
  -	BN_rand(a,200,0,0); /**/
  +	BN_bntest_rand(a,200,0,0); /**/
   	a->neg=rand_neg();
   	for (i=0; i<num0; i++)
   		{
  @@ -1036,7 +1034,7 @@
   	b=BN_new();
   	c=BN_new();
   
  -	BN_rand(a,200,0,0); /**/
  +	BN_bntest_rand(a,200,0,0); /**/
   	a->neg=rand_neg();
   	for (i=0; i<num0; i++)
   		{
  
  
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
CVS Repository Commit List                     openssl-cvs@openssl.org
Automated List Manager                           majordomo@openssl.org

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic