1 /* 2 * This file is auto-generated. Modifications will be lost. 3 * 4 * See https://android.googlesource.com/platform/bionic/+/master/libc/kernel/ 5 * for more information. 6 */ 7 #ifndef _UAPI_LINUX_FSCRYPT_H 8 #define _UAPI_LINUX_FSCRYPT_H 9 #include <linux/ioctl.h> 10 #include <linux/types.h> 11 #define FSCRYPT_POLICY_FLAGS_PAD_4 0x00 12 #define FSCRYPT_POLICY_FLAGS_PAD_8 0x01 13 #define FSCRYPT_POLICY_FLAGS_PAD_16 0x02 14 #define FSCRYPT_POLICY_FLAGS_PAD_32 0x03 15 #define FSCRYPT_POLICY_FLAGS_PAD_MASK 0x03 16 #define FSCRYPT_POLICY_FLAG_DIRECT_KEY 0x04 17 #define FSCRYPT_POLICY_FLAG_IV_INO_LBLK_64 0x08 18 #define FSCRYPT_POLICY_FLAG_IV_INO_LBLK_32 0x10 19 #define FSCRYPT_MODE_AES_256_XTS 1 20 #define FSCRYPT_MODE_AES_256_CTS 4 21 #define FSCRYPT_MODE_AES_128_CBC 5 22 #define FSCRYPT_MODE_AES_128_CTS 6 23 #define FSCRYPT_MODE_SM4_XTS 7 24 #define FSCRYPT_MODE_SM4_CTS 8 25 #define FSCRYPT_MODE_ADIANTUM 9 26 #define FSCRYPT_MODE_AES_256_HCTR2 10 27 #define FSCRYPT_POLICY_V1 0 28 #define FSCRYPT_KEY_DESCRIPTOR_SIZE 8 29 struct fscrypt_policy_v1 { 30 __u8 version; 31 __u8 contents_encryption_mode; 32 __u8 filenames_encryption_mode; 33 __u8 flags; 34 __u8 master_key_descriptor[FSCRYPT_KEY_DESCRIPTOR_SIZE]; 35 }; 36 #define FSCRYPT_KEY_DESC_PREFIX "fscrypt:" 37 #define FSCRYPT_KEY_DESC_PREFIX_SIZE 8 38 #define FSCRYPT_MAX_KEY_SIZE 64 39 struct fscrypt_key { 40 __u32 mode; 41 __u8 raw[FSCRYPT_MAX_KEY_SIZE]; 42 __u32 size; 43 }; 44 #define FSCRYPT_POLICY_V2 2 45 #define FSCRYPT_KEY_IDENTIFIER_SIZE 16 46 struct fscrypt_policy_v2 { 47 __u8 version; 48 __u8 contents_encryption_mode; 49 __u8 filenames_encryption_mode; 50 __u8 flags; 51 __u8 log2_data_unit_size; 52 __u8 __reserved[3]; 53 __u8 master_key_identifier[FSCRYPT_KEY_IDENTIFIER_SIZE]; 54 }; 55 struct fscrypt_get_policy_ex_arg { 56 __u64 policy_size; 57 union { 58 __u8 version; 59 struct fscrypt_policy_v1 v1; 60 struct fscrypt_policy_v2 v2; 61 } policy; 62 }; 63 #define FSCRYPT_KEY_SPEC_TYPE_DESCRIPTOR 1 64 #define FSCRYPT_KEY_SPEC_TYPE_IDENTIFIER 2 65 struct fscrypt_key_specifier { 66 __u32 type; 67 __u32 __reserved; 68 union { 69 __u8 __reserved[32]; 70 __u8 descriptor[FSCRYPT_KEY_DESCRIPTOR_SIZE]; 71 __u8 identifier[FSCRYPT_KEY_IDENTIFIER_SIZE]; 72 } u; 73 }; 74 struct fscrypt_provisioning_key_payload { 75 __u32 type; 76 __u32 __reserved; 77 __u8 raw[]; 78 }; 79 struct fscrypt_add_key_arg { 80 struct fscrypt_key_specifier key_spec; 81 __u32 raw_size; 82 __u32 key_id; 83 __u32 __reserved[7]; 84 #define __FSCRYPT_ADD_KEY_FLAG_HW_WRAPPED 0x00000001 85 __u32 __flags; 86 __u8 raw[]; 87 }; 88 struct fscrypt_remove_key_arg { 89 struct fscrypt_key_specifier key_spec; 90 #define FSCRYPT_KEY_REMOVAL_STATUS_FLAG_FILES_BUSY 0x00000001 91 #define FSCRYPT_KEY_REMOVAL_STATUS_FLAG_OTHER_USERS 0x00000002 92 __u32 removal_status_flags; 93 __u32 __reserved[5]; 94 }; 95 struct fscrypt_get_key_status_arg { 96 struct fscrypt_key_specifier key_spec; 97 __u32 __reserved[6]; 98 #define FSCRYPT_KEY_STATUS_ABSENT 1 99 #define FSCRYPT_KEY_STATUS_PRESENT 2 100 #define FSCRYPT_KEY_STATUS_INCOMPLETELY_REMOVED 3 101 __u32 status; 102 #define FSCRYPT_KEY_STATUS_FLAG_ADDED_BY_SELF 0x00000001 103 __u32 status_flags; 104 __u32 user_count; 105 __u32 __out_reserved[13]; 106 }; 107 #define FS_IOC_SET_ENCRYPTION_POLICY _IOR('f', 19, struct fscrypt_policy_v1) 108 #define FS_IOC_GET_ENCRYPTION_PWSALT _IOW('f', 20, __u8[16]) 109 #define FS_IOC_GET_ENCRYPTION_POLICY _IOW('f', 21, struct fscrypt_policy_v1) 110 #define FS_IOC_GET_ENCRYPTION_POLICY_EX _IOWR('f', 22, __u8[9]) 111 #define FS_IOC_ADD_ENCRYPTION_KEY _IOWR('f', 23, struct fscrypt_add_key_arg) 112 #define FS_IOC_REMOVE_ENCRYPTION_KEY _IOWR('f', 24, struct fscrypt_remove_key_arg) 113 #define FS_IOC_REMOVE_ENCRYPTION_KEY_ALL_USERS _IOWR('f', 25, struct fscrypt_remove_key_arg) 114 #define FS_IOC_GET_ENCRYPTION_KEY_STATUS _IOWR('f', 26, struct fscrypt_get_key_status_arg) 115 #define FS_IOC_GET_ENCRYPTION_NONCE _IOR('f', 27, __u8[16]) 116 #define fscrypt_policy fscrypt_policy_v1 117 #define FS_KEY_DESCRIPTOR_SIZE FSCRYPT_KEY_DESCRIPTOR_SIZE 118 #define FS_POLICY_FLAGS_PAD_4 FSCRYPT_POLICY_FLAGS_PAD_4 119 #define FS_POLICY_FLAGS_PAD_8 FSCRYPT_POLICY_FLAGS_PAD_8 120 #define FS_POLICY_FLAGS_PAD_16 FSCRYPT_POLICY_FLAGS_PAD_16 121 #define FS_POLICY_FLAGS_PAD_32 FSCRYPT_POLICY_FLAGS_PAD_32 122 #define FS_POLICY_FLAGS_PAD_MASK FSCRYPT_POLICY_FLAGS_PAD_MASK 123 #define FS_POLICY_FLAG_DIRECT_KEY FSCRYPT_POLICY_FLAG_DIRECT_KEY 124 #define FS_POLICY_FLAGS_VALID 0x07 125 #define FS_ENCRYPTION_MODE_INVALID 0 126 #define FS_ENCRYPTION_MODE_AES_256_XTS FSCRYPT_MODE_AES_256_XTS 127 #define FS_ENCRYPTION_MODE_AES_256_GCM 2 128 #define FS_ENCRYPTION_MODE_AES_256_CBC 3 129 #define FS_ENCRYPTION_MODE_AES_256_CTS FSCRYPT_MODE_AES_256_CTS 130 #define FS_ENCRYPTION_MODE_AES_128_CBC FSCRYPT_MODE_AES_128_CBC 131 #define FS_ENCRYPTION_MODE_AES_128_CTS FSCRYPT_MODE_AES_128_CTS 132 #define FS_ENCRYPTION_MODE_ADIANTUM FSCRYPT_MODE_ADIANTUM 133 #define FS_KEY_DESC_PREFIX FSCRYPT_KEY_DESC_PREFIX 134 #define FS_KEY_DESC_PREFIX_SIZE FSCRYPT_KEY_DESC_PREFIX_SIZE 135 #define FS_MAX_KEY_SIZE FSCRYPT_MAX_KEY_SIZE 136 #endif 137