History

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).

Eric Biggers committed 7 years ago

Commit 2336d0d1 parent 7af0ab02 files · +62 −43Browse files

Showing the changes to include/uapi/linux (1 of 2 files). Show all

Unified · Split

include/uapi/linux/fscrypt.h+42−23
@@ -10,35 +10,30 @@ · 9 unmodified lines
1010
1111 #include <linux/types.h>
1212
13−#define FS_KEY_DESCRIPTOR_SIZE 8
13+#define FSCRYPT_KEY_DESCRIPTOR_SIZE 8
1414
1515 /* Encryption policy flags */
16−#define FS_POLICY_FLAGS_PAD_4 0x00
17−#define FS_POLICY_FLAGS_PAD_8 0x01
18−#define FS_POLICY_FLAGS_PAD_16 0x02
19−#define FS_POLICY_FLAGS_PAD_32 0x03
20−#define FS_POLICY_FLAGS_PAD_MASK 0x03
21−#define FS_POLICY_FLAG_DIRECT_KEY 0x04 /* use master key directly */
22−#define FS_POLICY_FLAGS_VALID 0x07
16+#define FSCRYPT_POLICY_FLAGS_PAD_4 0x00
17+#define FSCRYPT_POLICY_FLAGS_PAD_8 0x01
18+#define FSCRYPT_POLICY_FLAGS_PAD_16 0x02
19+#define FSCRYPT_POLICY_FLAGS_PAD_32 0x03
20+#define FSCRYPT_POLICY_FLAGS_PAD_MASK 0x03
21+#define FSCRYPT_POLICY_FLAG_DIRECT_KEY 0x04 /* use master key directly */
22+#define FSCRYPT_POLICY_FLAGS_VALID 0x07
2323
2424 /* Encryption algorithms */
25−#define FS_ENCRYPTION_MODE_INVALID 0
26−#define FS_ENCRYPTION_MODE_AES_256_XTS 1
27−#define FS_ENCRYPTION_MODE_AES_256_GCM 2
28−#define FS_ENCRYPTION_MODE_AES_256_CBC 3
29−#define FS_ENCRYPTION_MODE_AES_256_CTS 4
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
25+#define FSCRYPT_MODE_AES_256_XTS 1
26+#define FSCRYPT_MODE_AES_256_CTS 4
27+#define FSCRYPT_MODE_AES_128_CBC 5
28+#define FSCRYPT_MODE_AES_128_CTS 6
29+#define FSCRYPT_MODE_ADIANTUM 9
3530
3631 struct fscrypt_policy {
3732 __u8 version;
3833 __u8 contents_encryption_mode;
3934 __u8 filenames_encryption_mode;
4035 __u8 flags;
41− __u8 master_key_descriptor[FS_KEY_DESCRIPTOR_SIZE];
36+ __u8 master_key_descriptor[FSCRYPT_KEY_DESCRIPTOR_SIZE];
4237 };
4338
4439 #define FS_IOC_SET_ENCRYPTION_POLICY _IOR('f', 19, struct fscrypt_policy)
@@ -46,16 +41,40 @@ struct fscrypt_policy { · 1 unmodified line
4641 #define FS_IOC_GET_ENCRYPTION_POLICY _IOW('f', 21, struct fscrypt_policy)
4742
4843 /* Parameters for passing an encryption key into the kernel keyring */
49−#define FS_KEY_DESC_PREFIX "fscrypt:"
50−#define FS_KEY_DESC_PREFIX_SIZE 8
44+#define FSCRYPT_KEY_DESC_PREFIX "fscrypt:"
45+#define FSCRYPT_KEY_DESC_PREFIX_SIZE 8
5146
5247 /* Structure that userspace passes to the kernel keyring */
53−#define FS_MAX_KEY_SIZE 64
48+#define FSCRYPT_MAX_KEY_SIZE 64
5449
5550 struct fscrypt_key {
5651 __u32 mode;
57− __u8 raw[FS_MAX_KEY_SIZE];
52+ __u8 raw[FSCRYPT_MAX_KEY_SIZE];
5853 __u32 size;
5954 };
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
6079
6180 #endif /* _UAPI_LINUX_FSCRYPT_H */