blob: 98ba7d6e4d1f0cf919952787ddd3703a6d6bc141 [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
Paul Crowley81796e92020-02-07 11:27:49 -080020#include <string>
21
Logan Chien0267ccf2018-05-02 10:57:56 +080022#include <linux/types.h>
Paul Lawrence2f32cda2015-05-05 14:28:25 -070023#include <stdbool.h>
Greg Kaiser57f9af62018-02-16 13:13:58 -080024#include <stdint.h>
Logan Chien0267ccf2018-05-02 10:57:56 +080025
Ken Sumrall160b4d62013-04-22 12:15:39 -070026#include <cutils/properties.h>
27
Ken Sumrall8f869aa2010-12-03 03:47:09 -080028#define CRYPT_FOOTER_OFFSET 0x4000
JP Abgrall502dc742013-11-01 13:06:20 -070029
Paul Lawrence74f29f12014-08-28 15:54:10 -070030/* Return values for cryptfs_crypto_complete */
Paul Crowley14c8c072018-09-18 13:30:21 -070031#define CRYPTO_COMPLETE_NOT_ENCRYPTED 1
32#define CRYPTO_COMPLETE_ENCRYPTED 0
33#define CRYPTO_COMPLETE_BAD_METADATA (-1)
34#define CRYPTO_COMPLETE_PARTIAL (-2)
35#define CRYPTO_COMPLETE_INCONSISTENT (-3)
36#define CRYPTO_COMPLETE_CORRUPT (-4)
Paul Lawrence74f29f12014-08-28 15:54:10 -070037
Rubin Xu85c01f92014-10-13 12:49:54 +010038/* Return values for cryptfs_getfield */
Paul Crowley14c8c072018-09-18 13:30:21 -070039#define CRYPTO_GETFIELD_OK 0
40#define CRYPTO_GETFIELD_ERROR_NO_FIELD (-1)
41#define CRYPTO_GETFIELD_ERROR_OTHER (-2)
Chih-Hung Hsiehaae79382016-06-10 14:13:59 -070042#define CRYPTO_GETFIELD_ERROR_BUF_TOO_SMALL (-3)
Rubin Xu85c01f92014-10-13 12:49:54 +010043
44/* Return values for cryptfs_setfield */
Paul Crowley14c8c072018-09-18 13:30:21 -070045#define CRYPTO_SETFIELD_OK 0
46#define CRYPTO_SETFIELD_ERROR_OTHER (-1)
Chih-Hung Hsiehaae79382016-06-10 14:13:59 -070047#define CRYPTO_SETFIELD_ERROR_FIELD_TOO_LONG (-2)
48#define CRYPTO_SETFIELD_ERROR_VALUE_TOO_LONG (-3)
Rubin Xu85c01f92014-10-13 12:49:54 +010049
50/* Return values for persist_del_key */
Paul Crowley14c8c072018-09-18 13:30:21 -070051#define PERSIST_DEL_KEY_OK 0
52#define PERSIST_DEL_KEY_ERROR_OTHER (-1)
53#define PERSIST_DEL_KEY_ERROR_NO_FIELD (-2)
Rubin Xu85c01f92014-10-13 12:49:54 +010054
Paul Crowley73be12d2020-02-03 12:22:03 -080055// Exposed for testing only
Paul Crowleyb64933a2017-10-31 08:25:55 -070056int match_multi_entry(const char* key, const char* field, unsigned index);
Paul Lawrence2f32cda2015-05-05 14:28:25 -070057
Paul Crowleyb64933a2017-10-31 08:25:55 -070058int cryptfs_crypto_complete(void);
59int cryptfs_check_passwd(const char* pw);
60int cryptfs_verify_passwd(const char* pw);
61int cryptfs_restart(void);
Paul Lawrence7ee87cf2017-12-22 10:12:06 -080062int cryptfs_enable(int type, const char* passwd, int no_ui);
Paul Crowleyb64933a2017-10-31 08:25:55 -070063int cryptfs_changepw(int type, const char* newpw);
Paul Lawrence7ee87cf2017-12-22 10:12:06 -080064int cryptfs_enable_default(int no_ui);
Paul Crowleyb64933a2017-10-31 08:25:55 -070065int cryptfs_setup_ext_volume(const char* label, const char* real_blkdev, const unsigned char* key,
Paul Crowley81796e92020-02-07 11:27:49 -080066 std::string* out_crypto_blkdev);
Paul Crowleyb64933a2017-10-31 08:25:55 -070067int cryptfs_revert_ext_volume(const char* label);
68int cryptfs_getfield(const char* fieldname, char* value, int len);
69int cryptfs_setfield(const char* fieldname, const char* value);
70int cryptfs_mount_default_encrypted(void);
71int cryptfs_get_password_type(void);
72const char* cryptfs_get_password(void);
73void cryptfs_clear_password(void);
74int cryptfs_isConvertibleToFBE(void);
Kenny Rootc4c70f12013-06-14 12:11:38 -070075
Greg Kaiser57f9af62018-02-16 13:13:58 -080076uint32_t cryptfs_get_keysize();
77const char* cryptfs_get_crypto_name();
78
Paul Crowleyb64933a2017-10-31 08:25:55 -070079#endif /* ANDROID_VOLD_CRYPTFS_H */