Pass::OTP(3pm)

Pass::OTP3pm

Perl implementation of hotp / totp algorithms

Usage

    use Pass::OTP qw(otp);
    use Pass::OTP::URI qw(parse);
    my $uri = "otpauth://totp/ACME:[email protected]?secret=HXDMVJECJJWSRB3HWIZR4IFUGFTMXBOZ&issuer=ACME&digits=6";
    my $otp_code = otp(parse($uri));

Overview

The "Pass::OTP" module provides implementation of HOTP and TOTP algorithms according to the RFC 4226 and RFC 6238.

Functions

hotp(%options)

Computes HMAC-based One-time Password (RFC 4226).

    HOTP(K,C) = Truncate(HMAC-SHA-1(K,C))

Step 1: Generate an HMAC-SHA-1 value

    Let HS = HMAC-SHA-1(K,C)

Step 2: Generate a 4-byte string (Dynamic Truncation)

    Let Sbits = DT(HS)

Step 3: Compute an HOTP value

    Let Snum = StToNum(Sbits)       # Convert S to a number in 0..2^{31}-1
    Return D = Snum mod 10^Digit    # D us a number in the range 0..10^{Digit}-1
totp(%options)

Computes Time-based One-time Password (RFC 6238).

    TOTP = HOTP(K,T)
    T = (Current Unix time - T0) / X
otp(%options)

Convenience wrapper which calls totp/hotp according to options.

Releases

2 releases since Debian 12 (Bookworm); the text changed 1 time.

  1. 12
  2. 13

From libpass-otp-perl 1.801-1 in Debian 13 (Trixie). Parsed by carta from the page's man source.