mirror of
https://github.com/polhenarejos/pico-hsm.git
synced 2026-01-17 09:28:05 +00:00
Added key unwrap support.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
parent
a29b01cdd8
commit
6cd575ea51
1 changed files with 16 additions and 0 deletions
16
sc_hsm.c
16
sc_hsm.c
|
|
@ -1331,6 +1331,20 @@ static int cmd_key_wrap() {
|
|||
return SW_OK();
|
||||
}
|
||||
|
||||
static int cmd_key_unwrap() {
|
||||
int key_id = P1(apdu);
|
||||
if (P2(apdu) != 0x93)
|
||||
return SW_WRONG_P1P2();
|
||||
if (!isUserAuthenticated)
|
||||
return SW_SECURITY_STATUS_NOT_SATISFIED();
|
||||
file_t *ef = search_dynamic_file((KEY_PREFIX << 8) | key_id);
|
||||
if (!ef)
|
||||
ef = file_new((KEY_PREFIX << 8) | key_id);
|
||||
flash_write_data_to_file(ef, apdu.cmd_apdu_data, apdu.cmd_apdu_data_len);
|
||||
low_flash_available();
|
||||
return SW_OK();
|
||||
}
|
||||
|
||||
typedef struct cmd
|
||||
{
|
||||
uint8_t ins;
|
||||
|
|
@ -1347,6 +1361,7 @@ typedef struct cmd
|
|||
#define INS_LIST_KEYS 0x58
|
||||
#define INS_SIGNATURE 0x68
|
||||
#define INS_WRAP 0x72
|
||||
#define INS_UNWRAP 0x74
|
||||
#define INS_CHALLENGE 0x84
|
||||
#define INS_SELECT_FILE 0xA4
|
||||
#define INS_READ_BINARY 0xB0
|
||||
|
|
@ -1371,6 +1386,7 @@ static const cmd_t cmds[] = {
|
|||
{ INS_KEY_GEN, cmd_key_gen },
|
||||
{ INS_SIGNATURE, cmd_signature },
|
||||
{ INS_WRAP, cmd_key_wrap },
|
||||
{ INS_UNWRAP, cmd_key_unwrap },
|
||||
{ 0x00, 0x0}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue