aboutsummaryrefslogtreecommitdiffstats
path: root/libsha2.h
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2019-02-09 20:44:43 +0100
committerMattias Andrée <maandree@kth.se>2019-02-09 20:44:43 +0100
commit8d0cea10adbe544c38ee458b9b2b67bba2c72959 (patch)
tree25cfa294cb284ca21ffb0a8c3793471dc6804543 /libsha2.h
parentMinor changes, add man pages, rename libsha2_state_initialise to libsha2_init (diff)
downloadlibsha2-8d0cea10adbe544c38ee458b9b2b67bba2c72959.tar.gz
libsha2-8d0cea10adbe544c38ee458b9b2b67bba2c72959.tar.bz2
libsha2-8d0cea10adbe544c38ee458b9b2b67bba2c72959.tar.xz
Add marshal and unmarshal functions
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'libsha2.h')
-rw-r--r--libsha2.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/libsha2.h b/libsha2.h
index 02a386b..801c6be 100644
--- a/libsha2.h
+++ b/libsha2.h
@@ -264,5 +264,30 @@ __attribute__((__leaf__, __nonnull__, __nothrow__))
#endif
void libsha2_unhex(char *restrict, const char *restrict);
+/**
+ * Marshal a 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_marshal(const struct libsha2_state *restrict, char *restrict);
+
+/**
+ * Unmarshal a 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_unmarshal(struct libsha2_state *restrict, const char *restrict, size_t);
+
#endif