aboutsummaryrefslogtreecommitdiff
path: root/mod/hmac.hxx
diff options
context:
space:
mode:
authorFrancois Kritzinger <francois@codesynthesis.com>2024-02-28 10:52:08 +0200
committerFrancois Kritzinger <francois@codesynthesis.com>2024-12-10 11:40:24 +0200
commiteedef97cd9679ae68d7c989f194d957a35a00dd1 (patch)
treea4a4f5a4e6cee1b7ff5aea68f8619bc5a9d29c07 /mod/hmac.hxx
parentabd6ede8444a89b6c56c20d06110cb3923b05bbe (diff)
Verify webhook request HMACs
Diffstat (limited to 'mod/hmac.hxx')
-rw-r--r--mod/hmac.hxx29
1 files changed, 29 insertions, 0 deletions
diff --git a/mod/hmac.hxx b/mod/hmac.hxx
new file mode 100644
index 0000000..586d0e8
--- /dev/null
+++ b/mod/hmac.hxx
@@ -0,0 +1,29 @@
+#ifndef MOD_HMAC_HXX
+#define MOD_HMAC_HXX
+
+#include <libbrep/types.hxx>
+#include <libbrep/utility.hxx>
+
+#include <mod/module-options.hxx>
+
+namespace brep
+{
+ // Compute the HMAC-SHA256 message authentication code over a message using
+ // the given key (alpha-numeric string, not encoded).
+ //
+ // Return the HMAC value or throw std::system_error in case of an error.
+ //
+ // Example output:
+ //
+ // 5e822587094c68e646db8b916da1db2056d92f1dea4252136a533b4147a30cb7
+ //
+ // Note that although any cryptographic hash function can be used to compute
+ // an HMAC, this implementation supports only SHA-256.
+ //
+ string
+ compute_hmac (const options::openssl_options&,
+ const void* message, size_t len,
+ const char* key);
+}
+
+#endif