1 /* 2 * Copyright (c) 2025 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 #ifndef OHCRYPTO_SIGNATURE_TEST_H 16 #define OHCRYPTO_SIGNATURE_TEST_H 17 18 #include "crypto_common.h" 19 #include "crypto_signature.h" 20 #include "crypto_asym_key.h" 21 #include "crypto_framework_common_test.h" 22 23 typedef struct { 24 uint8_t *algoName; 25 uint8_t *asymAlgoName; 26 int32_t msgLen; 27 } SignSpec; 28 29 typedef struct { 30 uint8_t *signAlgoName; 31 uint8_t *verifyAlgoName; 32 uint8_t *asymAlgoName; 33 uint8_t *digestAlgoName; 34 int32_t msgLen; 35 } OnlySignSpec; 36 37 typedef struct { 38 uint8_t *algoName; 39 uint8_t *asymAlgoName; 40 uint8_t *digestAlgoName; 41 int32_t msgLen; 42 } AsymSignSpec; 43 44 #define SKIP_NOHASH_TEST(value) \ 45 if (strlen(value) == strlen("NoHash") && memcmp(value, "NoHash", strlen("NoHash")) == 0) \ 46 return 47 48 #define SKIP_ED25519_TEST(value) \ 49 if (strlen(value) == strlen("Ed25519") && memcmp(value, "Ed25519", strlen("Ed25519")) == 0) \ 50 return 51 52 static uint8_t g_rsa_512_priKey[] = { 53 0x30, 0x82, 0x01, 0x3b, 0x02, 0x01, 0x00, 0x02, 0x41, 0x00, 0xb3, 0x61, 0x3c, 0x24, 0xfd, 0x9f, 54 0x7e, 0xad, 0x87, 0x36, 0x4d, 0x13, 0xd5, 0x7e, 0xef, 0x04, 0xc4, 0x57, 0xc5, 0x4c, 0x70, 0x5c, 55 0x49, 0x90, 0x4f, 0xd6, 0xde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be, 0x98, 0xab, 0x21, 0x6c, 0x1f, 67 0x59, 0x4c, 0x2a, 0x1e, 0x60, 0x58, 0xcf, 0x2c, 0xab, 0x6c, 0x34, 0x5a, 0x63, 0xca, 0x29, 0xec, 68 0x1a, 0x1e, 0xd7, 0x26, 0x4c, 0x67, 0x6a, 0xc7, 0x9f, 0x69, 0x02, 0x20, 0x74, 0x3f, 0x65, 0xfb, 69 0xc8, 0xcc, 0xcd, 0x20, 0x33, 0xd6, 0x16, 0xd8, 0x36, 0x76, 0xfc, 0xfb, 0x15, 0x5d, 0x4d, 0xd6, 70 0x1c, 0x6a, 0x68, 0x41, 0xfe, 0xd0, 0x26, 0x17, 0xe5, 0x66, 0x68, 0x2d, 0x02, 0x21, 0x00, 0x96, 71 0x19, 0x8e, 0xa3, 0xdc, 0x74, 0x7b, 0x2c, 0x3e, 0xe4, 0x5d, 0x78, 0xc9, 0x38, 0x5e, 0xc3, 0x2f, 72 0x1f, 0xe2, 0x41, 0x01, 0xaf, 0xfb, 0x56, 0xf7, 0xf9, 0xc9, 0x64, 0x42, 0x38, 0x5a, 0xc3 73 }; 74 75 static uint8_t g_rsa_512_pubKey[] = { 76 0x30, 0x5c, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 77 0x00, 0x03, 0x4b, 0x00, 0x30, 0x48, 0x02, 0x41, 0x00, 0xb3, 0x61, 0x3c, 0x24, 0xfd, 0x9f, 0x7e, 78 0xad, 0x87, 0x36, 0x4d, 0x13, 0xd5, 0x7e, 0xef, 0x04, 0xc4, 0x57, 0xc5, 0x4c, 0x70, 0x5c, 0x49, 79 0x90, 0x4f, 0xd6, 0xde, 0x5d, 0x37, 0xc0, 0x23, 0x6e, 0x23, 0xf0, 0x71, 0x64, 0xd8, 0xd7, 0x16, 80 0x1e, 0x32, 0x0c, 0xab, 0x0a, 0x76, 0xcd, 0x55, 0x96, 0xe7, 0x85, 0x6c, 0x7e, 0x39, 0x85, 0x0e, 81 0x0e, 0x43, 0x25, 0xc8, 0x90, 0x97, 0xe5, 0x40, 0x61, 0x02, 0x03, 0x01, 0x00, 0x01 82 }; 83 84 static uint8_t g_rsa_512_pubKey_n[] = { 85 0xB3, 0x61, 0x3C, 0x24, 0xFD, 0x9F, 0x7E, 0xAD, 0x87, 0x36, 0x4D, 0x13, 0xD5, 0x7E, 0xEF, 0x04, 86 0xC4, 0x57, 0xC5, 0x4C, 0x70, 0x5C, 0x49, 0x90, 0x4F, 0xD6, 0xDE, 0x5D, 0x37, 0xC0, 0x23, 0x6E, 87 0x23, 0xF0, 0x71, 0x64, 0xD8, 0xD7, 0x16, 0x1E, 0x32, 0x0C, 0xAB, 0x0A, 0x76, 0xCD, 0x55, 0x96, 88 0xE7, 0x85, 0x6C, 0x7E, 0x39, 0x85, 0x0E, 0x0E, 0x43, 0x25, 0xC8, 0x90, 0x97, 0xE5, 0x40, 0x61 89 }; 90 91 #endif // OHCRYPTO_SIGNATURE_TEST_H 92