aboutsummaryrefslogtreecommitdiffstats
path: root/libar2_type_to_string.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2022-01-16 19:58:57 +0100
committerMattias Andrée <maandree@kth.se>2022-01-16 19:58:57 +0100
commit8bdc2e4929068210d523c34c0b171b51ce96057f (patch)
treec77331e77b9777a37716bffb7365c4486a6df9a0 /libar2_type_to_string.c
downloadlibar2-8bdc2e4929068210d523c34c0b171b51ce96057f.tar.gz
libar2-8bdc2e4929068210d523c34c0b171b51ce96057f.tar.bz2
libar2-8bdc2e4929068210d523c34c0b171b51ce96057f.tar.xz
First commit1.0
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'libar2_type_to_string.c')
-rw-r--r--libar2_type_to_string.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/libar2_type_to_string.c b/libar2_type_to_string.c
new file mode 100644
index 0000000..3092101
--- /dev/null
+++ b/libar2_type_to_string.c
@@ -0,0 +1,19 @@
+/* See LICENSE file for copyright and license details. */
+#include "common.h"
+
+
+const char *
+libar2_type_to_string(enum libar2_argon2_type type, enum libar2_casing casing)
+{
+ static const char *strs[3][5] = {
+ {"argon2d", "argon2i", "argon2id", NULL, "argon2ds"},
+ {"Argon2d", "Argon2i", "Argon2id", NULL, "Argon2ds"},
+ {"ARGON2D", "ARGON2I", "ARGON2ID", NULL, "ARGON2DS"}
+ };
+
+ if (type < 0 || casing < 0 || type >= ELEMSOF(*strs) || casing >= ELEMSOF(strs) || !strs[casing][type]) {
+ errno = EINVAL;
+ return NULL;
+ }
+ return strs[casing][type];
+}