Skip to content

Conversation

@freddy77
Copy link
Contributor

Another set. First 2 are more or less easy. The third is more complicated, see the commit message.

  1. correct error messages from tests;
  2. constant time computation;
  3. rewrite base32 decoding to support all cases and more common syntax.

On C++ use std::cerr instead of std::cout.
On C fputs does not append a new line (compared to puts which does).

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Do not just stop if the number reach zero.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
All invalid characters in the string were interpreted as zero,
same as the equal ('=') padding.
For short strings treating padding as zero is fine ad the HMAC
algorithm pad the secret with zeroes if it fit into the
block. However if it does not fit the computation get wrong.
If the BASE32 secret is pretty large (104 characters for SHA1),
the key is replaced by an hashed version of it.
So, to make an example if the secret is up to 103 "A" characters
the binary key will be the same but adding any more "A" will cause the
key to change (and so the tokens).
This requires us to pass a key that is not multiple of 5 bytes,
so the implementation of otp_byte_secret() was changed to satisfy
this.
While at it catch and report invalid characters.
OTP_DEFAULT_BASE32_OFFSETS array was moved to C file, no reasons
to expose it.
Padding "=" characters are stripped at the beginning, allowing
to pass them or not, as most implementations are allowing this.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant