'EC' vs. 'ECDSA'
Submitted by: Nils Larsch
This commit is contained in:
parent
cc8aa08b02
commit
64376cd8ff
2 changed files with 13 additions and 10 deletions
21
apps/req.c
21
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();
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue