From 31d9446dc092f1787a19734ae9c30286a9fdba2a Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Tue, 27 Aug 2024 21:02:25 +0200 Subject: m misc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- libhashsum.h | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'libhashsum.h') diff --git a/libhashsum.h b/libhashsum.h index 7f828c0..29a8f6f 100644 --- a/libhashsum.h +++ b/libhashsum.h @@ -61,7 +61,7 @@ enum libhashsum_algorithm { LIBHASHSUM_SHA3_256, /**< SHA3-256 */ LIBHASHSUM_SHA3_384, /**< SHA3-384 */ LIBHASHSUM_SHA3_512, /**< SHA3-512 */ - LIBHASHSUM_SHAKE128 , /**< SHAKE128 */ + LIBHASHSUM_SHAKE128, /**< SHAKE128 */ LIBHASHSUM_SHAKE256, /**< SHAKE256 */ LIBHASHSUM_SHAKE512, /**< SHAKE512 */ LIBHASHSUM_RAWSHAKE128, /**< RawSHAKE128 */ @@ -306,6 +306,12 @@ enum libhashsum_algorithm { #define LIBHASHSUM_BLAKE512_HASH_SIZE 64 +#if defined(__GNUC__) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wpadded" +#endif + + /** * Hash state * @@ -602,6 +608,11 @@ struct libhashsum_hasher { }; +#if defined(__GNUC__) +# pragma GCC diagnostic pop +#endif + + /** * Create an initialised state for a hash algorithm * and return hash functions and details @@ -628,6 +639,20 @@ struct libhashsum_hasher { LIBHASHSUM_1_NONNULL_ int libhashsum_init_hasher(struct libhashsum_hasher *this, enum libhashsum_algorithm algorithm); +/** + * Inspect a hashing algorithm string to identify + * which algorithm it references + * + * @param algorithm_out Output parameter for the hashing algorithm + * identifier (set if 1 is returned) + * @param algorithm The hashing algorithm as a string + * @return 1 if the algorithm was recognised, 0 otherwise + * + * @since 1.0 + */ +LIBHASHSUM_NONNULL_ +int libhashsum_get_algorithm_string(enum libhashsum_algorithm *algorithm_out, const char *algorithm); + /** * Create an initialised state for a hash algorithm * and return hash functions and details @@ -1280,7 +1305,7 @@ int libhashsum_init_blakeb_hasher(struct libhashsum_hasher *this, size_t hashbit * @param this The output parameter for the functions, details, and state * @param hashbits Hash output size in bits * @param salt `NULL` (for all zeroes) or a salt - * @parma saltbytes The number of bytes in `salt` (ignored if `salt` is `NULL`), + * @param saltbytes The number of bytes in `salt` (ignored if `salt` is `NULL`), * shall be 16 for if `hashbits` is 224 or 256, and 32 if * `hashbits` is 384 or 512 * @return 0 on success, -1 on failure -- cgit v1.2.3-70-g09d2