From de3d878243988d150e496750595b3f6b08e17483 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Sun, 20 Aug 2023 22:04:25 +0200 Subject: Make the ‘b32toa’ dest a uint8_t* MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- b32.c | 4 ++-- b32.h | 3 ++- main.c | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/b32.c b/b32.c index 1503bf5..1c50aa5 100644 --- a/b32.c +++ b/b32.c @@ -22,7 +22,7 @@ static const uint8_t ctov[] = { }; bool -b32toa(char *dst, const char *src, size_t len) +b32toa(uint8_t *dst, const char *src, size_t len) { char c; size_t pad = 0; @@ -37,7 +37,7 @@ b32toa(char *dst, const char *src, size_t len) for (size_t j = 0; j < 8; j++) { c = src[i + j]; vs[j] = ctov[(uint8_t)c]; - if (vs[j] == 255) { + if (vs[j] == (uint8_t)-1) { if (c == '=' && j >= 8 - pad) vs[j] = 0; else diff --git a/b32.h b/b32.h index 090b39f..1555dd2 100644 --- a/b32.h +++ b/b32.h @@ -2,7 +2,8 @@ #define B32_B32_H #include +#include -bool b32toa(char *, const char *, size_t); +bool b32toa(uint8_t *, const char *, size_t); #endif diff --git a/main.c b/main.c index a69c7dd..d7d3d2d 100644 --- a/main.c +++ b/main.c @@ -186,7 +186,7 @@ bool totp(struct totp_config conf, uint32_t *code) { int off; - char *key; + uint8_t *key; uchar *mac; time_t epoch; size_t keylen; -- cgit v1.2.3