Fix change PIN when no PIN was introduced before.

Fixes #32

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
Pol Henarejos
2025-05-12 11:16:18 +02:00
parent d5a0d85b71
commit fccc48de43

View File

@@ -29,6 +29,10 @@ int cmd_change_pin() {
}
uint8_t pin_len = file_get_data(pw)[0];
uint16_t r = 0;
r = check_pin(pw, apdu.data, pin_len);
if (r != 0x9000) {
return r;
}
if ((r = load_dek()) != PICOKEY_OK) {
return SW_EXEC_ERROR();
}
@@ -38,10 +42,6 @@ int cmd_change_pin() {
dek[IV_SIZE + i] ^= otp_key_1[i];
}
}
r = check_pin(pw, apdu.data, pin_len);
if (r != 0x9000) {
return r;
}
uint8_t dhash[33];
dhash[0] = apdu.nc - pin_len;
double_hash_pin(apdu.data + pin_len, apdu.nc - pin_len, dhash + 1);