Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 The Android Open Source 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 | /* This structure starts 16,384 bytes before the end of a hardware |
| 18 | * partition that is encrypted. |
| 19 | * Immediately following this structure is the encrypted key. |
| 20 | * The keysize field tells how long the key is, in bytes. |
| 21 | * Then there is 32 bytes of padding, |
| 22 | * Finally there is the salt used with the user password. |
| 23 | * The salt is fixed at 16 bytes long. |
| 24 | * Obviously, the filesystem does not include the last 16 kbytes |
| 25 | * of the partition. |
| 26 | */ |
| 27 | |
a3955269 | 6ff55ce | 2013-01-08 16:14:56 +0000 | [diff] [blame] | 28 | #ifndef __CRYPTFS_H__ |
| 29 | #define __CRYPTFS_H__ |
| 30 | |
| 31 | #ifdef TW_INCLUDE_CRYPTO_SAMSUNG |
| 32 | #include "../libcrypt_samsung/include/libcrypt_samsung.h" |
| 33 | #endif |
| 34 | |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 35 | #define CRYPT_FOOTER_OFFSET 0x4000 |
| 36 | |
| 37 | #define MAX_CRYPTO_TYPE_NAME_LEN 64 |
| 38 | |
| 39 | #define SALT_LEN 16 |
| 40 | #define KEY_TO_SALT_PADDING 32 |
| 41 | |
| 42 | /* definitions of flags in the structure below */ |
| 43 | #define CRYPT_MNT_KEY_UNENCRYPTED 0x1 /* The key for the partition is not encrypted. */ |
| 44 | #define CRYPT_ENCRYPTION_IN_PROGRESS 0x2 /* Set when starting encryption, |
| 45 | * clear when done before rebooting */ |
| 46 | |
a3955269 | 6ff55ce | 2013-01-08 16:14:56 +0000 | [diff] [blame] | 47 | #ifdef TW_INCLUDE_CRYPTO_SAMSUNG |
| 48 | #define CRYPT_MNT_MAGIC_SAMSUNG 0xD0B5B1C5 |
| 49 | #endif |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 50 | #define CRYPT_MNT_MAGIC 0xD0B5B1C4 |
| 51 | |
| 52 | #define __le32 unsigned int |
| 53 | #define __le16 unsigned short int |
| 54 | |
a3955269 | 6ff55ce | 2013-01-08 16:14:56 +0000 | [diff] [blame] | 55 | #pragma pack(1) |
| 56 | |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 57 | struct crypt_mnt_ftr { |
| 58 | __le32 magic; /* See above */ |
| 59 | __le16 major_version; |
| 60 | __le16 minor_version; |
| 61 | __le32 ftr_size; /* in bytes, not including key following */ |
| 62 | __le32 flags; /* See above */ |
| 63 | __le32 keysize; /* in bytes */ |
| 64 | __le32 spare1; /* ignored */ |
| 65 | __le64 fs_size; /* Size of the encrypted fs, in 512 byte sectors */ |
| 66 | __le32 failed_decrypt_count; /* count of # of failed attempts to decrypt and |
| 67 | mount, set to 0 on successful mount */ |
a3955269 | 6ff55ce | 2013-01-08 16:14:56 +0000 | [diff] [blame] | 68 | char crypto_type_name[MAX_CRYPTO_TYPE_NAME_LEN]; /* The type of encryption |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 69 | needed to decrypt this |
| 70 | partition, null terminated */ |
| 71 | }; |
| 72 | |
a3955269 | 6ff55ce | 2013-01-08 16:14:56 +0000 | [diff] [blame] | 73 | #pragma pack() |
| 74 | |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 75 | |
| 76 | #ifdef __cplusplus |
| 77 | extern "C" { |
| 78 | #endif |
Ethan Yonker | 71413f4 | 2014-02-26 13:36:08 -0600 | [diff] [blame] | 79 | int cryptfs_check_footer(void); |
a3955269 | 6ff55ce | 2013-01-08 16:14:56 +0000 | [diff] [blame] | 80 | int cryptfs_check_passwd(const char *pw); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 81 | #ifdef __cplusplus |
| 82 | } |
| 83 | #endif |
| 84 | |
a3955269 | 6ff55ce | 2013-01-08 16:14:56 +0000 | [diff] [blame] | 85 | #endif // __CRYPTFS_H__ |
| 86 | |