package otp

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Otp.CoreSource

This module is the core of the library and its functions are not exposed except for testing purpose. Do note rely on it for production.

Sourceval increment : counter -> counter

Increments a counter by one step.

Sourceval hmac_sha1 : string -> counter -> string

Computes the hashed message authentication code given a secret (string) and a counter, according to RFC 2104. Validated with RFC 2202 tests vectors.

Sourceval dynamic_truncation : string -> int -> int

Computes the dynamic truncation function mentioned in RFC4226. The function has been tested with the example given in section 5.4.

  • parameter 1

    HS = HMAC-SHA1(key,counter) as described in section 5.3

  • parameter 2

    Number of digits of the code ('Digit' variable in section 5.3) Must be 6, 7 or 8.

  • returns

    Hashed Message Authentication Code (HMAC).

Sourceval hotp : ?nb_digits:int -> string -> counter -> int

Computes the HMAC from the number of digits, the shared secret and the counter. This is a combination of the hmac_sha1 followed by dynamic_truncation functions.

  • parameter nb_digits

    Number of digits of the HMAC.

  • parameter :

    The shared secret

  • parameter :

    the counter

  • returns

    Hashed Message Authentication Code (HMAC)

Sourceval mk_time : float -> string

Helper function to display a date from a Unix time value (provided by e.g. Unix.time)

Sourceval c2is : counter -> string

Helper function to display a counter as an integer string

Sourceval c2bs : counter -> string

Helper function to display a counter as a byte string