Skip to content

Commit d45a0bf

Browse files
committed
Fix verify on change pin.
Signed-off-by: Pol Henarejos <[email protected]>
1 parent 61261aa commit d45a0bf

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/openpgp/piv.c

+4-5
Original file line numberDiff line numberDiff line change
@@ -888,15 +888,14 @@ static int cmd_change_pin() {
888888
return SW_MEMORY_FAILURE();
889889
}
890890
uint8_t *pin_data = file_get_data(ef), pin_len = apdu.nc - pin_data[0];
891-
uint8_t dhash[33];
892-
double_hash_pin(apdu.data, pin_data[0], dhash + 1);
893-
if (memcmp(dhash, file_get_data(ef) + 1, sizeof(dhash) - 1) != 0) {
894-
return SW_SECURITY_STATUS_NOT_SATISFIED();
891+
uint16_t ret = check_pin(ef, apdu.data, pin_data[0]);
892+
if (ret != 0x9000) {
893+
return ret;
895894
}
895+
uint8_t dhash[33];
896896
dhash[0] = pin_len;
897897
double_hash_pin(apdu.data + pin_data[0], pin_len, dhash + 1);
898898
flash_write_data_to_file(ef, dhash, sizeof(dhash));
899-
pin_reset_retries(ef, true);
900899
low_flash_available();
901900
return SW_OK();
902901
}

0 commit comments

Comments
 (0)