aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ecryptfs/crypto.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ecryptfs/crypto.c')
-rw-r--r--fs/ecryptfs/crypto.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c
index 6046239465a1..485732751f09 100644
--- a/fs/ecryptfs/crypto.c
+++ b/fs/ecryptfs/crypto.c
@@ -1149,19 +1149,20 @@ ecryptfs_cipher_code_str_map[] = {
1149 1149
1150/** 1150/**
1151 * ecryptfs_code_for_cipher_string 1151 * ecryptfs_code_for_cipher_string
1152 * @crypt_stat: The cryptographic context 1152 * @cipher_name: The string alias for the cipher
1153 * @key_bytes: Length of key in bytes; used for AES code selection
1153 * 1154 *
1154 * Returns zero on no match, or the cipher code on match 1155 * Returns zero on no match, or the cipher code on match
1155 */ 1156 */
1156u8 ecryptfs_code_for_cipher_string(struct ecryptfs_crypt_stat *crypt_stat) 1157u8 ecryptfs_code_for_cipher_string(char *cipher_name, size_t key_bytes)
1157{ 1158{
1158 int i; 1159 int i;
1159 u8 code = 0; 1160 u8 code = 0;
1160 struct ecryptfs_cipher_code_str_map_elem *map = 1161 struct ecryptfs_cipher_code_str_map_elem *map =
1161 ecryptfs_cipher_code_str_map; 1162 ecryptfs_cipher_code_str_map;
1162 1163
1163 if (strcmp(crypt_stat->cipher, "aes") == 0) { 1164 if (strcmp(cipher_name, "aes") == 0) {
1164 switch (crypt_stat->key_size) { 1165 switch (key_bytes) {
1165 case 16: 1166 case 16:
1166 code = RFC2440_CIPHER_AES_128; 1167 code = RFC2440_CIPHER_AES_128;
1167 break; 1168 break;
@@ -1173,7 +1174,7 @@ u8 ecryptfs_code_for_cipher_string(struct ecryptfs_crypt_stat *crypt_stat)
1173 } 1174 }
1174 } else { 1175 } else {
1175 for (i = 0; i < ARRAY_SIZE(ecryptfs_cipher_code_str_map); i++) 1176 for (i = 0; i < ARRAY_SIZE(ecryptfs_cipher_code_str_map); i++)
1176 if (strcmp(crypt_stat->cipher, map[i].cipher_str) == 0){ 1177 if (strcmp(cipher_name, map[i].cipher_str) == 0) {
1177 code = map[i].cipher_code; 1178 code = map[i].cipher_code;
1178 break; 1179 break;
1179 } 1180 }