1 /*
2  * Copyright (C) 2023-2024 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_DETAILED_ECC_KEY_PARAMS_H
17 #define HCF_DETAILED_ECC_KEY_PARAMS_H
18 
19 #include <stdint.h>
20 #include <stdbool.h>
21 
22 #include "asy_key_params.h"
23 #include "big_integer.h"
24 
25 typedef struct HcfECField {
26     char *fieldType;
27 } HcfECField;
28 
29 typedef struct HcfECFieldFp {
30     HcfECField base;
31     HcfBigInteger p;
32 } HcfECFieldFp;
33 
34 typedef struct HcfPoint HcfPoint;
35 struct HcfPoint {
36     HcfBigInteger x;
37     HcfBigInteger y;
38 };
39 
40 typedef struct HcfEccCommParamsSpec {
41     HcfAsyKeyParamsSpec base;
42     HcfECField *field;
43     HcfBigInteger a;
44     HcfBigInteger b;
45     HcfPoint g;
46     HcfBigInteger n;
47     int32_t h;
48 } HcfEccCommParamsSpec;
49 
50 typedef struct HcfEccPubKeyParamsSpec {
51     HcfEccCommParamsSpec base;
52     HcfPoint pk;
53 } HcfEccPubKeyParamsSpec;
54 
55 typedef struct HcfEccPriKeyParamsSpec {
56     HcfEccCommParamsSpec base;
57     HcfBigInteger sk;
58 } HcfEccPriKeyParamsSpec;
59 
60 typedef struct HcfEccKeyPairParamsSpec {
61     HcfEccCommParamsSpec base;
62     HcfBigInteger sk;
63     HcfPoint pk;
64 } HcfEccKeyPairParamsSpec;
65 #ifdef __cplusplus
66 extern "C" {
67 #endif
68 
69 void FreeEcPointMem(HcfPoint *point);
70 
71 void FreeEccCommParamsSpec(HcfEccCommParamsSpec *spec);
72 
73 void DestroyEccPriKeySpec(HcfEccPriKeyParamsSpec *spec);
74 
75 void DestroyEccPubKeySpec(HcfEccPubKeyParamsSpec *spec);
76 
77 void DestroyEccKeyPairSpec(HcfEccKeyPairParamsSpec *spec);
78 
79 #ifdef __cplusplus
80 }
81 #endif
82 #endif