diff options
author | Mattias Andrée <maandree@kth.se> | 2017-10-14 01:01:14 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2017-10-14 01:01:14 +0200 |
commit | 3e1864aa14a33a3c917537a241f6a032cfcacf78 (patch) | |
tree | 25297b1363fa88c9f45b5102afa5e95d08e986c1 /libkeccak/hex.h | |
parent | Change style and license (diff) | |
download | libkeccak-3e1864aa14a33a3c917537a241f6a032cfcacf78.tar.gz libkeccak-3e1864aa14a33a3c917537a241f6a032cfcacf78.tar.bz2 libkeccak-3e1864aa14a33a3c917537a241f6a032cfcacf78.tar.xz |
General improvements
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'libkeccak/hex.h')
-rw-r--r-- | libkeccak/hex.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/libkeccak/hex.h b/libkeccak/hex.h new file mode 100644 index 0000000..25375d5 --- /dev/null +++ b/libkeccak/hex.h @@ -0,0 +1,44 @@ +/* See LICENSE file for copyright and license details. */ +#ifndef LIBKECCAK_HEX_H +#define LIBKECCAK_HEX_H 1 + +#include "internal.h" + +#include <stddef.h> + + +/** + * Convert a binary hashsum to lower case hexadecimal representation + * + * @param output Output array, should have an allocation size of at least `2 * n + 1` + * @param hashsum The hashsum to convert + * @param n The size of `hashsum` + */ +LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull, nothrow))) +void libkeccak_behex_lower(char *restrict output, const char *restrict hashsum, size_t n); + + +/** + * Convert a binary hashsum to upper case hexadecimal representation + * + * @param output Output array, should have an allocation size of at least `2 * n + 1` + * @param hashsum The hashsum to convert + * @param n The size of `hashsum` + */ +LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull, nothrow))) +void libkeccak_behex_upper(char *restrict output, const char *restrict hashsum, size_t n); + + +/** + * Convert a hexadecimal hashsum (both lower case, upper + * case and mixed is supported) to binary representation + * + * @param output Output array, should have an allocation size of at least `strlen(hashsum) / 2` + * @param hashsum The hashsum to convert + */ +LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull, nothrow))) +void libkeccak_unhex(char *restrict output, const char *restrict hashsum); + + +#endif + |