summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormar77i <mar77i@protonmail.ch>2017-08-23 09:51:56 +0200
committermar77i <mar77i@protonmail.ch>2017-08-23 09:51:56 +0200
commit5a3fab7a02802a8aab4a697ba3f1e56f8cca62f0 (patch)
treeae5b7c8b8694ea49f236cc259745c3c105a7356d
parent5865c1396c7ccd8a18d5147ef238e86c75dee93e (diff)
cosmetic changes. I don't know why.
-rw-r--r--otp.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/otp.c b/otp.c
index 1584d30..97bf387 100644
--- a/otp.c
+++ b/otp.c
@@ -102,9 +102,9 @@ static inline unsigned char *pack_be64(unsigned char data[], uint64_t value) {
}
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)
@@ -125,9 +125,9 @@ int calculate_otp(const char *line) {
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;
}