summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormar77i <mar77i@protonmail.ch>2020-01-13 15:24:17 +0100
committermar77i <mar77i@protonmail.ch>2020-01-13 15:24:17 +0100
commita1e04eee2ffcff4f5314c9ebc4cd115336a66078 (patch)
treec507cd39829b0f4188810505634055f4d787950e
parentc746245357198541fbf67c1151191566a8b18ac1 (diff)
keep line breaks at <=80 columns.
-rw-r--r--totp.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/totp.c b/totp.c
index d2d53c9..3663d87 100644
--- a/totp.c
+++ b/totp.c
@@ -94,7 +94,8 @@ int b32_decode(unsigned char *buf, size_t *len) {
return 0;
}
-static inline unsigned char *pack_be64(unsigned char data[], uint64_t value) {
+static inline unsigned char *pack_be64(unsigned char data[],
+ uint64_t value) {
size_t i;
for(i = 0; i < sizeof value; i++)
data[i] = (value >> ((sizeof value - 1 - i) * CHAR_BIT)) & 0xff;
@@ -121,13 +122,16 @@ int calculate_totp(const char *line) {
// fill data with the current time divided by INTERVAL_SECONDS
pack_be64(data, time(NULL) / INTERVAL_SECONDS);
- if(HMAC(EVP_sha1(), ptr, len, data, sizeof data, ptr, &hmac_len) == NULL) {
+ if(HMAC(EVP_sha1(), ptr, len, data, sizeof data,
+ ptr, &hmac_len) == NULL) {
fprintf(stderr, "\nError: hmac.\n");
return -1;
}
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);
+ printf("%06"PRIu32"\n", (
+ ((ptr[i] & 0x7f) << 24) | (ptr[i + 1] << 16) |
+ (ptr[i + 2] << 8) | ptr[i + 3]
+ ) % 1000000);
return 0;
}