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 #include "huks_misc_test.h"
17
18 #include <gtest/gtest.h>
19
20 using namespace testing::ext;
21 namespace Unittest::HuksMisc
22 {
23 class HuksMiscTest : public testing::Test
24 {
25 public:
26 static void SetUpTestCase(void);
27
28 static void TearDownTestCase(void);
29
30 void SetUp();
31
32 void TearDown();
33 };
34
SetUpTestCase(void)35 void HuksMiscTest::SetUpTestCase(void) {}
36
TearDownTestCase(void)37 void HuksMiscTest::TearDownTestCase(void) {}
38
SetUp()39 void HuksMiscTest::SetUp() {}
40
TearDown()41 void HuksMiscTest::TearDown() {}
42
43 /**
44 * @tc.name: HuksMiscTest.Security_HUKS_NAPI_Misc_0100
45 * @tc.desc: misc test
46 * @tc.type: FUNC
47 */
HWTEST_F(HuksMiscTest, Security_HUKS_NAPI_Misc_0100, TestSize.Level0)48 HWTEST_F(HuksMiscTest, Security_HUKS_NAPI_Misc_0100, TestSize.Level0)
49 {
50 ASSERT_EQ((uint32_t)OH_HUKS_DIGEST_NONE == 0, true);
51 ASSERT_EQ((uint32_t)OH_HUKS_DIGEST_MD5 == 1, true);
52 ASSERT_EQ((uint32_t)OH_HUKS_DIGEST_SM3 == 2, true);
53 ASSERT_EQ((uint32_t)OH_HUKS_DIGEST_SHA1 == 10, true);
54 ASSERT_EQ((uint32_t)OH_HUKS_DIGEST_SHA224 == 11, true);
55 ASSERT_EQ((uint32_t)OH_HUKS_DIGEST_SHA256 == 12, true);
56 ASSERT_EQ((uint32_t)OH_HUKS_DIGEST_SHA384 == 13, true);
57 ASSERT_EQ((uint32_t)OH_HUKS_DIGEST_SHA512 == 14, true);
58 ASSERT_EQ((uint32_t)OH_HUKS_PADDING_NONE == 0, true);
59 ASSERT_EQ((uint32_t)OH_HUKS_PADDING_OAEP == 1, true);
60 ASSERT_EQ((uint32_t)OH_HUKS_PADDING_PSS == 2, true);
61 ASSERT_EQ((uint32_t)OH_HUKS_PADDING_PKCS1_V1_5 == 3, true);
62 ASSERT_EQ((uint32_t)OH_HUKS_PADDING_PKCS5 == 4, true);
63 ASSERT_EQ((uint32_t)OH_HUKS_PADDING_PKCS7 == 5, true);
64 ASSERT_EQ((uint32_t)OH_HUKS_MODE_ECB == 1, true);
65 ASSERT_EQ((uint32_t)OH_HUKS_MODE_CBC == 2, true);
66 ASSERT_EQ((uint32_t)OH_HUKS_MODE_CTR == 3, true);
67 ASSERT_EQ((uint32_t)OH_HUKS_MODE_OFB == 4, true);
68 ASSERT_EQ((uint32_t)OH_HUKS_MODE_CCM == 31, true);
69 ASSERT_EQ((uint32_t)OH_HUKS_MODE_GCM == 32, true);
70 ASSERT_EQ((uint32_t)OH_HUKS_KEY_PURPOSE_ENCRYPT == 1, true);
71 ASSERT_EQ((uint32_t)OH_HUKS_KEY_PURPOSE_DECRYPT == 2, true);
72 ASSERT_EQ((uint32_t)OH_HUKS_KEY_PURPOSE_SIGN == 4, true);
73 ASSERT_EQ((uint32_t)OH_HUKS_KEY_PURPOSE_VERIFY == 8, true);
74 ASSERT_EQ((uint32_t)OH_HUKS_KEY_PURPOSE_DERIVE == 16, true);
75 ASSERT_EQ((uint32_t)OH_HUKS_KEY_PURPOSE_WRAP == 32, true);
76 ASSERT_EQ((uint32_t)OH_HUKS_KEY_PURPOSE_UNWRAP == 64, true);
77 ASSERT_EQ((uint32_t)OH_HUKS_KEY_PURPOSE_MAC == 128, true);
78 ASSERT_EQ((uint32_t)OH_HUKS_KEY_PURPOSE_AGREE == 256, true);
79 ASSERT_EQ((uint32_t)OH_HUKS_RSA_KEY_SIZE_512 == 512, true);
80 ASSERT_EQ((uint32_t)OH_HUKS_RSA_KEY_SIZE_768 == 768, true);
81 ASSERT_EQ((uint32_t)OH_HUKS_RSA_KEY_SIZE_1024 == 1024, true);
82 ASSERT_EQ((uint32_t)OH_HUKS_RSA_KEY_SIZE_2048 == 2048, true);
83 ASSERT_EQ((uint32_t)OH_HUKS_RSA_KEY_SIZE_3072 == 3072, true);
84 ASSERT_EQ((uint32_t)OH_HUKS_RSA_KEY_SIZE_4096 == 4096, true);
85 ASSERT_EQ((uint32_t)OH_HUKS_ECC_KEY_SIZE_224 == 224, true);
86 ASSERT_EQ((uint32_t)OH_HUKS_ECC_KEY_SIZE_256 == 256, true);
87 ASSERT_EQ((uint32_t)OH_HUKS_ECC_KEY_SIZE_384 == 384, true);
88 ASSERT_EQ((uint32_t)OH_HUKS_ECC_KEY_SIZE_521 == 521, true);
89 ASSERT_EQ((uint32_t)OH_HUKS_AES_KEY_SIZE_128 == 128, true);
90 ASSERT_EQ((uint32_t)OH_HUKS_AES_KEY_SIZE_192 == 192, true);
91 ASSERT_EQ((uint32_t)OH_HUKS_AES_KEY_SIZE_256 == 256, true);
92 ASSERT_EQ((uint32_t)OH_HUKS_AES_KEY_SIZE_512 == 512, true);
93 ASSERT_EQ((uint32_t)OH_HUKS_DH_KEY_SIZE_2048 == 2048, true);
94 ASSERT_EQ((uint32_t)OH_HUKS_DH_KEY_SIZE_3072 == 3072, true);
95 ASSERT_EQ((uint32_t)OH_HUKS_DH_KEY_SIZE_4096 == 4096, true);
96 ASSERT_EQ((uint32_t)OH_HUKS_SM2_KEY_SIZE_256 == 256, true);
97 ASSERT_EQ((uint32_t)OH_HUKS_SM4_KEY_SIZE_128 == 128, true);
98 ASSERT_EQ((uint32_t)OH_HUKS_ALG_RSA == 1, true);
99 ASSERT_EQ((uint32_t)OH_HUKS_ALG_ECC == 2, true);
100 ASSERT_EQ((uint32_t)OH_HUKS_ALG_DSA == 3, true);
101 ASSERT_EQ((uint32_t)OH_HUKS_ALG_AES == 20, true);
102 ASSERT_EQ((uint32_t)OH_HUKS_ALG_HMAC == 50, true);
103 ASSERT_EQ((uint32_t)OH_HUKS_ALG_HKDF == 51, true);
104 ASSERT_EQ((uint32_t)OH_HUKS_ALG_PBKDF2 == 52, true);
105 ASSERT_EQ((uint32_t)OH_HUKS_ALG_ECDH == 100, true);
106 ASSERT_EQ((uint32_t)OH_HUKS_ALG_X25519 == 101, true);
107 ASSERT_EQ((uint32_t)OH_HUKS_ALG_ED25519 == 102, true);
108 ASSERT_EQ((uint32_t)OH_HUKS_ALG_DH == 103, true);
109 ASSERT_EQ((uint32_t)OH_HUKS_ALG_SM2 == 150, true);
110 ASSERT_EQ((uint32_t)OH_HUKS_ALG_SM3 == 151, true);
111 ASSERT_EQ((uint32_t)OH_HUKS_ALG_SM4 == 152, true);
112 ASSERT_EQ((uint32_t)OH_HUKS_UNWRAP_SUITE_X25519_AES_256_GCM_NOPADDING == 1, true);
113 ASSERT_EQ((uint32_t)OH_HUKS_UNWRAP_SUITE_ECDH_AES_256_GCM_NOPADDING == 2, true);
114 ASSERT_EQ((uint32_t)OH_HUKS_KEY_GENERATE_TYPE_DEFAULT == 0, true);
115 ASSERT_EQ((uint32_t)OH_HUKS_KEY_GENERATE_TYPE_DERIVE == 1, true);
116 ASSERT_EQ((uint32_t)OH_HUKS_KEY_GENERATE_TYPE_AGREE == 2, true);
117 ASSERT_EQ((uint32_t)OH_HUKS_KEY_FLAG_IMPORT_KEY == 1, true);
118 ASSERT_EQ((uint32_t)OH_HUKS_KEY_FLAG_GENERATE_KEY == 2, true);
119 ASSERT_EQ((uint32_t)OH_HUKS_KEY_FLAG_AGREE_KEY == 3, true);
120 ASSERT_EQ((uint32_t)OH_HUKS_KEY_FLAG_DERIVE_KEY == 4, true);
121 ASSERT_EQ((uint32_t)OH_HUKS_STORAGE_TEMP == 0, true);
122 ASSERT_EQ((uint32_t)OH_HUKS_STORAGE_PERSISTENT == 1, true);
123 ASSERT_EQ((uint32_t)OH_HUKS_KEY_TYPE_PUBLIC_KEY == 0, true);
124 ASSERT_EQ((uint32_t)OH_HUKS_KEY_TYPE_PRIVATE_KEY == 1, true);
125 ASSERT_EQ((uint32_t)OH_HUKS_KEY_TYPE_KEY_PAIR == 2, true);
126 ASSERT_EQ((uint32_t)OH_HUKS_SUCCESS == 0, true);
127 ASSERT_EQ((uint32_t)OH_HUKS_ERR_CODE_PERMISSION_FAIL == 201, true);
128 ASSERT_EQ((uint32_t)OH_HUKS_ERR_CODE_ILLEGAL_ARGUMENT == 401, true);
129 ASSERT_EQ((uint32_t)OH_HUKS_ERR_CODE_NOT_SUPPORTED_API == 801, true);
130 ASSERT_EQ((uint32_t)OH_HUKS_ERR_CODE_FEATURE_NOT_SUPPORTED == 12000001, true);
131 ASSERT_EQ((uint32_t)OH_HUKS_ERR_CODE_MISSING_CRYPTO_ALG_ARGUMENT == 12000002, true);
132 ASSERT_EQ((uint32_t)OH_HUKS_ERR_CODE_INVALID_CRYPTO_ALG_ARGUMENT == 12000003, true);
133 ASSERT_EQ((uint32_t)OH_HUKS_ERR_CODE_FILE_OPERATION_FAIL == 12000004, true);
134 ASSERT_EQ((uint32_t)OH_HUKS_ERR_CODE_COMMUNICATION_FAIL == 12000005, true);
135 ASSERT_EQ((uint32_t)OH_HUKS_ERR_CODE_CRYPTO_FAIL == 12000006, true);
136 ASSERT_EQ((uint32_t)OH_HUKS_ERR_CODE_KEY_AUTH_PERMANENTLY_INVALIDATED == 12000007, true);
137 ASSERT_EQ((uint32_t)OH_HUKS_ERR_CODE_KEY_AUTH_VERIFY_FAILED == 12000008, true);
138 ASSERT_EQ((uint32_t)OH_HUKS_ERR_CODE_KEY_AUTH_TIME_OUT == 12000009, true);
139 ASSERT_EQ((uint32_t)OH_HUKS_ERR_CODE_SESSION_LIMIT == 12000010, true);
140 ASSERT_EQ((uint32_t)OH_HUKS_ERR_CODE_ITEM_NOT_EXIST == 12000011, true);
141 ASSERT_EQ((uint32_t)OH_HUKS_ERR_CODE_INTERNAL_ERROR == 12000012, true);
142 ASSERT_EQ((uint32_t)OH_HUKS_ERR_CODE_CREDENTIAL_NOT_EXIST == 12000013, true);
143 ASSERT_EQ((uint32_t)OH_HUKS_TAG_TYPE_INVALID == 0 << 28, true);
144 ASSERT_EQ((uint32_t)OH_HUKS_TAG_TYPE_INT == 1 << 28, true);
145 ASSERT_EQ((uint32_t)OH_HUKS_TAG_TYPE_UINT == 2 << 28, true);
146 ASSERT_EQ((uint32_t)OH_HUKS_TAG_TYPE_ULONG == 3 << 28, true);
147 ASSERT_EQ((uint32_t)OH_HUKS_TAG_TYPE_BOOL == 4 << 28, true);
148 ASSERT_EQ((uint32_t)OH_HUKS_TAG_TYPE_BYTES == 5 << 28, true);
149 ASSERT_EQ((uint32_t)OH_HUKS_USER_AUTH_TYPE_FINGERPRINT == 1 << 0, true);
150 ASSERT_EQ((uint32_t)OH_HUKS_USER_AUTH_TYPE_FACE == 1 << 1, true);
151 ASSERT_EQ((uint32_t)OH_HUKS_USER_AUTH_TYPE_PIN == 1 << 2, true);
152 ASSERT_EQ((uint32_t)OH_HUKS_AUTH_ACCESS_INVALID_CLEAR_PASSWORD == 1 << 0, true);
153 ASSERT_EQ((uint32_t)OH_HUKS_AUTH_ACCESS_INVALID_NEW_BIO_ENROLL == 1 << 1, true);
154 ASSERT_EQ((uint32_t)OH_HUKS_CHALLENGE_TYPE_NORMAL == 0, true);
155 ASSERT_EQ((uint32_t)OH_HUKS_CHALLENGE_TYPE_CUSTOM == 1, true);
156 ASSERT_EQ((uint32_t)OH_HUKS_CHALLENGE_TYPE_NONE == 2, true);
157 ASSERT_EQ((uint32_t)OH_HUKS_CHALLENGE_POS_0 == 0, true);
158 ASSERT_EQ((uint32_t)OH_HUKS_CHALLENGE_POS_1 == 1, true);
159 ASSERT_EQ((uint32_t)OH_HUKS_CHALLENGE_POS_2 == 2, true);
160 ASSERT_EQ((uint32_t)OH_HUKS_CHALLENGE_POS_3 == 3, true);
161 ASSERT_EQ((uint32_t)OH_HUKS_SECURE_SIGN_WITH_AUTHINFO == 1, true);
162 ASSERT_EQ((uint32_t)OH_HUKS_TAG_ALGORITHM == (OH_HUKS_TAG_TYPE_UINT | 1), true);
163 ASSERT_EQ((uint32_t)OH_HUKS_TAG_PURPOSE == (OH_HUKS_TAG_TYPE_UINT | 2), true);
164 ASSERT_EQ((uint32_t)OH_HUKS_TAG_KEY_SIZE == (OH_HUKS_TAG_TYPE_UINT | 3), true);
165 ASSERT_EQ((uint32_t)OH_HUKS_TAG_DIGEST == (OH_HUKS_TAG_TYPE_UINT | 4), true);
166 ASSERT_EQ((uint32_t)OH_HUKS_TAG_PADDING == (OH_HUKS_TAG_TYPE_UINT | 5), true);
167 ASSERT_EQ((uint32_t)OH_HUKS_TAG_BLOCK_MODE == (OH_HUKS_TAG_TYPE_UINT | 6), true);
168 ASSERT_EQ((uint32_t)OH_HUKS_TAG_KEY_TYPE == (OH_HUKS_TAG_TYPE_UINT | 7), true);
169 ASSERT_EQ((uint32_t)OH_HUKS_TAG_ASSOCIATED_DATA == (OH_HUKS_TAG_TYPE_BYTES | 8), true);
170 ASSERT_EQ((uint32_t)OH_HUKS_TAG_NONCE == (OH_HUKS_TAG_TYPE_BYTES | 9), true);
171 ASSERT_EQ((uint32_t)OH_HUKS_TAG_IV == (OH_HUKS_TAG_TYPE_BYTES | 10), true);
172 ASSERT_EQ((uint32_t)OH_HUKS_TAG_INFO == (OH_HUKS_TAG_TYPE_BYTES | 11), true);
173 ASSERT_EQ((uint32_t)OH_HUKS_TAG_SALT == (OH_HUKS_TAG_TYPE_BYTES | 12), true);
174 ASSERT_EQ((uint32_t)OH_HUKS_TAG_ITERATION == (OH_HUKS_TAG_TYPE_UINT | 14), true);
175 ASSERT_EQ((uint32_t)OH_HUKS_TAG_KEY_GENERATE_TYPE == (OH_HUKS_TAG_TYPE_UINT | 15), true);
176 ASSERT_EQ((uint32_t)OH_HUKS_TAG_AGREE_ALG == (OH_HUKS_TAG_TYPE_UINT | 19), true);
177 ASSERT_EQ((uint32_t)OH_HUKS_TAG_AGREE_PUBLIC_KEY_IS_KEY_ALIAS == (OH_HUKS_TAG_TYPE_BOOL | 20), true);
178 ASSERT_EQ((uint32_t)OH_HUKS_TAG_AGREE_PRIVATE_KEY_ALIAS == (OH_HUKS_TAG_TYPE_BYTES | 21), true);
179 ASSERT_EQ((uint32_t)OH_HUKS_TAG_AGREE_PUBLIC_KEY == (OH_HUKS_TAG_TYPE_BYTES | 22), true);
180 ASSERT_EQ((uint32_t)OH_HUKS_TAG_KEY_ALIAS == (OH_HUKS_TAG_TYPE_BYTES | 23), true);
181 ASSERT_EQ((uint32_t)OH_HUKS_TAG_DERIVE_KEY_SIZE == (OH_HUKS_TAG_TYPE_UINT | 24), true);
182 ASSERT_EQ((uint32_t)OH_HUKS_TAG_IMPORT_KEY_TYPE == (OH_HUKS_TAG_TYPE_UINT | 25), true);
183 ASSERT_EQ((uint32_t)OH_HUKS_TAG_UNWRAP_ALGORITHM_SUITE == (OH_HUKS_TAG_TYPE_UINT | 26), true);
184 ASSERT_EQ((uint32_t)OH_HUKS_TAG_ALL_USERS == (OH_HUKS_TAG_TYPE_BOOL | 301), true);
185 ASSERT_EQ((uint32_t)OH_HUKS_TAG_USER_ID == (OH_HUKS_TAG_TYPE_UINT | 302), true);
186 ASSERT_EQ((uint32_t)OH_HUKS_TAG_NO_AUTH_REQUIRED == (OH_HUKS_TAG_TYPE_BOOL | 303), true);
187 ASSERT_EQ((uint32_t)OH_HUKS_TAG_USER_AUTH_TYPE == (OH_HUKS_TAG_TYPE_UINT | 304), true);
188 ASSERT_EQ((uint32_t)OH_HUKS_TAG_AUTH_TIMEOUT == (OH_HUKS_TAG_TYPE_UINT | 305), true);
189 ASSERT_EQ((uint32_t)OH_HUKS_TAG_AUTH_TOKEN == (OH_HUKS_TAG_TYPE_BYTES | 306), true);
190 ASSERT_EQ((uint32_t)OH_HUKS_TAG_KEY_AUTH_ACCESS_TYPE == (OH_HUKS_TAG_TYPE_UINT | 307), true);
191 ASSERT_EQ((uint32_t)OH_HUKS_TAG_KEY_SECURE_SIGN_TYPE == (OH_HUKS_TAG_TYPE_UINT | 308), true);
192 ASSERT_EQ((uint32_t)OH_HUKS_TAG_CHALLENGE_TYPE == (OH_HUKS_TAG_TYPE_UINT | 309), true);
193 ASSERT_EQ((uint32_t)OH_HUKS_TAG_CHALLENGE_POS == (OH_HUKS_TAG_TYPE_UINT | 310), true);
194
195 ASSERT_EQ((uint32_t)OH_HUKS_TAG_ATTESTATION_CHALLENGE == (OH_HUKS_TAG_TYPE_BYTES | 501), true);
196 ASSERT_EQ((uint32_t)OH_HUKS_TAG_ATTESTATION_APPLICATION_ID == (OH_HUKS_TAG_TYPE_BYTES | 502), true);
197 ASSERT_EQ((uint32_t)OH_HUKS_TAG_ATTESTATION_ID_ALIAS == (OH_HUKS_TAG_TYPE_BYTES | 511), true);
198 ASSERT_EQ((uint32_t)OH_HUKS_TAG_ATTESTATION_ID_SEC_LEVEL_INFO == (OH_HUKS_TAG_TYPE_BYTES | 514), true);
199 ASSERT_EQ((uint32_t)OH_HUKS_TAG_ATTESTATION_ID_VERSION_INFO == (OH_HUKS_TAG_TYPE_BYTES | 515), true);
200
201 ASSERT_EQ((uint32_t)OH_HUKS_TAG_IS_KEY_ALIAS == (OH_HUKS_TAG_TYPE_BOOL | 1001), true);
202 ASSERT_EQ((uint32_t)OH_HUKS_TAG_KEY_STORAGE_FLAG == (OH_HUKS_TAG_TYPE_UINT | 1002), true);
203 ASSERT_EQ((uint32_t)OH_HUKS_TAG_IS_ALLOWED_WRAP == (OH_HUKS_TAG_TYPE_BOOL | 1003), true);
204 ASSERT_EQ((uint32_t)OH_HUKS_TAG_KEY_WRAP_TYPE == (OH_HUKS_TAG_TYPE_UINT | 1004), true);
205 ASSERT_EQ((uint32_t)OH_HUKS_TAG_KEY_AUTH_ID == (OH_HUKS_TAG_TYPE_BYTES | 1005), true);
206 ASSERT_EQ((uint32_t)OH_HUKS_TAG_KEY_ROLE == (OH_HUKS_TAG_TYPE_UINT | 1006), true);
207 ASSERT_EQ((uint32_t)OH_HUKS_TAG_KEY_FLAG == (OH_HUKS_TAG_TYPE_UINT | 1007), true);
208 ASSERT_EQ((uint32_t)OH_HUKS_TAG_IS_ASYNCHRONIZED == (OH_HUKS_TAG_TYPE_UINT | 1008), true);
209 ASSERT_EQ((uint32_t)OH_HUKS_TAG_KEY_DOMAIN == (OH_HUKS_TAG_TYPE_UINT | 1011), true);
210 ASSERT_EQ((uint32_t)OH_HUKS_TAG_SYMMETRIC_KEY_DATA == (OH_HUKS_TAG_TYPE_BYTES | 20001), true);
211 ASSERT_EQ((uint32_t)OH_HUKS_TAG_ASYMMETRIC_PUBLIC_KEY_DATA == (OH_HUKS_TAG_TYPE_BYTES | 20002), true);
212 ASSERT_EQ((uint32_t)OH_HUKS_TAG_ASYMMETRIC_PRIVATE_KEY_DATA == (OH_HUKS_TAG_TYPE_BYTES | 20003), true);
213
214 struct OH_Huks_Result result;
215 ASSERT_EQ(sizeof(result.errorCode) == sizeof(int32_t), true);
216 ASSERT_EQ(sizeof(result.errorMsg) == sizeof(const char *), true);
217 ASSERT_EQ(sizeof(result.data) == sizeof(uint8_t *), true);
218
219 struct OH_Huks_Blob blob;
220 ASSERT_EQ(sizeof(blob.size) == sizeof(uint32_t), true);
221 ASSERT_EQ(sizeof(blob.data) == sizeof(uint8_t *), true);
222
223 struct OH_Huks_Param param;
224 ASSERT_EQ(sizeof(param.tag) == sizeof(uint32_t), true);
225 ASSERT_EQ(sizeof(param.boolParam) == sizeof(bool), true);
226 ASSERT_EQ(sizeof(param.int32Param) == sizeof(int32_t), true);
227 ASSERT_EQ(sizeof(param.uint32Param) == sizeof(uint32_t), true);
228 ASSERT_EQ(sizeof(param.uint64Param) == sizeof(uint64_t), true);
229 ASSERT_EQ(sizeof(param.blob) == sizeof(struct OH_Huks_Blob), true);
230
231 struct OH_Huks_ParamSet paramset;
232 ASSERT_EQ(sizeof(paramset.paramSetSize) == sizeof(uint32_t), true);
233 ASSERT_EQ(sizeof(paramset.paramsCnt) == sizeof(uint32_t), true);
234 ASSERT_EQ(sizeof(paramset.params[0]) == sizeof(struct OH_Huks_Param), true);
235
236 struct OH_Huks_CertChain certChain;
237 ASSERT_EQ(sizeof(certChain.certs) == sizeof(struct OH_Huks_Blob *), true);
238 ASSERT_EQ(sizeof(certChain.certsCount) == sizeof(uint32_t), true);
239
240 struct OH_Huks_KeyInfo keyInfo;
241 ASSERT_EQ(sizeof(keyInfo.alias) == sizeof(struct OH_Huks_Blob), true);
242 ASSERT_EQ(sizeof(keyInfo.paramSet) == sizeof(struct OH_Huks_ParamSet *), true);
243
244 struct OH_Huks_PubKeyInfo pubKeyInfo;
245 ASSERT_EQ(sizeof(pubKeyInfo.keyAlg) == sizeof(OH_Huks_KeyAlg), true);
246 ASSERT_EQ(sizeof(pubKeyInfo.keySize) == sizeof(uint32_t), true);
247 ASSERT_EQ(sizeof(pubKeyInfo.nOrXSize) == sizeof(uint32_t), true);
248 ASSERT_EQ(sizeof(pubKeyInfo.eOrYSize) == sizeof(uint32_t), true);
249 ASSERT_EQ(sizeof(pubKeyInfo.placeHolder) == sizeof(uint32_t), true);
250
251 struct OH_Huks_KeyMaterialRsa keyMaterialRsa;
252 ASSERT_EQ(sizeof(keyMaterialRsa.keyAlg) == sizeof(OH_Huks_KeyAlg), true);
253 ASSERT_EQ(sizeof(keyMaterialRsa.keySize) == sizeof(uint32_t), true);
254 ASSERT_EQ(sizeof(keyMaterialRsa.nSize) == sizeof(uint32_t), true);
255 ASSERT_EQ(sizeof(keyMaterialRsa.eSize) == sizeof(uint32_t), true);
256 ASSERT_EQ(sizeof(keyMaterialRsa.dSize) == sizeof(uint32_t), true);
257
258 struct OH_Huks_KeyMaterialEcc keyMaterialEcc;
259 ASSERT_EQ(sizeof(keyMaterialEcc.keyAlg) == sizeof(OH_Huks_KeyAlg), true);
260 ASSERT_EQ(sizeof(keyMaterialEcc.keySize) == sizeof(uint32_t), true);
261 ASSERT_EQ(sizeof(keyMaterialEcc.xSize) == sizeof(uint32_t), true);
262 ASSERT_EQ(sizeof(keyMaterialEcc.ySize) == sizeof(uint32_t), true);
263 ASSERT_EQ(sizeof(keyMaterialEcc.zSize) == sizeof(uint32_t), true);
264
265 struct OH_Huks_KeyMaterialDsa keyMaterialDsa;
266 ASSERT_EQ(sizeof(keyMaterialDsa.keyAlg) == sizeof(OH_Huks_KeyAlg), true);
267 ASSERT_EQ(sizeof(keyMaterialDsa.keySize) == sizeof(uint32_t), true);
268 ASSERT_EQ(sizeof(keyMaterialDsa.xSize) == sizeof(uint32_t), true);
269 ASSERT_EQ(sizeof(keyMaterialDsa.ySize) == sizeof(uint32_t), true);
270 ASSERT_EQ(sizeof(keyMaterialDsa.pSize) == sizeof(uint32_t), true);
271 ASSERT_EQ(sizeof(keyMaterialDsa.qSize) == sizeof(uint32_t), true);
272 ASSERT_EQ(sizeof(keyMaterialDsa.gSize) == sizeof(uint32_t), true);
273
274 struct OH_Huks_KeyMaterialDh keyMaterialDh;
275 ASSERT_EQ(sizeof(keyMaterialDh.keyAlg) == sizeof(OH_Huks_KeyAlg), true);
276 ASSERT_EQ(sizeof(keyMaterialDh.keySize) == sizeof(uint32_t), true);
277 ASSERT_EQ(sizeof(keyMaterialDh.pubKeySize) == sizeof(uint32_t), true);
278 ASSERT_EQ(sizeof(keyMaterialDh.priKeySize) == sizeof(uint32_t), true);
279 ASSERT_EQ(sizeof(keyMaterialDh.reserved) == sizeof(uint32_t), true);
280
281 struct OH_Huks_KeyMaterial25519 keyMaterial25519;
282 ASSERT_EQ(sizeof(keyMaterial25519.keyAlg) == sizeof(OH_Huks_KeyAlg), true);
283 ASSERT_EQ(sizeof(keyMaterial25519.keySize) == sizeof(uint32_t), true);
284 ASSERT_EQ(sizeof(keyMaterial25519.pubKeySize) == sizeof(uint32_t), true);
285 ASSERT_EQ(sizeof(keyMaterial25519.priKeySize) == sizeof(uint32_t), true);
286 ASSERT_EQ(sizeof(keyMaterial25519.reserved) == sizeof(uint32_t), true);
287 }
288 } // namespace Unittest::HuksMisc
289