Ethan Yonker | 79f88bd | 2016-12-09 14:52:12 -0600 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 Team Win Recovery Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef __EXT4CRYPT_TAR_H |
| 18 | #define __EXT4CRYPT_TAR_H |
| 19 | |
| 20 | #include <sys/cdefs.h> |
| 21 | #include <stdbool.h> |
| 22 | #include <cutils/multiuser.h> |
| 23 | |
Ethan Yonker | fefe591 | 2017-09-30 22:22:13 -0500 | [diff] [blame] | 24 | // ext4enc:TODO Include structure from somewhere sensible |
| 25 | // MUST be in sync with ext4_crypto.c in kernel |
| 26 | #define EXT4_KEY_DESCRIPTOR_SIZE 8 |
| 27 | #define EXT4_KEY_DESCRIPTOR_SIZE_HEX 17 |
| 28 | |
| 29 | // ext4enc:TODO Get value from somewhere sensible |
| 30 | #define EXT4_IOC_SET_ENCRYPTION_POLICY _IOR('f', 19, struct ext4_encryption_policy) |
| 31 | #define EXT4_IOC_GET_ENCRYPTION_POLICY _IOW('f', 21, struct ext4_encryption_policy) |
| 32 | |
Ethan Yonker | 79f88bd | 2016-12-09 14:52:12 -0600 | [diff] [blame] | 33 | __BEGIN_DECLS |
| 34 | |
Ethan Yonker | fefe591 | 2017-09-30 22:22:13 -0500 | [diff] [blame] | 35 | struct ext4_encryption_policy { |
| 36 | char version; |
| 37 | char contents_encryption_mode; |
| 38 | char filenames_encryption_mode; |
| 39 | char flags; |
| 40 | char master_key_descriptor[EXT4_KEY_DESCRIPTOR_SIZE]; |
| 41 | } __attribute__((__packed__)); |
| 42 | |
Ethan Yonker | 79f88bd | 2016-12-09 14:52:12 -0600 | [diff] [blame] | 43 | bool lookup_ref_key(const char* policy, char* policy_type); |
| 44 | bool lookup_ref_tar(const char* policy_type, char* policy); |
| 45 | |
| 46 | void policy_to_hex(const char* policy, char* hex); |
| 47 | bool e4crypt_policy_set(const char *directory, const char *policy, |
| 48 | size_t policy_length, int contents_encryption_mode); |
| 49 | bool e4crypt_policy_get(const char *directory, char *policy, |
| 50 | size_t policy_length, int contents_encryption_mode); |
Ethan Yonker | fefe591 | 2017-09-30 22:22:13 -0500 | [diff] [blame] | 51 | void e4crypt_policy_fill_default_struct(struct ext4_encryption_policy *eep); |
| 52 | bool e4crypt_policy_set_struct(const char *directory, const struct ext4_encryption_policy *eep); |
| 53 | bool e4crypt_policy_get_struct(const char *directory, struct ext4_encryption_policy *eep); |
Ethan Yonker | 79f88bd | 2016-12-09 14:52:12 -0600 | [diff] [blame] | 54 | |
| 55 | bool e4crypt_set_mode(); |
| 56 | __END_DECLS |
| 57 | |
| 58 | #endif |