summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2016-04-02 15:12:58 +0200
committerRichard Levitte <levitte@openssl.org>2016-04-06 16:19:17 +0200
commit9862e9aa98ee1e38fbcef8d1dd5db0e750eb5e8d (patch)
treed7ddbd0b7d4c97875479e3b9cd52fdf579ca2434 /apps
parent3e41ac35281827b59e55d51058cf6bb086c1f2b5 (diff)
Make the RSA structure opaque
Move rsa_st away from public headers. Add accessor/writer functions for the public RSA data. Adapt all other source to use the accessors and writers. Reviewed-by: Matt Caswell <matt@openssl.org>
Diffstat (limited to 'apps')
-rw-r--r--apps/genrsa.c12
-rw-r--r--apps/req.c8
-rw-r--r--apps/rsa.c4
-rw-r--r--apps/x509.c8
4 files changed, 20 insertions, 12 deletions
diff --git a/apps/genrsa.c b/apps/genrsa.c
index 0b0123fa1d..8b6dd03d08 100644
--- a/apps/genrsa.c
+++ b/apps/genrsa.c
@@ -104,9 +104,10 @@ int genrsa_main(int argc, char **argv)
{
BN_GENCB *cb = BN_GENCB_new();
PW_CB_DATA cb_data;
- ENGINE *e = NULL;
+ ENGINE *eng = NULL;
BIGNUM *bn = BN_new();
BIO *out = NULL;
+ BIGNUM *e;
RSA *rsa = NULL;
const EVP_CIPHER *enc = NULL;
int ret = 1, num = DEFBITS, private = 0;
@@ -141,7 +142,7 @@ int genrsa_main(int argc, char **argv)
outfile = opt_arg();
break;
case OPT_ENGINE:
- e = setup_engine(opt_arg(), 0);
+ eng = setup_engine(opt_arg(), 0);
break;
case OPT_RAND:
inrand = opt_arg();
@@ -182,7 +183,7 @@ int genrsa_main(int argc, char **argv)
BIO_printf(bio_err, "Generating RSA private key, %d bit long modulus\n",
num);
- rsa = e ? RSA_new_method(e) : RSA_new();
+ rsa = eng ? RSA_new_method(eng) : RSA_new();
if (rsa == NULL)
goto end;
@@ -191,8 +192,9 @@ int genrsa_main(int argc, char **argv)
app_RAND_write_file(NULL);
- hexe = BN_bn2hex(rsa->e);
- dece = BN_bn2dec(rsa->e);
+ RSA_get0_key(rsa, NULL, &e, NULL);
+ hexe = BN_bn2hex(e);
+ dece = BN_bn2dec(e);
if (hexe && dece) {
BIO_printf(bio_err, "e is %s (0x%s)\n", dece, hexe);
}
diff --git a/apps/req.c b/apps/req.c
index b6a545fa38..e3869bab19 100644
--- a/apps/req.c
+++ b/apps/req.c
@@ -811,9 +811,11 @@ int req_main(int argc, char **argv)
}
fprintf(stdout, "Modulus=");
#ifndef OPENSSL_NO_RSA
- if (EVP_PKEY_base_id(tpubkey) == EVP_PKEY_RSA)
- BN_print(out, EVP_PKEY_get0_RSA(tpubkey)->n);
- else
+ if (EVP_PKEY_base_id(tpubkey) == EVP_PKEY_RSA) {
+ BIGNUM *n;
+ RSA_get0_key(EVP_PKEY_get0_RSA(tpubkey), &n, NULL, NULL);
+ BN_print(out, n);
+ } else
#endif
fprintf(stdout, "Wrong Algorithm type");
EVP_PKEY_free(tpubkey);
diff --git a/apps/rsa.c b/apps/rsa.c
index 38cedf7b77..980d9ef911 100644
--- a/apps/rsa.c
+++ b/apps/rsa.c
@@ -310,8 +310,10 @@ int rsa_main(int argc, char **argv)
}
if (modulus) {
+ BIGNUM *n;
+ RSA_get0_key(rsa, &n, NULL, NULL);
BIO_printf(out, "Modulus=");
- BN_print(out, rsa->n);
+ BN_print(out, n);
BIO_printf(out, "\n");
}
diff --git a/apps/x509.c b/apps/x509.c
index bc5623365a..6ee26115ee 100644
--- a/apps/x509.c
+++ b/apps/x509.c
@@ -727,9 +727,11 @@ int x509_main(int argc, char **argv)
}
BIO_printf(out, "Modulus=");
#ifndef OPENSSL_NO_RSA
- if (EVP_PKEY_id(pkey) == EVP_PKEY_RSA)
- BN_print(out, EVP_PKEY_get0_RSA(pkey)->n);
- else
+ if (EVP_PKEY_id(pkey) == EVP_PKEY_RSA) {
+ BIGNUM *n;
+ RSA_get0_key(EVP_PKEY_get0_RSA(pkey), &n, NULL, NULL);
+ BN_print(out, n);
+ } else
#endif
#ifndef OPENSSL_NO_DSA
if (EVP_PKEY_id(pkey) == EVP_PKEY_DSA) {