"print" is GNU bc specific.
[oweals/openssl.git] / crypto / rsa / rsa_lib.c
index c0ca2923a699d123f6933b79864c2f2c64fcabed..074a4f5074b44e4b8aab81ef7cd9ced2bffd5ebd 100644 (file)
@@ -67,7 +67,7 @@ const char *RSA_version="RSA" OPENSSL_VERSION_PTEXT;
 
 static RSA_METHOD *default_RSA_meth=NULL;
 static int rsa_meth_num=0;
-static STACK *rsa_meth=NULL;
+static STACK_OF(CRYPTO_EX_DATA_FUNCS) *rsa_meth=NULL;
 
 RSA *RSA_new(void)
        {
@@ -105,10 +105,14 @@ RSA *RSA_new_method(RSA_METHOD *meth)
 
        if (default_RSA_meth == NULL)
                {
+#ifdef RSA_NULL
+               default_RSA_meth=RSA_null_method();
+#else
 #ifdef RSAref
                default_RSA_meth=RSA_PKCS1_RSAref();
 #else
                default_RSA_meth=RSA_PKCS1_SSLeay();
+#endif
 #endif
                }
        ret=(RSA *)Malloc(sizeof(RSA));
@@ -146,7 +150,7 @@ RSA *RSA_new_method(RSA_METHOD *meth)
                ret=NULL;
                }
        else
-               CRYPTO_new_ex_data(rsa_meth,(char *)ret,&ret->ex_data);
+               CRYPTO_new_ex_data(rsa_meth,ret,&ret->ex_data);
        return(ret);
        }
 
@@ -169,7 +173,7 @@ void RSA_free(RSA *r)
                }
 #endif
 
-       CRYPTO_free_ex_data(rsa_meth,(char *)r,&r->ex_data);
+       CRYPTO_free_ex_data(rsa_meth,r,&r->ex_data);
 
        if (r->meth->finish != NULL)
                r->meth->finish(r);
@@ -187,20 +191,20 @@ void RSA_free(RSA *r)
        Free(r);
        }
 
-int RSA_get_ex_new_index(long argl, char *argp, int (*new_func)(),
-            int (*dup_func)(), void (*free_func)())
+int RSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
+            CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
         {
        rsa_meth_num++;
        return(CRYPTO_get_ex_new_index(rsa_meth_num-1,
                &rsa_meth,argl,argp,new_func,dup_func,free_func));
         }
 
-int RSA_set_ex_data(RSA *r, int idx, char *arg)
+int RSA_set_ex_data(RSA *r, int idx, void *arg)
        {
        return(CRYPTO_set_ex_data(&r->ex_data,idx,arg));
        }
 
-char *RSA_get_ex_data(RSA *r, int idx)
+void *RSA_get_ex_data(RSA *r, int idx)
        {
        return(CRYPTO_get_ex_data(&r->ex_data,idx));
        }
@@ -265,19 +269,19 @@ int RSA_blinding_on(RSA *rsa, BN_CTX *p_ctx)
        if (rsa->blinding != NULL)
                BN_BLINDING_free(rsa->blinding);
 
-       A= &(ctx->bn[0]);
-       ctx->tos++;
+       BN_CTX_start(ctx);
+       A = BN_CTX_get(ctx);
        if (!BN_rand(A,BN_num_bits(rsa->n)-1,1,0)) goto err;
        if ((Ai=BN_mod_inverse(NULL,A,rsa->n,ctx)) == NULL) goto err;
 
        if (!rsa->meth->bn_mod_exp(A,A,rsa->e,rsa->n,ctx,rsa->_method_mod_n))
            goto err;
        rsa->blinding=BN_BLINDING_new(A,Ai,rsa->n);
-       ctx->tos--;
        rsa->flags|=RSA_FLAG_BLINDING;
        BN_free(Ai);
        ret=1;
 err:
+       BN_CTX_end(ctx);
        if (ctx != p_ctx) BN_CTX_free(ctx);
        return(ret);
        }