API参考
载入中...
搜索中...
未找到
app_sm.h
1/*
2 * This file is part of the openHiTLS project.
3 *
4 * openHiTLS is licensed under the Mulan PSL v2.
5 * You can use this software according to the terms and conditions of the Mulan PSL v2.
6 * You may obtain a copy of Mulan PSL v2 at:
7 *
8 * http://license.coscl.org.cn/MulanPSL2
9 *
10 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
11 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
12 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
13 * See the Mulan PSL v2 for more details.
14 */
15#ifndef HITLS_APP_SM_H
16#define HITLS_APP_SM_H
17
18#include <stdint.h>
19#include <limits.h>
20#include "app_provider.h"
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25#ifdef HITLS_APP_SM_MODE
26#define HITLS_SM_OPTIONS_ENUM \
27 HITLS_SM_OPT_SM, \
28 HITLS_SM_OPT_UUID, \
29 HITLS_SM_OPT_WORKPATH
30
31#define HITLS_SM_OPTIONS \
32 {"sm", HITLS_SM_OPT_SM, HITLS_APP_OPT_VALUETYPE_NO_VALUE, "Enable SM mode"}, \
33 {"uuid", HITLS_SM_OPT_UUID, HITLS_APP_OPT_VALUETYPE_STRING, "UUID of the key (repeatable)"}, \
34 {"workpath", HITLS_SM_OPT_WORKPATH, HITLS_APP_OPT_VALUETYPE_DIR, "Specify the working directory"}
35
36#define HITLS_APP_SM_CASES(optType, smParam) \
37 switch (optType) { \
38 case HITLS_SM_OPT_SM: \
39 (smParam)->smTag = 1; \
40 break; \
41 case HITLS_SM_OPT_UUID: \
42 (smParam)->uuid = HITLS_APP_OptGetValueStr(); \
43 break; \
44 case HITLS_SM_OPT_WORKPATH: \
45 (smParam)->workPath = HITLS_APP_OptGetValueStr(); \
46 break; \
47 default: \
48 break; \
49 }
50
51typedef enum {
52 HITLS_APP_SM_STATUS_CLOSE = 0,
53 HITLS_APP_SM_STATUS_OPEN = 1,
54 HITLS_APP_SM_STATUS_INIT = 2,
55 HITLS_APP_SM_STATUS_SELFTEST = 3,
56 HITLS_APP_SM_STATUS_MANAGER = 4,
57 HITLS_APP_SM_STATUS_KEY_PARAMETER_INPUT = 5,
58 HITLS_APP_SM_STATUS_APPORVED = 6,
59 HITLS_APP_SM_STATUS_ERROR = 7,
60} HITLS_APP_SM_Status;
61
62typedef struct {
63 char *uuid;
64 int32_t smTag;
65 char *workPath;
66 uint8_t *password;
67 uint32_t passwordLen;
68 int32_t status;
69} HITLS_APP_SM_Param;
70
83int32_t HITLS_APP_SM_Init(AppProvider *provider, const char *workPath, char **password, int32_t *status);
84
85int32_t HITLS_APP_SM_IntegrityCheck(AppProvider *provider);
86
87int32_t HITLS_APP_SM_PeriodicRandomCheck(AppProvider *provider);
88
89char *HITLS_APP_GetAppPath(void);
90
91int32_t HITLS_APP_SM_RootUserCheck(void);
92
93void HITLS_APP_SM_PrintLog(int32_t ret);
94
95#endif
96
97#ifdef __cplusplus
98}
99#endif
100#endif
定义 app_provider.h:25