1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * Copyright (c) 2019 Fuzhou Rockchip Electronics Co., Ltd
4 */
5
6 #ifndef WRITE_KEYBOX_H_
7 #define WRITE_KEYBOX_H_
8
9 #include <common.h>
10 #include <optee_include/tee_client_api.h>
11
12 #if defined CONFIG_ANDROID_WRITE_KEYBOX && defined CONFIG_ANDROID_KEYMASTER_CA
13 /*
14 * write_keybox_to_secure_storage
15 *
16 * @received_data: the data received from usb
17 * @len: size of received_data
18 *
19 * @return a negative number in case of error, or 0 on success.
20 */
21 uint32_t write_keybox_to_secure_storage(uint8_t *received_data, uint32_t len);
22
23 /*
24 * write_to_secure_storage
25 *
26 * @is_use_rpmb: 0, write data to security patition
27 * 1, write data to rpmb
28 * @filename: the file name of data written to secure storage
29 * @filename_size: size of filename
30 * @data: the data want to write to secure storage
31 * @data_size: size of data
32 *
33 * @return a nonzero number in case of error, or 0 on success.
34 */
35 TEEC_Result write_to_security_storage(uint8_t is_use_rpmb,
36 uint8_t *filename,
37 uint32_t filename_size,
38 uint8_t *data,
39 uint32_t data_size);
40 /*
41 * read_raw_data_from_secure_storege
42 *
43 * @raw_data: the data read from secure storage
44 * @data_size: size of raw data
45 *
46 * @return size of raw_data in case of success, or 0 on fail
47 */
48 uint32_t read_raw_data_from_secure_storage(uint8_t *received_data,
49 uint32_t len);
50 char *new_strstr(const char *s1, const char *s2, uint32_t l1);
51 #else
write_keybox_to_secure_storage(uint8_t * raw_data,uint32_t data_size)52 inline uint32_t write_keybox_to_secure_storage(uint8_t *raw_data,
53 uint32_t data_size)
54 {
55 return -EPERM;
56 }
57
read_raw_data_from_secure_storage(uint8_t * received_data,uint32_t len)58 inline uint32_t read_raw_data_from_secure_storage(uint8_t *received_data,
59 uint32_t len)
60 {
61 return -EPERM;
62 }
63 #endif
64 #endif
65