* Hudson (tjh@cryptsoft.com).
*
*/
+
+#ifndef NO_RSA
+
#include "apps.h"
+#include <string.h>
#include <openssl/err.h>
#include <openssl/pem.h>
+#include <openssl/engine.h>
#define RSA_SIGN 1
#define RSA_VERIFY 2
int MAIN(int argc, char **argv)
{
+ ENGINE *e = NULL;
BIO *in = NULL, *out = NULL;
char *infile = NULL, *outfile = NULL;
+ char *engine = NULL;
char *keyfile = NULL;
char rsa_mode = RSA_VERIFY, key_type = KEY_PRIVKEY;
int keyform = FORMAT_PEM;
} else if(!strcmp(*argv, "-inkey")) {
if (--argc < 1) badarg = 1;
keyfile = *(++argv);
+ } else if(!strcmp(*argv, "-engine")) {
+ if (--argc < 1) badarg = 1;
+ engine = *(++argv);
} else if(!strcmp(*argv, "-pubin")) {
key_type = KEY_PUBKEY;
} else if(!strcmp(*argv, "-certin")) {
goto end;
}
+ if (engine != NULL)
+ {
+ if((e = ENGINE_by_id(engine)) == NULL)
+ {
+ BIO_printf(bio_err,"invalid engine \"%s\"\n",
+ engine);
+ goto end;
+ }
+ if(!ENGINE_set_default(e, ENGINE_METHOD_ALL))
+ {
+ BIO_printf(bio_err,"can't use that engine\n");
+ goto end;
+ }
+ BIO_printf(bio_err,"engine \"%s\" set.\n", engine);
+ /* Free our "structural" reference. */
+ ENGINE_free(e);
+ }
+
/* FIXME: seed PRNG only if needed */
app_RAND_load_file(NULL, bio_err, 0);
switch(key_type) {
case KEY_PRIVKEY:
- pkey = load_key(bio_err, keyfile, keyform, NULL);
+ pkey = load_key(bio_err, keyfile, keyform, NULL, e);
break;
case KEY_PUBKEY:
- pkey = load_pubkey(bio_err, keyfile, keyform);
+ pkey = load_pubkey(bio_err, keyfile, keyform, e);
break;
case KEY_CERT:
ERR_print_errors(bio_err);
goto end;
}
- } else out = BIO_new_fp(stdout, BIO_NOCLOSE);
+ } else {
+ out = BIO_new_fp(stdout, BIO_NOCLOSE);
+#ifdef VMS
+ {
+ BIO *tmpbio = BIO_new(BIO_f_linebuffer());
+ out = BIO_push(tmpbio, out);
+ }
+#endif
+ }
keysize = RSA_size(rsa);
end:
RSA_free(rsa);
BIO_free(in);
- BIO_free(out);
+ BIO_free_all(out);
if(rsa_in) OPENSSL_free(rsa_in);
if(rsa_out) OPENSSL_free(rsa_out);
return ret;
BIO_printf(bio_err, "-hexdump hex dump output\n");
}
+#endif