summary refs log tree commit diff stats
path: root/include/crypto/hmac.h
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 /include/crypto/hmac.h
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 'include/crypto/hmac.h')
-rw-r--r--include/crypto/hmac.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/include/crypto/hmac.h b/include/crypto/hmac.h
index da8a1e3ceb..af3d5f8feb 100644
--- a/include/crypto/hmac.h
+++ b/include/crypto/hmac.h
@@ -90,6 +90,12 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(QCryptoHmac, qcrypto_hmac_free)
  * The memory referenced in @result must be released with a call
  * to g_free() when no longer required by the caller.
  *
+ * If @result_len is set to a NULL pointer, no result will be returned, and
+ * the hmac object can be used for further invocations of qcrypto_hmac_bytes()
+ * or qcrypto_hmac_bytesv() until a non-NULL pointer is provided. This allows
+ * to build the hmac across memory regions that are not available at the same
+ * time.
+ *
  * Returns:
  *  0 on success, -1 on error
  */
@@ -123,6 +129,12 @@ int qcrypto_hmac_bytesv(QCryptoHmac *hmac,
  * The memory referenced in @result must be released with a call
  * to g_free() when no longer required by the caller.
  *
+ * If @result_len is set to a NULL pointer, no result will be returned, and
+ * the hmac object can be used for further invocations of qcrypto_hmac_bytes()
+ * or qcrypto_hmac_bytesv() until a non-NULL pointer is provided. This allows
+ * to build the hmac across memory regions that are not available at the same
+ * time.
+ *
  * Returns:
  *  0 on success, -1 on error
  */