Skip to content

Commit

Permalink
X25519 key imported is little-endian
Browse files Browse the repository at this point in the history
  • Loading branch information
z4yx committed Dec 20, 2024
1 parent aa0a466 commit 1d369ad
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/key.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 1d369ad

Please sign in to comment.