-
Notifications
You must be signed in to change notification settings - Fork 0
4 enhance otp codes #8
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
Conversation
|
@nehemiah-nf please make changes as per the following comments by Copilot.
|
|
The maximum value of binary is 0x7fffffff which is 2,147,483,647 which has only 10 digits so any modulo greater than 10 is just being redundant and not actually showing that many digits in the password. It would just be a bunch of 0s followed by the 10 digit code. |
Nice catch. The following should resolve, please update the OTP generation to use var offset = hash[^1] & 0xFL;
var binary =
((hash[offset] & 0x7FL) << 24) |
((hash[offset + 1] & 0xFFL) << 16) |
((hash[offset + 2] & 0xFFL) << 8) |
(hash[offset + 3] & 0xFFL);
var password = binary % (long)Math.Pow(10, digits); |
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.
Pull Request Overview
This PR enhances the OTP service by making core parameters configurable, tightening validation, and improving numeric handling in code generation.
- Secret length is now a public, settable property.
- Time interval for code validity is configurable with validation.
- Bitwise operations and digit limits updated to use long types.
Comments suppressed due to low confidence (1)
Tools/OtpService.cs:22
- The new
TimeIntervalsetter and its validation should have unit tests covering both valid and invalid values to prevent regressions when adjusting code validity periods.
if (value <= 0)
Closes #4