aboutsummaryrefslogtreecommitdiffstats
path: root/libsha2.h
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2019-02-10 17:20:40 +0100
committerMattias Andrée <maandree@kth.se>2019-02-10 17:20:40 +0100
commit9d4bd0942daca7b705d73de7341834444567b457 (patch)
treeed217ffaf0babdd8fb9031ef0b042eb2817c82dc /libsha2.h
parentAdd HMAC and use void * instead of char * for binary data (diff)
downloadlibsha2-9d4bd0942daca7b705d73de7341834444567b457.tar.gz
libsha2-9d4bd0942daca7b705d73de7341834444567b457.tar.bz2
libsha2-9d4bd0942daca7b705d73de7341834444567b457.tar.xz
Add libsha2_hmac_[un]marshal
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--libsha2.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/libsha2.h b/libsha2.h
index d4d52bf..21e0b98 100644
--- a/libsha2.h
+++ b/libsha2.h
@@ -363,5 +363,30 @@ __attribute__((__leaf__, __nonnull__, __nothrow__))
#endif
int libsha2_hmac_digest(struct libsha2_hmac_state *restrict, const void *, size_t, void *);
+/**
+ * Marshal an HMAC state into a buffer
+ *
+ * @param state The state to marshal
+ * @param buf Output buffer, `NULL` to only return the required size
+ * @return The number of bytes marshalled to `buf`
+ */
+#if defined(__GNUC__)
+__attribute__((__leaf__, __nonnull__(1), __nothrow__))
+#endif
+size_t libsha2_hmac_marshal(const struct libsha2_hmac_state *restrict, void *restrict);
+
+/**
+ * Unmarshal an HMAC state from a buffer
+ *
+ * @param state Output parameter for the unmarshalled state
+ * @param buf The buffer from which the state shall be unmarshalled
+ * @param bufsize The maximum number of bytes that can be unmarshalled
+ * @return The number of read bytes, 0 on failure
+ */
+#if defined(__GNUC__)
+__attribute__((__leaf__, __nonnull__, __nothrow__))
+#endif
+size_t libsha2_hmac_unmarshal(struct libsha2_hmac_state *restrict, const void *restrict, size_t);
+
#endif