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
10 10
11#include <linux/types.h>11#include <linux/types.h>
12 12
13#define FS_KEY_DESCRIPTOR_SIZE 813#define FSCRYPT_KEY_DESCRIPTOR_SIZE 8
14 14
15/* Encryption policy flags */15/* Encryption policy flags */
16#define FS_POLICY_FLAGS_PAD_4 0x0016#define FSCRYPT_POLICY_FLAGS_PAD_4 0x00
17#define FS_POLICY_FLAGS_PAD_8 0x0117#define FSCRYPT_POLICY_FLAGS_PAD_8 0x01
18#define FS_POLICY_FLAGS_PAD_16 0x0218#define FSCRYPT_POLICY_FLAGS_PAD_16 0x02
19#define FS_POLICY_FLAGS_PAD_32 0x0319#define FSCRYPT_POLICY_FLAGS_PAD_32 0x03
20#define FS_POLICY_FLAGS_PAD_MASK 0x0320#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 0x0722#define FSCRYPT_POLICY_FLAGS_VALID 0x07
23 23
24/* Encryption algorithms */24/* Encryption algorithms */
25#define FS_ENCRYPTION_MODE_INVALID 025#define FSCRYPT_MODE_AES_256_XTS 1
26#define FS_ENCRYPTION_MODE_AES_256_XTS 126#define FSCRYPT_MODE_AES_256_CTS 4
27#define FS_ENCRYPTION_MODE_AES_256_GCM 227#define FSCRYPT_MODE_AES_128_CBC 5
28#define FS_ENCRYPTION_MODE_AES_256_CBC 328#define FSCRYPT_MODE_AES_128_CTS 6
29#define FS_ENCRYPTION_MODE_AES_256_CTS 429#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 { · 1 unmodified line
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 845#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 6448#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 */