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:
		@@ -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);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user