aboutsummaryrefslogtreecommitdiffstats
path: root/algorithm_output_size.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2019-02-09 18:20:57 +0100
committerMattias Andrée <maandree@kth.se>2019-02-09 18:20:57 +0100
commit242430d5e52cf8ee49dcd1701cf134e7454910c6 (patch)
treee3238ce604ffb0d80a4e122cd40d5807372f187f /algorithm_output_size.c
parentMerge pull request #2 from maaku/no-trailing-comma (diff)
downloadlibsha2-242430d5e52cf8ee49dcd1701cf134e7454910c6.tar.gz
libsha2-242430d5e52cf8ee49dcd1701cf134e7454910c6.tar.bz2
libsha2-242430d5e52cf8ee49dcd1701cf134e7454910c6.tar.xz
Change license to ISC and reorganise
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--algorithm_output_size.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/algorithm_output_size.c b/algorithm_output_size.c
new file mode 100644
index 0000000..9089aa4
--- /dev/null
+++ b/algorithm_output_size.c
@@ -0,0 +1,24 @@
+/* See LICENSE file for copyright and license details. */
+#include "common.h"
+
+
+/**
+ * Get the output size of an algorithm
+ *
+ * @parma algorithm The hashing algorithm
+ * @return The number of bytes in the output, zero on error
+ */
+size_t
+libsha2_algorithm_output_size(enum libsha2_algorithm algorithm)
+{
+ switch (algorithm) {
+ case LIBSHA2_224: return 28;
+ case LIBSHA2_256: return 32;
+ case LIBSHA2_384: return 48;
+ case LIBSHA2_512: return 64;
+ case LIBSHA2_512_224: return 28;
+ case LIBSHA2_512_256: return 32;
+ default:
+ return errno = EINVAL, 0;
+ }
+}