From d923111f50e59196ec4b84d943ccfb652a9d77d8 Mon Sep 17 00:00:00 2001 From: Francois Kritzinger Date: Wed, 28 Feb 2024 10:52:08 +0200 Subject: Verify webhook request HMACs --- mod/hmac.hxx | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 mod/hmac.hxx (limited to 'mod/hmac.hxx') diff --git a/mod/hmac.hxx b/mod/hmac.hxx new file mode 100644 index 0000000..104b629 --- /dev/null +++ b/mod/hmac.hxx @@ -0,0 +1,29 @@ +#ifndef MOD_HMAC_HXX +#define MOD_HMAC_HXX + +#include +#include + +#include + +namespace brep +{ + // Compute the HMAC-SHA256 message authentication code over a message using + // the given key. + // + // Return the HMAC 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 vector& message, + const char* key); +} + +#endif -- cgit v1.1