• 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_OEPNSSL_CLASS_H
17 #define HCF_OEPNSSL_CLASS_H
18 
19 #include "pub_key.h"
20 #include "pri_key.h"
21 #include "key_pair.h"
22 
23 #include <openssl/bn.h>
24 #include <openssl/dsa.h>
25 #include <openssl/ec.h>
26 #include <openssl/evp.h>
27 #include <openssl/rsa.h>
28 
29 typedef struct {
30     HcfPubKey base;
31 
32     int32_t curveId;
33 
34     EC_KEY *ecKey;
35 
36     char *fieldType;
37 } HcfOpensslEccPubKey;
38 #define HCF_OPENSSL_ECC_PUB_KEY_CLASS "OPENSSL.ECC.PUB_KEY"
39 
40 typedef struct {
41     HcfPriKey base;
42 
43     int32_t curveId;
44 
45     EC_KEY *ecKey;
46 
47     char *fieldType;
48 } HcfOpensslEccPriKey;
49 #define HCF_OPENSSL_ECC_PRI_KEY_CLASS "OPENSSL.ECC.PRI_KEY"
50 
51 typedef struct {
52     HcfKeyPair base;
53 } HcfOpensslEccKeyPair;
54 #define HCF_OPENSSL_ECC_KEY_PAIR_CLASS "OPENSSL.ECC.KEY_PAIR"
55 
56 typedef struct {
57     HcfPubKey base;
58 
59     uint32_t bits;
60 
61     RSA *pk;
62 } HcfOpensslRsaPubKey;
63 #define OPENSSL_RSA_PUBKEY_CLASS "OPENSSL.RSA.PUB_KEY"
64 
65 typedef struct {
66     HcfPriKey base;
67 
68     uint32_t bits;
69 
70     RSA *sk;
71 } HcfOpensslRsaPriKey;
72 #define OPENSSL_RSA_PRIKEY_CLASS "OPENSSL.RSA.PRI_KEY"
73 
74 typedef struct {
75     HcfKeyPair base;
76 } HcfOpensslRsaKeyPair;
77 #define OPENSSL_RSA_KEYPAIR_CLASS "OPENSSL.RSA.KEY_PAIR"
78 
79 typedef struct {
80     HcfPubKey base;
81 
82     DSA *pk;
83 } HcfOpensslDsaPubKey;
84 #define OPENSSL_DSA_PUBKEY_CLASS "OPENSSL.DSA.PUB_KEY"
85 
86 typedef struct {
87     HcfPriKey base;
88 
89     DSA *sk;
90 } HcfOpensslDsaPriKey;
91 #define OPENSSL_DSA_PRIKEY_CLASS "OPENSSL.DSA.PRI_KEY"
92 
93 typedef struct {
94     HcfKeyPair base;
95 } HcfOpensslDsaKeyPair;
96 #define OPENSSL_DSA_KEYPAIR_CLASS "OPENSSL.DSA.KEY_PAIR"
97 
98 typedef struct {
99     HcfPubKey base;
100 
101     int32_t curveId;
102 
103     EC_KEY *ecKey;
104 } HcfOpensslSm2PubKey;
105 #define HCF_OPENSSL_SM2_PUB_KEY_CLASS "OPENSSL.SM2.PUB_KEY"
106 
107 typedef struct {
108     HcfPriKey base;
109 
110     int32_t curveId;
111 
112     EC_KEY *ecKey;
113 } HcfOpensslSm2PriKey;
114 #define HCF_OPENSSL_SM2_PRI_KEY_CLASS "OPENSSL.SM2.PRI_KEY"
115 
116 typedef struct {
117     HcfKeyPair base;
118 } HcfOpensslSm2KeyPair;
119 #define HCF_OPENSSL_SM2_KEY_PAIR_CLASS "OPENSSL.SM2.KEY_PAIR"
120 
121 #define OPENSSL_RSA_CIPHER_CLASS "OPENSSL.RSA.CIPHER"
122 #define OPENSSL_3DES_CIPHER_CLASS "OPENSSL.3DES.CIPHER"
123 #define OPENSSL_AES_CIPHER_CLASS "OPENSSL.AES.CIPHER"
124 #define OPENSSL_SM4_CIPHER_CLASS "OPENSSL.SM4.CIPHER"
125 #define OPENSSL_SM2_CIPHER_CLASS "OPENSSL.SM2.CIPHER"
126 
127 #endif
128