admin管理员组文章数量:1401940
I'm using Botan2 to implement a 2-factor-authentification. I cannot find any information which format Botan2 expects the secret key to be. If I just enter the same key as string I enter in the authenticator app (Google Authenticator in this case) I'm not getting the same 6-digit number as a result.
By trial-and-error I found that I get the same 6-digit number when I center in the Authenticator App AAAAAAAAAAAAAAAA
and when I pass the string "0000000000000000"
to Botan::SymmetricKey
. But BBBBBBBBBBBBBBBB
does not correspond to 1111111111111111
.
As a minimal example I have this command line program which expects a 6-digit code as first cmd line parameter like ./totp-test.o 123456
#include <iostream>
#include <botan/otp.h>
#include <chrono>
using namespace std;
int main(int argc, char* argv[]) {
// I have to enter AAAAAAAAAAAAAAAA in authenticator app to match the 6-digit number
Botan::SymmetricKey key ("0000000000000000");
Botan::TOTP totp (key);
chrono::time_point now = chrono::time_point_cast<chrono::milliseconds>(
chrono::system_clock::now()
);
cout<<"local totp: "<<totp.generate_totp (now)<<endl;
int given_totp = atoi(argv[1]);
cout<<"given totp: "<<given_totp<<endl;
cout<<"verify: " <<totp.verify_totp (given_totp, now)<<endl;
return 0;
I'm very sure all my clocks are synced.
本文标签: cBotan2 TOTP how to convert secretStack Overflow
版权声明:本文标题:c++ - Botan2 TOTP how to convert secret? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744329789a2600906.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论