}
int calculate_otp(const char *line) {
- size_t i, len = 0;
+ size_t len = 0;
unsigned int hmac_len = 0;
- unsigned char data[sizeof(uint64_t)], *ptr;
+ unsigned char data[sizeof(uint64_t)], *ptr, i;
if(line == NULL)
return -1;
if(strlen(line) < 2)
fprintf(stderr, "\nError: hmac.\n");
return -1;
}
- i = ptr[hmac_len - 1] & 0x0f;
- printf("%06"PRIu32"\n", (((ptr[i + 0] & 0x7f) << 24) | (ptr[i + 1] << 16) |
- (ptr[i + 2] << 8) | ptr[i + 3]) % 1000000);
+ i = ptr[hmac_len - 1] & 0xf;
+ printf("%06"PRIu32"\n", (((ptr[i] & 0x7f) << 24) | (ptr[i + 1] << 16) |
+ (ptr[i + 2] << 8) | ptr[i + 3]) % 1000000);
return 0;
}