• 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 HCF_SYM_KEY_GENERATOR_H
17 #define HCF_SYM_KEY_GENERATOR_H
18 
19 #include <stdint.h>
20 #include "result.h"
21 #include "sym_key.h"
22 
23 /**
24  * @brief Provides a wrapped HcfSymKeyGenerator instance.
25  *
26  * @since 9
27  * @version 1.0
28  */
29 typedef struct HcfSymKeyGenerator HcfSymKeyGenerator;
30 
31 /**
32  * @brief Provides generation capabilities for symmetric key objects.
33  *
34  * @since 9
35  * @version 1.0
36  */
37 struct HcfSymKeyGenerator {
38     HcfObjectBase base;
39 
40     /** Generate symmetric key object */
41     HcfResult (*generateSymKey)(HcfSymKeyGenerator *self, HcfSymKey **symKey);
42 
43     /** Convert byte data to symmetric key object */
44     HcfResult (*convertSymKey)(HcfSymKeyGenerator *self, const HcfBlob *key, HcfSymKey **symKey);
45 
46     /** Get the algorithm name of the current these key generator objects */
47     const char *(*getAlgoName)(HcfSymKeyGenerator *self);
48 };
49 
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
53 
54 /**
55  * @brief Generate a symmetric key generator object based on the algorithm name.
56  *
57  * @param algoName Specifies the type of generated symmetric key generator object.
58  * @param returnObj return pointer to generate symmetric key generator object.
59  * @return Returns the status code of the execution
60  * @since 9
61  * @version 1.0
62  */
63 HcfResult HcfSymKeyGeneratorCreate(const char *algoName, HcfSymKeyGenerator **returnObj);
64 
65 #ifdef __cplusplus
66 }
67 #endif
68 
69 #endif
70