"print" is GNU bc specific.
[oweals/openssl.git] / crypto / rsa / rsa_gen.c
index 89e2f2e2e2d527c594695d425dba3c0f7eebec47..95e636d3f0233e3148e13c545d626539e5ccc8a7 100644 (file)
@@ -74,11 +74,12 @@ RSA *RSA_generate_key(int bits, unsigned long e_value,
        if (ctx == NULL) goto err;
        ctx2=BN_CTX_new();
        if (ctx2 == NULL) goto err;
-       r0= &(ctx->bn[0]);
-       r1= &(ctx->bn[1]);
-       r2= &(ctx->bn[2]);
-       r3= &(ctx->bn[3]);
-       ctx->tos+=4;
+       BN_CTX_start(ctx);
+       r0 = BN_CTX_get(ctx);
+       r1 = BN_CTX_get(ctx);
+       r2 = BN_CTX_get(ctx);
+       r3 = BN_CTX_get(ctx);
+       if (r3 == NULL) goto err;
 
        bitsp=(bits+1)/2;
        bitsq=bits-bitsp;
@@ -157,7 +158,7 @@ RSA *RSA_generate_key(int bits, unsigned long e_value,
                goto err;
                }
 */
-       rsa->d=(BIGNUM *)BN_mod_inverse(NULL,rsa->e,r0,ctx2);   /* d */
+       rsa->d=BN_mod_inverse(NULL,rsa->e,r0,ctx2);     /* d */
        if (rsa->d == NULL) goto err;
 
        /* calculate d mod (p-1) */
@@ -181,6 +182,7 @@ err:
                RSAerr(RSA_F_RSA_GENERATE_KEY,ERR_LIB_BN);
                ok=0;
                }
+       BN_CTX_end(ctx);
        BN_CTX_free(ctx);
        BN_CTX_free(ctx2);