Skip to content
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

help with source code #10

Open
asdffdsazqqq opened this issue Sep 7, 2022 · 3 comments
Open

help with source code #10

asdffdsazqqq opened this issue Sep 7, 2022 · 3 comments

Comments

@asdffdsazqqq
Copy link

asdffdsazqqq commented Sep 7, 2022

No description provided.

@asdffdsazqqq
Copy link
Author

hello, thanks for the source code,

i setup andOTP and KeePass to use MyLegoDoor as the secret key.
both programs always output the same 6-digit TOTP code

the issue with the source code is that it does not seem to get the current time, uses a static unix epoch number.
so i tried to tweak the source code.
after four hours, still cannot figure it out, as i am python programmer pretending to be a c lang programmer

i am EST timezone, so i tried three timezones.
tho setting the timezone does not seem to do anything

void main(void)
{
	char c;
	uint8_t hmacKey[] = {0x4d, 0x79, 0x4c, 0x65, 0x67, 0x6f, 0x44, 0x6f, 0x6f, 0x72}; // Secret key
	TOTP(hmacKey, 10, 30);  // Secret key, Key length, Timestep (7200s - 2hours)

	uint32_t newCode = getCodeFromTimestamp(time(NULL));                                            // Timestamp Now
	printf("newCode-notimezone=%d", newCode);

	setTimezone(-4);                                                                                 // Set timezone
	newCode = getCodeFromTimestamp(time(NULL));                                            // Timestamp Now
	printf("newCode.timezone-4=%d", newCode);

	setTimezone(-5);                                                                                 // Set timezone
	newCode = getCodeFromTimestamp(time(NULL));                                            // Timestamp Now
	printf("newCode.timezone-5=%d", newCode);

	c = getchar();
	return 0;
}

and the output is
newCode-notimezone=436434 ---- newCode.timezone-4=436434 ---- newCode.timezone-5=436434

thanks much,
david

@Netthaw
Copy link
Owner

Netthaw commented Sep 9, 2022

Hello David,

Thanks for the feedback.
getCodeFromTimestamp is not supported yet.
by the way you can get TOTP code using getCodeFromTimeStruct instead if you want to set timezone.

I will fix this issue.

Thanks,
Weck

@asdffdsazqqq
Copy link
Author

asdffdsazqqq commented Sep 9, 2022

Weck, thanks

i tried many different ways but always the 6-digit key never matches andOTP and keepass.
here are two examples,

	uint8_t hmacKey[] = {0x4d, 0x79, 0x4c, 0x65, 0x67, 0x6f, 0x44, 0x6f, 0x6f, 0x72}; 	// Secret key = MyLegoDoor
	TOTP(hmacKey, 10, 30);   // Secret key, Key length, Timestep (7200s - 2hours)

	time_t rawtime;
	struct tm *info;
	time( &rawtime );
	info = localtime( &rawtime );

   	uint32_t newCode = getCodeFromTimeStruct(*info);
	printf("newCode=%d", newCode);
	uint8_t hmacKey[] = {0x4d, 0x79, 0x4c, 0x65, 0x67, 0x6f, 0x44, 0x6f, 0x6f, 0x72}; 	// Secret key = MyLegoDoor
	TOTP(hmacKey, 10, 30);   // Secret key, Key length, Timestep (7200s - 2hours)

	time_t now;
	struct tm *info = localtime(&now);

   	uint32_t newCode = getCodeFromTimeStruct(*info);
	printf("newCode=%d", newCode);

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants