[EMAIL PROTECTED] wrote:
...
>   Index: rsa_gen.c
>   ===================================================================
>   RCS file: /e/openssl/cvs/openssl/crypto/rsa/rsa_gen.c,v
>   retrieving revision 1.8
>   retrieving revision 1.9
>   diff -u -r1.8 -r1.9
...
>   +   /* We need the RSA components non-NULL */
>   +   if(!rsa->n && ((rsa->n=BN_new()) == NULL)) goto err;
>   +   if(!rsa->d && ((rsa->d=BN_new()) == NULL)) goto err;
>   +   if(!rsa->e && ((rsa->e=BN_new()) == NULL)) goto err;
>   +   if(!rsa->p && ((rsa->p=BN_new()) == NULL)) goto err;
>   +   if(!rsa->q && ((rsa->q=BN_new()) == NULL)) goto err;
>   +   if(!rsa->dmp1 && ((rsa->dmp1=BN_new()) == NULL)) goto err;
>   +   if(!rsa->dmq1 && ((rsa->dmq1=BN_new()) == NULL)) goto err;
>   +   if(!rsa->iqmp && ((rsa->iqmp=BN_new()) == NULL)) goto err;

Hi Geoff,

there is small memory leak in rsa_gen.c (see attached patch).

Regards,
Nils
Index: crypto/rsa/rsa_gen.c
===================================================================
RCS file: /home/nils/openssl-cvs/openssl/crypto/rsa/rsa_gen.c,v
retrieving revision 1.9
diff -u -r1.9 rsa_gen.c
--- crypto/rsa/rsa_gen.c	2002/12/08 05:24:25	1.9
+++ crypto/rsa/rsa_gen.c	2002/12/08 14:54:26
@@ -166,22 +166,16 @@
 		goto err;
 		}
 */
-	rsa->d=BN_mod_inverse(NULL,rsa->e,r0,ctx2);	/* d */
-	if (rsa->d == NULL) goto err;
+	if (!BN_mod_inverse(rsa->d,rsa->e,r0,ctx2)) goto err;	/* d */
 
 	/* calculate d mod (p-1) */
-	rsa->dmp1=BN_new();
-	if (rsa->dmp1 == NULL) goto err;
 	if (!BN_mod(rsa->dmp1,rsa->d,r1,ctx)) goto err;
 
 	/* calculate d mod (q-1) */
-	rsa->dmq1=BN_new();
-	if (rsa->dmq1 == NULL) goto err;
 	if (!BN_mod(rsa->dmq1,rsa->d,r2,ctx)) goto err;
 
 	/* calculate inverse of q mod p */
-	rsa->iqmp=BN_mod_inverse(NULL,rsa->q,rsa->p,ctx2);
-	if (rsa->iqmp == NULL) goto err;
+	if (!BN_mod_inverse(rsa->iqmp,rsa->q,rsa->p,ctx2)) goto err;
 
 	ok=1;
 err:

Reply via email to