From: Richard Levitte Date: Mon, 17 May 2004 04:39:00 +0000 (+0000) Subject: Make it possible for the user to choose the digest used to create the X-Git-Tag: OpenSSL_0_9_7e~95 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=736ce650c62a389d81a66131282cd61d0f1e7e7e;p=openssl Make it possible for the user to choose the digest used to create the key. --- diff --git a/apps/enc.c b/apps/enc.c index bd1ecfc6ff..f9520248b9 100644 --- a/apps/enc.c +++ b/apps/enc.c @@ -114,6 +114,7 @@ int MAIN(int argc, char **argv) unsigned char salt[PKCS5_SALT_LEN]; char *str=NULL, *passarg = NULL, *pass = NULL; char *hkey=NULL,*hiv=NULL,*hsalt = NULL; + char *md=NULL; int enc=1,printkey=0,i,base64=0; int debug=0,olb64=0,nosalt=0; const EVP_CIPHER *cipher=NULL,*c; @@ -254,6 +255,11 @@ int MAIN(int argc, char **argv) if (--argc < 1) goto bad; hiv= *(++argv); } + else if (strcmp(*argv,"-md") == 0) + { + if (--argc < 1) goto bad; + md= *(++argv); + } else if ((argv[0][0] == '-') && ((c=EVP_get_cipherbyname(&(argv[0][1]))) != NULL)) { @@ -275,6 +281,8 @@ bad: BIO_printf(bio_err,"%-14s key is the next argument\n","-k"); BIO_printf(bio_err,"%-14s key is the first line of the file argument\n","-kfile"); BIO_printf(bio_err,"%-14s key/iv in hex is the next argument\n","-K/-iv"); + BIO_printf(bio_err,"%-14s the next argument is the md to use to create a key,\n","-md"); + BIO_printf(bio_err,"%-14s one of md2, md5, sha or sha1\n"); BIO_printf(bio_err,"%-14s print the iv/key (then exit if -P)\n","-[pP]"); BIO_printf(bio_err,"%-14s buffer size\n","-bufsize "); #ifndef OPENSSL_NO_ENGINE @@ -297,6 +305,12 @@ bad: e = setup_engine(bio_err, engine, 0); #endif + if (md && dgst=EVP_get_digestbyname(md)) == NULL) + { + BIO_printf(bio_err,"%s is an unsupported message digest type\n",md); + goto end; + } + if (dgst == NULL) { if (in_FIPS_mode)