blob: 28d1887cc41c94a308870c17c81298b8f11bf275 [file] [log] [blame]
Ken Sumrall8f869aa2010-12-03 03:47:09 -08001/*
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
Paul Crowleyb64933a2017-10-31 08:25:55 -070017#ifndef ANDROID_VOLD_CRYPTFS_H
18#define ANDROID_VOLD_CRYPTFS_H
19
Logan Chien0267ccf2018-05-02 10:57:56 +080020#include <linux/types.h>
Paul Lawrence2f32cda2015-05-05 14:28:25 -070021#include <stdbool.h>
Greg Kaiser57f9af62018-02-16 13:13:58 -080022#include <stdint.h>
Logan Chien0267ccf2018-05-02 10:57:56 +080023
Ken Sumrall160b4d62013-04-22 12:15:39 -070024#include <cutils/properties.h>
25
Ken Sumrall8f869aa2010-12-03 03:47:09 -080026#define CRYPT_FOOTER_OFFSET 0x4000
JP Abgrall502dc742013-11-01 13:06:20 -070027
Paul Lawrence74f29f12014-08-28 15:54:10 -070028/* Return values for cryptfs_crypto_complete */
Paul Crowley14c8c072018-09-18 13:30:21 -070029#define CRYPTO_COMPLETE_NOT_ENCRYPTED 1
30#define CRYPTO_COMPLETE_ENCRYPTED 0
31#define CRYPTO_COMPLETE_BAD_METADATA (-1)
32#define CRYPTO_COMPLETE_PARTIAL (-2)
33#define CRYPTO_COMPLETE_INCONSISTENT (-3)
34#define CRYPTO_COMPLETE_CORRUPT (-4)
Paul Lawrence74f29f12014-08-28 15:54:10 -070035
Rubin Xu85c01f92014-10-13 12:49:54 +010036/* Return values for cryptfs_getfield */
Paul Crowley14c8c072018-09-18 13:30:21 -070037#define CRYPTO_GETFIELD_OK 0
38#define CRYPTO_GETFIELD_ERROR_NO_FIELD (-1)
39#define CRYPTO_GETFIELD_ERROR_OTHER (-2)
Chih-Hung Hsiehaae79382016-06-10 14:13:59 -070040#define CRYPTO_GETFIELD_ERROR_BUF_TOO_SMALL (-3)
Rubin Xu85c01f92014-10-13 12:49:54 +010041
42/* Return values for cryptfs_setfield */
Paul Crowley14c8c072018-09-18 13:30:21 -070043#define CRYPTO_SETFIELD_OK 0
44#define CRYPTO_SETFIELD_ERROR_OTHER (-1)
Chih-Hung Hsiehaae79382016-06-10 14:13:59 -070045#define CRYPTO_SETFIELD_ERROR_FIELD_TOO_LONG (-2)
46#define CRYPTO_SETFIELD_ERROR_VALUE_TOO_LONG (-3)
Rubin Xu85c01f92014-10-13 12:49:54 +010047
48/* Return values for persist_del_key */
Paul Crowley14c8c072018-09-18 13:30:21 -070049#define PERSIST_DEL_KEY_OK 0
50#define PERSIST_DEL_KEY_ERROR_OTHER (-1)
51#define PERSIST_DEL_KEY_ERROR_NO_FIELD (-2)
Rubin Xu85c01f92014-10-13 12:49:54 +010052
Paul Crowley73be12d2020-02-03 12:22:03 -080053// Exposed for testing only
Paul Crowleyb64933a2017-10-31 08:25:55 -070054int match_multi_entry(const char* key, const char* field, unsigned index);
Paul Lawrence2f32cda2015-05-05 14:28:25 -070055
Paul Crowleyb64933a2017-10-31 08:25:55 -070056int cryptfs_crypto_complete(void);
57int cryptfs_check_passwd(const char* pw);
58int cryptfs_verify_passwd(const char* pw);
59int cryptfs_restart(void);
Paul Lawrence7ee87cf2017-12-22 10:12:06 -080060int cryptfs_enable(int type, const char* passwd, int no_ui);
Paul Crowleyb64933a2017-10-31 08:25:55 -070061int cryptfs_changepw(int type, const char* newpw);
Paul Lawrence7ee87cf2017-12-22 10:12:06 -080062int cryptfs_enable_default(int no_ui);
Paul Crowleyb64933a2017-10-31 08:25:55 -070063int cryptfs_setup_ext_volume(const char* label, const char* real_blkdev, const unsigned char* key,
Greg Kaiser57f9af62018-02-16 13:13:58 -080064 char* out_crypto_blkdev);
Paul Crowleyb64933a2017-10-31 08:25:55 -070065int cryptfs_revert_ext_volume(const char* label);
66int cryptfs_getfield(const char* fieldname, char* value, int len);
67int cryptfs_setfield(const char* fieldname, const char* value);
68int cryptfs_mount_default_encrypted(void);
69int cryptfs_get_password_type(void);
70const char* cryptfs_get_password(void);
71void cryptfs_clear_password(void);
72int cryptfs_isConvertibleToFBE(void);
Kenny Rootc4c70f12013-06-14 12:11:38 -070073
Greg Kaiser57f9af62018-02-16 13:13:58 -080074uint32_t cryptfs_get_keysize();
75const char* cryptfs_get_crypto_name();
76
Paul Crowleyb64933a2017-10-31 08:25:55 -070077#endif /* ANDROID_VOLD_CRYPTFS_H */