summaryrefslogtreecommitdiffstats
path: root/web/server/h2o/libh2o/deps/picotls/deps/cifra/src/hmac.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 02:57:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 02:57:58 +0000
commitbe1c7e50e1e8809ea56f2c9d472eccd8ffd73a97 (patch)
tree9754ff1ca740f6346cf8483ec915d4054bc5da2d /web/server/h2o/libh2o/deps/picotls/deps/cifra/src/hmac.h
parentInitial commit. (diff)
downloadnetdata-be1c7e50e1e8809ea56f2c9d472eccd8ffd73a97.tar.xz
netdata-be1c7e50e1e8809ea56f2c9d472eccd8ffd73a97.zip
Adding upstream version 1.44.3.upstream/1.44.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--web/server/h2o/libh2o/deps/picotls/deps/cifra/src/hmac.h78
1 files changed, 78 insertions, 0 deletions
diff --git a/web/server/h2o/libh2o/deps/picotls/deps/cifra/src/hmac.h b/web/server/h2o/libh2o/deps/picotls/deps/cifra/src/hmac.h
new file mode 100644
index 00000000..2f9ea7b0
--- /dev/null
+++ b/web/server/h2o/libh2o/deps/picotls/deps/cifra/src/hmac.h
@@ -0,0 +1,78 @@
+/*
+ * cifra - embedded cryptography library
+ * Written in 2014 by Joseph Birr-Pixton <jpixton@gmail.com>
+ *
+ * To the extent possible under law, the author(s) have dedicated all
+ * copyright and related and neighboring rights to this software to the
+ * public domain worldwide. This software is distributed without any
+ * warranty.
+ *
+ * You should have received a copy of the CC0 Public Domain Dedication
+ * along with this software. If not, see
+ * <http://creativecommons.org/publicdomain/zero/1.0/>.
+ */
+
+#ifndef HMAC_H
+#define HMAC_H
+
+#include <stddef.h>
+#include <stdint.h>
+
+#include "chash.h"
+
+/**
+ * HMAC
+ * ====
+ * This is a one-shot and incremental interface to computing
+ * HMAC with any hash function.
+ *
+ * (Note: HMAC with SHA3 is possible, but is probably not a
+ * sensible thing to want.)
+ */
+
+/* .. c:type:: cf_hmac_ctx
+ * HMAC incremental interface context.
+ *
+ * .. c:member:: cf_hmac_ctx.hash
+ * Hash function description.
+ *
+ * .. c:member:: cf_hmac_ctx.inner
+ * Inner hash computation.
+ *
+ * .. c:member:: cf_hmac_ctx.outer
+ * Outer hash computation.
+ */
+typedef struct
+{
+ const cf_chash *hash;
+ cf_chash_ctx inner;
+ cf_chash_ctx outer;
+} cf_hmac_ctx;
+
+/* .. c:function:: $DECL
+ * Set up ctx for computing a HMAC using the given hash and key. */
+void cf_hmac_init(cf_hmac_ctx *ctx,
+ const cf_chash *hash,
+ const uint8_t *key, size_t nkey);
+
+/* .. c:function:: $DECL
+ * Input data. */
+void cf_hmac_update(cf_hmac_ctx *ctx,
+ const void *data, size_t ndata);
+
+/* .. c:function:: $DECL
+ * Finish and compute HMAC.
+ * `ctx->hash->hashsz` bytes are written to `out`. */
+void cf_hmac_finish(cf_hmac_ctx *ctx, uint8_t *out);
+
+/* .. c:function:: $DECL
+ * One shot interface: compute `HMAC_hash(key, msg)`, writing the
+ * answer (which is `hash->hashsz` long) to `out`.
+ *
+ * This function does not fail. */
+void cf_hmac(const uint8_t *key, size_t nkey,
+ const uint8_t *msg, size_t nmsg,
+ uint8_t *out,
+ const cf_chash *hash);
+
+#endif