aboutsummaryrefslogtreecommitdiffstats
path: root/libsha2.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--libsha2.h35
-rw-r--r--libsha2.h.029
2 files changed, 50 insertions, 14 deletions
diff --git a/libsha2.h b/libsha2.h
index 21e0b98..c2112aa 100644
--- a/libsha2.h
+++ b/libsha2.h
@@ -330,18 +330,28 @@ __attribute__((__leaf__, __nonnull__, __nothrow__))
int libsha2_hmac_init(struct libsha2_hmac_state *restrict, enum libsha2_algorithm, const void *restrict, size_t);
/**
+ * Get the output size of the algorithm specified for an HMAC state
+ *
+ * @param state The state
+ * @return The number of bytes in the output, zero on error
+ */
+#if defined(__GNUC__)
+__attribute__((__nothrow__, __nonnull__, __pure__))
+#endif
+size_t libsha2_hmac_state_output_size(const struct libsha2_hmac_state *restrict);
+
+/**
* Feed data into the HMAC algorithm
*
- * @param state The state of the algorithm
- * @param data Data to feed into the algorithm
- * @param n The number of bytes to feed into the
- * algorithm, this must be a multiple of 8
- * @return Zero on success, -1 on error
+ * @param state The state of the algorithm
+ * @param data Data to feed into the algorithm
+ * @param n The number of bytes to feed into the
+ * algorithm, this must be a multiple of 8
*/
#if defined(__GNUC__)
__attribute__((__leaf__, __nonnull__, __nothrow__))
#endif
-int libsha2_hmac_update(struct libsha2_hmac_state *restrict, const void *restrict, size_t);
+void libsha2_hmac_update(struct libsha2_hmac_state *restrict, const void *restrict, size_t);
/**
* Feed data into the HMAC algorithm and
@@ -351,17 +361,16 @@ int libsha2_hmac_update(struct libsha2_hmac_state *restrict, const void *restric
* `libsha2_hmac_update` and `libsha2_hmac_update`
* can be called again
*
- * @param state The state of the algorithm
- * @param data Data to feed into the algorithm
- * @param n The number of bytes to feed into the algorithm
- * @param output The output buffer for the hash, it will be as
- * large as for the underlaying hash algorithm
- * @return Zero on success, -1 on error
+ * @param state The state of the algorithm
+ * @param data Data to feed into the algorithm
+ * @param n The number of bytes to feed into the algorithm
+ * @param output The output buffer for the hash, it will be as
+ * large as for the underlaying hash algorithm
*/
#if defined(__GNUC__)
__attribute__((__leaf__, __nonnull__, __nothrow__))
#endif
-int libsha2_hmac_digest(struct libsha2_hmac_state *restrict, const void *, size_t, void *);
+void libsha2_hmac_digest(struct libsha2_hmac_state *restrict, const void *, size_t, void *);
/**
* Marshal an HMAC state into a buffer
diff --git a/libsha2.h.0 b/libsha2.h.0
index e1a0060..237e406 100644
--- a/libsha2.h.0
+++ b/libsha2.h.0
@@ -1,4 +1,4 @@
-.TH LIBSHA2.H 0 2019-02-09 libjson
+.TH LIBSHA2.H 0 2019-02-10 libjson
.SH NAME
libsha2.h \- SHA 2 library header
.SH SYNOPSIS
@@ -29,6 +29,13 @@ void libsha2_behex_upper(char *restrict \fIoutput\fP, const void *restrict \fIha
void libsha2_unhex(void *restrict \fIoutput\fP, const char *restrict \fIhashsum\fP);
size_t libsha2_marshal(const struct libsha2_state *restrict \fIstate\fP, void *restrict \fIbuf\fP);
size_t libsha2_unmarshal(struct libsha2_state *restrict \fIstate\fP, const void *restrict \fIbuf\fP, size_t \fIbufsize\fP);
+int libsha2_hmac_init(struct libsha2_hmac_state *restrict \fIstate\fP, enum libsha2_algorithm \fIalgorithm\fP,
+ const void *restrict \fIkey\fP, size_t \fIkeylen\fP);
+size_t libsha2_hmac_state_output_size(const struct libsha2_hmac_state *restrict \fIstate\fP);
+void libsha2_hmac_update(struct libsha2_hmac_state *restrict \fIstate\fP, const void *restrict \fIdata\fP, size_t \fIn\fP);
+void libsha2_hmac_digest(struct libsha2_hmac_state *restrict \fIstate\fP, const void *\fIdata\fP, size_t \fIn\fP, void *\fIoutput\fP);
+size_t libsha2_hmac_marshal(const struct libsha2_hmac_state *restrict \fIstate\fP, void *restrict \fIbuf\fP);
+size_t libsha2_hmac_unmarshal(struct libsha2_hmac_state *restrict \fIstate\fP, const void *restrict \fIbuf\fP, size_t \fIbufsize\fP);
.fi
.PP
Link with
@@ -97,6 +104,21 @@ Marshal a hashing state.
.TP
.BR libsha2_unmarshal (3)
Unmarshal a hashing state.
+.TP
+.BR libsha2_hmac_init (3)
+Initialise HMAC hashing state.
+.TP
+.BR libsha2_hmac_update (3)
+Feed data into the HMAC hashing state.
+.TP
+.BR libsha2_hmac_digest (3)
+Get the result of an HMAC hashing.
+.TP
+.BR libsha2_hmac_marshal (3)
+Marshal an HMAC hashing state.
+.TP
+.BR libsha2_hmac_unmarshal (3)
+Unmarshal an HMAC hashing state.
.SH EXAMPLES
None.
.SH APPLICATION USAGE
@@ -114,6 +136,11 @@ None.
.BR libsha2_behex_lower (3),
.BR libsha2_behex_upper (3),
.BR libsha2_digest (3),
+.BR libsha2_hmac_digest (3),
+.BR libsha2_hmac_init (3),
+.BR libsha2_hmac_marshal (3),
+.BR libsha2_hmac_unmarshal (3),
+.BR libsha2_hmac_update (3),
.BR libsha2_init (3),
.BR libsha2_marshal (3),
.BR libsha2_state_output_size (3),