package otp

  1. Overview
  2. Docs
Time-base One Time Password (OTP) based on RFC6238 with an HMAC-SHA1 algorithm and a 6 digits code in OCAML

Install

dune-project
 Dependency

Authors

Maintainers

Sources

0.2.2.tar.gz
md5=358389b8f0869e47ecee646d39ce315b
sha512=46982fc43ecc8ed857ef19add6a3dee6b33309d2fc957faf44d3e9547f173ddbfe137f9307437435d0534f7a999fa9dc4157ab74c4b96a3702805b3f3039ced4

doc/otp/Otp/Core/index.html

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