Download the PHP package jp3cki/totp without Composer
On this page you can find all versions of the php package jp3cki/totp. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Please rate this library. Is it a good library?
Informations about the package totp
totp
PHP implementation of RFC6238 (TOTP: Time-Based One-Time Password Algorithm).
Requirements
- PHP (64-bits): PHP 8.2 or later
- PHP Extensions: hash
Install
- Set up Composer, the de facto standard package manager.
php composer.phar require jp3cki/totp
Usage
Security Notes
- Replay protection is the caller's responsibility.
Totp::verify()does not remember which one-time codes have already been used. Per RFC 6238 §5.2, a server MUST reject any TOTP value that was previously accepted within the validity window. Store the most recently accepted time-step (or the accepted code itself) per user, and reject any submission that is equal to or older than it. - Rate-limit verification attempts. A 6-digit code with the default ±1-step window leaves roughly 3 codes valid at any moment, i.e. a 3-in-1,000,000 chance per guess. Without throttling, an attacker can brute force a valid code in minutes. Apply per-account lockout or exponential back-off in the calling application.
- Restrict the hash algorithm to RFC 6238 values. The library only accepts
sha1,sha256, andsha512. Do not forward an untrustedhashparameter intocalc()/verify()from user input.
License
Copyright (c) 2015-2026 AIZAWA Hina <[email protected]>
Contributing
Patches and/or report issues are welcome.
- Please create new branch for each issue or feature. (should not work in master branch)
- Please write and run test.
$ make test - Please run check-style for static code analysis and coding rule checking.
$ make check-style - Please clean up commits.
- Please create new pull-request for each issue or feature.
- Please use Japanese or very simple English to create new pull-request or issue.
Breaking Changes
-
v4.0.0
- Minimum environment is now PHP 8.2
Totp::calc()andTotp::verify()no longer accept arbitrary hash algorithms fromhash_algos(). Onlysha1,sha256, andsha512(the algorithms defined by RFC 6238) are allowed; any other value now throwsInvalidArgumentException. Callers that previously passed values such asmd5orcrc32must switch to one of the supported algorithms.- The default verification window of
Totp::verify()is narrowed.$acceptStepPastnow defaults to1(was2), matching the maximum drift recommended by RFC 6238 §5.2. To restore the previous behaviour, pass$acceptStepPast: 2explicitly. Totp::generateKey()now defaults to a 160-bit shared secret (was 80 bits), matching the HMAC-SHA1 output length recommended by RFC 4226 §4 R6. Existing keys keep working; only newly generated keys are longer. PassTotp::generateKey(80)to restore the previous size.
-
v3.0.0
- Minimum environment is now PHP 8.1
- v2.0.0
- Minimum environment is now PHP 7.2
- Argument types are now strictly enforced
- Removed
Random::generate*(). Always userandom_bytes()now.
All versions of totp with dependencies
PHP Build Version
Package Version
Requires
php Version
>= 8.2
php-64bit Version >= 8.2
ext-hash Version *
paragonie/constant_time_encoding Version ^3.0
php-64bit Version >= 8.2
ext-hash Version *
paragonie/constant_time_encoding Version ^3.0
The package jp3cki/totp contains the following files
Loading the files please wait ...