aboutsummaryrefslogblamecommitdiffstats
path: root/libar2_type_to_string.c
blob: 30921015db1224b2ff73a6690b2a9a7b13ec40e0 (plain) (tree)


















                                                                                                                 
/* 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];
}