• 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 
21 #include "huks_three_stage_test_common.h"
22 #include "native_huks_api.h"
23 #include "native_huks_param.h"
24 #include "native_huks_type.h"
25 
26 namespace Unittest::DhAgree
27 {
28 static const std::string g_inData =
29     "OH_HUKS_DH_Agree_Test_00000000000000000000000000000000000000000000000000000000000000"
30     "00000000000000000000000000000000000000000000000000000000000000000000000000000000"
31     "0000000000000000000000000000000000000000000000000000000000000000000000000_string";
32 static const uint32_t DH_COMMON_SIZE = 2048;
33 
34 static struct OH_Huks_Blob g_keyAlias01001 = {strlen("HksDHAgreeKeyAliasTest001_1"),
35                                               (uint8_t *)"HksDHAgreeKeyAliasTest001_1"};
36 static struct OH_Huks_Blob g_keyAlias02001 = {strlen("HksDHAgreeKeyAliasTest001_2"),
37                                               (uint8_t *)"HksDHAgreeKeyAliasTest001_2"};
38 static struct OH_Huks_Blob g_keyAliasFinal1001 = {strlen("HksDHAgreeKeyAliasTest001_1_final"),
39                                                   (uint8_t *)"HksDHAgreeKeyAliasTest001_1_final"};
40 static struct OH_Huks_Blob g_keyAliasFinal2001 = {strlen("HksDHAgreeKeyAliasTest001_2_final"),
41                                                   (uint8_t *)"HksDHAgreeKeyAliasTest001_2_final"};
42 static struct OH_Huks_Param g_genParams001[] = {
43     {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_DH},
44     {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_AGREE},
45     {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_DH_KEY_SIZE_2048},
46     {.tag = OH_HUKS_TAG_AUTH_STORAGE_LEVEL, .uint32Param = OH_HUKS_AUTH_STORAGE_LEVEL_DE}};
47 static struct OH_Huks_Param g_agreeParams01Init001[] = {
48     {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_DH},
49     {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_AGREE},
50     {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_AES_KEY_SIZE_256},
51     {.tag = OH_HUKS_TAG_AUTH_STORAGE_LEVEL, .uint32Param = OH_HUKS_AUTH_STORAGE_LEVEL_DE}};
52 static struct OH_Huks_Param g_agreeParams01Finish001[] = {
53     {.tag = OH_HUKS_TAG_KEY_STORAGE_FLAG, .uint32Param = OH_HUKS_STORAGE_PERSISTENT},
54     {.tag = OH_HUKS_TAG_IS_KEY_ALIAS, .boolParam = true},
55     {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_AES},
56     {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_AES_KEY_SIZE_256},
57     {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_DERIVE},
58     {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_SHA256},
59     {.tag = OH_HUKS_TAG_KEY_ALIAS, .blob = g_keyAliasFinal1001},
60     {.tag = OH_HUKS_TAG_PADDING, .uint32Param = OH_HUKS_PADDING_NONE},
61     {.tag = OH_HUKS_TAG_BLOCK_MODE, .uint32Param = OH_HUKS_MODE_CBC},
62     {.tag = OH_HUKS_TAG_AUTH_STORAGE_LEVEL, .uint32Param = OH_HUKS_AUTH_STORAGE_LEVEL_DE}};
63 static struct OH_Huks_Param g_agreeParams02Init001[] = {
64     {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_DH},
65     {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_AGREE},
66     {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_AES_KEY_SIZE_256},
67     {.tag = OH_HUKS_TAG_AUTH_STORAGE_LEVEL, .uint32Param = OH_HUKS_AUTH_STORAGE_LEVEL_DE}};
68 static struct OH_Huks_Param g_agreeParams02Finish001[] = {
69     {.tag = OH_HUKS_TAG_KEY_STORAGE_FLAG, .uint32Param = OH_HUKS_STORAGE_PERSISTENT},
70     {.tag = OH_HUKS_TAG_IS_KEY_ALIAS, .boolParam = true},
71     {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_AES},
72     {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_AES_KEY_SIZE_256},
73     {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_DERIVE},
74     {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_SHA256},
75     {.tag = OH_HUKS_TAG_KEY_ALIAS, .blob = g_keyAliasFinal2001},
76     {.tag = OH_HUKS_TAG_PADDING, .uint32Param = OH_HUKS_PADDING_NONE},
77     {.tag = OH_HUKS_TAG_BLOCK_MODE, .uint32Param = OH_HUKS_MODE_CBC},
78     {.tag = OH_HUKS_TAG_AUTH_STORAGE_LEVEL, .uint32Param = OH_HUKS_AUTH_STORAGE_LEVEL_DE}};
79 int Security_HUKS_NAPI_Agree_DH_0100(void);
80 }  // namespace Unittest::DhAgree
81 #endif  // HUKS_AGREE_DH_TEST_H