summaryrefslogtreecommitdiffstats
path: root/crypto_backend.h
diff options
context:
space:
mode:
authorAdriaan de Jong <dejong@fox-it.com>2011-06-23 17:18:32 +0200
committerDavid Sommerseth <davids@redhat.com>2011-10-19 22:13:25 +0200
commite8c950f12dfd6187f084fb06b6fe6e57c030bdad (patch)
tree15e115f4a19d45c189d8435a018c9df8c05cffcb /crypto_backend.h
parentd5f4461779899dc13be3fc7d41e0f0ac308ffa73 (diff)
downloadopenvpn-e8c950f12dfd6187f084fb06b6fe6e57c030bdad.tar.gz
openvpn-e8c950f12dfd6187f084fb06b6fe6e57c030bdad.tar.xz
openvpn-e8c950f12dfd6187f084fb06b6fe6e57c030bdad.zip
Refactored HMAC functions
Signed-off-by: Adriaan de Jong <dejong@fox-it.com> Acked-by: David Sommerseth <davids@redhat.com> Signed-off-by: David Sommerseth <davids@redhat.com>
Diffstat (limited to 'crypto_backend.h')
-rw-r--r--crypto_backend.h60
1 files changed, 60 insertions, 0 deletions
diff --git a/crypto_backend.h b/crypto_backend.h
index b6fd996..ae3e7fb 100644
--- a/crypto_backend.h
+++ b/crypto_backend.h
@@ -264,4 +264,64 @@ void md_ctx_update (md_ctx_t *ctx, const uint8_t *src, int src_len);
void md_ctx_final (md_ctx_t *ctx, uint8_t *dst);
+/*
+ *
+ * Generic HMAC functions
+ *
+ */
+
+/*
+ * Initialises the given HMAC context, using the given digest
+ * and key.
+ *
+ * @param ctx HMAC context to intialise
+ * @param key The key to use for the HMAC
+ * @param key_len The key length to use
+ * @param kt Static message digest parameters
+ * @param prefix Prefix to use when printing debug information.
+ *
+ */
+void hmac_ctx_init (hmac_ctx_t *ctx, const uint8_t *key, int key_length,
+ const md_kt_t *kt, const char *prefix);
+
+/*
+ * Free the given HMAC context.
+ *
+ * @param ctx HMAC context
+ */
+void hmac_ctx_cleanup(hmac_ctx_t *ctx);
+
+/*
+ * Returns the size of the HMAC output by the given HMAC Context
+ *
+ * @param ctx HMAC context.
+ *
+ * @return Size of the HMAC, or \0 if ctx is NULL.
+ */
+int hmac_ctx_size (const hmac_ctx_t *ctx);
+
+/*
+ * Resets the given HMAC context, preserving the associated key information
+ *
+ * @param ctx HMAC context. May not be NULL.
+ */
+void hmac_ctx_reset (hmac_ctx_t *ctx);
+
+/*
+ * Process the given data for use in the HMAC.
+ *
+ * @param ctx HMAC context. May not be NULL.
+ * @param src The buffer to HMAC. May not be NULL.
+ * @param src_len The length of the incoming buffer.
+ */
+void hmac_ctx_update (hmac_ctx_t *ctx, const uint8_t *src, int src_len);
+
+/*
+ * Output the HMAC to the given buffer.
+ *
+ * @param ctx HMAC context. May not be NULL.
+ * @param dst buffer to write the HMAC to. May not be NULL.
+ */
+void hmac_ctx_final (hmac_ctx_t *ctx, uint8_t *dst);
+
#endif /* CRYPTO_BACKEND_H_ */