Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Minor type cleanup ("unsigned char" -> "uint8_t").
  • Loading branch information
icculus committed Jun 18, 2017
1 parent 0e1ae31 commit 6c04634
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions otp.c
Expand Up @@ -63,7 +63,7 @@ int totp(const char *base32_secret, char *dst, int dstlen)
int decodedlen;
uint64_t secs;
uint8_t timebytes[8];
unsigned char digest[SHA1_DIGEST_LENGTH];
uint8_t digest[SHA1_DIGEST_LENGTH];
uint8_t *bytes;
uint32_t val;

Expand All @@ -79,7 +79,7 @@ int totp(const char *base32_secret, char *dst, int dstlen)

SHA1Hmac(decoded, decodedlen, timebytes, 8, digest);

bytes = (uint8_t *) (digest + (digest[SHA1_DIGEST_LENGTH-1] & 0xF));
bytes = digest + (digest[SHA1_DIGEST_LENGTH-1] & 0xF);
val = (((uint32_t) bytes[0]) << 24) | (((uint32_t) bytes[1]) << 16) |
(((uint32_t) bytes[2]) << 8) | (((uint32_t) bytes[3]));
val &= 0x7FFFFFFF; /* drop most significant bit. */
Expand Down

0 comments on commit 6c04634

Please sign in to comment.