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 HKS_IMPORT_WRAPPED_KEY_TEST_COMMON_H
17 #define HKS_IMPORT_WRAPPED_KEY_TEST_COMMON_H
18 
19 #include "hks_type.h"
20 
21 namespace Unittest::ImportWrappedKey {
22     struct HksImportWrappedKeyTestParams {
23         struct HksBlob *wrappingKeyAlias;
24         struct HksBlob *agreeKeyAlgName;
25         struct HksParamSet *genWrappingKeyParamSet;
26         uint32_t publicKeySize;
27 
28         struct HksBlob *callerKeyAlias;
29         struct HksParamSet *genCallerKeyParamSet;
30 
31         struct HksBlob *callerKekAlias;
32         struct HksBlob *callerKek;
33         struct HksParamSet *importCallerKekParamSet;
34 
35         struct HksBlob *callerAgreeKeyAlias;
36         struct HksParamSet *agreeParamSet;
37 
38         struct HksParamSet *importWrappedKeyParamSet;
39         struct HksBlob *importedKeyAlias;
40         struct HksBlob *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 }
61 #endif // HKS_IMPORT_WRAPPED_KEY_TEST_COMMON_H
62