summaryrefslogtreecommitdiffstats
path: root/apps/genrsa.c
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2000-10-26 23:07:28 +0200
committerRichard Levitte <levitte@openssl.org>2000-10-26 23:07:28 +0200
commit5270e7025e11b2fd1a5bdf8d81feded1167b1c87 (patch)
tree3bb44c37f4bb6469f738a10127050b023e0d7fb5 /apps/genrsa.c
parentAdd a note about the recent DSO changes in CHANGES. (diff)
downloadopenssl-5270e7025e11b2fd1a5bdf8d81feded1167b1c87.tar.xz
openssl-5270e7025e11b2fd1a5bdf8d81feded1167b1c87.zip
Merge the engine branch into the main trunk. All conflicts resolved.
At the same time, add VMS support for Rijndael.
Diffstat (limited to 'apps/genrsa.c')
-rw-r--r--apps/genrsa.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/apps/genrsa.c b/apps/genrsa.c
index ac0b709e7a..e7445e6a49 100644
--- a/apps/genrsa.c
+++ b/apps/genrsa.c
@@ -69,6 +69,7 @@
#include <openssl/evp.h>
#include <openssl/x509.h>
#include <openssl/pem.h>
+#include <openssl/engine.h>
#define DEFBITS 512
#undef PROG
@@ -80,6 +81,7 @@ int MAIN(int, char **);
int MAIN(int argc, char **argv)
{
+ ENGINE *e = NULL;
int ret=1;
RSA *rsa=NULL;
int i,num=DEFBITS;
@@ -88,6 +90,7 @@ int MAIN(int argc, char **argv)
unsigned long f4=RSA_F4;
char *outfile=NULL;
char *passargout = NULL, *passout = NULL;
+ char *engine=NULL;
char *inrand=NULL;
BIO *out=NULL;
@@ -116,6 +119,11 @@ int MAIN(int argc, char **argv)
f4=3;
else if (strcmp(*argv,"-F4") == 0 || strcmp(*argv,"-f4") == 0)
f4=RSA_F4;
+ else if (strcmp(*argv,"-engine") == 0)
+ {
+ if (--argc < 1) goto bad;
+ engine= *(++argv);
+ }
else if (strcmp(*argv,"-rand") == 0)
{
if (--argc < 1) goto bad;
@@ -154,6 +162,7 @@ bad:
BIO_printf(bio_err," -passout arg output file pass phrase source\n");
BIO_printf(bio_err," -f4 use F4 (0x10001) for the E value\n");
BIO_printf(bio_err," -3 use 3 for the E value\n");
+ BIO_printf(bio_err," -engine e use engine e, possibly a hardware device.\n");
BIO_printf(bio_err," -rand file%cfile%c...\n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR);
BIO_printf(bio_err," load the file (or the files in the directory) into\n");
BIO_printf(bio_err," the random number generator\n");
@@ -167,6 +176,24 @@ bad:
goto err;
}
+ if (engine != NULL)
+ {
+ if((e = ENGINE_by_id(engine)) == NULL)
+ {
+ BIO_printf(bio_err,"invalid engine \"%s\"\n",
+ engine);
+ goto err;
+ }
+ if(!ENGINE_set_default(e, ENGINE_METHOD_ALL))
+ {
+ BIO_printf(bio_err,"can't use that engine\n");
+ goto err;
+ }
+ BIO_printf(bio_err,"engine \"%s\" set.\n", engine);
+ /* Free our "structural" reference. */
+ ENGINE_free(e);
+ }
+
if (outfile == NULL)
{
BIO_set_fp(out,stdout,BIO_NOCLOSE);
@@ -186,7 +213,8 @@ bad:
}
}
- if (!app_RAND_load_file(NULL, bio_err, 1) && inrand == NULL)
+ if (!app_RAND_load_file(NULL, bio_err, 1) && inrand == NULL
+ && !RAND_status())
{
BIO_printf(bio_err,"warning, not much extra random data, consider using the -rand option\n");
}