aboutsummaryrefslogtreecommitdiffstats
path: root/libsha2.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--libsha2.h25
-rw-r--r--libsha2.h.010
2 files changed, 35 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
diff --git a/libsha2.h.0 b/libsha2.h.0
index 5e79f73..a12c6ad 100644
--- a/libsha2.h.0
+++ b/libsha2.h.0
@@ -27,6 +27,8 @@ int libsha2_sum_fd(int \fIfd\fP, enum libsha2_algorithm \fIalgorithm\fP, char *r
void libsha2_behex_lower(char *restrict \fIoutput\fP, const char *restrict \fIhashsum\fP, size_t \fIn\fP);
void libsha2_behex_upper(char *restrict \fIoutput\fP, const char *restrict \fIhashsum\fP, size_t \fIn\fP);
void libsha2_unhex(char *restrict \fIoutput\fP, const char *restrict \fIhashsum\fP);
+size_t libsha2_marshal(const struct libsha2_state *restrict \fIstate\fP, char *restrict \fIbuf\fP);
+size_t libsha2_unmarshal(struct libsha2_state *restrict \fIstate\fP, const char *restrict \fIbuf\fP, size_t \fIbufsize\fP);
.fi
.PP
Link with
@@ -86,6 +88,12 @@ to hexadecimal.
.TP
.BR libsha2_unhex (3)
Convert a hexadecimal hash to binary.
+.TP
+.BR libsha2_marshal (3)
+Marshal a hashing state.
+.TP
+.BR libsha2_unmarshal (3)
+Unmarshal a hashing state.
.SH EXAMPLES
None.
.SH APPLICATION USAGE
@@ -104,7 +112,9 @@ None.
.BR libsha2_behex_upper (3),
.BR libsha2_digest (3),
.BR libsha2_init (3),
+.BR libsha2_marshal (3),
.BR libsha2_state_output_size (3),
.BR libsha2_sum_fd (3),
.BR libsha2_unhex (3),
+.BR libsha2_unmarshal (3),
.BR libsha2_update (3)