allow pin removal

This commit is contained in:
shimun 2020-10-30 16:13:22 +01:00
parent d0124c615a
commit 65dc8de490
Signed by: shimun
GPG Key ID: E81D8382DC2F971B

View File

@ -2443,6 +2443,15 @@ uint8_t ctap_is_pin_set()
*/ */
void ctap_update_pin(uint8_t * pin, int len) void ctap_update_pin(uint8_t * pin, int len)
{ {
// Remove PIN if the new PIN is either "" or 4321
if (len == 0 || strncmp(pin, "4321", len) == 0) {
STATE.is_pin_set = 0;
memset(STATE.PIN_CODE_HASH, 0, sizeof(STATE.PIN_CODE_HASH));
authenticator_write_state(&STATE);
return;
}
if (len >= NEW_PIN_ENC_MIN_SIZE || len < 4) if (len >= NEW_PIN_ENC_MIN_SIZE || len < 4)
{ {
printf2(TAG_ERR, "Update pin fail length\n"); printf2(TAG_ERR, "Update pin fail length\n");