-
Notifications
You must be signed in to change notification settings - Fork 171
Full RFC6238 Compatibility #656
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
The full TOTP specification supports not only SHA1, but also SHA256 and SHA512. Up til now, the TOTP provider in this plugin (and most other PHP implementations) claims to support a specified hash type, but doesn't actually work with anything other than SHA1. This is due to key lengths and hash lengths being _different_ for the three hash variants. This change introcudes support for both SHA256 and SHA512, porting the implementation directly from https://github.com/ericmann/totp. See https://tools.ietf.org/html/rfc6238#section-1.2 for more information on the `MAY USE` notation for SHA256 and SHA512. See https://tools.ietf.org/html/rfc6238#appendix-A for a fully compliant reference implementation in Java. See https://tools.ietf.org/html/rfc6238#appendix-B for test vectors showing TOTPs generated for specific time values and the three hash variants. See https://github.com/ericmann/totp/blob/master/test/phpunit/ReferenceTest.php for example unit tests verifying this particular implementation before it was ported to the plugin.
According to the linter: > Method name "Two_Factor_Totp::__set_time" is discouraged; PHP has reserved all method names with a double underscore prefix for future use. Rename the function to make the linter happy.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
kasparsd
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I has just one question. Please see the comment inline the pull request.
| usort( $ticks, array( __CLASS__, 'abssort' ) ); | ||
|
|
||
| $time = floor( time() / self::DEFAULT_TIME_STEP_SEC ); | ||
| $time = floor( self::time() / self::DEFAULT_TIME_STEP_SEC ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be using $time_step now that it is passed in?
What?
Adds support for SHA256 and SHA512 hashes for the underlying TOTP algorithm to fully support the RFC6238 spec.
Replaces #207 for a cleaner GH expereince.
Why?
Up til now, the TOTP provider in this plugin (and most other PHP implementations) claims to support a specified hash type, but doesn't actually work with anything other than SHA1.
This is due to key lengths and hash lengths being different for the three hash variants.
How?
This change introcudes support for both SHA256 and SHA512, porting the implementation directly from https://github.com/ericmann/totp.
See https://tools.ietf.org/html/rfc6238#section-1.2 for more information on the MAY USE notation for SHA256 and SHA512.
See https://tools.ietf.org/html/rfc6238#appendix-A for a fully compliant reference implementation in Java.
Testing Instructions
See https://tools.ietf.org/html/rfc6238#appendix-B for test vectors showing TOTPs generated for specific time values and the three hash variants.
See https://github.com/ericmann/totp/blob/master/test/phpunit/ReferenceTest.php for example unit tests verifying this particular implementation before it was ported to the plugin.
Changelog Entry