@@ -211,31 +211,39 @@ static int _ecc_issue446(void)
211
211
int err , stat = 0 ;
212
212
unsigned char hash [64 ];
213
213
unsigned long hashlen ;
214
- const unsigned char msg [] = { 0x31 ,0x32 ,0x33 ,0x34 ,0x30 ,0x30 };
214
+ const unsigned char msg1 [] = { 0x31 ,0x32 ,0x33 ,0x34 ,0x30 ,0x30 };
215
+ const unsigned char msg2 [] = { 0x36 ,0x39 ,0x38 ,0x31 ,0x39 };
215
216
const unsigned char pub [] = {
216
217
0x04 ,
217
218
0x29 ,0x27 ,0xb1 ,0x05 ,0x12 ,0xba ,0xe3 ,0xed ,0xdc ,0xfe ,0x46 ,0x78 ,0x28 ,0x12 ,0x8b ,0xad ,
218
219
0x29 ,0x03 ,0x26 ,0x99 ,0x19 ,0xf7 ,0x08 ,0x60 ,0x69 ,0xc8 ,0xc4 ,0xdf ,0x6c ,0x73 ,0x28 ,0x38 ,
219
220
0xc7 ,0x78 ,0x79 ,0x64 ,0xea ,0xac ,0x00 ,0xe5 ,0x92 ,0x1f ,0xb1 ,0x49 ,0x8a ,0x60 ,0xf4 ,0x60 ,
220
221
0x67 ,0x66 ,0xb3 ,0xd9 ,0x68 ,0x50 ,0x01 ,0x55 ,0x8d ,0x1a ,0x97 ,0x4e ,0x73 ,0x41 ,0x51 ,0x3e
221
222
};
222
- /* msg +pub+sig1 test vector is from wycheproof/ecdsa_test VALID */
223
+ /* msg1 +pub+sig1 test vector is from wycheproof/ecdsa_test VALID */
223
224
const unsigned char sig1 [] = {
224
225
0x30 ,0x45 ,0x02 ,0x20 ,0x2b ,0xa3 ,0xa8 ,0xbe ,0x6b ,0x94 ,0xd5 ,0xec ,0x80 ,0xa6 ,0xd9 ,0xd1 ,0x19 ,0x0a ,
225
226
0x43 ,0x6e ,0xff ,0xe5 ,0x0d ,0x85 ,0xa1 ,0xee ,0xe8 ,0x59 ,0xb8 ,0xcc ,0x6a ,0xf9 ,0xbd ,0x5c ,0x2e ,0x18 ,
226
227
0x02 ,0x21 ,0x00 ,0xb3 ,0x29 ,0xf4 ,0x79 ,0xa2 ,0xbb ,0xd0 ,0xa5 ,0xc3 ,0x84 ,0xee ,0x14 ,0x93 ,0xb1 ,0xf5 ,
227
228
0x18 ,0x6a ,0x87 ,0x13 ,0x9c ,0xac ,0x5d ,0xf4 ,0x08 ,0x7c ,0x13 ,0x4b ,0x49 ,0x15 ,0x68 ,0x47 ,0xdb ,
228
229
};
229
- /* msg +pub+sig2 test vector is from wycheproof/ecdsa_test INVALID (changing tag value of sequence) */
230
+ /* msg1 +pub+sig2 test vector is from wycheproof/ecdsa_test INVALID (changing tag value of sequence) */
230
231
const unsigned char sig2 [] = {
231
232
0x31 ,0x45 ,0x02 ,0x20 ,0x2b ,0xa3 ,0xa8 ,0xbe ,0x6b ,0x94 ,0xd5 ,0xec ,0x80 ,0xa6 ,0xd9 ,0xd1 ,0x19 ,0x0a ,
232
233
0x43 ,0x6e ,0xff ,0xe5 ,0x0d ,0x85 ,0xa1 ,0xee ,0xe8 ,0x59 ,0xb8 ,0xcc ,0x6a ,0xf9 ,0xbd ,0x5c ,0x2e ,0x18 ,
233
234
0x02 ,0x21 ,0x00 ,0xb3 ,0x29 ,0xf4 ,0x79 ,0xa2 ,0xbb ,0xd0 ,0xa5 ,0xc3 ,0x84 ,0xee ,0x14 ,0x93 ,0xb1 ,0xf5 ,
234
235
0x18 ,0x6a ,0x87 ,0x13 ,0x9c ,0xac ,0x5d ,0xf4 ,0x08 ,0x7c ,0x13 ,0x4b ,0x49 ,0x15 ,0x68 ,0x47 ,0xdb ,
235
236
};
237
+ /* msg2+pub+sig3 test vector is from wycheproof/ecdsa_test VALID (Edge case for Shamir multiplication) */
238
+ const unsigned char sig3 [] = {
239
+ 0x30 ,0x44 ,0x02 ,0x20 ,0x64 ,0xa1 ,0xaa ,0xb5 ,0x00 ,0x0d ,0x0e ,0x80 ,0x4f ,0x3e ,0x2f ,0xc0 ,0x2b ,0xde ,
240
+ 0xe9 ,0xbe ,0x8f ,0xf3 ,0x12 ,0x33 ,0x4e ,0x2b ,0xa1 ,0x6d ,0x11 ,0x54 ,0x7c ,0x97 ,0x71 ,0x1c ,0x89 ,0x8e ,
241
+ 0x02 ,0x20 ,0x6a ,0xf0 ,0x15 ,0x97 ,0x1c ,0xc3 ,0x0b ,0xe6 ,0xd1 ,0xa2 ,0x06 ,0xd4 ,0xe0 ,0x13 ,0xe0 ,0x99 ,
242
+ 0x77 ,0x72 ,0xa2 ,0xf9 ,0x1d ,0x73 ,0x28 ,0x6f ,0xfd ,0x68 ,0x3b ,0x9b ,0xb2 ,0xcf ,0x4f ,0x1b ,
243
+ };
236
244
237
245
hashlen = sizeof (hash );
238
- DO (hash_memory (find_hash ("sha256" ), msg , sizeof (msg ), hash , & hashlen ));
246
+ DO (hash_memory (find_hash ("sha256" ), msg1 , sizeof (msg1 ), hash , & hashlen ));
239
247
DO (ecc_find_curve ("secp256r1" , & cu ));
240
248
DO (ecc_set_curve (cu , & key ));
241
249
DO (ecc_set_key (pub , sizeof (pub ), PK_PUBLIC , & key ));
@@ -246,6 +254,11 @@ static int _ecc_issue446(void)
246
254
err = ecc_verify_hash (sig2 , sizeof (sig2 ), hash , hashlen , & stat , & key );
247
255
if (err == CRYPT_OK && stat == 1 ) return CRYPT_FAIL_TESTVECTOR ; /* expected result: INVALID */
248
256
257
+ hashlen = sizeof (hash );
258
+ DO (hash_memory (find_hash ("sha256" ), msg2 , sizeof (msg2 ), hash , & hashlen ));
259
+ DO (ecc_verify_hash (sig3 , sizeof (sig3 ), hash , hashlen , & stat , & key ));
260
+ if (stat != 1 ) return CRYPT_FAIL_TESTVECTOR ; /* expected result: VALID */
261
+
249
262
ecc_free (& key );
250
263
return CRYPT_OK ;
251
264
}
0 commit comments