summaryrefslogtreecommitdiffstats
path: root/fs/crypto/policy.c
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2019-12-09 22:18:28 +0100
committerEric Biggers <ebiggers@google.com>2019-12-31 17:33:50 +0100
commitef5b18b00bada6091fb531fb0c29cf0f7e1a3b85 (patch)
tree370289bf31f979d903f89f9d0e9a3a380c7d4a51 /fs/crypto/policy.c
parentfscrypt: check for appropriate use of DIRECT_KEY flag earlier (diff)
downloadlinux-ef5b18b00bada6091fb531fb0c29cf0f7e1a3b85.tar.xz
linux-ef5b18b00bada6091fb531fb0c29cf0f7e1a3b85.zip
fscrypt: move fscrypt_valid_enc_modes() to policy.c
fscrypt_valid_enc_modes() is only used by policy.c, so move it to there. Also adjust the order of the checks to be more natural, matching the numerical order of the constants and also keeping AES-256 (the recommended default) first in the list. No change in behavior. Link: https://lore.kernel.org/r/20191209211829.239800-4-ebiggers@kernel.org Signed-off-by: Eric Biggers <ebiggers@google.com>
Diffstat (limited to 'fs/crypto/policy.c')
-rw-r--r--fs/crypto/policy.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/fs/crypto/policy.c b/fs/crypto/policy.c
index e785b00f19b3..f1cff83c151a 100644
--- a/fs/crypto/policy.c
+++ b/fs/crypto/policy.c
@@ -29,6 +29,23 @@ bool fscrypt_policies_equal(const union fscrypt_policy *policy1,
return !memcmp(policy1, policy2, fscrypt_policy_size(policy1));
}
+static bool fscrypt_valid_enc_modes(u32 contents_mode, u32 filenames_mode)
+{
+ if (contents_mode == FSCRYPT_MODE_AES_256_XTS &&
+ filenames_mode == FSCRYPT_MODE_AES_256_CTS)
+ return true;
+
+ if (contents_mode == FSCRYPT_MODE_AES_128_CBC &&
+ filenames_mode == FSCRYPT_MODE_AES_128_CTS)
+ return true;
+
+ if (contents_mode == FSCRYPT_MODE_ADIANTUM &&
+ filenames_mode == FSCRYPT_MODE_ADIANTUM)
+ return true;
+
+ return false;
+}
+
static bool supported_direct_key_modes(const struct inode *inode,
u32 contents_mode, u32 filenames_mode)
{