• 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 HKS_KEYNODE_H
17 #define HKS_KEYNODE_H
18 
19 #include <stdint.h>
20 
21 #include "hks_double_list.h"
22 #include "hks_type.h"
23 
24 #define HKS_OPERATION_PARAM_CNT 3
25 #define HKS_UINT64_MAX 0xFFFFFFFFFFFFFFFF
26 #define HKS_KEYNODE_HANDLE_INVALID_VALUE 0
27 #define HKS_KEYNODE_HANDLE_INITIAL_VALUE 1
28 
29 struct HuksKeyNode {
30     struct DoubleList listHead;
31     struct HksParamSet *keyBlobParamSet;
32 
33     /**
34      * @brief used to cache params of caller and state or temp prop in memory during using key
35      * CURRENT state:
36      * uint64_t crypto_ctx;     // crypto engine context
37      */
38     struct HksParamSet *runtimeParamSet; // only used to store caller's paramset
39 
40     /**
41      * @brief used to cache params of caller and state or temp prop in memory during using key
42      * CURRENT state:
43      * bool     isSecureAccess; // is set secure access
44      * bool     isSupportSecureSign; // is set secure sign tag
45      * bool     isAppendUpdateData;  // is append update data for auth info
46      * uint8 challenge[TOKEN_SIZE];// key challenge(token)
47      * uint32_t accessTime;     // key init access timestamp in second
48      * int32_t keyAuthResult;   // key auth result cache
49      */
50     struct HksParamSet *authRuntimeParamSet;
51     uint64_t handle;
52 };
53 
54 #ifdef __cplusplus
55 extern "C" {
56 #endif
57 
58 struct HuksKeyNode *HksCreateKeyNode(const struct HksBlob *key, const struct HksParamSet *paramSet);
59 
60 struct HuksKeyNode *HksQueryKeyNode(uint64_t handle);
61 
62 void HksDeleteKeyNode(uint64_t handle);
63 
64 #ifdef __cplusplus
65 }
66 #endif
67 
68 #endif