Nitrokey / nitrokey-pro-firmware

Firmware for the Nitrokey Pro device
GNU General Public License v3.0
118 stars 21 forks source link

OTP SECRETs begining with 0x00 are not stored in the slots #19

Closed baquilla closed 7 years ago

baquilla commented 8 years ago

Any secret (hotp o totp) beginning with 0x00 are ignored because only the first byte is checked (it's really a rudimentary check!) to know if secret have to be stored (user has type a new one) or keep the old one. htop.c/write_to_slot()/line 500.

An example. This was may google TOTP secret:

base32[aaxp ip2r v6ux xivu mqmh najd zhqy bgs3] hex[002EF43F51AFA97BA2B46418768123C9E1809A5B]

This secret never trust the condition if (secret[0] == 0). So any secret beginig with 0x00 gives the same code as: oathtool --totp --time-step-size=30s --digits 6 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF because FLASH memories clear to 0xFF.

Workaround: Change the secret, request a new one or disable and reenable two step authentication. Depends on the provider.