• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef DEVICE_ATTEST_OEM_ADAPTER_H
17 #define DEVICE_ATTEST_OEM_ADAPTER_H
18 
19 #include <stdint.h>
20 
21 #ifdef __cplusplus
22 #if __cplusplus
23 extern "C" {
24 #endif
25 #endif /* __cplusplus */
26 
27 #define TOKEN_SIZE 151
28 #define TOKEN_FLAG_SIZE 4
29 #define TOKEN_WITH_FLAG_SIZE (TOKEN_SIZE + TOKEN_FLAG_SIZE)
30 #define TOKEN_ADDR "/data/service/el1/public/device_attest"
31 #define TOKEN_A_ADDR "tokenA"
32 #define TOKEN_B_ADDR "tokenB"
33 #define BITS_PER_BYTE 8
34 
35 /**
36  * @brief Get Manufacturekey value from device.
37  *
38  * @param manufacturekey : the result Manufacturekey, if get successfully.
39  * @param len : length of the acKey.
40  * @returns 0 if success, otherwise -1.
41  */
42 int32_t OEMGetManufacturekey(char* manufacturekey, uint32_t len);
43 
44 /**
45  * @brief Get ProdId value from device.
46  *
47  * @param productId : product IDs to be populated with.
48  * @param len : length of the productId.
49  * @returns 0 if success, otherwise -1.
50  */
51 int32_t OEMGetProductId(char* productId, uint32_t len);
52 
53 /**
54  * @brief Read token value from device.
55  *
56  * @param token : the result token value, if read successfully.
57  * @param len : length of the token.
58  * @returns 0 if success and get the update area token,
59  *         -1 if failed,
60  *         -2 if no pre-made token.
61  */
62 int32_t OEMReadToken(char *token, uint32_t len);
63 
64 /**
65  * @brief Write token value to device.
66  *
67  * @param token : the token to write.
68  * @param len : length of the token.
69  * @returns 0 if success, otherwise -1.
70  */
71 int32_t OEMWriteToken(const char *token, uint32_t len);
72 
73 /**
74  * @brief Get ProdKey value from device.
75  *
76  * @param productKey : The productKey value
77  * @param len : The productKey len.
78  * @returns 0 if success, otherwise -1.
79  */
80 int32_t OEMGetProductKey(char* productKey, uint32_t len);
81 
82 #ifdef __cplusplus
83 #if __cplusplus
84 }
85 #endif
86 #endif /* __cplusplus */
87 
88 #endif
89