From 6e3af681aa5927d2ab2861e94c0cfea6fa42c0ab Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 10 Feb 2019 17:54:09 +0100 Subject: Minor improvement and man pages for HMAC MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- libsha2.h | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) (limited to 'libsha2.h') diff --git a/libsha2.h b/libsha2.h index 21e0b98..c2112aa 100644 --- a/libsha2.h +++ b/libsha2.h @@ -329,19 +329,29 @@ __attribute__((__leaf__, __nonnull__, __nothrow__)) #endif 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 -- cgit v1.2.3-70-g09d2