aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/rsa/rsa_depr.c
diff options
context:
space:
mode:
authorGeoff Thorpe <geoff@openssl.org>2004-04-26 15:31:35 +0000
committerGeoff Thorpe <geoff@openssl.org>2004-04-26 15:31:35 +0000
commitbcfea9fb25738b007cfef48d5070376c4398675a (patch)
tree4c60cc4cb29540bf98072e95c712495a129cc646 /crypto/rsa/rsa_depr.c
parentf3f52d7f45967af4f70045921dfa12e6faedcc92 (diff)
downloadopenssl-bcfea9fb25738b007cfef48d5070376c4398675a.tar.gz
Allow RSA key-generation to specify an arbitrary public exponent. Jelte
proposed the change and submitted the patch, I jiggled it slightly and adjusted the other parts of openssl that were affected. PR: 867 Submitted by: Jelte Jansen Reviewed by: Geoff Thorpe
Diffstat (limited to 'crypto/rsa/rsa_depr.c')
-rw-r--r--crypto/rsa/rsa_depr.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/crypto/rsa/rsa_depr.c b/crypto/rsa/rsa_depr.c
index 2d87cd39f3..73fa6eea90 100644
--- a/crypto/rsa/rsa_depr.c
+++ b/crypto/rsa/rsa_depr.c
@@ -62,23 +62,39 @@
#include <openssl/bn.h>
#include <openssl/rsa.h>
+#ifdef OPENSSL_NO_DEPRECATED
+
static void *dummy=&dummy;
-#ifndef OPENSSL_NO_DEPRECATED
+#else
+
RSA *RSA_generate_key(int bits, unsigned long e_value,
void (*callback)(int,int,void *), void *cb_arg)
{
BN_GENCB cb;
- RSA *rsa;
+ int i;
+ RSA *rsa = RSA_new();
+ BIGNUM *e = BN_new();
- if((rsa=RSA_new()) == NULL)
- return 0;
+ if(!rsa || !e) goto err;
+
+ /* The problem is when building with 8, 16, or 32 BN_ULONG,
+ * unsigned long can be larger */
+ for (i=0; i<sizeof(unsigned long)*8; i++)
+ {
+ if (e_value & (1UL<<i))
+ BN_set_bit(e,i);
+ }
BN_GENCB_set_old(&cb, callback, cb_arg);
- if(RSA_generate_key_ex(rsa, bits, e_value, &cb))
+ if(RSA_generate_key_ex(rsa, bits, e, &cb)) {
+ BN_free(e);
return rsa;
- RSA_free(rsa);
+ }
+err:
+ if(e) BN_free(e);
+ if(rsa) RSA_free(rsa);
return 0;
}
#endif