Skip to content

Commit 057b4d6

Browse files
committed
Fix ED25519/ED448 handling in keymgmt import
1 parent 4b7a9ad commit 057b4d6

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/provider.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,16 +348,37 @@ static const char *pkey_name_from_evp_pkey(const EVP_PKEY *pkey)
348348

349349
static const char *pkey_name_from_ossl_param(const OSSL_PARAM *params)
350350
{
351+
/* EC keys */
351352
if (OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_GROUP_NAME) ||
352353
OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_PUB_KEY) ||
353354
OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_EC_ENCODING) ||
354355
OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_EC_POINT_CONVERSION_FORMAT)) {
355356
return "EC";
356357
}
358+
359+
/* RSA keys */
357360
if (OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_RSA_N) ||
358361
OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_RSA_E)) {
359362
return "RSA";
360363
}
364+
365+
/* Ed25519 / Ed448 */
366+
if (OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_MANDATORY_DIGEST)) {
367+
const OSSL_PARAM *p;
368+
369+
p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_PRIV_KEY);
370+
if (p != NULL && p->data_type == OSSL_PARAM_OCTET_STRING) {
371+
if (p->data_size == 32) return "ED25519";
372+
if (p->data_size == 57) return "ED448";
373+
}
374+
p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_PUB_KEY);
375+
if (p != NULL && p->data_type == OSSL_PARAM_OCTET_STRING) {
376+
if (p->data_size == 32) return "ED25519";
377+
if (p->data_size == 57) return "ED448";
378+
}
379+
/* fallback: we know it's EdDSA, but can't tell which */
380+
return NULL;
381+
}
361382
return NULL;
362383
}
363384

0 commit comments

Comments
 (0)