-
Notifications
You must be signed in to change notification settings - Fork 224
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
Regeneration of a key not possible #83
Comments
I'm not sure this needs a new function, named Regenerate, but rather more clarity about the code flows for serialization and deserialization. |
Of course, a note in the documentation and an example could help here. However, I think the user should not be responsible for the decoding of the secret. Basically, as a user, I would assume that the set option "Secret", which is also a field of the key is used unprocessed. The function does not introduce any breaking changes, which is why I would prefer it to a correction in the documentation. |
Need to be clear here, its not "encrypted"; Its base32 encoded. |
I had made a mistake in my choice of words. Regardless of whether it is encoded or encrypted, the library should provide a way to recover the key from the secret. |
Plaenkler, thanks for saving my hide with your example! I would never have figured that out. var secret []byte needed to become this for me to get it to work secret := make([]byte, base32.StdEncoding.DecodedLen(len(opts.Secret))) |
Thanks for the info have adjusted it in the pull request |
🔍 Problem Description:
I am encountering a problem where I cannot recover the QR code after restarting my application. The key.Secret() is the only information that is permanently stored. However, it seems impossible to recover the same key using only the secret.
💡 Relevant Code Snippet:
In the code section below from totp.go (lines 182-192), I initially believed that the key could be recovered only from the secret.
However, recent tests have contradicted this assumption.
🔬 Test Results:
keySecret: JRKDOQRSJJBDIVCRLJJEQS22KBGQINGFQMRUGZHDGNKYINBUSRKI
key.Secret(): KKKJFUIT2RKJJUUSSCIREVMQ2SJRFEURKRKMZDES2CI5IQJFHEORSRJVJFKR22JBCEOTSLLFEU4QSVKNJEWS
🛠️ Environment:
🏁 Expected Outcome:
My expectation is to get a key with the exact same secret when entering the secret.
🚫 Actual Outcome:
Because the entered secret is encoded again, another secret is created.
📝 Solution:
I assume that this decision was made on purpose so I provide a wrapper that decrypts the entered secret first.
The text was updated successfully, but these errors were encountered: