summaryrefslogtreecommitdiff
path: root/libfscrypt
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2018-10-23 13:39:07 -0700
committerEric Biggers <ebiggers@google.com>2018-10-25 17:10:15 -0700
commitb0ff883fb6f32b3dee1eddb5ee64fa739b19e974 (patch)
tree2c0adbb1f50eb882ee4d5cf2af9ebdd7ab1afbc0 /libfscrypt
parentb46c3591e1e2b091d0fb727715a8d617dfc80aa6 (diff)
downloadextras-b0ff883fb6f32b3dee1eddb5ee64fa739b19e974.tar.gz
libfscrypt: get the fscrypt kernel API declarations from linux/fs.h
bionic now has linux/fs.h from the 4.14 kernel, which has the fscrypt kernel API declarations. Replace the manual declarations in libfscrypt, except for the mode numbers which are not supported by the upstream kernel. Test: built, booted device with f2fs encryption Change-Id: I6c663813828e3e0639d9be4298bff2bd4ec36c66
Diffstat (limited to 'libfscrypt')
-rw-r--r--libfscrypt/fscrypt.cpp29
1 files changed, 4 insertions, 25 deletions
diff --git a/libfscrypt/fscrypt.cpp b/libfscrypt/fscrypt.cpp
index 59297318..bf611887 100644
--- a/libfscrypt/fscrypt.cpp
+++ b/libfscrypt/fscrypt.cpp
@@ -22,9 +22,10 @@
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
+#include <linux/fs.h>
#include <string.h>
-#include <sys/syscall.h>
#include <sys/stat.h>
+#include <sys/syscall.h>
#include <sys/types.h>
#include <unistd.h>
@@ -34,34 +35,12 @@
#include <logwrap/logwrap.h>
#include <utils/misc.h>
-// TODO Include these definitions from <linux/fs.h>
-
-#define FS_KEY_DESCRIPTOR_SIZE 8
-#define FS_KEY_DESCRIPTOR_SIZE_HEX 17
+#define FS_KEY_DESCRIPTOR_SIZE_HEX (2 * FS_KEY_DESCRIPTOR_SIZE + 1)
-struct fscrypt_policy {
- uint8_t version;
- uint8_t contents_encryption_mode;
- uint8_t filenames_encryption_mode;
- uint8_t flags;
- uint8_t master_key_descriptor[FS_KEY_DESCRIPTOR_SIZE];
-} __attribute__((__packed__));
-
-#define FS_ENCRYPTION_MODE_AES_256_XTS 1
-#define FS_ENCRYPTION_MODE_AES_256_CTS 4
+/* modes not supported by upstream kernel, so not in <linux/fs.h> */
#define FS_ENCRYPTION_MODE_AES_256_HEH 126
#define FS_ENCRYPTION_MODE_PRIVATE 127
-#define FS_POLICY_FLAGS_PAD_4 0x00
-#define FS_POLICY_FLAGS_PAD_8 0x01
-#define FS_POLICY_FLAGS_PAD_16 0x02
-#define FS_POLICY_FLAGS_PAD_32 0x03
-#define FS_POLICY_FLAGS_PAD_MASK 0x03
-#define FS_POLICY_FLAGS_VALID 0x03
-
-#define FS_IOC_SET_ENCRYPTION_POLICY _IOR('f', 19, struct fscrypt_policy)
-#define FS_IOC_GET_ENCRYPTION_POLICY _IOW('f', 21, struct fscrypt_policy)
-
#define HEX_LOOKUP "0123456789abcdef"
bool fscrypt_is_native() {