|
From: | derek cooper |
Subject: | [OATH-Toolkit-help] Help with OATHLIB |
Date: | Tue, 29 Mar 2016 09:06:04 +0000 |
Hello,
I am trying to generate TOTP tokens using OATHLIB, with the following test program: #include <stdio.h> #include <string.h> #include <time.h> #include <liboath/oath.h> int main(int argc, char *argv[]){ int rc=1; const char* secret="12345678901234567890123456789011"; size_t secretlen=32; size_t window=0; unsigned digits=6; char mytoken[10]; time_t now; rc=oath_init(); if (rc == 0) printf("liboath: %i\n",OATH_OK); now=time(NULL); rc=oath_totp_generate(secret, secretlen, now, OATH_TOTP_DEFAULT_TIME_STEP_SIZE, OATH_TOTP_DEFAULT_START_TIME, digits, mytoken); if (rc == 0) printf("Time: %i Token: %s\n",now,&mytoken); rc=oath_done(); return 0; } I compile the program with: cc oath.c -o test1 -loath However the token generated does not match with the same token using oathtool, when i use a real token (values above are dummy ones) oathtool returns the correct value, but the test c program does not. the results: oathtool -v --totp 12345678901234567890123456789011 ;./test1 Hex secret: 12345678901234567890123456789011 Base32 secret: CI2FM6EQCI2FM6EQCI2FM6EQCE====== Digits: 6 Window size: 0 Step size (seconds): 30 Start time: 1970-01-01 00:00:00 UTC (0) Current time: 2016-03-29 08:19:44 UTC (1459239584) Counter: 0x2E63527 (48641319) 012625 liboath: 0 Time: 1459239584 Token: 815393 As you can see oathtool time (seconds) 1459239584 matches ok, but the tokens are different? 012625 verses 815393 Any pointers or help would be most welcome. Thanks Derek |
[Prev in Thread] | Current Thread | [Next in Thread] |