Add ED25519 support for commandline key generation

Enable the key-job class to parse ED25519 key description
without size and EC-Group correctly.
Don't check the size parameter of ED25519 keys.
This commit is contained in:
Christian Hohnstaedt 2021-04-08 12:50:34 +02:00
parent 46f6959f5d
commit 7ace0db0d5
2 changed files with 20 additions and 2 deletions

View File

@ -158,7 +158,7 @@ pki_key *db_key::newKey(const keyjob &task, const QString &name)
{
pki_key *key = NULL;
if (!task.isEC()) {
if (!task.isEC() && !task.isED25519()) {
if (task.size < 32) {
XCA_WARN(tr("Key size too small !"));
return NULL;
@ -176,6 +176,8 @@ pki_key *db_key::newKey(const keyjob &task, const QString &name)
}
key->generate(task);
key->pkiSource = generated;
if (key->getIntName().isEmpty())
key->autoIntName(name);
key = dynamic_cast<pki_key*>(insert(key));
emit keyDone(key);
createSuccess(key);

View File

@ -109,17 +109,23 @@ class keyjob
keyjob(const QString &desc)
{
QStringList sl = desc.split(':');
if (sl.size() == 1)
sl += "";
if (sl.size() != 2)
return;
ktype = keytype::byName(sl[0]);
size = 0;
ec_nid = NID_undef;
if (isEC())
ec_nid = OBJ_txt2nid(sl[1].toLatin1());
else
else if (!isED25519())
size = sl[1].toInt();
slot = slotid();
}
QString toString()
{
if (isED25519())
return ktype.name;
return QString("%1:%2").arg(ktype.name)
.arg(isEC() ?
OBJ_obj2QString(OBJ_nid2obj(ec_nid)) :
@ -133,10 +139,20 @@ class keyjob
{
return ktype.type == EVP_PKEY_EC;
}
bool isED25519() const
{
#ifdef EVP_PKEY_ED25519
return ktype.type == EVP_PKEY_ED25519;
#else
return false;
#endif
}
bool isValid()
{
if (!ktype.isValid())
return false;
if (isED25519())
return true;
if (isEC() && builtinCurves.containNid(ec_nid))
return true;
if (!isEC() && size > 0)