2 * crypto_mode.c --- convert between encryption modes and strings
4 * Copyright (C) 1999 Theodore Ts'o <tytso@mit.edu>
7 * This file may be redistributed under the terms of the GNU Library
8 * General Public License, version 2.
27 static struct mode mode_list[] = {
28 { EXT4_ENCRYPTION_MODE_INVALID, "Invalid"},
29 { EXT4_ENCRYPTION_MODE_AES_256_XTS, "AES-256-XTS"},
30 { EXT4_ENCRYPTION_MODE_AES_256_GCM, "AES-256-GCM"},
31 { EXT4_ENCRYPTION_MODE_AES_256_CBC, "AES-256-CBC"},
35 const char *e2p_encmode2string(int num)
40 for (p = mode_list; p->string; p++) {
44 sprintf(buf, "ENC_MODE_%d", num);
49 * Returns the hash algorithm, or -1 on error
51 int e2p_string2encmode(char *string)
57 for (p = mode_list; p->string; p++) {
58 if (!strcasecmp(string, p->string)) {
62 if (strncasecmp(string, "ENC_MODE_", 9))
67 num = strtol(string+9, &eptr, 10);
68 if (num > 255 || num < 0)