• 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_WRAPPED_TEST_COMMON_H
17 #define HUKS_WRAPPED_TEST_COMMON_H
18 
19 #include "huks_three_stage_test_common.h"
20 
21 namespace Unittest::ImportWrapped {
22     struct HksImportWrappedKeyTestParams {
23         struct OH_Huks_Blob *wrappingKeyAlias;
24         struct OH_Huks_Blob *agreeKeyAlgName;
25         struct OH_Huks_ParamSet *genWrappingKeyParamSet;
26         uint32_t publicKeySize;
27 
28         struct OH_Huks_Blob *callerKeyAlias;
29         struct OH_Huks_ParamSet *genCallerKeyParamSet;
30 
31         struct OH_Huks_Blob *callerKekAlias;
32         struct OH_Huks_Blob *callerKek;
33         struct OH_Huks_ParamSet *importCallerKekParamSet;
34 
35         struct OH_Huks_Blob *callerAgreeKeyAlias;
36         struct OH_Huks_ParamSet *agreeParamSet;
37 
38         struct OH_Huks_ParamSet *importWrappedKeyParamSet;
39         struct OH_Huks_Blob *importedKeyAlias;
40         struct OH_Huks_Blob *importedPlainKey;
41         uint32_t keyMaterialLen;
42     };
43 
44     static const uint32_t IV_SIZE = 16;
45     static uint8_t IV[IV_SIZE] = "bababababababab";
46 
47     static const uint32_t AAD_SIZE = 16;
48     static uint8_t AAD[AAD_SIZE] = "abababababababa";
49 
50     static const uint32_t NONCE_SIZE = 12;
51     static uint8_t NONCE[NONCE_SIZE] = "hahahahahah";
52 
53     static const uint32_t AEAD_TAG_SIZE = 16;
54 
55     static const uint32_t X25519_256_SIZE = 256;
56 
57     void HksImportWrappedKeyTestCommonCase(const struct HksImportWrappedKeyTestParams *params);
58 
59     void HksClearKeysForWrappedKeyTest(const struct HksImportWrappedKeyTestParams *params);
60 } //namespace Unittest::ImportWrapped
61 #endif // HUKS_WRAPPED_TEST_COMMON_H
62