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_test_curve25519.h" 17 #include "hks_api.h" 18 #include "hks_param.h" 19 #include "hks_test_log.h" 20 #include "hks_type.h" 21 22 #define TEST_ALIAS_ED25519 "test_ed25519" 23 #define TEST_PLAIN_TEST_ED25519 "This is a plain text! Hello world and thanks for watching ED25519~" 24 #define TEST_CURVE_256 256 25 #define TEST_CURVE_512 512 26 27 static uint8_t g_buffer[TEST_CURVE_256]; 28 static uint32_t g_bufferSize = TEST_CURVE_256; 29 static uint8_t g_pubKey[TEST_CURVE_512] = {0}; 30 static uint32_t g_pubKeyLen = TEST_CURVE_512; 31 32 int32_t TestGenerateEd25519Key(struct HksBlob alias); 33 34 int32_t TestSignEd25519(struct HksBlob alias); 35 36 int32_t TestVerifyEd25519(struct HksBlob alias); 37 38 int32_t TestImportEd25519(struct HksBlob alias, struct HksBlob *pubKeyInfo); 39 40 int32_t TestExportImportEd25519SignVerify(struct HksBlob alias); 41 42 int32_t TestCurve25519All(); 43 44 int32_t BuildTeeSignParamSet(struct HksParamSet **paramSet); 45 46 int32_t BuildLocalVerifyParamSet(struct HksParamSet **paramSet); 47 48 int32_t TestEd25519SignTeeVerifyLocal(); 49 50 int32_t TestSignEd25519Wrong(struct HksBlob alias); 51 52 int32_t TestCurve25519SignWrong(); 53 54 int32_t TestVerifyEd25519Wrong(struct HksBlob alias); 55 56 int32_t TestCurve25519verifyWrong();