From 1d369ad2f3d2d46983fade8b2d277211f3f2282c Mon Sep 17 00:00:00 2001 From: z4yx Date: Fri, 20 Dec 2024 22:56:34 +0800 Subject: [PATCH] X25519 key imported is little-endian --- src/key.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/key.c b/src/key.c index 8f8a3fae..539e857e 100644 --- a/src/key.c +++ b/src/key.c @@ -136,6 +136,9 @@ int ck_parse_piv(ck_key_t *key, const uint8_t *buf, size_t buf_len) { return KEY_ERR_LENGTH; } memcpy(key->ecc.pri, p, PRIVATE_KEY_LENGTH[key->meta.type]); + if (key->meta.type == X25519) { + swap_big_number_endian(key->ecc.pri); // Private key of x25519 is encoded in little endian + } if (!ecc_verify_private_key(key->meta.type, &key->ecc)) { memzero(key, sizeof(ck_key_t)); return KEY_ERR_DATA;