summary refs log tree commit diff stats
path: root/crypto/hmac-glib.c
diff options
context:
space:
mode:
authorJan Kiszka <jan.kiszka@siemens.com>2025-09-01 07:56:26 +0200
committerPhilippe Mathieu-Daudé <philmd@linaro.org>2025-09-02 17:58:05 +0200
commit22ece1a6ebf5d9e0b0a3e376dcfbfe9d96d209b9 (patch)
treeb499f0730fcacb52ae4499817a1efe2b971dbc73 /crypto/hmac-glib.c
parente2d7c1a3cdc46d6b2e8afa8db8a7ef4c2740a2fe (diff)
downloadfocaccia-qemu-22ece1a6ebf5d9e0b0a3e376dcfbfe9d96d209b9.tar.gz
focaccia-qemu-22ece1a6ebf5d9e0b0a3e376dcfbfe9d96d209b9.zip
crypto/hmac: Allow to build hmac over multiple qcrypto_gnutls_hmac_bytes[v] calls
If the buffers that should be considered for building the hmac are not
available at the same time, the current API is unsuitable. Extend it so
that passing a NULL pointer as result_len is used as indicator that
further buffers will be passed in succeeding calls to
qcrypto_gnutls_hmac_bytes[v].

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <2d3539c247a6c323491a3821f0e5b6fc382a4686.1756706188.git.jan.kiszka@siemens.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Diffstat (limited to 'crypto/hmac-glib.c')
-rw-r--r--crypto/hmac-glib.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/crypto/hmac-glib.c b/crypto/hmac-glib.c
index ea80c8d1b2..b845133a05 100644
--- a/crypto/hmac-glib.c
+++ b/crypto/hmac-glib.c
@@ -104,7 +104,9 @@ qcrypto_glib_hmac_bytesv(QCryptoHmac *hmac,
         return -1;
     }
 
-    if (*resultlen == 0) {
+    if (resultlen == NULL) {
+        return 0;
+    } else if (*resultlen == 0) {
         *resultlen = ret;
         *result = g_new0(uint8_t, *resultlen);
     } else if (*resultlen != ret) {