The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

Title: One Time Password Generation and Verification
Version: 0.1.1
Date: 2024-01-22
Description: Generating and validating One-time Password based on Hash-based Message Authentication Code (HOTP) and Time Based One-time Password (TOTP) according to RFC 4226 https://datatracker.ietf.org/doc/html/rfc4226 and RFC 6238 https://datatracker.ietf.org/doc/html/rfc6238.
License: MIT + file LICENSE
Encoding: UTF-8
URL: https://github.com/randy3k/otp
BugReports: https://github.com/randy3k/otp/issues
Imports: R6, base64url, openssl
RoxygenNote: 7.3.0
Suggests: testthat (≥ 2.1.0), covr
NeedsCompilation: no
Packaged: 2024-01-22 23:56:59 UTC; randylai
Author: Randy Lai [aut, cre, cph]
Maintainer: Randy Lai <randy.cs.lai@gmail.com>
Repository: CRAN
Date/Publication: 2024-01-23 00:20:02 UTC

otp: One Time Password Generation and Verification

Description

Generating and validating One-time Password based on Hash-based Message Authentication Code (HOTP) and Time Based One-time Password (TOTP) according to RFC 4226 https://datatracker.ietf.org/doc/html/rfc4226 and RFC 6238 https://datatracker.ietf.org/doc/html/rfc6238.

Author(s)

Maintainer: Randy Lai randy.cs.lai@gmail.com [copyright holder]

See Also

Useful links:


HMAC based One Time Password (HOTP)

Description

An R6 class that implements the HMAC based One Time Password (HOTP) algorithm.

Initialization

HOTP$new(secret, digits = 6L, algorithm = "sha1")

Create an One Time Password object

Methods

HOTP$at(counter)

Generate an one time password at counter value.

HOTP$verify(code, counter, ahead = 0L)

Verify if a given one time password is valid. Returns the matching counter value if there is a match within the ahead window. Otherwise return NULL.

HOTP$provisioning_uri(name, issuer = NULL, counter = 0L)

Return a provisioning uri which is compatible with google authenticator format.

See Also

https://datatracker.ietf.org/doc/html/rfc4226

Examples

p <- HOTP$new("JBSWY3DPEHPK3PXP")
p$at(8)

p$verify("964230", 8)
p$verify("964230", 7, ahead = 3)

p$provisioning_uri("Alice", issuer = "example.com", counter = 5)

Time based One Time Password (TOTP)

Description

An R6 class that implements the Time based One Time Password (TOTP) algorithm.

Initialization

TOTP$new(secret, digits = 6L, period = 30, algorithm = "sha1")

Create an One Time Password object

Methods

TOTP$at_time(t)

Generate an one time password at a given time value.

HOTP$verify(code, t, behind = 0L)

Verify if a given one time password is valid. Returns the beginning time of the time step window if there is a match within the behind window. Otherwise return NULL.

HOTP$provisioning_uri(name, issuer = NULL)

Return a provisioning uri which is compatible with google authenticator format.

See Also

https://datatracker.ietf.org/doc/html/rfc6238

Examples

p <- TOTP$new("JBSWY3DPEHPK3PXP")
(code <- p$now())
p$verify(code, behind = 1)

(current_time <- Sys.time())
(code <- p$at_time(current_time))
p$verify(code, current_time + 30, behind = 1)

p$provisioning_uri("Alice", issuer = "example.com")

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.