mirror of
https://github.com/chris2511/xca.git
synced 2026-09-12 19:51:05 +05:00
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:
parent
46f6959f5d
commit
7ace0db0d5
@ -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);
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user