mirror of
https://github.com/polhenarejos/pico-hsm.git
synced 2026-01-27 05:49:20 +00:00
Fix loading and saving Montgomery keys.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
parent
7376817724
commit
1d3232df36
2 changed files with 2 additions and 2 deletions
|
|
@ -102,7 +102,7 @@ int cmd_decrypt_asym() {
|
|||
free(kdata);
|
||||
return SW_DATA_INVALID();
|
||||
}
|
||||
r = mbedtls_mpi_read_binary(&ctx.ctx.mbed_ecdh.d, kdata + 1, key_size - 1);
|
||||
r = mbedtls_ecp_read_key(gid, (mbedtls_ecdsa_context *)&ctx.ctx.mbed_ecdh, kdata + 1, key_size - 1);
|
||||
mbedtls_platform_zeroize(kdata, key_size);
|
||||
free(kdata);
|
||||
if (r != 0) {
|
||||
|
|
|
|||
|
|
@ -502,7 +502,7 @@ int store_keys(void *key_ctx, int type, uint8_t key_id) {
|
|||
mbedtls_ecdsa_context *ecdsa = (mbedtls_ecdsa_context *) key_ctx;
|
||||
key_size = mbedtls_mpi_size(&ecdsa->d);
|
||||
kdata[0] = ecdsa->grp.id & 0xff;
|
||||
mbedtls_mpi_write_binary(&ecdsa->d, kdata + 1, key_size);
|
||||
mbedtls_ecp_write_key(ecdsa, kdata + 1, key_size);
|
||||
key_size++;
|
||||
}
|
||||
else if (type & HSM_KEY_AES) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue