Giter Club home page Giter Club logo

Comments (3)

szszszsz avatar szszszsz commented on August 19, 2024

AFAIR Pro stores its date in 64 bit POSIX seconds (which covers next 1000 years). To confirm and check how the data is sent in protocol.

from nitrokey-pro-firmware.

szszszsz avatar szszszsz commented on August 19, 2024

Nitrokey Pro passes the 64-bit tests for TOTP time setting and code generation. Related test:
https://github.com/Nitrokey/libnitrokey/blob/3eb4856ed8c9a5a8179679f2432c01d382a9c07a/unittest/test_pro.py#L436-L458

Closing as question.

from nitrokey-pro-firmware.

szszszsz avatar szszszsz commented on August 19, 2024

B. Pro v0.10+ (to be released as v0.11; current master):
Code for TOTP looks almost the same as in Storage version. All time-related variables are 64 bit. Value is calculated in [5]. Before that it routed from [6].

Tests show that device response is same as with the Python library, but unexpectedly only until using time in 60 bits (with value 30 as a TOTP period). Doubling period allows to use 61 bit time value, which sounds, like the window counter would be the limiter (counter = time/period; 55 bits for a successful use -> logโ‚‚ ((2^60)รท30)). This variable is 64-bit, and as such is passed to the hmac-sha1 calculation. Perhaps not all bits are taken into account due to hmac-sha1 implementation, or algorithm itself. Even 55 bits will suffice though [7] (assuming period=1), so there is no need to pursue this in practice.

I need yet to see, whether the device is off with the calculations, or rather the library (used as a ground of truth), or both - in case both device and the Python OTP library would give wrong results.

[5] https://github.com/Nitrokey/nitrokey-pro-firmware/blob/master/src/hotp/hotp.c#L158
[6] https://github.com/Nitrokey/nitrokey-pro-firmware/blob/master/src/hotp/hotp.c#L686
[7] IPython3 session:

In [10]: datetime.datetime.fromtimestamp(2**31-1)
Out[10]: datetime.datetime(2038, 1, 19, 4, 14, 7)

In [11]: datetime.datetime.fromtimestamp(2**55-1)
ValueError: year 1141709097 is out of range

In [12]: datetime.datetime.fromtimestamp(2**32-1)
Out[12]: datetime.datetime(2106, 2, 7, 7, 28, 15)

from nitrokey-pro-firmware.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.