From 41d75149462599337229f5a67db60f9f43507102 Mon Sep 17 00:00:00 2001 From: Nandor Kracser Date: Fri, 15 Aug 2025 13:07:16 +0200 Subject: [PATCH] refactor: update HMAC_SHA256 function to return error status --- example.c | 4 ++-- test.c | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/example.c b/example.c index 83781b4..63029ed 100644 --- a/example.c +++ b/example.c @@ -9,9 +9,9 @@ int HMAC_SHA256(const unsigned char *data, size_t data_len, unsigned char *out, size_t *out_len) { unsigned int len = 0; - HMAC(EVP_sha256(), key, key_len, data, data_len, out, &len); + char *ac = HMAC(EVP_sha256(), key, key_len, data, data_len, out, &len); *out_len = len; - return 0; + return (ac != NULL) ? 0 : -1; } int main() diff --git a/test.c b/test.c index 7d5d2c8..727f861 100644 --- a/test.c +++ b/test.c @@ -1,4 +1,3 @@ -#include #include #include #include @@ -10,9 +9,9 @@ int HMAC_SHA256(const unsigned char *data, size_t data_len, unsigned char *out, size_t *out_len) { unsigned int len = 0; - HMAC(EVP_sha256(), key, key_len, data, data_len, out, &len); + char *ac = HMAC(EVP_sha256(), key, key_len, data, data_len, out, &len); *out_len = len; - return 0; + return (ac != NULL) ? 0 : -1; } START_TEST(AwsSigv4Test_AwsSigv4Sign)