aboutsummaryrefslogtreecommitdiffstats
path: root/include/uapi/linux/fscrypt.h
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2019-08-04 22:35:44 -0400
committerEric Biggers <ebiggers@google.com>2019-08-12 22:05:16 -0400
commit2336d0deb2d4680349de59d6fbdfc338437be191 (patch)
tree84497efa31e75ff365e5cfb262d7d3cecbee45f3 /include/uapi/linux/fscrypt.h
parent7af0ab0d3aab951518b0d520f95e9f6b1995ec69 (diff)
fscrypt: use FSCRYPT_ prefix for uapi constants
Prefix all filesystem encryption UAPI constants except the ioctl numbers with "FSCRYPT_" rather than with "FS_". This namespaces the constants more appropriately and makes it clear that they are related specifically to the filesystem encryption feature, and to the 'fscrypt_*' structures. With some of the old names like "FS_POLICY_FLAGS_VALID", it was not immediately clear that the constant had anything to do with encryption. This is also useful because we'll be adding more encryption-related constants, e.g. for the policy version, and we'd otherwise have to choose whether to use unclear names like FS_POLICY_V1 or inconsistent names like FS_ENCRYPTION_POLICY_V1. For source compatibility with existing userspace programs, keep the old names defined as aliases to the new names. Finally, as long as new names are being defined anyway, I skipped defining new names for the fscrypt mode numbers that aren't actually used: INVALID (0), AES_256_GCM (2), AES_256_CBC (3), SPECK128_256_XTS (7), and SPECK128_256_CTS (8). Reviewed-by: Theodore Ts'o <tytso@mit.edu> Signed-off-by: Eric Biggers <ebiggers@google.com>
Diffstat (limited to 'include/uapi/linux/fscrypt.h')
-rw-r--r--include/uapi/linux/fscrypt.h65
1 files changed, 42 insertions, 23 deletions
diff --git a/include/uapi/linux/fscrypt.h b/include/uapi/linux/fscrypt.h
index 26f6d2c19afd..674b0452ef57 100644
--- a/include/uapi/linux/fscrypt.h
+++ b/include/uapi/linux/fscrypt.h
@@ -10,35 +10,30 @@
10 10
11#include <linux/types.h> 11#include <linux/types.h>
12 12
13#define FS_KEY_DESCRIPTOR_SIZE 8 13#define FSCRYPT_KEY_DESCRIPTOR_SIZE 8
14 14
15/* Encryption policy flags */ 15/* Encryption policy flags */
16#define FS_POLICY_FLAGS_PAD_4 0x00 16#define FSCRYPT_POLICY_FLAGS_PAD_4 0x00
17#define FS_POLICY_FLAGS_PAD_8 0x01 17#define FSCRYPT_POLICY_FLAGS_PAD_8 0x01
18#define FS_POLICY_FLAGS_PAD_16 0x02 18#define FSCRYPT_POLICY_FLAGS_PAD_16 0x02
19#define FS_POLICY_FLAGS_PAD_32 0x03 19#define FSCRYPT_POLICY_FLAGS_PAD_32 0x03
20#define FS_POLICY_FLAGS_PAD_MASK 0x03 20#define FSCRYPT_POLICY_FLAGS_PAD_MASK 0x03
21#define FS_POLICY_FLAG_DIRECT_KEY 0x04 /* use master key directly */ 21#define FSCRYPT_POLICY_FLAG_DIRECT_KEY 0x04 /* use master key directly */
22#define FS_POLICY_FLAGS_VALID 0x07 22#define FSCRYPT_POLICY_FLAGS_VALID 0x07
23 23
24/* Encryption algorithms */ 24/* Encryption algorithms */
25#define FS_ENCRYPTION_MODE_INVALID 0 25#define FSCRYPT_MODE_AES_256_XTS 1
26#define FS_ENCRYPTION_MODE_AES_256_XTS 1 26#define FSCRYPT_MODE_AES_256_CTS 4
27#define FS_ENCRYPTION_MODE_AES_256_GCM 2 27#define FSCRYPT_MODE_AES_128_CBC 5
28#define FS_ENCRYPTION_MODE_AES_256_CBC 3 28#define FSCRYPT_MODE_AES_128_CTS 6
29#define FS_ENCRYPTION_MODE_AES_256_CTS 4 29#define FSCRYPT_MODE_ADIANTUM 9
30#define FS_ENCRYPTION_MODE_AES_128_CBC 5
31#define FS_ENCRYPTION_MODE_AES_128_CTS 6
32#define FS_ENCRYPTION_MODE_SPECK128_256_XTS 7 /* Removed, do not use. */
33#define FS_ENCRYPTION_MODE_SPECK128_256_CTS 8 /* Removed, do not use. */
34#define FS_ENCRYPTION_MODE_ADIANTUM 9
35 30
36struct fscrypt_policy { 31struct fscrypt_policy {
37 __u8 version; 32 __u8 version;
38 __u8 contents_encryption_mode; 33 __u8 contents_encryption_mode;
39 __u8 filenames_encryption_mode; 34 __u8 filenames_encryption_mode;
40 __u8 flags; 35 __u8 flags;
41 __u8 master_key_descriptor[FS_KEY_DESCRIPTOR_SIZE]; 36 __u8 master_key_descriptor[FSCRYPT_KEY_DESCRIPTOR_SIZE];
42}; 37};
43 38
44#define FS_IOC_SET_ENCRYPTION_POLICY _IOR('f', 19, struct fscrypt_policy) 39#define FS_IOC_SET_ENCRYPTION_POLICY _IOR('f', 19, struct fscrypt_policy)
@@ -46,16 +41,40 @@ struct fscrypt_policy {
46#define FS_IOC_GET_ENCRYPTION_POLICY _IOW('f', 21, struct fscrypt_policy) 41#define FS_IOC_GET_ENCRYPTION_POLICY _IOW('f', 21, struct fscrypt_policy)
47 42
48/* Parameters for passing an encryption key into the kernel keyring */ 43/* Parameters for passing an encryption key into the kernel keyring */
49#define FS_KEY_DESC_PREFIX "fscrypt:" 44#define FSCRYPT_KEY_DESC_PREFIX "fscrypt:"
50#define FS_KEY_DESC_PREFIX_SIZE 8 45#define FSCRYPT_KEY_DESC_PREFIX_SIZE 8
51 46
52/* Structure that userspace passes to the kernel keyring */ 47/* Structure that userspace passes to the kernel keyring */
53#define FS_MAX_KEY_SIZE 64 48#define FSCRYPT_MAX_KEY_SIZE 64
54 49
55struct fscrypt_key { 50struct fscrypt_key {
56 __u32 mode; 51 __u32 mode;
57 __u8 raw[FS_MAX_KEY_SIZE]; 52 __u8 raw[FSCRYPT_MAX_KEY_SIZE];
58 __u32 size; 53 __u32 size;
59}; 54};
55/**********************************************************************/
56
57/* old names; don't add anything new here! */
58#define FS_KEY_DESCRIPTOR_SIZE FSCRYPT_KEY_DESCRIPTOR_SIZE
59#define FS_POLICY_FLAGS_PAD_4 FSCRYPT_POLICY_FLAGS_PAD_4
60#define FS_POLICY_FLAGS_PAD_8 FSCRYPT_POLICY_FLAGS_PAD_8
61#define FS_POLICY_FLAGS_PAD_16 FSCRYPT_POLICY_FLAGS_PAD_16
62#define FS_POLICY_FLAGS_PAD_32 FSCRYPT_POLICY_FLAGS_PAD_32
63#define FS_POLICY_FLAGS_PAD_MASK FSCRYPT_POLICY_FLAGS_PAD_MASK
64#define FS_POLICY_FLAG_DIRECT_KEY FSCRYPT_POLICY_FLAG_DIRECT_KEY
65#define FS_POLICY_FLAGS_VALID FSCRYPT_POLICY_FLAGS_VALID
66#define FS_ENCRYPTION_MODE_INVALID 0 /* never used */
67#define FS_ENCRYPTION_MODE_AES_256_XTS FSCRYPT_MODE_AES_256_XTS
68#define FS_ENCRYPTION_MODE_AES_256_GCM 2 /* never used */
69#define FS_ENCRYPTION_MODE_AES_256_CBC 3 /* never used */
70#define FS_ENCRYPTION_MODE_AES_256_CTS FSCRYPT_MODE_AES_256_CTS
71#define FS_ENCRYPTION_MODE_AES_128_CBC FSCRYPT_MODE_AES_128_CBC
72#define FS_ENCRYPTION_MODE_AES_128_CTS FSCRYPT_MODE_AES_128_CTS
73#define FS_ENCRYPTION_MODE_SPECK128_256_XTS 7 /* removed */
74#define FS_ENCRYPTION_MODE_SPECK128_256_CTS 8 /* removed */
75#define FS_ENCRYPTION_MODE_ADIANTUM FSCRYPT_MODE_ADIANTUM
76#define FS_KEY_DESC_PREFIX FSCRYPT_KEY_DESC_PREFIX
77#define FS_KEY_DESC_PREFIX_SIZE FSCRYPT_KEY_DESC_PREFIX_SIZE
78#define FS_MAX_KEY_SIZE FSCRYPT_MAX_KEY_SIZE
60 79
61#endif /* _UAPI_LINUX_FSCRYPT_H */ 80#endif /* _UAPI_LINUX_FSCRYPT_H */