1 /* 2 * Copyright (C) 2022 - This file is part of libecc project 3 * 4 * Authors: 5 * Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr> 6 * Ryad BENADJILA <ryadbenadjila@gmail.com> 7 * 8 * This software is licensed under a dual BSD and GPL v2 license. 9 * See LICENSE file at the root folder of the project. 10 */ 11 #ifndef __DBIGN_TEST_VECTORS_H__ 12 #define __DBIGN_TEST_VECTORS_H__ 13 14 #if defined(WITH_HASH_BELT_HASH) && defined(WITH_CURVE_BIGN256V1) 15 /************************************************/ 16 static const u8 dbign_1_test_vectors_priv_key[] = { 17 0x69, 0xe2, 0x73, 0xc2, 0x5f, 0x23, 0x79, 0x0c, 0x9e, 0x42, 0x32, 0x07, 0xed, 0x1f, 0x28, 0x34, 0x18, 0xf2, 0x74, 0x9c, 0x32, 0xf0, 0x33, 0x45, 0x67, 0x39, 0x73, 0x4b, 0xb8, 0xb5, 0x66, 0x1f, 18 }; 19 static const u8 dbign_1_test_vectors_expected_sig[] = { 20 0x19, 0xd3, 0x2b, 0x7e, 0x01, 0xe2, 0x5b, 0xae, 0x4a, 0x70, 0xeb, 0x6b, 0xca, 0x42, 0x60, 0x2c, 21 0xca, 0x6a, 0x13, 0x94, 0x44, 0x51, 0xbc, 0xc5, 0xd4, 0xc5, 0x4c, 0xfd, 0x87, 0x37, 0x61, 0x9c, 0x32, 0x8b, 0x8a, 0x58, 0xfb, 0x9c, 0x68, 0xfd, 0x17, 0xd5, 0x69, 0xf7, 0xd0, 0x64, 0x95, 0xfb, 22 }; 23 static const u8 dbign_1_test_vectors_adata[] = { 24 0x00, 0x0b, 0x00, 0x00, 25 0x06, 0x09, 0x2A, 0x70, 0x00, 0x02, 0x00, 0x22, 0x65, 0x1F, 0x51, 26 }; 27 28 static const ec_test_case dbign_1_test_case = { 29 .name = "DBIGN-BELT-HASH/dbign256v1 1", 30 .ec_str_p = &bign256v1_str_params, 31 .priv_key = dbign_1_test_vectors_priv_key, 32 .priv_key_len = sizeof(dbign_1_test_vectors_priv_key), 33 .nn_random = NULL, 34 .hash_type = BELT_HASH, 35 .msg = "\xB1\x94\xBA\xC8\x0A\x08\xF5\x3B\x36\x6D\x00\x8E\x58", 36 .msglen = 13, 37 .sig_type = DBIGN, 38 .exp_sig = dbign_1_test_vectors_expected_sig, 39 .exp_siglen = sizeof(dbign_1_test_vectors_expected_sig), 40 .adata = dbign_1_test_vectors_adata, 41 .adata_len = sizeof(dbign_1_test_vectors_adata) 42 }; 43 44 /********************************************************************/ 45 static const u8 dbign_2_test_vectors_priv_key[] = { 46 0x69, 0xe2, 0x73, 0xc2, 0x5f, 0x23, 0x79, 0x0c, 0x9e, 0x42, 0x32, 0x07, 0xed, 0x1f, 0x28, 0x34, 0x18, 0xf2, 0x74, 0x9c, 0x32, 0xf0, 0x33, 0x45, 0x67, 0x39, 0x73, 0x4b, 0xb8, 0xb5, 0x66, 0x1f, 47 }; 48 static const u8 dbign_2_test_vectors_expected_sig[] = { 49 0x2a, 0x0e, 0xf2, 0x4b, 0xa6, 0x2d, 0x63, 0xa3, 0x34, 0x10, 0x3f, 0x47, 0x0d, 0xc7, 0x55, 0xeb, 50 0x2c, 0x51, 0xba, 0x3d, 0x57, 0xaa, 0x4e, 0xfe, 0xd5, 0x61, 0x76, 0x19, 0x04, 0xf9, 0x39, 0x9e, 0x0f, 0xf6, 0x18, 0x04, 0xfb, 0x46, 0xec, 0xa1, 0x74, 0xe1, 0xdd, 0xd9, 0xe5, 0x5e, 0x25, 0x64, 51 }; 52 static const u8 dbign_2_test_vectors_adata[] = { 53 0x00, 0x0b, 0x00, 0x17, 54 0x06, 0x09, 0x2A, 0x70, 0x00, 0x02, 0x00, 0x22, 0x65, 0x1F, 0x51, 55 0xBE, 0x32, 0x97, 0x13, 0x43, 0xFC, 0x9A, 0x48, 0xA0, 0x2A, 0x88, 0x5F, 0x19, 0x4B, 0x09, 0xA1, 0x7E, 0xCD, 0xA4, 0xD0, 0x15, 0x44, 0xAF, 56 }; 57 58 static const ec_test_case dbign_2_test_case = { 59 .name = "DBIGN-BELT-HASH/dbign256v1 2", 60 .ec_str_p = &bign256v1_str_params, 61 .priv_key = dbign_2_test_vectors_priv_key, 62 .priv_key_len = sizeof(dbign_2_test_vectors_priv_key), 63 .nn_random = NULL, 64 .hash_type = BELT_HASH, 65 .msg = "\xB1\x94\xBA\xC8\x0A\x08\xF5\x3B\x36\x6D\x00\x8E\x58\x4A\x5D\xE4\x85\x04\xFA\x9D\x1B\xB6\xC7\xAC\x25\x2E\x72\xC2\x02\xFD\xCE\x0D\x5B\xE3\xD6\x12\x17\xB9\x61\x81\xFE\x67\x86\xAD\x71\x6B\x89\x0B", 66 .msglen = 48, 67 .sig_type = DBIGN, 68 .exp_sig = dbign_2_test_vectors_expected_sig, 69 .exp_siglen = sizeof(dbign_2_test_vectors_expected_sig), 70 .adata = dbign_2_test_vectors_adata, 71 .adata_len = sizeof(dbign_2_test_vectors_adata) 72 }; 73 74 /********************************************************************/ 75 static const u8 dbign_3_test_vectors_priv_key[] = { 76 0xb3, 0x8a, 0x57, 0x70, 0xaa, 0xe8, 0x97, 0x73, 0x1a, 0xe3, 0x69, 0xaa, 0x48, 0x91, 0xf3, 0x14, 0xd4, 0xae, 0x76, 0x94, 0x29, 0xf3, 0xde, 0x94, 0xeb, 0x9b, 0x36, 0xdf, 0x79, 0x89, 0x62, 0x79, 77 }; 78 79 static const u8 dbign_3_test_vectors_expected_sig[] = { 80 0x3d, 0xcf, 0xf8, 0x86, 0x87, 0xa9, 0x8a, 0xbb, 0x01, 0xce, 0x2d, 0xe8, 0x3e, 0x3a, 0x65, 0xeb, 81 0x69, 0xd1, 0x6a, 0x47, 0x50, 0x87, 0x50, 0xfb, 0x6f, 0x18, 0x64, 0x2c, 0x1b, 0x48, 0xb4, 0xaf, 0xff, 0xcd, 0x59, 0xcf, 0xd9, 0x98, 0x6f, 0xe9, 0xf2, 0xbb, 0xea, 0x99, 0xb9, 0x65, 0xb0, 0x1b, 82 }; 83 static const u8 dbign_3_test_vectors_adata[] = { 84 0x00, 0x0b, 0x00, 0x00, 85 0x06, 0x09, 0x2A, 0x70, 0x00, 0x02, 0x00, 0x22, 0x65, 0x1F, 0x51, 86 }; 87 88 static const ec_test_case dbign_3_test_case = { 89 .name = "DBIGN-BELT-HASH/dbign256v1 3", 90 .ec_str_p = &bign256v1_str_params, 91 .priv_key = dbign_3_test_vectors_priv_key, 92 .priv_key_len = sizeof(dbign_3_test_vectors_priv_key), 93 .nn_random = NULL, 94 .hash_type = BELT_HASH, 95 .msg = "\xB1\x94\xBA\xC8\x0A\x08\xF5\x3B\x36\x6D\x00\x8E\x58\x4A\x5D\xE4\x85\x04\xFA\x9D\x1B\xB6\xC7\xAC\x25\x2E\x72\xC2\x02\xFD\xCE\x0D\x5B\xE3\xD6\x12\x17\xB9\x61\x81\xFE\x67\x86\xAD\x71\x6B\x89\x0B", 96 .msglen = 48, 97 .sig_type = DBIGN, 98 .exp_sig = dbign_3_test_vectors_expected_sig, 99 .exp_siglen = sizeof(dbign_3_test_vectors_expected_sig), 100 .adata = dbign_3_test_vectors_adata, 101 .adata_len = sizeof(dbign_3_test_vectors_adata) 102 }; 103 #endif 104 105 #if defined(WITH_HASH_BASH384) && defined(WITH_CURVE_BIGN384V1) 106 /********************************************************************/ 107 static const u8 dbign_4_test_vectors_priv_key[] = { 108 0x0e, 0xb5, 0x93, 0x2d, 0x23, 0x1a, 0xe1, 0x37, 0x61, 0x41, 0x80, 0xec, 0x3b, 0xbe, 0x08, 0x0f, 0x93, 0xba, 0x80, 0x27, 0x8f, 0x05, 0xd8, 0x2f, 0x87, 0x6a, 0xf9, 0xf9, 0xea, 0x0a, 0xf1, 0x9e, 0x6c, 0xa1, 0x6f, 0x21, 0x6c, 0x38, 0x21, 0xdc, 0x72, 0x23, 0x3c, 0x7b, 0xbf, 0x1d, 0xc2, 0x84, 109 }; 110 static const u8 dbign_4_test_vectors_expected_sig[] = { 111 0xc2, 0xf6, 0x0f, 0x84, 0x00, 0xc1, 0xe4, 0xdd, 0xc4, 0x7f, 0x05, 0xd9, 0x6c, 0x0f, 0xed, 0x1e, 0xe3, 0x0a, 0xb2, 0x29, 0x87, 0x5d, 0xff, 0xb3, 112 0xfa, 0xd2, 0xd7, 0x0e, 0xb8, 0x05, 0x56, 0x64, 0x12, 0xff, 0x35, 0xef, 0x62, 0xc0, 0x6f, 0xa6, 0x6b, 0x42, 0x5f, 0x21, 0x30, 0x60, 0x40, 0x9c, 0x6c, 0x06, 0xfc, 0x04, 0xf5, 0x0c, 0x63, 0x7e, 0x84, 0xbb, 0x3e, 0x7a, 0x29, 0x81, 0x51, 0xaa, 0xb1, 0x1a, 0x50, 0xb8, 0xe1, 0x52, 0x91, 0xbc, 113 }; 114 static const u8 dbign_4_test_vectors_adata[] = { 115 0x00, 0x0b, 0x00, 0x00, 116 0x06, 0x09, 0x2A, 0x70, 0x00, 0x02, 0x00, 0x22, 0x65, 0x4d, 0x0c, 117 }; 118 static const ec_test_case dbign_4_test_case = { 119 .name = "BIGN-BASH384/dbign384v1 4", 120 .ec_str_p = &bign384v1_str_params, 121 .priv_key = dbign_4_test_vectors_priv_key, 122 .priv_key_len = sizeof(dbign_4_test_vectors_priv_key), 123 .nn_random = NULL, 124 .hash_type = BASH384, 125 .msg = "\xb1\x94\xba\xc8\x0a\x08\xf5\x3b\x36\x6d\x00\x8e\x58\x4a\x5d\xe4\x85\x04\xfa\x9d\x1b\xb6\xc7\xac\x25\x2e\x72\xc2\x02\xfd\xce\x0d\x5b\xe3\xd6\x12\x17\xb9\x61\x81\xfe\x67\x86\xad\x71\x6b\x89\x0b\x5c\xb0\xc0\xff\x33\xc3\x56\xb8\x35\xc4\x05\xae\xd8\xe0\x7f\x99\xe1\x2b\xdc\x1a\xe2\x82\x57\xec\x70\x3f\xcc\xf0\x95\xee\x8d\xf1\xc1\xab\x76\x38\x9f\xe6\x78\xca\xf7\xc6\xf8\x60\xd5\xbb\x9c", 126 .msglen = 95, 127 .sig_type = DBIGN, 128 .exp_sig = dbign_4_test_vectors_expected_sig, 129 .exp_siglen = sizeof(dbign_4_test_vectors_expected_sig), 130 .adata = dbign_4_test_vectors_adata, 131 .adata_len = sizeof(dbign_4_test_vectors_adata) 132 }; 133 /********************************************************************/ 134 static const u8 dbign_5_test_vectors_priv_key[] = { 135 0x2d, 0x27, 0xc3, 0x89, 0x27, 0x29, 0xfd, 0xb6, 0xf0, 0xee, 0xa7, 0xf8, 0x4e, 0x15, 0x2d, 0x30, 0x24, 0x60, 0xc9, 0x84, 0xde, 0xcb, 0xf6, 0xe6, 0xff, 0x4b, 0xce, 0xfb, 0x89, 0xb1, 0x5d, 0xd2, 0xe8, 0x4d, 0x10, 0xd6, 0x09, 0x92, 0x80, 0x2d, 0x66, 0x6b, 0xb8, 0x05, 0x5f, 0x31, 0xe1, 0x04, 136 }; 137 static const u8 dbign_5_test_vectors_expected_sig[] = { 138 0x50, 0x0d, 0x4d, 0x66, 0xd4, 0xa6, 0x8a, 0xfc, 0xbb, 0x1d, 0xa7, 0x04, 0xa8, 0xc3, 0xdb, 0x4d, 0x97, 0xb6, 0x2f, 0x71, 0xe8, 0xcb, 0xfd, 0x06, 139 0x27, 0xa8, 0x45, 0x1b, 0x30, 0x3f, 0x1b, 0x00, 0x84, 0xb3, 0xab, 0xf0, 0x21, 0x6e, 0x8c, 0x1d, 0x2f, 0x24, 0x75, 0x78, 0x0a, 0x50, 0x6d, 0xc8, 0x29, 0x7e, 0xb7, 0xab, 0x58, 0x73, 0x03, 0xd9, 0x9a, 0x1f, 0x9b, 0x90, 0x7e, 0xec, 0x1a, 0x0d, 0xf8, 0x41, 0x16, 0x53, 0x57, 0xcd, 0x92, 0x6a, 140 }; 141 static const u8 dbign_5_test_vectors_adata[] = { 142 0x00, 0x0b, 0x00, 0x00, 143 0x06, 0x09, 0x2A, 0x70, 0x00, 0x02, 0x00, 0x22, 0x65, 0x4d, 0x0c, 144 }; 145 static const ec_test_case dbign_5_test_case = { 146 .name = "BIGN-BASH384/dbign384v1 5", 147 .ec_str_p = &bign384v1_str_params, 148 .priv_key = dbign_5_test_vectors_priv_key, 149 .priv_key_len = sizeof(dbign_5_test_vectors_priv_key), 150 .nn_random = NULL, 151 .hash_type = BASH384, 152 .msg = "\xb1\x94\xba\xc8\x0a\x08\xf5\x3b\x36\x6d\x00\x8e\x58\x4a\x5d\xe4\x85\x04\xfa\x9d\x1b\xb6\xc7\xac\x25\x2e\x72\xc2\x02\xfd\xce\x0d\x5b\xe3\xd6\x12\x17\xb9\x61\x81\xfe\x67\x86\xad\x71\x6b\x89\x0b\x5c\xb0\xc0\xff\x33\xc3\x56\xb8\x35\xc4\x05\xae\xd8\xe0\x7f\x99\xe1\x2b\xdc\x1a\xe2\x82\x57\xec\x70\x3f\xcc\xf0\x95\xee\x8d\xf1\xc1\xab\x76\x38\x9f\xe6\x78\xca\xf7\xc6\xf8\x60\xd5\xbb\x9c\x4f", 153 .msglen = 96, 154 .sig_type = DBIGN, 155 .exp_sig = dbign_5_test_vectors_expected_sig, 156 .exp_siglen = sizeof(dbign_5_test_vectors_expected_sig), 157 .adata = dbign_5_test_vectors_adata, 158 .adata_len = sizeof(dbign_5_test_vectors_adata) 159 }; 160 161 #endif 162 163 #if defined(WITH_HASH_BASH512) && defined(WITH_CURVE_BIGN512V1) 164 /********************************************************************/ 165 static const u8 dbign_6_test_vectors_priv_key[] = { 166 0xb8, 0xb9, 0x4a, 0xd2, 0xe5, 0x05, 0x02, 0xc5, 0x21, 0xe8, 0x8f, 0x1b, 0xcf, 0x97, 0x0b, 0x1b, 0x47, 0x78, 0x02, 0x31, 0x5b, 0xfe, 0x1f, 0x71, 0xd8, 0x55, 0x71, 0xa2, 0xd1, 0xc1, 0x90, 0x60, 0xba, 0xa2, 0xf1, 0xe0, 0x7d, 0x73, 0xd5, 0x2f, 0x37, 0x31, 0x0b, 0x04, 0x02, 0x3a, 0xbf, 0x33, 0x63, 0xb5, 0xf2, 0x95, 0x2a, 0x62, 0x17, 0xa4, 0x8a, 0x56, 0xf4, 0x3e, 0x35, 0x96, 0xc0, 0xbe, 167 }; 168 static const u8 dbign_6_test_vectors_expected_sig[] = { 169 0x6e, 0x40, 0xef, 0x8f, 0xf9, 0x9e, 0x26, 0x86, 0xc8, 0x88, 0x53, 0xbb, 0x89, 0xd4, 0xbb, 0x92, 0x33, 0xe8, 0x07, 0x36, 0x5a, 0x32, 0x57, 0x57, 0x1d, 0x53, 0x68, 0xbf, 0x5d, 0x83, 0xd1, 0x5e, 170 0x21, 0x83, 0x5b, 0xd6, 0xfa, 0x3b, 0x3d, 0xae, 0x93, 0x30, 0xc2, 0x79, 0x6c, 0x80, 0x3e, 0xee, 0xc9, 0x70, 0x3a, 0x81, 0xe7, 0x40, 0xfd, 0x6d, 0xd8, 0x51, 0xd0, 0x7d, 0xb9, 0x55, 0x72, 0x6c, 0x60, 0x86, 0x8d, 0x61, 0x4b, 0x23, 0x54, 0xe6, 0xd6, 0x4c, 0xf0, 0xd8, 0xdc, 0x9e, 0xf4, 0x79, 0x63, 0xf7, 0x0b, 0xb0, 0xd6, 0xf4, 0x21, 0x67, 0x54, 0x56, 0xbf, 0xbb, 0xb2, 0x03, 0xf2, 0x43, 171 }; 172 static const u8 dbign_6_test_vectors_adata[] = { 173 0x00, 0x0b, 0x00, 0x00, 174 0x06, 0x09, 0x2A, 0x70, 0x00, 0x02, 0x00, 0x22, 0x65, 0x4d, 0x0d, 175 }; 176 static const ec_test_case dbign_6_test_case = { 177 .name = "BIGN-BASH512/dbign512v1 6", 178 .ec_str_p = &bign512v1_str_params, 179 .priv_key = dbign_6_test_vectors_priv_key, 180 .priv_key_len = sizeof(dbign_6_test_vectors_priv_key), 181 .nn_random = NULL, 182 .hash_type = BASH512, 183 .msg = "\xb1\x94\xba\xc8\x0a\x08\xf5\x3b\x36\x6d\x00\x8e\x58\x4a\x5d\xe4\x85\x04\xfa\x9d\x1b\xb6\xc7\xac\x25\x2e\x72\xc2\x02\xfd\xce\x0d\x5b\xe3\xd6\x12\x17\xb9\x61\x81\xfe\x67\x86\xad\x71\x6b\x89\x0b\x5c\xb0\xc0\xff\x33\xc3\x56\xb8\x35\xc4\x05\xae\xd8\xe0\x7f", 184 .msglen = 63, 185 .sig_type = DBIGN, 186 .exp_sig = dbign_6_test_vectors_expected_sig, 187 .exp_siglen = sizeof(dbign_6_test_vectors_expected_sig), 188 .adata = dbign_6_test_vectors_adata, 189 .adata_len = sizeof(dbign_6_test_vectors_adata) 190 }; 191 /********************************************************************/ 192 static const u8 dbign_7_test_vectors_priv_key[] = { 193 0x33, 0x0e, 0xea, 0x5c, 0xcd, 0xc8, 0x96, 0x5a, 0x4c, 0x05, 0xfc, 0x9c, 0x44, 0xde, 0x84, 0xd4, 0x53, 0x45, 0xd8, 0xdd, 0x5e, 0x04, 0xc3, 0x02, 0xff, 0xb9, 0x35, 0x76, 0xbd, 0x20, 0x7a, 0x56, 0x6c, 0x00, 0x7c, 0x95, 0x3b, 0x1f, 0x95, 0xb9, 0x88, 0x7c, 0x2d, 0x64, 0x14, 0x7a, 0x57, 0xf1, 0xeb, 0x0f, 0xe1, 0x02, 0x3e, 0x4f, 0xd5, 0x1f, 0xb3, 0xd5, 0xa8, 0xea, 0xd4, 0x88, 0x01, 0xa9, 194 }; 195 static const u8 dbign_7_test_vectors_expected_sig[] = { 196 0x3d, 0x2e, 0x3b, 0x3e, 0x2a, 0x2a, 0xed, 0x58, 0x34, 0x7e, 0x87, 0xf2, 0x8c, 0xf8, 0xde, 0xe9, 0xd3, 0xfd, 0x6f, 0x91, 0x07, 0xe6, 0xf9, 0x0b, 0xd6, 0x75, 0x4a, 0x37, 0xe7, 0x8d, 0x8f, 0x63, 197 0xfb, 0x5c, 0xc4, 0xdc, 0x39, 0xfb, 0x56, 0x7f, 0xa8, 0x54, 0x1b, 0x7f, 0x62, 0x86, 0x42, 0x02, 0xbb, 0x53, 0x62, 0x6c, 0xb2, 0x40, 0x70, 0x14, 0xea, 0x40, 0xef, 0x04, 0xbd, 0x20, 0xae, 0x19, 0x21, 0x39, 0xae, 0x24, 0x76, 0x9b, 0x20, 0x00, 0x9b, 0x7c, 0x99, 0x75, 0x1e, 0xbc, 0xef, 0x52, 0xf6, 0xfe, 0xfa, 0xe0, 0xc3, 0xaa, 0xd8, 0xf1, 0x2e, 0x78, 0xb2, 0x5e, 0x9b, 0xcc, 0x21, 0xec, 198 }; 199 static const u8 dbign_7_test_vectors_adata[] = { 200 0x00, 0x0b, 0x00, 0x00, 201 0x06, 0x09, 0x2A, 0x70, 0x00, 0x02, 0x00, 0x22, 0x65, 0x4d, 0x0d, 202 }; 203 static const ec_test_case dbign_7_test_case = { 204 .name = "BIGN-BASH512/dbign512v1 7", 205 .ec_str_p = &bign512v1_str_params, 206 .priv_key = dbign_7_test_vectors_priv_key, 207 .priv_key_len = sizeof(dbign_7_test_vectors_priv_key), 208 .nn_random = NULL, 209 .hash_type = BASH512, 210 .msg = "\xb1\x94\xba\xc8\x0a\x08\xf5\x3b\x36\x6d\x00\x8e\x58\x4a\x5d\xe4\x85\x04\xfa\x9d\x1b\xb6\xc7\xac\x25\x2e\x72\xc2\x02\xfd\xce\x0d\x5b\xe3\xd6\x12\x17\xb9\x61\x81\xfe\x67\x86\xad\x71\x6b\x89\x0b\x5c\xb0\xc0\xff\x33\xc3\x56\xb8\x35\xc4\x05\xae\xd8\xe0\x7f\x99", 211 .msglen = 64, 212 .sig_type = DBIGN, 213 .exp_sig = dbign_7_test_vectors_expected_sig, 214 .exp_siglen = sizeof(dbign_7_test_vectors_expected_sig), 215 .adata = dbign_7_test_vectors_adata, 216 .adata_len = sizeof(dbign_7_test_vectors_adata) 217 }; 218 219 #endif 220 221 222 /************************************************/ 223 #define DBIGN_ALL_TESTS() \ 224 &dbign_1_test_case, \ 225 &dbign_2_test_case, \ 226 &dbign_3_test_case, \ 227 &dbign_4_test_case, \ 228 &dbign_5_test_case, \ 229 &dbign_6_test_case, \ 230 &dbign_7_test_case, 231 232 #endif /* __DBIGN_TEST_VECTORS_H__ */ 233