• 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 HUKS_AGREE_DH_TEST_H
17 #define HUKS_AGREE_DH_TEST_H
18 
19 #include <string>
20 #include "huks_three_stage_test_common.h"
21 #include "native_huks_api.h"
22 #include "native_huks_param.h"
23 #include "native_huks_type.h"
24 
25 namespace Unittest::DhAgree {
26 static const std::string g_inData = "OH_HUKS_DH_Agree_Test_00000000000000000000000000000000000000000000000000000000000000"
27                                     "00000000000000000000000000000000000000000000000000000000000000000000000000000000"
28                                     "0000000000000000000000000000000000000000000000000000000000000000000000000_string";
29 static const uint32_t DH_COMMON_SIZE = 2048;
30 
31 static struct OH_Huks_Blob g_keyAlias01001 = {
32     strlen("HksDHAgreeKeyAliasTest001_1"),
33     (uint8_t *)"HksDHAgreeKeyAliasTest001_1"
34 };
35 static struct OH_Huks_Blob g_keyAlias02001 = {
36     strlen("HksDHAgreeKeyAliasTest001_2"),
37     (uint8_t *)"HksDHAgreeKeyAliasTest001_2"
38 };
39 static struct OH_Huks_Blob g_keyAliasFinal1001 = {
40     strlen("HksDHAgreeKeyAliasTest001_1_final"),
41     (uint8_t *)"HksDHAgreeKeyAliasTest001_1_final"
42 };
43 static struct OH_Huks_Blob g_keyAliasFinal2001 = {
44     strlen("HksDHAgreeKeyAliasTest001_2_final"),
45     (uint8_t *)"HksDHAgreeKeyAliasTest001_2_final"
46 };
47 static struct OH_Huks_Param g_genParams001[] = {
48     {
49         .tag = OH_HUKS_TAG_ALGORITHM,
50         .uint32Param = OH_HUKS_ALG_DH
51     }, {
52         .tag = OH_HUKS_TAG_PURPOSE,
53         .uint32Param = OH_HUKS_KEY_PURPOSE_AGREE
54     }, {
55         .tag = OH_HUKS_TAG_KEY_SIZE,
56         .uint32Param = OH_HUKS_DH_KEY_SIZE_2048
57     }
58 };
59 static struct OH_Huks_Param g_agreeParams01Init001[] = {
60     {
61         .tag = OH_HUKS_TAG_ALGORITHM,
62         .uint32Param = OH_HUKS_ALG_DH
63     }, {
64         .tag = OH_HUKS_TAG_PURPOSE,
65         .uint32Param = OH_HUKS_KEY_PURPOSE_AGREE
66     }, {
67         .tag = OH_HUKS_TAG_KEY_SIZE,
68         .uint32Param = OH_HUKS_AES_KEY_SIZE_256
69     }
70 };
71 static struct OH_Huks_Param g_agreeParams01Finish001[] = {
72     {
73         .tag = OH_HUKS_TAG_KEY_STORAGE_FLAG,
74         .uint32Param = OH_HUKS_STORAGE_PERSISTENT
75     }, {
76         .tag = OH_HUKS_TAG_IS_KEY_ALIAS,
77         .boolParam = true
78     }, {
79         .tag = OH_HUKS_TAG_ALGORITHM,
80         .uint32Param = OH_HUKS_ALG_AES
81     }, {
82         .tag = OH_HUKS_TAG_KEY_SIZE,
83         .uint32Param = OH_HUKS_AES_KEY_SIZE_256
84     }, {
85         .tag = OH_HUKS_TAG_PURPOSE,
86         .uint32Param = OH_HUKS_KEY_PURPOSE_DERIVE
87     }, {
88         .tag = OH_HUKS_TAG_DIGEST,
89         .uint32Param = OH_HUKS_DIGEST_SHA256
90     }, {
91         .tag = OH_HUKS_TAG_KEY_ALIAS,
92         .blob = g_keyAliasFinal1001
93     }, {
94         .tag = OH_HUKS_TAG_PADDING,
95         .uint32Param = OH_HUKS_PADDING_NONE
96     }, {
97         .tag = OH_HUKS_TAG_BLOCK_MODE,
98         .uint32Param = OH_HUKS_MODE_CBC
99     }
100 };
101 static struct OH_Huks_Param g_agreeParams02Init001[] = {
102     {
103         .tag = OH_HUKS_TAG_ALGORITHM,
104         .uint32Param = OH_HUKS_ALG_DH
105     }, {
106         .tag = OH_HUKS_TAG_PURPOSE,
107         .uint32Param = OH_HUKS_KEY_PURPOSE_AGREE
108     }, {
109         .tag = OH_HUKS_TAG_KEY_SIZE,
110         .uint32Param = OH_HUKS_AES_KEY_SIZE_256
111     }
112 };
113 static struct OH_Huks_Param g_agreeParams02Finish001[] = {
114     {
115         .tag = OH_HUKS_TAG_KEY_STORAGE_FLAG,
116         .uint32Param = OH_HUKS_STORAGE_PERSISTENT
117     }, {
118         .tag = OH_HUKS_TAG_IS_KEY_ALIAS,
119         .boolParam = true
120     }, {
121         .tag = OH_HUKS_TAG_ALGORITHM,
122         .uint32Param = OH_HUKS_ALG_AES
123     }, {
124         .tag = OH_HUKS_TAG_KEY_SIZE,
125         .uint32Param = OH_HUKS_AES_KEY_SIZE_256
126     }, {
127         .tag = OH_HUKS_TAG_PURPOSE,
128         .uint32Param = OH_HUKS_KEY_PURPOSE_DERIVE
129     }, {
130         .tag = OH_HUKS_TAG_DIGEST,
131         .uint32Param = OH_HUKS_DIGEST_SHA256
132     }, {
133         .tag = OH_HUKS_TAG_KEY_ALIAS,
134         .blob = g_keyAliasFinal2001
135     }, {
136         .tag = OH_HUKS_TAG_PADDING,
137         .uint32Param = OH_HUKS_PADDING_NONE
138     }, {
139         .tag = OH_HUKS_TAG_BLOCK_MODE,
140         .uint32Param = OH_HUKS_MODE_CBC
141     }
142 };
143 int Security_HUKS_NAPI_Agree_DH_0100(void);
144 } // namespace Unittest::DhAgree
145 #endif // HUKS_AGREE_DH_TEST_H