diff options
author | beck <> | 2000-03-19 11:13:58 +0000 |
---|---|---|
committer | beck <> | 2000-03-19 11:13:58 +0000 |
commit | 796d609550df3a33fc11468741c5d2f6d3df4c11 (patch) | |
tree | 6c6d539061caa20372dad0ac4ddb1dfae2fbe7fe /src/lib/libcrypto/rsa/rsa_lib.c | |
parent | 5be3114c1fd7e0dfea1e38d3abb4cbba75244419 (diff) | |
download | openbsd-796d609550df3a33fc11468741c5d2f6d3df4c11.tar.gz openbsd-796d609550df3a33fc11468741c5d2f6d3df4c11.tar.bz2 openbsd-796d609550df3a33fc11468741c5d2f6d3df4c11.zip |
OpenSSL 0.9.5 merge
*warning* this bumps shared lib minors for libssl and libcrypto from 2.1 to 2.2
if you are using the ssl26 packages for ssh and other things to work you will
need to get new ones (see ~beck/libsslsnap/<arch>) on cvs or ~beck/src-patent.tar.gz on cvs
Diffstat (limited to 'src/lib/libcrypto/rsa/rsa_lib.c')
-rw-r--r-- | src/lib/libcrypto/rsa/rsa_lib.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/lib/libcrypto/rsa/rsa_lib.c b/src/lib/libcrypto/rsa/rsa_lib.c index c0ca2923a6..074a4f5074 100644 --- a/src/lib/libcrypto/rsa/rsa_lib.c +++ b/src/lib/libcrypto/rsa/rsa_lib.c | |||
@@ -67,7 +67,7 @@ const char *RSA_version="RSA" OPENSSL_VERSION_PTEXT; | |||
67 | 67 | ||
68 | static RSA_METHOD *default_RSA_meth=NULL; | 68 | static RSA_METHOD *default_RSA_meth=NULL; |
69 | static int rsa_meth_num=0; | 69 | static int rsa_meth_num=0; |
70 | static STACK *rsa_meth=NULL; | 70 | static STACK_OF(CRYPTO_EX_DATA_FUNCS) *rsa_meth=NULL; |
71 | 71 | ||
72 | RSA *RSA_new(void) | 72 | RSA *RSA_new(void) |
73 | { | 73 | { |
@@ -105,11 +105,15 @@ RSA *RSA_new_method(RSA_METHOD *meth) | |||
105 | 105 | ||
106 | if (default_RSA_meth == NULL) | 106 | if (default_RSA_meth == NULL) |
107 | { | 107 | { |
108 | #ifdef RSA_NULL | ||
109 | default_RSA_meth=RSA_null_method(); | ||
110 | #else | ||
108 | #ifdef RSAref | 111 | #ifdef RSAref |
109 | default_RSA_meth=RSA_PKCS1_RSAref(); | 112 | default_RSA_meth=RSA_PKCS1_RSAref(); |
110 | #else | 113 | #else |
111 | default_RSA_meth=RSA_PKCS1_SSLeay(); | 114 | default_RSA_meth=RSA_PKCS1_SSLeay(); |
112 | #endif | 115 | #endif |
116 | #endif | ||
113 | } | 117 | } |
114 | ret=(RSA *)Malloc(sizeof(RSA)); | 118 | ret=(RSA *)Malloc(sizeof(RSA)); |
115 | if (ret == NULL) | 119 | if (ret == NULL) |
@@ -146,7 +150,7 @@ RSA *RSA_new_method(RSA_METHOD *meth) | |||
146 | ret=NULL; | 150 | ret=NULL; |
147 | } | 151 | } |
148 | else | 152 | else |
149 | CRYPTO_new_ex_data(rsa_meth,(char *)ret,&ret->ex_data); | 153 | CRYPTO_new_ex_data(rsa_meth,ret,&ret->ex_data); |
150 | return(ret); | 154 | return(ret); |
151 | } | 155 | } |
152 | 156 | ||
@@ -169,7 +173,7 @@ void RSA_free(RSA *r) | |||
169 | } | 173 | } |
170 | #endif | 174 | #endif |
171 | 175 | ||
172 | CRYPTO_free_ex_data(rsa_meth,(char *)r,&r->ex_data); | 176 | CRYPTO_free_ex_data(rsa_meth,r,&r->ex_data); |
173 | 177 | ||
174 | if (r->meth->finish != NULL) | 178 | if (r->meth->finish != NULL) |
175 | r->meth->finish(r); | 179 | r->meth->finish(r); |
@@ -187,20 +191,20 @@ void RSA_free(RSA *r) | |||
187 | Free(r); | 191 | Free(r); |
188 | } | 192 | } |
189 | 193 | ||
190 | int RSA_get_ex_new_index(long argl, char *argp, int (*new_func)(), | 194 | int RSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, |
191 | int (*dup_func)(), void (*free_func)()) | 195 | CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) |
192 | { | 196 | { |
193 | rsa_meth_num++; | 197 | rsa_meth_num++; |
194 | return(CRYPTO_get_ex_new_index(rsa_meth_num-1, | 198 | return(CRYPTO_get_ex_new_index(rsa_meth_num-1, |
195 | &rsa_meth,argl,argp,new_func,dup_func,free_func)); | 199 | &rsa_meth,argl,argp,new_func,dup_func,free_func)); |
196 | } | 200 | } |
197 | 201 | ||
198 | int RSA_set_ex_data(RSA *r, int idx, char *arg) | 202 | int RSA_set_ex_data(RSA *r, int idx, void *arg) |
199 | { | 203 | { |
200 | return(CRYPTO_set_ex_data(&r->ex_data,idx,arg)); | 204 | return(CRYPTO_set_ex_data(&r->ex_data,idx,arg)); |
201 | } | 205 | } |
202 | 206 | ||
203 | char *RSA_get_ex_data(RSA *r, int idx) | 207 | void *RSA_get_ex_data(RSA *r, int idx) |
204 | { | 208 | { |
205 | return(CRYPTO_get_ex_data(&r->ex_data,idx)); | 209 | return(CRYPTO_get_ex_data(&r->ex_data,idx)); |
206 | } | 210 | } |
@@ -265,19 +269,19 @@ int RSA_blinding_on(RSA *rsa, BN_CTX *p_ctx) | |||
265 | if (rsa->blinding != NULL) | 269 | if (rsa->blinding != NULL) |
266 | BN_BLINDING_free(rsa->blinding); | 270 | BN_BLINDING_free(rsa->blinding); |
267 | 271 | ||
268 | A= &(ctx->bn[0]); | 272 | BN_CTX_start(ctx); |
269 | ctx->tos++; | 273 | A = BN_CTX_get(ctx); |
270 | if (!BN_rand(A,BN_num_bits(rsa->n)-1,1,0)) goto err; | 274 | if (!BN_rand(A,BN_num_bits(rsa->n)-1,1,0)) goto err; |
271 | if ((Ai=BN_mod_inverse(NULL,A,rsa->n,ctx)) == NULL) goto err; | 275 | if ((Ai=BN_mod_inverse(NULL,A,rsa->n,ctx)) == NULL) goto err; |
272 | 276 | ||
273 | if (!rsa->meth->bn_mod_exp(A,A,rsa->e,rsa->n,ctx,rsa->_method_mod_n)) | 277 | if (!rsa->meth->bn_mod_exp(A,A,rsa->e,rsa->n,ctx,rsa->_method_mod_n)) |
274 | goto err; | 278 | goto err; |
275 | rsa->blinding=BN_BLINDING_new(A,Ai,rsa->n); | 279 | rsa->blinding=BN_BLINDING_new(A,Ai,rsa->n); |
276 | ctx->tos--; | ||
277 | rsa->flags|=RSA_FLAG_BLINDING; | 280 | rsa->flags|=RSA_FLAG_BLINDING; |
278 | BN_free(Ai); | 281 | BN_free(Ai); |
279 | ret=1; | 282 | ret=1; |
280 | err: | 283 | err: |
284 | BN_CTX_end(ctx); | ||
281 | if (ctx != p_ctx) BN_CTX_free(ctx); | 285 | if (ctx != p_ctx) BN_CTX_free(ctx); |
282 | return(ret); | 286 | return(ret); |
283 | } | 287 | } |