summaryrefslogtreecommitdiff
path: root/ext/openssl/ossl_pkey_rsa.c
diff options
context:
space:
mode:
authornahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-11-04 05:12:31 +0000
committernahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-11-04 05:12:31 +0000
commitab682d95e077b43db7dfd293744aa546888d7e35 (patch)
tree588eefd840864850059897fa5c5227f3d0a86a1f /ext/openssl/ossl_pkey_rsa.c
parent3463615a69288dd066df0579eea087737a6c6bf8 (diff)
* ext/openssl/ossl_pkey_rsa.c (rsa_generate): [SECURITY] Set RSA
exponent value correctly. Awful bug. This bug caused exponent of generated key to be always '1'. By default, and regardless of e given as a parameter. !!! Keys generated by this code (trunk after 2011-09-01) must be re-generated !!! (ruby_1_9_3 is safe) * test/openssl/test_pkey_rsa.rb: Add tests for default exponent and specifying exponent by a parameter. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33633 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/openssl/ossl_pkey_rsa.c')
-rw-r--r--ext/openssl/ossl_pkey_rsa.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/ext/openssl/ossl_pkey_rsa.c b/ext/openssl/ossl_pkey_rsa.c
index 1e28b4f..3f6d52c 100644
--- a/ext/openssl/ossl_pkey_rsa.c
+++ b/ext/openssl/ossl_pkey_rsa.c
@@ -110,7 +110,7 @@ rsa_generate(int size, int exp)
if (rsa) RSA_free(rsa);
return 0;
}
- for (i = 0; i < (int)sizeof(exp); ++i) {
+ for (i = 0; i < (int)sizeof(exp) * 8; ++i) {
if (exp & (1 << i)) {
if (BN_set_bit(e, i) == 0) {
BN_free(e);