• 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 CERT_MANAGER_KEY_OPERATION_H
17 #define CERT_MANAGER_KEY_OPERATION_H
18 
19 #include "cm_type.h"
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 enum CmSignVerifyCmd {
26     SIGN_VERIFY_CMD_UPDATE,
27     SIGN_VERIFY_CMD_FINISH,
28     SIGN_VERIFY_CMD_ABORT,
29 };
30 
31 struct CmKeyProperties {
32     uint32_t algType;
33     uint32_t keySize;
34     uint32_t padding;
35     uint32_t digest;
36     uint32_t purpose;
37     enum CmAuthStorageLevel level; /* 添加level */
38 };
39 
40 int32_t CmKeyOpGenMacKey(const struct CmBlob *alias, enum CmAuthStorageLevel level);
41 
42 int32_t CmKeyOpGenMacKeyIfNotExist(const struct CmBlob *alias);
43 
44 int32_t CmKeyOpDeleteKey(const struct CmBlob *alias, enum CmAuthStorageLevel level);
45 
46 int32_t CmKeyOpCalcMac(const struct CmBlob *alias, const struct CmBlob *srcData,
47     struct CmBlob *mac, enum CmAuthStorageLevel level);
48 
49 int32_t CmKeyOpImportKey(const struct CmBlob *alias, const struct CmKeyProperties *properties,
50     const struct CmBlob *keyPair);
51 
52 int32_t CmKeyOpInit(const struct CmContext *context, const struct CmBlob *alias, const struct CmSignatureSpec *spec,
53     enum CmAuthStorageLevel level, struct CmBlob *handle);
54 
55 int32_t CmKeyOpProcess(enum CmSignVerifyCmd cmdId, const struct CmContext *context, const struct CmBlob *handle,
56     const struct CmBlob *inData, struct CmBlob *outData);
57 
58 #ifdef __cplusplus
59 }
60 #endif
61 
62 #endif /* CERT_MANAGER_KEY_OPERATION_H */
63 
64