]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
fscrypt: move fscrypt_valid_enc_modes() to policy.c
authorEric Biggers <ebiggers@google.com>
Mon, 9 Dec 2019 21:18:28 +0000 (13:18 -0800)
committerEric Biggers <ebiggers@google.com>
Tue, 31 Dec 2019 16:33:50 +0000 (10:33 -0600)
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>
fs/crypto/fscrypt_private.h
fs/crypto/policy.c

index 41b061cdf06eee1e0a15c0e4ca6fa1806a645316..71f496fe71732574fe118cfe19879617cebbc9e1 100644 (file)
@@ -206,24 +206,6 @@ typedef enum {
        FS_ENCRYPT,
 } fscrypt_direction_t;
 
-static inline bool fscrypt_valid_enc_modes(u32 contents_mode,
-                                          u32 filenames_mode)
-{
-       if (contents_mode == FSCRYPT_MODE_AES_128_CBC &&
-           filenames_mode == FSCRYPT_MODE_AES_128_CTS)
-               return true;
-
-       if (contents_mode == FSCRYPT_MODE_AES_256_XTS &&
-           filenames_mode == FSCRYPT_MODE_AES_256_CTS)
-               return true;
-
-       if (contents_mode == FSCRYPT_MODE_ADIANTUM &&
-           filenames_mode == FSCRYPT_MODE_ADIANTUM)
-               return true;
-
-       return false;
-}
-
 /* crypto.c */
 extern struct kmem_cache *fscrypt_info_cachep;
 extern int fscrypt_initialize(unsigned int cop_flags);
index e785b00f19b300727242a38a98864469a3f5f0a2..f1cff83c151acff4a85ceb2307e0a28824897922 100644 (file)
@@ -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)
 {