diff options
author | markus <> | 2003-03-17 19:57:16 +0000 |
---|---|---|
committer | markus <> | 2003-03-17 19:57:16 +0000 |
commit | f70fbcbe107b93fd24d31f9afa4e99bf2464a2b7 (patch) | |
tree | bec19d17062fad889c529144dab8655dc0a8de38 | |
parent | a4c0f9de9c618e0271a7e122136bdfe50301a6d7 (diff) | |
download | openbsd-f70fbcbe107b93fd24d31f9afa4e99bf2464a2b7.tar.gz openbsd-f70fbcbe107b93fd24d31f9afa4e99bf2464a2b7.tar.bz2 openbsd-f70fbcbe107b93fd24d31f9afa4e99bf2464a2b7.zip |
update to official patch from openssl.org; ok deraadt@, millert@
-rw-r--r-- | src/lib/libcrypto/rsa/rsa_eay.c | 42 | ||||
-rw-r--r-- | src/lib/libcrypto/rsa/rsa_lib.c | 12 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/rsa/rsa_eay.c | 42 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/rsa/rsa_lib.c | 12 |
4 files changed, 56 insertions, 52 deletions
diff --git a/src/lib/libcrypto/rsa/rsa_eay.c b/src/lib/libcrypto/rsa/rsa_eay.c index 3fe1cd6540..a3f549d8e6 100644 --- a/src/lib/libcrypto/rsa/rsa_eay.c +++ b/src/lib/libcrypto/rsa/rsa_eay.c | |||
@@ -97,21 +97,6 @@ const RSA_METHOD *RSA_PKCS1_SSLeay(void) | |||
97 | return(&rsa_pkcs1_eay_meth); | 97 | return(&rsa_pkcs1_eay_meth); |
98 | } | 98 | } |
99 | 99 | ||
100 | static void rsa_eay_blinding(RSA *rsa, BN_CTX *ctx) | ||
101 | { | ||
102 | CRYPTO_w_lock(CRYPTO_LOCK_RSA); | ||
103 | /* Check again inside the lock - the macro's check is racey */ | ||
104 | if(rsa->blinding == NULL) | ||
105 | RSA_blinding_on(rsa, ctx); | ||
106 | CRYPTO_w_unlock(CRYPTO_LOCK_RSA); | ||
107 | } | ||
108 | #define BLINDING_HELPER(rsa, ctx) \ | ||
109 | do { \ | ||
110 | if(((rsa)->flags & RSA_FLAG_BLINDING) && \ | ||
111 | ((rsa)->blinding == NULL)) \ | ||
112 | rsa_eay_blinding(rsa, ctx); \ | ||
113 | } while(0) | ||
114 | |||
115 | static int RSA_eay_public_encrypt(int flen, const unsigned char *from, | 100 | static int RSA_eay_public_encrypt(int flen, const unsigned char *from, |
116 | unsigned char *to, RSA *rsa, int padding) | 101 | unsigned char *to, RSA *rsa, int padding) |
117 | { | 102 | { |
@@ -208,6 +193,25 @@ err: | |||
208 | return(r); | 193 | return(r); |
209 | } | 194 | } |
210 | 195 | ||
196 | static int rsa_eay_blinding(RSA *rsa, BN_CTX *ctx) | ||
197 | { | ||
198 | int ret = 1; | ||
199 | CRYPTO_w_lock(CRYPTO_LOCK_RSA); | ||
200 | /* Check again inside the lock - the macro's check is racey */ | ||
201 | if(rsa->blinding == NULL) | ||
202 | ret = RSA_blinding_on(rsa, ctx); | ||
203 | CRYPTO_w_unlock(CRYPTO_LOCK_RSA); | ||
204 | return ret; | ||
205 | } | ||
206 | |||
207 | #define BLINDING_HELPER(rsa, ctx, err_instr) \ | ||
208 | do { \ | ||
209 | if(((rsa)->flags & RSA_FLAG_BLINDING) && \ | ||
210 | ((rsa)->blinding == NULL) && \ | ||
211 | !rsa_eay_blinding(rsa, ctx)) \ | ||
212 | err_instr \ | ||
213 | } while(0) | ||
214 | |||
211 | /* signing */ | 215 | /* signing */ |
212 | static int RSA_eay_private_encrypt(int flen, const unsigned char *from, | 216 | static int RSA_eay_private_encrypt(int flen, const unsigned char *from, |
213 | unsigned char *to, RSA *rsa, int padding) | 217 | unsigned char *to, RSA *rsa, int padding) |
@@ -252,7 +256,7 @@ static int RSA_eay_private_encrypt(int flen, const unsigned char *from, | |||
252 | goto err; | 256 | goto err; |
253 | } | 257 | } |
254 | 258 | ||
255 | BLINDING_HELPER(rsa, ctx); | 259 | BLINDING_HELPER(rsa, ctx, goto err;); |
256 | 260 | ||
257 | if (rsa->flags & RSA_FLAG_BLINDING) | 261 | if (rsa->flags & RSA_FLAG_BLINDING) |
258 | if (!BN_BLINDING_convert(&f,rsa->blinding,ctx)) goto err; | 262 | if (!BN_BLINDING_convert(&f,rsa->blinding,ctx)) goto err; |
@@ -331,7 +335,7 @@ static int RSA_eay_private_decrypt(int flen, const unsigned char *from, | |||
331 | goto err; | 335 | goto err; |
332 | } | 336 | } |
333 | 337 | ||
334 | BLINDING_HELPER(rsa, ctx); | 338 | BLINDING_HELPER(rsa, ctx, goto err;); |
335 | 339 | ||
336 | if (rsa->flags & RSA_FLAG_BLINDING) | 340 | if (rsa->flags & RSA_FLAG_BLINDING) |
337 | if (!BN_BLINDING_convert(&f,rsa->blinding,ctx)) goto err; | 341 | if (!BN_BLINDING_convert(&f,rsa->blinding,ctx)) goto err; |
@@ -607,10 +611,6 @@ err: | |||
607 | static int RSA_eay_init(RSA *rsa) | 611 | static int RSA_eay_init(RSA *rsa) |
608 | { | 612 | { |
609 | rsa->flags|=RSA_FLAG_CACHE_PUBLIC|RSA_FLAG_CACHE_PRIVATE; | 613 | rsa->flags|=RSA_FLAG_CACHE_PUBLIC|RSA_FLAG_CACHE_PRIVATE; |
610 | |||
611 | /* Enforce blinding. */ | ||
612 | rsa->flags|=RSA_FLAG_BLINDING; | ||
613 | |||
614 | return(1); | 614 | return(1); |
615 | } | 615 | } |
616 | 616 | ||
diff --git a/src/lib/libcrypto/rsa/rsa_lib.c b/src/lib/libcrypto/rsa/rsa_lib.c index f71870a338..37fff8bce3 100644 --- a/src/lib/libcrypto/rsa/rsa_lib.c +++ b/src/lib/libcrypto/rsa/rsa_lib.c | |||
@@ -70,7 +70,13 @@ static const RSA_METHOD *default_RSA_meth=NULL; | |||
70 | 70 | ||
71 | RSA *RSA_new(void) | 71 | RSA *RSA_new(void) |
72 | { | 72 | { |
73 | return(RSA_new_method(NULL)); | 73 | RSA *r=RSA_new_method(NULL); |
74 | |||
75 | #ifndef OPENSSL_NO_FORCE_RSA_BLINDING | ||
76 | r->flags|=RSA_FLAG_BLINDING; | ||
77 | #endif | ||
78 | |||
79 | return r; | ||
74 | } | 80 | } |
75 | 81 | ||
76 | void RSA_set_default_method(const RSA_METHOD *meth) | 82 | void RSA_set_default_method(const RSA_METHOD *meth) |
@@ -181,10 +187,6 @@ RSA *RSA_new_method(ENGINE *engine) | |||
181 | OPENSSL_free(ret); | 187 | OPENSSL_free(ret); |
182 | ret=NULL; | 188 | ret=NULL; |
183 | } | 189 | } |
184 | |||
185 | /* Enforce blinding. */ | ||
186 | ret->flags |= RSA_FLAG_BLINDING; | ||
187 | |||
188 | return(ret); | 190 | return(ret); |
189 | } | 191 | } |
190 | 192 | ||
diff --git a/src/lib/libssl/src/crypto/rsa/rsa_eay.c b/src/lib/libssl/src/crypto/rsa/rsa_eay.c index 3fe1cd6540..a3f549d8e6 100644 --- a/src/lib/libssl/src/crypto/rsa/rsa_eay.c +++ b/src/lib/libssl/src/crypto/rsa/rsa_eay.c | |||
@@ -97,21 +97,6 @@ const RSA_METHOD *RSA_PKCS1_SSLeay(void) | |||
97 | return(&rsa_pkcs1_eay_meth); | 97 | return(&rsa_pkcs1_eay_meth); |
98 | } | 98 | } |
99 | 99 | ||
100 | static void rsa_eay_blinding(RSA *rsa, BN_CTX *ctx) | ||
101 | { | ||
102 | CRYPTO_w_lock(CRYPTO_LOCK_RSA); | ||
103 | /* Check again inside the lock - the macro's check is racey */ | ||
104 | if(rsa->blinding == NULL) | ||
105 | RSA_blinding_on(rsa, ctx); | ||
106 | CRYPTO_w_unlock(CRYPTO_LOCK_RSA); | ||
107 | } | ||
108 | #define BLINDING_HELPER(rsa, ctx) \ | ||
109 | do { \ | ||
110 | if(((rsa)->flags & RSA_FLAG_BLINDING) && \ | ||
111 | ((rsa)->blinding == NULL)) \ | ||
112 | rsa_eay_blinding(rsa, ctx); \ | ||
113 | } while(0) | ||
114 | |||
115 | static int RSA_eay_public_encrypt(int flen, const unsigned char *from, | 100 | static int RSA_eay_public_encrypt(int flen, const unsigned char *from, |
116 | unsigned char *to, RSA *rsa, int padding) | 101 | unsigned char *to, RSA *rsa, int padding) |
117 | { | 102 | { |
@@ -208,6 +193,25 @@ err: | |||
208 | return(r); | 193 | return(r); |
209 | } | 194 | } |
210 | 195 | ||
196 | static int rsa_eay_blinding(RSA *rsa, BN_CTX *ctx) | ||
197 | { | ||
198 | int ret = 1; | ||
199 | CRYPTO_w_lock(CRYPTO_LOCK_RSA); | ||
200 | /* Check again inside the lock - the macro's check is racey */ | ||
201 | if(rsa->blinding == NULL) | ||
202 | ret = RSA_blinding_on(rsa, ctx); | ||
203 | CRYPTO_w_unlock(CRYPTO_LOCK_RSA); | ||
204 | return ret; | ||
205 | } | ||
206 | |||
207 | #define BLINDING_HELPER(rsa, ctx, err_instr) \ | ||
208 | do { \ | ||
209 | if(((rsa)->flags & RSA_FLAG_BLINDING) && \ | ||
210 | ((rsa)->blinding == NULL) && \ | ||
211 | !rsa_eay_blinding(rsa, ctx)) \ | ||
212 | err_instr \ | ||
213 | } while(0) | ||
214 | |||
211 | /* signing */ | 215 | /* signing */ |
212 | static int RSA_eay_private_encrypt(int flen, const unsigned char *from, | 216 | static int RSA_eay_private_encrypt(int flen, const unsigned char *from, |
213 | unsigned char *to, RSA *rsa, int padding) | 217 | unsigned char *to, RSA *rsa, int padding) |
@@ -252,7 +256,7 @@ static int RSA_eay_private_encrypt(int flen, const unsigned char *from, | |||
252 | goto err; | 256 | goto err; |
253 | } | 257 | } |
254 | 258 | ||
255 | BLINDING_HELPER(rsa, ctx); | 259 | BLINDING_HELPER(rsa, ctx, goto err;); |
256 | 260 | ||
257 | if (rsa->flags & RSA_FLAG_BLINDING) | 261 | if (rsa->flags & RSA_FLAG_BLINDING) |
258 | if (!BN_BLINDING_convert(&f,rsa->blinding,ctx)) goto err; | 262 | if (!BN_BLINDING_convert(&f,rsa->blinding,ctx)) goto err; |
@@ -331,7 +335,7 @@ static int RSA_eay_private_decrypt(int flen, const unsigned char *from, | |||
331 | goto err; | 335 | goto err; |
332 | } | 336 | } |
333 | 337 | ||
334 | BLINDING_HELPER(rsa, ctx); | 338 | BLINDING_HELPER(rsa, ctx, goto err;); |
335 | 339 | ||
336 | if (rsa->flags & RSA_FLAG_BLINDING) | 340 | if (rsa->flags & RSA_FLAG_BLINDING) |
337 | if (!BN_BLINDING_convert(&f,rsa->blinding,ctx)) goto err; | 341 | if (!BN_BLINDING_convert(&f,rsa->blinding,ctx)) goto err; |
@@ -607,10 +611,6 @@ err: | |||
607 | static int RSA_eay_init(RSA *rsa) | 611 | static int RSA_eay_init(RSA *rsa) |
608 | { | 612 | { |
609 | rsa->flags|=RSA_FLAG_CACHE_PUBLIC|RSA_FLAG_CACHE_PRIVATE; | 613 | rsa->flags|=RSA_FLAG_CACHE_PUBLIC|RSA_FLAG_CACHE_PRIVATE; |
610 | |||
611 | /* Enforce blinding. */ | ||
612 | rsa->flags|=RSA_FLAG_BLINDING; | ||
613 | |||
614 | return(1); | 614 | return(1); |
615 | } | 615 | } |
616 | 616 | ||
diff --git a/src/lib/libssl/src/crypto/rsa/rsa_lib.c b/src/lib/libssl/src/crypto/rsa/rsa_lib.c index f71870a338..37fff8bce3 100644 --- a/src/lib/libssl/src/crypto/rsa/rsa_lib.c +++ b/src/lib/libssl/src/crypto/rsa/rsa_lib.c | |||
@@ -70,7 +70,13 @@ static const RSA_METHOD *default_RSA_meth=NULL; | |||
70 | 70 | ||
71 | RSA *RSA_new(void) | 71 | RSA *RSA_new(void) |
72 | { | 72 | { |
73 | return(RSA_new_method(NULL)); | 73 | RSA *r=RSA_new_method(NULL); |
74 | |||
75 | #ifndef OPENSSL_NO_FORCE_RSA_BLINDING | ||
76 | r->flags|=RSA_FLAG_BLINDING; | ||
77 | #endif | ||
78 | |||
79 | return r; | ||
74 | } | 80 | } |
75 | 81 | ||
76 | void RSA_set_default_method(const RSA_METHOD *meth) | 82 | void RSA_set_default_method(const RSA_METHOD *meth) |
@@ -181,10 +187,6 @@ RSA *RSA_new_method(ENGINE *engine) | |||
181 | OPENSSL_free(ret); | 187 | OPENSSL_free(ret); |
182 | ret=NULL; | 188 | ret=NULL; |
183 | } | 189 | } |
184 | |||
185 | /* Enforce blinding. */ | ||
186 | ret->flags |= RSA_FLAG_BLINDING; | ||
187 | |||
188 | return(ret); | 190 | return(ret); |
189 | } | 191 | } |
190 | 192 | ||