mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-26 22:40:25 +00:00
Increment U2F counter before authentication (#1595)
* Fix U2F counter endianness * Increment U2F counter before using it * U2F: increment counter before use * U2F: don't increment on U2fCheckOnly Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
parent
831da59ed0
commit
c964099c8c
1 changed files with 3 additions and 3 deletions
|
@ -277,8 +277,8 @@ static uint16_t u2f_authenticate(U2fData* U2F, uint8_t* buf) {
|
|||
}
|
||||
U2F->user_present = false;
|
||||
|
||||
// The 4 byte counter is represented in big endian
|
||||
be_u2f_counter = lfs_tobe32(U2F->counter);
|
||||
// The 4 byte counter is represented in big endian. Increment it before use
|
||||
be_u2f_counter = lfs_tobe32(U2F->counter + 1);
|
||||
|
||||
// Generate hash
|
||||
sha256_start(&sha_ctx);
|
||||
|
@ -318,8 +318,8 @@ static uint16_t u2f_authenticate(U2fData* U2F, uint8_t* buf) {
|
|||
uint8_t signature_len = u2f_der_encode_signature(resp->signature, signature);
|
||||
memcpy(resp->signature + signature_len, state_no_error, 2);
|
||||
|
||||
FURI_LOG_D(TAG, "Counter: %lu", U2F->counter);
|
||||
U2F->counter++;
|
||||
FURI_LOG_D(TAG, "Counter: %lu", U2F->counter);
|
||||
u2f_data_cnt_write(U2F->counter);
|
||||
|
||||
if(U2F->callback != NULL) U2F->callback(U2fNotifyAuthSuccess, U2F->context);
|
||||
|
|
Loading…
Reference in a new issue