summaryrefslogtreecommitdiff
path: root/crypt.h
diff options
context:
space:
mode:
authorꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2022-09-19 20:31:20 +0800
committerꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2022-09-19 20:31:20 +0800
commit6f71dc4695754b27bcfcb5b1e8da1fc1b4b04c3b (patch)
treeab418d2784dd30dfa6f3ecd4a9740b6f3daa8029 /crypt.h
parente594d063888db9f36a4682bc31348cea952eadaa (diff)
Reduce buffer size for unsigned char arrays
They're not strings, so no need for extra byte for the terminating NUL.
Diffstat (limited to 'crypt.h')
-rw-r--r--crypt.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/crypt.h b/crypt.h
index 57d4689..9ae3038 100644
--- a/crypt.h
+++ b/crypt.h
@@ -13,7 +13,7 @@ static inline bool crypt_maccmp(const char *key, const char *query,
gcry_mac_setkey(hd, key, strlen(key));
gcry_mac_write(hd, query, strlen(query));
static size_t hmacsha256_len = 32;
- unsigned char hmacsha256[hmacsha256_len + 1];
+ unsigned char hmacsha256[hmacsha256_len];
gcry_mac_read(hd, hmacsha256, &hmacsha256_len);
gcry_mac_close(hd);
char hmacsha256_str[hmacsha256_len * 2 + 1];
@@ -28,7 +28,7 @@ static inline void crypt_getnonce(char buf[], const size_t buf_len)
{
buf[0] = '\0';
const size_t nonce_len = buf_len / 2;
- unsigned char nonce[nonce_len + 1];
+ unsigned char nonce[nonce_len];
gcry_create_nonce(nonce, nonce_len);
for (int i = 0; i < nonce_len; i++)
sprintf(buf, "%s%02x", buf, nonce[i]);