mirror of
https://github.com/polhenarejos/pico-hsm.git
synced 2026-02-01 08:09:24 +00:00
Accept arbitrary SO-PIN length on reset retry.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
parent
3d7f714936
commit
173ca7678d
1 changed files with 7 additions and 9 deletions
|
|
@ -36,16 +36,15 @@ int cmd_reset_retry() {
|
|||
if (P1(apdu) == 0x0 || P1(apdu) == 0x2) {
|
||||
int newpin_len = 0;
|
||||
if (P1(apdu) == 0x0) {
|
||||
if (apdu.nc <= 8) {
|
||||
uint8_t so_pin_len = file_read_uint8(file_get_data(file_sopin));
|
||||
if (apdu.nc <= so_pin_len + 1) {
|
||||
return SW_WRONG_LENGTH();
|
||||
}
|
||||
uint16_t r = check_pin(file_sopin, apdu.data, 8);
|
||||
uint16_t r = check_pin(file_sopin, apdu.data, so_pin_len);
|
||||
if (r != 0x9000) {
|
||||
return r;
|
||||
}
|
||||
newpin_len = apdu.nc - 8;
|
||||
has_session_sopin = true;
|
||||
hash_multi(apdu.data, 8, session_sopin);
|
||||
newpin_len = apdu.nc - so_pin_len;
|
||||
}
|
||||
else if (P1(apdu) == 0x2) {
|
||||
if (!has_session_sopin) {
|
||||
|
|
@ -83,15 +82,14 @@ int cmd_reset_retry() {
|
|||
return SW_COMMAND_NOT_ALLOWED();
|
||||
}
|
||||
if (P1(apdu) == 0x1) {
|
||||
if (apdu.nc != 8) {
|
||||
uint8_t so_pin_len = file_read_uint8(file_get_data(file_sopin));
|
||||
if (apdu.nc != so_pin_len) {
|
||||
return SW_WRONG_LENGTH();
|
||||
}
|
||||
uint16_t r = check_pin(file_sopin, apdu.data, 8);
|
||||
uint16_t r = check_pin(file_sopin, apdu.data, so_pin_len);
|
||||
if (r != 0x9000) {
|
||||
return r;
|
||||
}
|
||||
has_session_sopin = true;
|
||||
hash_multi(apdu.data, 8, session_sopin);
|
||||
}
|
||||
else if (P1(apdu) == 0x3) {
|
||||
if (!has_session_sopin) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue