From 4ece4861f8597a1e23500306c2cd908a7fab2b7a Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Tue, 25 Oct 2022 08:25:53 +0200 Subject: [PATCH] Counter should be 8 bytes long With 4 bytes the test vectors do not pass the right values. Similarly, the TOTP implementatation uses 8 byte long int. As per RFC4226, 5.1. Notation and Symbols [1]: C 8-byte counter value, the moving factor. This counter MUST be synchronized between the HOTP generator (client) and the HOTP validator (server). [1] https://www.rfc-editor.org/rfc/rfc4226#page-5 --- src/authenticator.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/authenticator.rs b/src/authenticator.rs index 3df8e0781d..8397d6f3b4 100644 --- a/src/authenticator.rs +++ b/src/authenticator.rs @@ -501,11 +501,11 @@ where postcard_serialize_bytes(&credential).unwrap(), None )); - + let counter_long: u64 = counter.into(); crate::calculate::calculate( &mut self.trussed, credential.algorithm, - &counter.to_be_bytes(), + &counter_long.to_be_bytes(), credential.secret, ) } else {