From 64376cd8ff7ac2db8e4645a365184f782bd7b835 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bodo=20M=C3=B6ller?= Date: Fri, 16 Aug 2002 11:19:07 +0000 Subject: [PATCH] 'EC' vs. 'ECDSA' Submitted by: Nils Larsch --- apps/req.c | 21 ++++++++++++--------- crypto/evp/p_lib.c | 2 +- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/apps/req.c b/apps/req.c index 1f24be79bd..1105e59e67 100644 --- a/apps/req.c +++ b/apps/req.c @@ -152,7 +152,7 @@ int MAIN(int argc, char **argv) #ifndef OPENSSL_NO_DSA DSA *dsa_params=NULL; #endif -#ifndef OPENSSL_NO_EC +#ifndef OPENSSL_NO_ECDSA EC_KEY *ec_params = NULL; #endif unsigned long nmflag = 0; @@ -327,8 +327,8 @@ int MAIN(int argc, char **argv) } else #endif -#ifndef OPENSSL_NO_EC - if (strncmp("ecdsa:",p,4) == 0) +#ifndef OPENSSL_NO_ECDSA + if (strncmp("ec:",p,4) == 0) { X509 *xtmp=NULL; EVP_PKEY *dtmp; @@ -354,7 +354,8 @@ int MAIN(int argc, char **argv) goto end; } - if ((dtmp=X509_get_pubkey(xtmp)) == NULL) goto end; + if ((dtmp=X509_get_pubkey(xtmp))==NULL) + goto end; if (dtmp->type == EVP_PKEY_EC) ec_params = ECParameters_dup(dtmp->pkey.eckey); EVP_PKEY_free(dtmp); @@ -485,7 +486,9 @@ bad: BIO_printf(bio_err," the random number generator\n"); BIO_printf(bio_err," -newkey rsa:bits generate a new RSA key of 'bits' in size\n"); BIO_printf(bio_err," -newkey dsa:file generate a new DSA key, parameters taken from CA in 'file'\n"); - BIO_printf(bio_err," -newkey ecdsa:file generate a new ECDSA key, parameters taken from CA in 'file'\n"); +#ifndef OPENSSL_NO_ECDSA + BIO_printf(bio_err," -newkey ec:file generate a new EC key, parameters taken from CA in 'file'\n"); +#endif BIO_printf(bio_err," -[digest] Digest to sign with (md5, sha1, md2, mdc2, md4)\n"); BIO_printf(bio_err," -config file request template file.\n"); BIO_printf(bio_err," -subj arg set or modify request subject\n"); @@ -708,14 +711,14 @@ bad: } if (newkey < MIN_KEY_LENGTH && (pkey_type == TYPE_RSA || pkey_type == TYPE_DSA)) - /* TODO: appropriate minimal keylength for the different algorithm (esp. ECDSA) */ { BIO_printf(bio_err,"private key length is too short,\n"); BIO_printf(bio_err,"it needs to be at least %d bits, not %d\n",MIN_KEY_LENGTH,newkey); goto end; } BIO_printf(bio_err,"Generating a %d bit %s private key\n", - newkey,(pkey_type == TYPE_RSA)?"RSA":(pkey_type == TYPE_DSA)?"DSA":"ECDSA"); + newkey,(pkey_type == TYPE_RSA)?"RSA": + (pkey_type == TYPE_DSA)?"DSA":"EC"); if ((pkey=EVP_PKEY_new()) == NULL) goto end; @@ -737,7 +740,7 @@ bad: dsa_params=NULL; } #endif -#ifndef OPENSSL_NO_EC +#ifndef OPENSSL_NO_ECDSA if (pkey_type == TYPE_EC) { if (!EC_KEY_generate_key(ec_params)) goto end; @@ -1137,7 +1140,7 @@ end: #ifndef OPENSSL_NO_DSA if (dsa_params != NULL) DSA_free(dsa_params); #endif -#ifndef OPENSSL_NO_EC +#ifndef OPENSSL_NO_ECDSA if (ec_params != NULL) EC_KEY_free(ec_params); #endif apps_shutdown(); diff --git a/crypto/evp/p_lib.c b/crypto/evp/p_lib.c index 1056e4bffd..c7a3dee108 100644 --- a/crypto/evp/p_lib.c +++ b/crypto/evp/p_lib.c @@ -117,7 +117,7 @@ int EVP_PKEY_size(EVP_PKEY *pkey) if (pkey->type == EVP_PKEY_DSA) return(DSA_size(pkey->pkey.dsa)); #endif -#ifndef OPENSSL_NO_EC +#ifndef OPENSSL_NO_ECDSA if (pkey->type == EVP_PKEY_EC) return(ECDSA_size(pkey->pkey.eckey)); #endif -- 2.34.1