1 /* 2 * Copyright (C) 2023 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 "hks_derive_test.h" 17 18 #include "hks_api.h" 19 #include "hks_param.h" 20 #include "hks_test_api_performance.h" 21 #include "hks_test_common.h" 22 #include "hks_test_log.h" 23 24 #define DEFAULT_DERIVE_SIZE 32 25 #define DEFAULT_INFO_SIZE 55 26 #define DEFAULT_SALT_SIZE 16 27 28 static const struct HksTestDeriveParams g_testDeriveParams[] = { 29 /* hkdf-sha256-salt-info */ 30 { 0, HKS_SUCCESS, { true, DEFAULT_KEY_ALIAS_SIZE, true, DEFAULT_KEY_ALIAS_SIZE }, 31 { 32 true, /* genKey params */ 33 true, HKS_ALG_AES, 34 true, HKS_AES_KEY_SIZE_256, 35 true, HKS_KEY_PURPOSE_DERIVE, 36 true, HKS_DIGEST_SHA256, 37 false, 0, 38 false, 0, 39 false, 0 }, 40 { 0 }, 41 { 42 true, /* derive params */ 43 true, HKS_ALG_HKDF, 44 true, HKS_KEY_PURPOSE_DERIVE, 45 true, HKS_DIGEST_SHA256, 46 false, 0, 47 true, DEFAULT_SALT_SIZE, 48 true, DEFAULT_INFO_SIZE, 49 false, true }, 50 { 51 true, DEFAULT_DERIVE_SIZE, true, DEFAULT_DERIVE_SIZE }, 52 { 53 false, 0, false, 0 } 54 }, 55 56 /* local: hkdf-sha256-salt-info */ 57 { 1, HKS_SUCCESS, { true, DEFAULT_KEY_ALIAS_SIZE, true, DEFAULT_KEY_ALIAS_SIZE }, 58 { 59 true, /* genKey params */ 60 true, HKS_ALG_AES, 61 true, HKS_AES_KEY_SIZE_256, 62 true, HKS_KEY_PURPOSE_DERIVE, 63 true, HKS_DIGEST_SHA256, 64 false, 0, 65 false, 0, 66 true, HKS_STORAGE_TEMP }, 67 { 0 }, 68 { 69 true, /* derive params */ 70 true, HKS_ALG_HKDF, 71 true, HKS_KEY_PURPOSE_DERIVE, 72 true, HKS_DIGEST_SHA256, 73 false, 0, 74 true, DEFAULT_SALT_SIZE, 75 true, DEFAULT_INFO_SIZE, 76 true, false }, 77 { 78 true, DEFAULT_DERIVE_SIZE, true, DEFAULT_DERIVE_SIZE }, 79 { 80 true, DEFAULT_LOCAL_KEY_SIZE, true, DEFAULT_LOCAL_KEY_SIZE } 81 }, 82 }; 83