blob: 728b775b51de6f84ad59de2b285b280c7c1fd77c [file] [log] [blame]
bigbiff7ba75002020-04-11 20:47:09 -04001/*
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#ifndef ANDROID_VOLD_CRYPTFS_H
18#define ANDROID_VOLD_CRYPTFS_H
19
bigbiffa957f072021-03-07 18:20:29 -050020#include <string>
bigbiff7ba75002020-04-11 20:47:09 -040021
22#include <linux/types.h>
23#include <stdbool.h>
24#include <stdint.h>
25
26#include <cutils/properties.h>
27
bigbiffa957f072021-03-07 18:20:29 -050028#include "KeyBuffer.h"
29#include "KeyUtil.h"
bigbiff7ba75002020-04-11 20:47:09 -040030
31#define CRYPT_FOOTER_OFFSET 0x4000
bigbiff7ba75002020-04-11 20:47:09 -040032
33/* Return values for cryptfs_crypto_complete */
34#define CRYPTO_COMPLETE_NOT_ENCRYPTED 1
35#define CRYPTO_COMPLETE_ENCRYPTED 0
36#define CRYPTO_COMPLETE_BAD_METADATA (-1)
37#define CRYPTO_COMPLETE_PARTIAL (-2)
38#define CRYPTO_COMPLETE_INCONSISTENT (-3)
39#define CRYPTO_COMPLETE_CORRUPT (-4)
40
bigbiff7ba75002020-04-11 20:47:09 -040041/* Return values for cryptfs_getfield */
42#define CRYPTO_GETFIELD_OK 0
43#define CRYPTO_GETFIELD_ERROR_NO_FIELD (-1)
44#define CRYPTO_GETFIELD_ERROR_OTHER (-2)
45#define CRYPTO_GETFIELD_ERROR_BUF_TOO_SMALL (-3)
46
47/* Return values for cryptfs_setfield */
48#define CRYPTO_SETFIELD_OK 0
49#define CRYPTO_SETFIELD_ERROR_OTHER (-1)
50#define CRYPTO_SETFIELD_ERROR_FIELD_TOO_LONG (-2)
51#define CRYPTO_SETFIELD_ERROR_VALUE_TOO_LONG (-3)
52
53/* Return values for persist_del_key */
54#define PERSIST_DEL_KEY_OK 0
55#define PERSIST_DEL_KEY_ERROR_OTHER (-1)
56#define PERSIST_DEL_KEY_ERROR_NO_FIELD (-2)
57
bigbiffa957f072021-03-07 18:20:29 -050058// Exposed for testing only
bigbiff7ba75002020-04-11 20:47:09 -040059int match_multi_entry(const char* key, const char* field, unsigned index);
bigbiff7ba75002020-04-11 20:47:09 -040060
61int cryptfs_crypto_complete(void);
62int cryptfs_check_passwd(const char* pw);
63int cryptfs_verify_passwd(const char* pw);
64int cryptfs_restart(void);
65int cryptfs_enable(int type, const char* passwd, int no_ui);
66int cryptfs_changepw(int type, const char* newpw);
67int cryptfs_enable_default(int no_ui);
bigbiffa957f072021-03-07 18:20:29 -050068int cryptfs_setup_ext_volume(const char* label, const char* real_blkdev,
69 const ::KeyBuffer& key, std::string* out_crypto_blkdev);
bigbiff7ba75002020-04-11 20:47:09 -040070int cryptfs_getfield(const char* fieldname, char* value, int len);
71int cryptfs_setfield(const char* fieldname, const char* value);
72int cryptfs_mount_default_encrypted(void);
73int cryptfs_get_password_type(void);
74const char* cryptfs_get_password(void);
75void cryptfs_clear_password(void);
76int cryptfs_isConvertibleToFBE(void);
bigbiffa957f072021-03-07 18:20:29 -050077const KeyGeneration cryptfs_get_keygen();
bigbiff7ba75002020-04-11 20:47:09 -040078
79#endif /* ANDROID_VOLD_CRYPTFS_H */