7 #if defined HAVE_CONFIG_H 20 #ifdef ENABLE_OPENSSL_TESTS 21 #include "openssl/bn.h" 22 #include "openssl/ec.h" 23 #include "openssl/ecdsa.h" 24 #include "openssl/obj_mac.h" 30 #if !defined(VG_CHECK) 31 # if defined(VALGRIND) 32 # include <valgrind/memcheck.h> 33 # define VG_UNDEF(x,y) VALGRIND_MAKE_MEM_UNDEFINED((x),(y)) 34 # define VG_CHECK(x,y) VALGRIND_CHECK_MEM_IS_DEFINED((x),(y)) 36 # define VG_UNDEF(x,y) 37 # define VG_CHECK(x,y) 62 unsigned char b32[32];
112 unsigned char b32[32];
125 unsigned char b32[32];
139 unsigned char ctmp[32];
193 CHECK(ecount2 == 10);
195 CHECK(ecount2 == 11);
199 CHECK(ecount2 == 12);
203 CHECK(ecount2 == 13);
209 CHECK(ecount2 == 13);
242 static const char *inputs[8] = {
243 "",
"abc",
"message digest",
"secure hash algorithm",
"SHA256 is considered to be safe",
244 "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
245 "For this sample, this 63-byte string will be used as input data",
246 "This is exactly 64 bytes long, not counting the terminating byte" 248 static const unsigned char outputs[8][32] = {
249 {0xe3, 0xb0, 0xc4, 0x42, 0x98, 0xfc, 0x1c, 0x14, 0x9a, 0xfb, 0xf4, 0xc8, 0x99, 0x6f, 0xb9, 0x24, 0x27, 0xae, 0x41, 0xe4, 0x64, 0x9b, 0x93, 0x4c, 0xa4, 0x95, 0x99, 0x1b, 0x78, 0x52, 0xb8, 0x55},
250 {0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea, 0x41, 0x41, 0x40, 0xde, 0x5d, 0xae, 0x22, 0x23, 0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c, 0xb4, 0x10, 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad},
251 {0xf7, 0x84, 0x6f, 0x55, 0xcf, 0x23, 0xe1, 0x4e, 0xeb, 0xea, 0xb5, 0xb4, 0xe1, 0x55, 0x0c, 0xad, 0x5b, 0x50, 0x9e, 0x33, 0x48, 0xfb, 0xc4, 0xef, 0xa3, 0xa1, 0x41, 0x3d, 0x39, 0x3c, 0xb6, 0x50},
252 {0xf3, 0x0c, 0xeb, 0x2b, 0xb2, 0x82, 0x9e, 0x79, 0xe4, 0xca, 0x97, 0x53, 0xd3, 0x5a, 0x8e, 0xcc, 0x00, 0x26, 0x2d, 0x16, 0x4c, 0xc0, 0x77, 0x08, 0x02, 0x95, 0x38, 0x1c, 0xbd, 0x64, 0x3f, 0x0d},
253 {0x68, 0x19, 0xd9, 0x15, 0xc7, 0x3f, 0x4d, 0x1e, 0x77, 0xe4, 0xe1, 0xb5, 0x2d, 0x1f, 0xa0, 0xf9, 0xcf, 0x9b, 0xea, 0xea, 0xd3, 0x93, 0x9f, 0x15, 0x87, 0x4b, 0xd9, 0x88, 0xe2, 0xa2, 0x36, 0x30},
254 {0x24, 0x8d, 0x6a, 0x61, 0xd2, 0x06, 0x38, 0xb8, 0xe5, 0xc0, 0x26, 0x93, 0x0c, 0x3e, 0x60, 0x39, 0xa3, 0x3c, 0xe4, 0x59, 0x64, 0xff, 0x21, 0x67, 0xf6, 0xec, 0xed, 0xd4, 0x19, 0xdb, 0x06, 0xc1},
255 {0xf0, 0x8a, 0x78, 0xcb, 0xba, 0xee, 0x08, 0x2b, 0x05, 0x2a, 0xe0, 0x70, 0x8f, 0x32, 0xfa, 0x1e, 0x50, 0xc5, 0xc4, 0x21, 0xaa, 0x77, 0x2b, 0xa5, 0xdb, 0xb4, 0x06, 0xa2, 0xea, 0x6b, 0xe3, 0x42},
256 {0xab, 0x64, 0xef, 0xf7, 0xe8, 0x8e, 0x2e, 0x46, 0x16, 0x5e, 0x29, 0xf2, 0xbc, 0xe4, 0x18, 0x26, 0xbd, 0x4c, 0x7b, 0x35, 0x52, 0xf6, 0xb3, 0x82, 0xa9, 0xe7, 0xd3, 0xaf, 0x47, 0xc2, 0x45, 0xf8}
259 for (i = 0; i < 8; i++) {
260 unsigned char out[32];
265 CHECK(memcmp(
out, outputs[i], 32) == 0);
266 if (strlen(inputs[i]) > 0) {
272 CHECK(memcmp(
out, outputs[i], 32) == 0);
278 static const char *keys[6] = {
279 "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b",
281 "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa",
282 "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19",
283 "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa",
284 "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" 286 static const char *inputs[6] = {
287 "\x48\x69\x20\x54\x68\x65\x72\x65",
288 "\x77\x68\x61\x74\x20\x64\x6f\x20\x79\x61\x20\x77\x61\x6e\x74\x20\x66\x6f\x72\x20\x6e\x6f\x74\x68\x69\x6e\x67\x3f",
289 "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd",
290 "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd",
291 "\x54\x65\x73\x74\x20\x55\x73\x69\x6e\x67\x20\x4c\x61\x72\x67\x65\x72\x20\x54\x68\x61\x6e\x20\x42\x6c\x6f\x63\x6b\x2d\x53\x69\x7a\x65\x20\x4b\x65\x79\x20\x2d\x20\x48\x61\x73\x68\x20\x4b\x65\x79\x20\x46\x69\x72\x73\x74",
292 "\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x74\x65\x73\x74\x20\x75\x73\x69\x6e\x67\x20\x61\x20\x6c\x61\x72\x67\x65\x72\x20\x74\x68\x61\x6e\x20\x62\x6c\x6f\x63\x6b\x2d\x73\x69\x7a\x65\x20\x6b\x65\x79\x20\x61\x6e\x64\x20\x61\x20\x6c\x61\x72\x67\x65\x72\x20\x74\x68\x61\x6e\x20\x62\x6c\x6f\x63\x6b\x2d\x73\x69\x7a\x65\x20\x64\x61\x74\x61\x2e\x20\x54\x68\x65\x20\x6b\x65\x79\x20\x6e\x65\x65\x64\x73\x20\x74\x6f\x20\x62\x65\x20\x68\x61\x73\x68\x65\x64\x20\x62\x65\x66\x6f\x72\x65\x20\x62\x65\x69\x6e\x67\x20\x75\x73\x65\x64\x20\x62\x79\x20\x74\x68\x65\x20\x48\x4d\x41\x43\x20\x61\x6c\x67\x6f\x72\x69\x74\x68\x6d\x2e" 294 static const unsigned char outputs[6][32] = {
295 {0xb0, 0x34, 0x4c, 0x61, 0xd8, 0xdb, 0x38, 0x53, 0x5c, 0xa8, 0xaf, 0xce, 0xaf, 0x0b, 0xf1, 0x2b, 0x88, 0x1d, 0xc2, 0x00, 0xc9, 0x83, 0x3d, 0xa7, 0x26, 0xe9, 0x37, 0x6c, 0x2e, 0x32, 0xcf, 0xf7},
296 {0x5b, 0xdc, 0xc1, 0x46, 0xbf, 0x60, 0x75, 0x4e, 0x6a, 0x04, 0x24, 0x26, 0x08, 0x95, 0x75, 0xc7, 0x5a, 0x00, 0x3f, 0x08, 0x9d, 0x27, 0x39, 0x83, 0x9d, 0xec, 0x58, 0xb9, 0x64, 0xec, 0x38, 0x43},
297 {0x77, 0x3e, 0xa9, 0x1e, 0x36, 0x80, 0x0e, 0x46, 0x85, 0x4d, 0xb8, 0xeb, 0xd0, 0x91, 0x81, 0xa7, 0x29, 0x59, 0x09, 0x8b, 0x3e, 0xf8, 0xc1, 0x22, 0xd9, 0x63, 0x55, 0x14, 0xce, 0xd5, 0x65, 0xfe},
298 {0x82, 0x55, 0x8a, 0x38, 0x9a, 0x44, 0x3c, 0x0e, 0xa4, 0xcc, 0x81, 0x98, 0x99, 0xf2, 0x08, 0x3a, 0x85, 0xf0, 0xfa, 0xa3, 0xe5, 0x78, 0xf8, 0x07, 0x7a, 0x2e, 0x3f, 0xf4, 0x67, 0x29, 0x66, 0x5b},
299 {0x60, 0xe4, 0x31, 0x59, 0x1e, 0xe0, 0xb6, 0x7f, 0x0d, 0x8a, 0x26, 0xaa, 0xcb, 0xf5, 0xb7, 0x7f, 0x8e, 0x0b, 0xc6, 0x21, 0x37, 0x28, 0xc5, 0x14, 0x05, 0x46, 0x04, 0x0f, 0x0e, 0xe3, 0x7f, 0x54},
300 {0x9b, 0x09, 0xff, 0xa7, 0x1b, 0x94, 0x2f, 0xcb, 0x27, 0x63, 0x5f, 0xbc, 0xd5, 0xb0, 0xe9, 0x44, 0xbf, 0xdc, 0x63, 0x64, 0x4f, 0x07, 0x13, 0x93, 0x8a, 0x7f, 0x51, 0x53, 0x5c, 0x3a, 0x35, 0xe2}
303 for (i = 0; i < 6; i++) {
305 unsigned char out[32];
309 CHECK(memcmp(
out, outputs[i], 32) == 0);
310 if (strlen(inputs[i]) > 0) {
316 CHECK(memcmp(
out, outputs[i], 32) == 0);
322 static const unsigned char key1[65] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x00, 0x4b, 0xf5, 0x12, 0x2f, 0x34, 0x45, 0x54, 0xc5, 0x3b, 0xde, 0x2e, 0xbb, 0x8c, 0xd2, 0xb7, 0xe3, 0xd1, 0x60, 0x0a, 0xd6, 0x31, 0xc3, 0x85, 0xa5, 0xd7, 0xcc, 0xe2, 0x3c, 0x77, 0x85, 0x45, 0x9a, 0};
323 static const unsigned char out1[3][32] = {
324 {0x4f, 0xe2, 0x95, 0x25, 0xb2, 0x08, 0x68, 0x09, 0x15, 0x9a, 0xcd, 0xf0, 0x50, 0x6e, 0xfb, 0x86, 0xb0, 0xec, 0x93, 0x2c, 0x7b, 0xa4, 0x42, 0x56, 0xab, 0x32, 0x1e, 0x42, 0x1e, 0x67, 0xe9, 0xfb},
325 {0x2b, 0xf0, 0xff, 0xf1, 0xd3, 0xc3, 0x78, 0xa2, 0x2d, 0xc5, 0xde, 0x1d, 0x85, 0x65, 0x22, 0x32, 0x5c, 0x65, 0xb5, 0x04, 0x49, 0x1a, 0x0c, 0xbd, 0x01, 0xcb, 0x8f, 0x3a, 0xa6, 0x7f, 0xfd, 0x4a},
326 {0xf5, 0x28, 0xb4, 0x10, 0xcb, 0x54, 0x1f, 0x77, 0x00, 0x0d, 0x7a, 0xfb, 0x6c, 0x5b, 0x53, 0xc5, 0xc4, 0x71, 0xea, 0xb4, 0x3e, 0x46, 0x6d, 0x9a, 0xc5, 0x19, 0x0c, 0x39, 0xc8, 0x2f, 0xd8, 0x2e}
329 static const unsigned char key2[64] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe3, 0xb0, 0xc4, 0x42, 0x98, 0xfc, 0x1c, 0x14, 0x9a, 0xfb, 0xf4, 0xc8, 0x99, 0x6f, 0xb9, 0x24, 0x27, 0xae, 0x41, 0xe4, 0x64, 0x9b, 0x93, 0x4c, 0xa4, 0x95, 0x99, 0x1b, 0x78, 0x52, 0xb8, 0x55};
330 static const unsigned char out2[3][32] = {
331 {0x9c, 0x23, 0x6c, 0x16, 0x5b, 0x82, 0xae, 0x0c, 0xd5, 0x90, 0x65, 0x9e, 0x10, 0x0b, 0x6b, 0xab, 0x30, 0x36, 0xe7, 0xba, 0x8b, 0x06, 0x74, 0x9b, 0xaf, 0x69, 0x81, 0xe1, 0x6f, 0x1a, 0x2b, 0x95},
332 {0xdf, 0x47, 0x10, 0x61, 0x62, 0x5b, 0xc0, 0xea, 0x14, 0xb6, 0x82, 0xfe, 0xee, 0x2c, 0x9c, 0x02, 0xf2, 0x35, 0xda, 0x04, 0x20, 0x4c, 0x1d, 0x62, 0xa1, 0x53, 0x6c, 0x6e, 0x17, 0xae, 0xd7, 0xa9},
333 {0x75, 0x97, 0x88, 0x7c, 0xbd, 0x76, 0x32, 0x1f, 0x32, 0xe3, 0x04, 0x40, 0x67, 0x9a, 0x22, 0xcf, 0x7f, 0x8d, 0x9d, 0x2e, 0xac, 0x39, 0x0e, 0x58, 0x1f, 0xea, 0x09, 0x1c, 0xe2, 0x02, 0xba, 0x94}
337 unsigned char out[32];
341 for (i = 0; i < 3; i++) {
343 CHECK(memcmp(
out, out1[i], 32) == 0);
348 for (i = 0; i < 3; i++) {
350 CHECK(memcmp(
out, out1[i], 32) != 0);
355 for (i = 0; i < 3; i++) {
357 CHECK(memcmp(
out, out2[i], 32) == 0);
367 static const unsigned int rounds[7] = {1, 30, 73, 156, 322, 653, 1316};
370 static const uint32_t mults[6] = {1, 3, 21, 289, 0x9999, 0x80402011};
372 unsigned int usebits = bits > 6 ? 6 : bits;
373 unsigned int maxshift = bits - usebits;
376 uint64_t x[6][27] = {{0}};
377 unsigned int i, shift,
m;
380 for (i = 0; i < rounds[usebits]; i++) {
382 CHECK((((uint64_t)r) >> bits) == 0);
383 for (
m = 0;
m <
sizeof(mults) /
sizeof(mults[0]);
m++) {
384 uint32_t rm = r * mults[
m];
385 for (shift = 0; shift <= maxshift; shift++) {
386 x[
m][shift] |= (((uint64_t)1) << ((rm >> shift) & ((1 << usebits) - 1)));
390 for (
m = 0;
m <
sizeof(mults) /
sizeof(mults[0]);
m++) {
391 for (shift = 0; shift <= maxshift; shift++) {
393 CHECK(((~x[
m][shift]) << (64 - (1 << usebits))) == 0);
401 int rounds = (subrange * 2073) / 100;
404 CHECK((range % subrange) == 0);
405 for (i = 0; i < rounds; i++) {
409 x |= (((uint64_t)1) << r);
412 CHECK(((~x) << (64 - subrange)) == 0);
418 for (b = 1; b <= 32; b++) {
424 static const uint32_t ms[] = {1, 3, 17, 1000, 13771, 999999, 33554432};
425 static const uint32_t ss[] = {1, 3, 6, 9, 13, 31, 64};
427 for (
m = 0;
m <
sizeof(ms) /
sizeof(ms[0]);
m++) {
428 for (s = 0; s <
sizeof(ss) /
sizeof(ss[0]); s++) {
505 for (i = 0; i < 100*
count; i++) {
549 for (i = 0; i < 256; i += 4) {
553 for (j = 0; j < 4; j++) {
574 for (j = 0; j < now; j++) {
645 unsigned char cone[1] = {0x01};
662 for (i = 0; i < 100; ++i) {
665 int expected = r.
d[0] % (1 << shift);
711 for (i = 0; i < bit; i++) {
801 for (i = 0; i < 128 *
count; i++) {
822 unsigned char bin[32];
827 CHECK(overflow == 1);
835 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL,
836 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL
854 #if defined(USE_SCALAR_INV_NUM) 858 unsigned char chal[32][2][32] = {
859 {{0xff, 0xff, 0x03, 0x07, 0x00, 0x00, 0x00, 0x00,
860 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03,
861 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff,
862 0xff, 0xff, 0x03, 0x00, 0xc0, 0xff, 0xff, 0xff},
863 {0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00,
864 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8,
865 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
866 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff}},
867 {{0xef, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00,
868 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00,
869 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
870 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
871 {0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
872 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0,
873 0xff, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff,
874 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x80, 0xff}},
875 {{0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
876 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00,
877 0x80, 0x00, 0x00, 0x80, 0xff, 0x3f, 0x00, 0x00,
878 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0x00},
879 {0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0x80,
880 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0xe0,
881 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00,
882 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff}},
883 {{0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
884 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x80,
885 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
886 0x00, 0x1e, 0xf8, 0xff, 0xff, 0xff, 0xfd, 0xff},
887 {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f,
888 0x00, 0x00, 0x00, 0xf8, 0xff, 0x03, 0x00, 0xe0,
889 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff,
890 0xf3, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00}},
891 {{0x80, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0x00,
892 0x00, 0x1c, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
893 0xff, 0xff, 0xff, 0xe0, 0xff, 0xff, 0xff, 0x00,
894 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff},
895 {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00,
896 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
897 0xff, 0x1f, 0x00, 0x00, 0x80, 0xff, 0xff, 0x3f,
898 0x00, 0xfe, 0xff, 0xff, 0xff, 0xdf, 0xff, 0xff}},
899 {{0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, 0xfc, 0x9f,
900 0xff, 0xff, 0xff, 0x00, 0x80, 0x00, 0x00, 0x80,
901 0xff, 0x0f, 0xfc, 0xff, 0x7f, 0x00, 0x00, 0x00,
902 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00},
903 {0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
904 0x00, 0x00, 0xf8, 0xff, 0x0f, 0xc0, 0xff, 0xff,
905 0xff, 0x1f, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff,
906 0xff, 0xff, 0xff, 0x07, 0x80, 0xff, 0xff, 0xff}},
907 {{0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00,
908 0x80, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff,
909 0xf7, 0xff, 0xff, 0xef, 0xff, 0xff, 0xff, 0x00,
910 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xf0},
911 {0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff,
912 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00,
913 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff,
914 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}},
915 {{0x00, 0xf8, 0xff, 0x03, 0xff, 0xff, 0xff, 0x00,
916 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
917 0x80, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff,
918 0xff, 0xff, 0x03, 0xc0, 0xff, 0x0f, 0xfc, 0xff},
919 {0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0xff, 0xff,
920 0xff, 0x01, 0x00, 0x00, 0x00, 0x3f, 0x00, 0xc0,
921 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
922 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}},
923 {{0x8f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
924 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff,
925 0xff, 0x7f, 0x00, 0x00, 0x80, 0x00, 0x00, 0x80,
926 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00},
927 {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
928 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
929 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
930 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
931 {{0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff,
932 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
933 0xff, 0xff, 0x03, 0x00, 0x80, 0x00, 0x00, 0x80,
934 0xff, 0xff, 0xff, 0x00, 0x00, 0x80, 0xff, 0x7f},
935 {0xff, 0xcf, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00,
936 0x00, 0xc0, 0xff, 0xcf, 0xff, 0xff, 0xff, 0xff,
937 0xbf, 0xff, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00,
938 0x80, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00}},
939 {{0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff,
940 0xff, 0xff, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff,
941 0xff, 0xff, 0xff, 0x00, 0x80, 0x00, 0x00, 0x80,
942 0xff, 0x01, 0xfc, 0xff, 0x01, 0x00, 0xfe, 0xff},
943 {0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00,
944 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
945 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0,
946 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00}},
947 {{0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
948 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
949 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
950 0x7f, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x80},
951 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
952 0x00, 0xf8, 0xff, 0x01, 0x00, 0xf0, 0xff, 0xff,
953 0xe0, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00,
954 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
955 {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
956 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
957 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
958 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0x00},
959 {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00,
960 0xfc, 0xff, 0xff, 0x3f, 0xf0, 0xff, 0xff, 0x3f,
961 0x00, 0x00, 0xf8, 0x07, 0x00, 0x00, 0x00, 0xff,
962 0xff, 0xff, 0xff, 0xff, 0x0f, 0x7e, 0x00, 0x00}},
963 {{0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
964 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x80,
965 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
966 0xff, 0xff, 0x1f, 0x00, 0x00, 0xfe, 0x07, 0x00},
967 {0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff,
968 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
969 0xff, 0xfb, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00,
970 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60}},
971 {{0xff, 0x01, 0x00, 0xff, 0xff, 0xff, 0x0f, 0x00,
972 0x80, 0x7f, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x03,
973 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
974 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
975 {0xff, 0xff, 0x1f, 0x00, 0xf0, 0xff, 0xff, 0xff,
976 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
977 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
978 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00}},
979 {{0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
980 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
981 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
982 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
983 {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
984 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf1, 0xff,
985 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03,
986 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff}},
987 {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
988 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
989 0xc0, 0xff, 0xff, 0xcf, 0xff, 0x1f, 0x00, 0x00,
990 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80},
991 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
992 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff,
993 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x7e,
994 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
995 {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
996 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff,
997 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
998 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00},
999 {0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
1000 0xff, 0xff, 0x7f, 0x00, 0x80, 0x00, 0x00, 0x00,
1001 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
1002 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff}},
1003 {{0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x80,
1004 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
1005 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
1006 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00},
1007 {0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1008 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x80,
1009 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff,
1010 0xff, 0x7f, 0xf8, 0xff, 0xff, 0x1f, 0x00, 0xfe}},
1011 {{0xff, 0xff, 0xff, 0x3f, 0xf8, 0xff, 0xff, 0xff,
1012 0xff, 0x03, 0xfe, 0x01, 0x00, 0x00, 0x00, 0x00,
1013 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1014 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07},
1015 {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
1016 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
1017 0xff, 0xff, 0xff, 0xff, 0x01, 0x80, 0xff, 0xff,
1018 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00}},
1019 {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1020 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1021 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1022 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
1023 {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1024 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe,
1025 0xba, 0xae, 0xdc, 0xe6, 0xaf, 0x48, 0xa0, 0x3b,
1026 0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41, 0x40}},
1027 {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1028 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1029 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1030 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01},
1031 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1032 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1033 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1034 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
1035 {{0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1036 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1037 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1038 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
1039 {0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1040 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1041 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1042 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}},
1043 {{0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xc0,
1044 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1045 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff,
1046 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f},
1047 {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00,
1048 0xf0, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00,
1049 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff,
1050 0xff, 0xff, 0xff, 0xff, 0x01, 0xff, 0xff, 0xff}},
1051 {{0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1052 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1053 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1054 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
1055 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1056 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1057 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1058 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02}},
1059 {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1060 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe,
1061 0xba, 0xae, 0xdc, 0xe6, 0xaf, 0x48, 0xa0, 0x3b,
1062 0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41, 0x40},
1063 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1064 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1065 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1066 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}},
1067 {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1068 0x7e, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x07, 0x00,
1069 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
1070 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
1071 {0xff, 0x01, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff,
1072 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x80,
1073 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00,
1074 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}},
1075 {{0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x00,
1076 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
1077 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01,
1078 0x80, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff},
1079 {0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff,
1080 0xff, 0xff, 0x3f, 0x00, 0xf8, 0xff, 0xff, 0xff,
1081 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1082 0xff, 0x3f, 0x00, 0x00, 0xc0, 0xf1, 0x7f, 0x00}},
1083 {{0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
1084 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff,
1085 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
1086 0x80, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0x00},
1087 {0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01,
1088 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff,
1089 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x80, 0x1f,
1090 0x00, 0x00, 0xfc, 0xff, 0xff, 0x01, 0xff, 0xff}},
1091 {{0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
1092 0x80, 0x00, 0x00, 0x80, 0xff, 0x03, 0xe0, 0x01,
1093 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xfc, 0xff,
1094 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00},
1095 {0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
1096 0xfe, 0xff, 0xff, 0xf0, 0x07, 0x00, 0x3c, 0x80,
1097 0xff, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff,
1098 0xff, 0xff, 0x07, 0xe0, 0xff, 0x00, 0x00, 0x00}},
1099 {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
1100 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1101 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0xf8,
1102 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x80},
1103 {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1104 0xff, 0xff, 0xff, 0xff, 0xff, 0x0c, 0x80, 0x00,
1105 0x00, 0x00, 0x00, 0xc0, 0x7f, 0xfe, 0xff, 0x1f,
1106 0x00, 0xfe, 0xff, 0x03, 0x00, 0x00, 0xfe, 0xff}},
1107 {{0xff, 0xff, 0x81, 0xff, 0xff, 0xff, 0xff, 0x00,
1108 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x83,
1109 0xff, 0xff, 0x00, 0x00, 0x80, 0x00, 0x00, 0x80,
1110 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0xf0},
1111 {0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff,
1112 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00,
1113 0xf8, 0x07, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff,
1114 0xff, 0xc7, 0xff, 0xff, 0xe0, 0xff, 0xff, 0xff}}
1116 unsigned char res[32][2][32] = {
1117 {{0x0c, 0x3b, 0x0a, 0xca, 0x8d, 0x1a, 0x2f, 0xb9,
1118 0x8a, 0x7b, 0x53, 0x5a, 0x1f, 0xc5, 0x22, 0xa1,
1119 0x07, 0x2a, 0x48, 0xea, 0x02, 0xeb, 0xb3, 0xd6,
1120 0x20, 0x1e, 0x86, 0xd0, 0x95, 0xf6, 0x92, 0x35},
1121 {0xdc, 0x90, 0x7a, 0x07, 0x2e, 0x1e, 0x44, 0x6d,
1122 0xf8, 0x15, 0x24, 0x5b, 0x5a, 0x96, 0x37, 0x9c,
1123 0x37, 0x7b, 0x0d, 0xac, 0x1b, 0x65, 0x58, 0x49,
1124 0x43, 0xb7, 0x31, 0xbb, 0xa7, 0xf4, 0x97, 0x15}},
1125 {{0xf1, 0xf7, 0x3a, 0x50, 0xe6, 0x10, 0xba, 0x22,
1126 0x43, 0x4d, 0x1f, 0x1f, 0x7c, 0x27, 0xca, 0x9c,
1127 0xb8, 0xb6, 0xa0, 0xfc, 0xd8, 0xc0, 0x05, 0x2f,
1128 0xf7, 0x08, 0xe1, 0x76, 0xdd, 0xd0, 0x80, 0xc8},
1129 {0xe3, 0x80, 0x80, 0xb8, 0xdb, 0xe3, 0xa9, 0x77,
1130 0x00, 0xb0, 0xf5, 0x2e, 0x27, 0xe2, 0x68, 0xc4,
1131 0x88, 0xe8, 0x04, 0xc1, 0x12, 0xbf, 0x78, 0x59,
1132 0xe6, 0xa9, 0x7c, 0xe1, 0x81, 0xdd, 0xb9, 0xd5}},
1133 {{0x96, 0xe2, 0xee, 0x01, 0xa6, 0x80, 0x31, 0xef,
1134 0x5c, 0xd0, 0x19, 0xb4, 0x7d, 0x5f, 0x79, 0xab,
1135 0xa1, 0x97, 0xd3, 0x7e, 0x33, 0xbb, 0x86, 0x55,
1136 0x60, 0x20, 0x10, 0x0d, 0x94, 0x2d, 0x11, 0x7c},
1137 {0xcc, 0xab, 0xe0, 0xe8, 0x98, 0x65, 0x12, 0x96,
1138 0x38, 0x5a, 0x1a, 0xf2, 0x85, 0x23, 0x59, 0x5f,
1139 0xf9, 0xf3, 0xc2, 0x81, 0x70, 0x92, 0x65, 0x12,
1140 0x9c, 0x65, 0x1e, 0x96, 0x00, 0xef, 0xe7, 0x63}},
1141 {{0xac, 0x1e, 0x62, 0xc2, 0x59, 0xfc, 0x4e, 0x5c,
1142 0x83, 0xb0, 0xd0, 0x6f, 0xce, 0x19, 0xf6, 0xbf,
1143 0xa4, 0xb0, 0xe0, 0x53, 0x66, 0x1f, 0xbf, 0xc9,
1144 0x33, 0x47, 0x37, 0xa9, 0x3d, 0x5d, 0xb0, 0x48},
1145 {0x86, 0xb9, 0x2a, 0x7f, 0x8e, 0xa8, 0x60, 0x42,
1146 0x26, 0x6d, 0x6e, 0x1c, 0xa2, 0xec, 0xe0, 0xe5,
1147 0x3e, 0x0a, 0x33, 0xbb, 0x61, 0x4c, 0x9f, 0x3c,
1148 0xd1, 0xdf, 0x49, 0x33, 0xcd, 0x72, 0x78, 0x18}},
1149 {{0xf7, 0xd3, 0xcd, 0x49, 0x5c, 0x13, 0x22, 0xfb,
1150 0x2e, 0xb2, 0x2f, 0x27, 0xf5, 0x8a, 0x5d, 0x74,
1151 0xc1, 0x58, 0xc5, 0xc2, 0x2d, 0x9f, 0x52, 0xc6,
1152 0x63, 0x9f, 0xba, 0x05, 0x76, 0x45, 0x7a, 0x63},
1153 {0x8a, 0xfa, 0x55, 0x4d, 0xdd, 0xa3, 0xb2, 0xc3,
1154 0x44, 0xfd, 0xec, 0x72, 0xde, 0xef, 0xc0, 0x99,
1155 0xf5, 0x9f, 0xe2, 0x52, 0xb4, 0x05, 0x32, 0x58,
1156 0x57, 0xc1, 0x8f, 0xea, 0xc3, 0x24, 0x5b, 0x94}},
1157 {{0x05, 0x83, 0xee, 0xdd, 0x64, 0xf0, 0x14, 0x3b,
1158 0xa0, 0x14, 0x4a, 0x3a, 0x41, 0x82, 0x7c, 0xa7,
1159 0x2c, 0xaa, 0xb1, 0x76, 0xbb, 0x59, 0x64, 0x5f,
1160 0x52, 0xad, 0x25, 0x29, 0x9d, 0x8f, 0x0b, 0xb0},
1161 {0x7e, 0xe3, 0x7c, 0xca, 0xcd, 0x4f, 0xb0, 0x6d,
1162 0x7a, 0xb2, 0x3e, 0xa0, 0x08, 0xb9, 0xa8, 0x2d,
1163 0xc2, 0xf4, 0x99, 0x66, 0xcc, 0xac, 0xd8, 0xb9,
1164 0x72, 0x2a, 0x4a, 0x3e, 0x0f, 0x7b, 0xbf, 0xf4}},
1165 {{0x8c, 0x9c, 0x78, 0x2b, 0x39, 0x61, 0x7e, 0xf7,
1166 0x65, 0x37, 0x66, 0x09, 0x38, 0xb9, 0x6f, 0x70,
1167 0x78, 0x87, 0xff, 0xcf, 0x93, 0xca, 0x85, 0x06,
1168 0x44, 0x84, 0xa7, 0xfe, 0xd3, 0xa4, 0xe3, 0x7e},
1169 {0xa2, 0x56, 0x49, 0x23, 0x54, 0xa5, 0x50, 0xe9,
1170 0x5f, 0xf0, 0x4d, 0xe7, 0xdc, 0x38, 0x32, 0x79,
1171 0x4f, 0x1c, 0xb7, 0xe4, 0xbb, 0xf8, 0xbb, 0x2e,
1172 0x40, 0x41, 0x4b, 0xcc, 0xe3, 0x1e, 0x16, 0x36}},
1173 {{0x0c, 0x1e, 0xd7, 0x09, 0x25, 0x40, 0x97, 0xcb,
1174 0x5c, 0x46, 0xa8, 0xda, 0xef, 0x25, 0xd5, 0xe5,
1175 0x92, 0x4d, 0xcf, 0xa3, 0xc4, 0x5d, 0x35, 0x4a,
1176 0xe4, 0x61, 0x92, 0xf3, 0xbf, 0x0e, 0xcd, 0xbe},
1177 {0xe4, 0xaf, 0x0a, 0xb3, 0x30, 0x8b, 0x9b, 0x48,
1178 0x49, 0x43, 0xc7, 0x64, 0x60, 0x4a, 0x2b, 0x9e,
1179 0x95, 0x5f, 0x56, 0xe8, 0x35, 0xdc, 0xeb, 0xdc,
1180 0xc7, 0xc4, 0xfe, 0x30, 0x40, 0xc7, 0xbf, 0xa4}},
1181 {{0xd4, 0xa0, 0xf5, 0x81, 0x49, 0x6b, 0xb6, 0x8b,
1182 0x0a, 0x69, 0xf9, 0xfe, 0xa8, 0x32, 0xe5, 0xe0,
1183 0xa5, 0xcd, 0x02, 0x53, 0xf9, 0x2c, 0xe3, 0x53,
1184 0x83, 0x36, 0xc6, 0x02, 0xb5, 0xeb, 0x64, 0xb8},
1185 {0x1d, 0x42, 0xb9, 0xf9, 0xe9, 0xe3, 0x93, 0x2c,
1186 0x4c, 0xee, 0x6c, 0x5a, 0x47, 0x9e, 0x62, 0x01,
1187 0x6b, 0x04, 0xfe, 0xa4, 0x30, 0x2b, 0x0d, 0x4f,
1188 0x71, 0x10, 0xd3, 0x55, 0xca, 0xf3, 0x5e, 0x80}},
1189 {{0x77, 0x05, 0xf6, 0x0c, 0x15, 0x9b, 0x45, 0xe7,
1190 0xb9, 0x11, 0xb8, 0xf5, 0xd6, 0xda, 0x73, 0x0c,
1191 0xda, 0x92, 0xea, 0xd0, 0x9d, 0xd0, 0x18, 0x92,
1192 0xce, 0x9a, 0xaa, 0xee, 0x0f, 0xef, 0xde, 0x30},
1193 {0xf1, 0xf1, 0xd6, 0x9b, 0x51, 0xd7, 0x77, 0x62,
1194 0x52, 0x10, 0xb8, 0x7a, 0x84, 0x9d, 0x15, 0x4e,
1195 0x07, 0xdc, 0x1e, 0x75, 0x0d, 0x0c, 0x3b, 0xdb,
1196 0x74, 0x58, 0x62, 0x02, 0x90, 0x54, 0x8b, 0x43}},
1197 {{0xa6, 0xfe, 0x0b, 0x87, 0x80, 0x43, 0x67, 0x25,
1198 0x57, 0x5d, 0xec, 0x40, 0x50, 0x08, 0xd5, 0x5d,
1199 0x43, 0xd7, 0xe0, 0xaa, 0xe0, 0x13, 0xb6, 0xb0,
1200 0xc0, 0xd4, 0xe5, 0x0d, 0x45, 0x83, 0xd6, 0x13},
1201 {0x40, 0x45, 0x0a, 0x92, 0x31, 0xea, 0x8c, 0x60,
1202 0x8c, 0x1f, 0xd8, 0x76, 0x45, 0xb9, 0x29, 0x00,
1203 0x26, 0x32, 0xd8, 0xa6, 0x96, 0x88, 0xe2, 0xc4,
1204 0x8b, 0xdb, 0x7f, 0x17, 0x87, 0xcc, 0xc8, 0xf2}},
1205 {{0xc2, 0x56, 0xe2, 0xb6, 0x1a, 0x81, 0xe7, 0x31,
1206 0x63, 0x2e, 0xbb, 0x0d, 0x2f, 0x81, 0x67, 0xd4,
1207 0x22, 0xe2, 0x38, 0x02, 0x25, 0x97, 0xc7, 0x88,
1208 0x6e, 0xdf, 0xbe, 0x2a, 0xa5, 0x73, 0x63, 0xaa},
1209 {0x50, 0x45, 0xe2, 0xc3, 0xbd, 0x89, 0xfc, 0x57,
1210 0xbd, 0x3c, 0xa3, 0x98, 0x7e, 0x7f, 0x36, 0x38,
1211 0x92, 0x39, 0x1f, 0x0f, 0x81, 0x1a, 0x06, 0x51,
1212 0x1f, 0x8d, 0x6a, 0xff, 0x47, 0x16, 0x06, 0x9c}},
1213 {{0x33, 0x95, 0xa2, 0x6f, 0x27, 0x5f, 0x9c, 0x9c,
1214 0x64, 0x45, 0xcb, 0xd1, 0x3c, 0xee, 0x5e, 0x5f,
1215 0x48, 0xa6, 0xaf, 0xe3, 0x79, 0xcf, 0xb1, 0xe2,
1216 0xbf, 0x55, 0x0e, 0xa2, 0x3b, 0x62, 0xf0, 0xe4},
1217 {0x14, 0xe8, 0x06, 0xe3, 0xbe, 0x7e, 0x67, 0x01,
1218 0xc5, 0x21, 0x67, 0xd8, 0x54, 0xb5, 0x7f, 0xa4,
1219 0xf9, 0x75, 0x70, 0x1c, 0xfd, 0x79, 0xdb, 0x86,
1220 0xad, 0x37, 0x85, 0x83, 0x56, 0x4e, 0xf0, 0xbf}},
1221 {{0xbc, 0xa6, 0xe0, 0x56, 0x4e, 0xef, 0xfa, 0xf5,
1222 0x1d, 0x5d, 0x3f, 0x2a, 0x5b, 0x19, 0xab, 0x51,
1223 0xc5, 0x8b, 0xdd, 0x98, 0x28, 0x35, 0x2f, 0xc3,
1224 0x81, 0x4f, 0x5c, 0xe5, 0x70, 0xb9, 0xeb, 0x62},
1225 {0xc4, 0x6d, 0x26, 0xb0, 0x17, 0x6b, 0xfe, 0x6c,
1226 0x12, 0xf8, 0xe7, 0xc1, 0xf5, 0x2f, 0xfa, 0x91,
1227 0x13, 0x27, 0xbd, 0x73, 0xcc, 0x33, 0x31, 0x1c,
1228 0x39, 0xe3, 0x27, 0x6a, 0x95, 0xcf, 0xc5, 0xfb}},
1229 {{0x30, 0xb2, 0x99, 0x84, 0xf0, 0x18, 0x2a, 0x6e,
1230 0x1e, 0x27, 0xed, 0xa2, 0x29, 0x99, 0x41, 0x56,
1231 0xe8, 0xd4, 0x0d, 0xef, 0x99, 0x9c, 0xf3, 0x58,
1232 0x29, 0x55, 0x1a, 0xc0, 0x68, 0xd6, 0x74, 0xa4},
1233 {0x07, 0x9c, 0xe7, 0xec, 0xf5, 0x36, 0x73, 0x41,
1234 0xa3, 0x1c, 0xe5, 0x93, 0x97, 0x6a, 0xfd, 0xf7,
1235 0x53, 0x18, 0xab, 0xaf, 0xeb, 0x85, 0xbd, 0x92,
1236 0x90, 0xab, 0x3c, 0xbf, 0x30, 0x82, 0xad, 0xf6}},
1237 {{0xc6, 0x87, 0x8a, 0x2a, 0xea, 0xc0, 0xa9, 0xec,
1238 0x6d, 0xd3, 0xdc, 0x32, 0x23, 0xce, 0x62, 0x19,
1239 0xa4, 0x7e, 0xa8, 0xdd, 0x1c, 0x33, 0xae, 0xd3,
1240 0x4f, 0x62, 0x9f, 0x52, 0xe7, 0x65, 0x46, 0xf4},
1241 {0x97, 0x51, 0x27, 0x67, 0x2d, 0xa2, 0x82, 0x87,
1242 0x98, 0xd3, 0xb6, 0x14, 0x7f, 0x51, 0xd3, 0x9a,
1243 0x0b, 0xd0, 0x76, 0x81, 0xb2, 0x4f, 0x58, 0x92,
1244 0xa4, 0x86, 0xa1, 0xa7, 0x09, 0x1d, 0xef, 0x9b}},
1245 {{0xb3, 0x0f, 0x2b, 0x69, 0x0d, 0x06, 0x90, 0x64,
1246 0xbd, 0x43, 0x4c, 0x10, 0xe8, 0x98, 0x1c, 0xa3,
1247 0xe1, 0x68, 0xe9, 0x79, 0x6c, 0x29, 0x51, 0x3f,
1248 0x41, 0xdc, 0xdf, 0x1f, 0xf3, 0x60, 0xbe, 0x33},
1249 {0xa1, 0x5f, 0xf7, 0x1d, 0xb4, 0x3e, 0x9b, 0x3c,
1250 0xe7, 0xbd, 0xb6, 0x06, 0xd5, 0x60, 0x06, 0x6d,
1251 0x50, 0xd2, 0xf4, 0x1a, 0x31, 0x08, 0xf2, 0xea,
1252 0x8e, 0xef, 0x5f, 0x7d, 0xb6, 0xd0, 0xc0, 0x27}},
1253 {{0x62, 0x9a, 0xd9, 0xbb, 0x38, 0x36, 0xce, 0xf7,
1254 0x5d, 0x2f, 0x13, 0xec, 0xc8, 0x2d, 0x02, 0x8a,
1255 0x2e, 0x72, 0xf0, 0xe5, 0x15, 0x9d, 0x72, 0xae,
1256 0xfc, 0xb3, 0x4f, 0x02, 0xea, 0xe1, 0x09, 0xfe},
1257 {0x00, 0x00, 0x00, 0x00, 0xfa, 0x0a, 0x3d, 0xbc,
1258 0xad, 0x16, 0x0c, 0xb6, 0xe7, 0x7c, 0x8b, 0x39,
1259 0x9a, 0x43, 0xbb, 0xe3, 0xc2, 0x55, 0x15, 0x14,
1260 0x75, 0xac, 0x90, 0x9b, 0x7f, 0x9a, 0x92, 0x00}},
1261 {{0x8b, 0xac, 0x70, 0x86, 0x29, 0x8f, 0x00, 0x23,
1262 0x7b, 0x45, 0x30, 0xaa, 0xb8, 0x4c, 0xc7, 0x8d,
1263 0x4e, 0x47, 0x85, 0xc6, 0x19, 0xe3, 0x96, 0xc2,
1264 0x9a, 0xa0, 0x12, 0xed, 0x6f, 0xd7, 0x76, 0x16},
1265 {0x45, 0xaf, 0x7e, 0x33, 0xc7, 0x7f, 0x10, 0x6c,
1266 0x7c, 0x9f, 0x29, 0xc1, 0xa8, 0x7e, 0x15, 0x84,
1267 0xe7, 0x7d, 0xc0, 0x6d, 0xab, 0x71, 0x5d, 0xd0,
1268 0x6b, 0x9f, 0x97, 0xab, 0xcb, 0x51, 0x0c, 0x9f}},
1269 {{0x9e, 0xc3, 0x92, 0xb4, 0x04, 0x9f, 0xc8, 0xbb,
1270 0xdd, 0x9e, 0xc6, 0x05, 0xfd, 0x65, 0xec, 0x94,
1271 0x7f, 0x2c, 0x16, 0xc4, 0x40, 0xac, 0x63, 0x7b,
1272 0x7d, 0xb8, 0x0c, 0xe4, 0x5b, 0xe3, 0xa7, 0x0e},
1273 {0x43, 0xf4, 0x44, 0xe8, 0xcc, 0xc8, 0xd4, 0x54,
1274 0x33, 0x37, 0x50, 0xf2, 0x87, 0x42, 0x2e, 0x00,
1275 0x49, 0x60, 0x62, 0x02, 0xfd, 0x1a, 0x7c, 0xdb,
1276 0x29, 0x6c, 0x6d, 0x54, 0x53, 0x08, 0xd1, 0xc8}},
1277 {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1278 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1279 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1280 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
1281 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1282 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1283 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1284 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
1285 {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1286 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1287 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1288 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
1289 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1290 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1291 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1292 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}},
1293 {{0x27, 0x59, 0xc7, 0x35, 0x60, 0x71, 0xa6, 0xf1,
1294 0x79, 0xa5, 0xfd, 0x79, 0x16, 0xf3, 0x41, 0xf0,
1295 0x57, 0xb4, 0x02, 0x97, 0x32, 0xe7, 0xde, 0x59,
1296 0xe2, 0x2d, 0x9b, 0x11, 0xea, 0x2c, 0x35, 0x92},
1297 {0x27, 0x59, 0xc7, 0x35, 0x60, 0x71, 0xa6, 0xf1,
1298 0x79, 0xa5, 0xfd, 0x79, 0x16, 0xf3, 0x41, 0xf0,
1299 0x57, 0xb4, 0x02, 0x97, 0x32, 0xe7, 0xde, 0x59,
1300 0xe2, 0x2d, 0x9b, 0x11, 0xea, 0x2c, 0x35, 0x92}},
1301 {{0x28, 0x56, 0xac, 0x0e, 0x4f, 0x98, 0x09, 0xf0,
1302 0x49, 0xfa, 0x7f, 0x84, 0xac, 0x7e, 0x50, 0x5b,
1303 0x17, 0x43, 0x14, 0x89, 0x9c, 0x53, 0xa8, 0x94,
1304 0x30, 0xf2, 0x11, 0x4d, 0x92, 0x14, 0x27, 0xe8},
1305 {0x39, 0x7a, 0x84, 0x56, 0x79, 0x9d, 0xec, 0x26,
1306 0x2c, 0x53, 0xc1, 0x94, 0xc9, 0x8d, 0x9e, 0x9d,
1307 0x32, 0x1f, 0xdd, 0x84, 0x04, 0xe8, 0xe2, 0x0a,
1308 0x6b, 0xbe, 0xbb, 0x42, 0x40, 0x67, 0x30, 0x6c}},
1309 {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1310 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
1311 0x45, 0x51, 0x23, 0x19, 0x50, 0xb7, 0x5f, 0xc4,
1312 0x40, 0x2d, 0xa1, 0x73, 0x2f, 0xc9, 0xbe, 0xbd},
1313 {0x27, 0x59, 0xc7, 0x35, 0x60, 0x71, 0xa6, 0xf1,
1314 0x79, 0xa5, 0xfd, 0x79, 0x16, 0xf3, 0x41, 0xf0,
1315 0x57, 0xb4, 0x02, 0x97, 0x32, 0xe7, 0xde, 0x59,
1316 0xe2, 0x2d, 0x9b, 0x11, 0xea, 0x2c, 0x35, 0x92}},
1317 {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1318 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe,
1319 0xba, 0xae, 0xdc, 0xe6, 0xaf, 0x48, 0xa0, 0x3b,
1320 0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41, 0x40},
1321 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1322 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1323 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1324 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}},
1325 {{0x1c, 0xc4, 0xf7, 0xda, 0x0f, 0x65, 0xca, 0x39,
1326 0x70, 0x52, 0x92, 0x8e, 0xc3, 0xc8, 0x15, 0xea,
1327 0x7f, 0x10, 0x9e, 0x77, 0x4b, 0x6e, 0x2d, 0xdf,
1328 0xe8, 0x30, 0x9d, 0xda, 0xe8, 0x9a, 0x65, 0xae},
1329 {0x02, 0xb0, 0x16, 0xb1, 0x1d, 0xc8, 0x57, 0x7b,
1330 0xa2, 0x3a, 0xa2, 0xa3, 0x38, 0x5c, 0x8f, 0xeb,
1331 0x66, 0x37, 0x91, 0xa8, 0x5f, 0xef, 0x04, 0xf6,
1332 0x59, 0x75, 0xe1, 0xee, 0x92, 0xf6, 0x0e, 0x30}},
1333 {{0x8d, 0x76, 0x14, 0xa4, 0x14, 0x06, 0x9f, 0x9a,
1334 0xdf, 0x4a, 0x85, 0xa7, 0x6b, 0xbf, 0x29, 0x6f,
1335 0xbc, 0x34, 0x87, 0x5d, 0xeb, 0xbb, 0x2e, 0xa9,
1336 0xc9, 0x1f, 0x58, 0xd6, 0x9a, 0x82, 0xa0, 0x56},
1337 {0xd4, 0xb9, 0xdb, 0x88, 0x1d, 0x04, 0xe9, 0x93,
1338 0x8d, 0x3f, 0x20, 0xd5, 0x86, 0xa8, 0x83, 0x07,
1339 0xdb, 0x09, 0xd8, 0x22, 0x1f, 0x7f, 0xf1, 0x71,
1340 0xc8, 0xe7, 0x5d, 0x47, 0xaf, 0x8b, 0x72, 0xe9}},
1341 {{0x83, 0xb9, 0x39, 0xb2, 0xa4, 0xdf, 0x46, 0x87,
1342 0xc2, 0xb8, 0xf1, 0xe6, 0x4c, 0xd1, 0xe2, 0xa9,
1343 0xe4, 0x70, 0x30, 0x34, 0xbc, 0x52, 0x7c, 0x55,
1344 0xa6, 0xec, 0x80, 0xa4, 0xe5, 0xd2, 0xdc, 0x73},
1345 {0x08, 0xf1, 0x03, 0xcf, 0x16, 0x73, 0xe8, 0x7d,
1346 0xb6, 0x7e, 0x9b, 0xc0, 0xb4, 0xc2, 0xa5, 0x86,
1347 0x02, 0x77, 0xd5, 0x27, 0x86, 0xa5, 0x15, 0xfb,
1348 0xae, 0x9b, 0x8c, 0xa9, 0xf9, 0xf8, 0xa8, 0x4a}},
1349 {{0x8b, 0x00, 0x49, 0xdb, 0xfa, 0xf0, 0x1b, 0xa2,
1350 0xed, 0x8a, 0x9a, 0x7a, 0x36, 0x78, 0x4a, 0xc7,
1351 0xf7, 0xad, 0x39, 0xd0, 0x6c, 0x65, 0x7a, 0x41,
1352 0xce, 0xd6, 0xd6, 0x4c, 0x20, 0x21, 0x6b, 0xc7},
1353 {0xc6, 0xca, 0x78, 0x1d, 0x32, 0x6c, 0x6c, 0x06,
1354 0x91, 0xf2, 0x1a, 0xe8, 0x43, 0x16, 0xea, 0x04,
1355 0x3c, 0x1f, 0x07, 0x85, 0xf7, 0x09, 0x22, 0x08,
1356 0xba, 0x13, 0xfd, 0x78, 0x1e, 0x3f, 0x6f, 0x62}},
1357 {{0x25, 0x9b, 0x7c, 0xb0, 0xac, 0x72, 0x6f, 0xb2,
1358 0xe3, 0x53, 0x84, 0x7a, 0x1a, 0x9a, 0x98, 0x9b,
1359 0x44, 0xd3, 0x59, 0xd0, 0x8e, 0x57, 0x41, 0x40,
1360 0x78, 0xa7, 0x30, 0x2f, 0x4c, 0x9c, 0xb9, 0x68},
1361 {0xb7, 0x75, 0x03, 0x63, 0x61, 0xc2, 0x48, 0x6e,
1362 0x12, 0x3d, 0xbf, 0x4b, 0x27, 0xdf, 0xb1, 0x7a,
1363 0xff, 0x4e, 0x31, 0x07, 0x83, 0xf4, 0x62, 0x5b,
1364 0x19, 0xa5, 0xac, 0xa0, 0x32, 0x58, 0x0d, 0xa7}},
1365 {{0x43, 0x4f, 0x10, 0xa4, 0xca, 0xdb, 0x38, 0x67,
1366 0xfa, 0xae, 0x96, 0xb5, 0x6d, 0x97, 0xff, 0x1f,
1367 0xb6, 0x83, 0x43, 0xd3, 0xa0, 0x2d, 0x70, 0x7a,
1368 0x64, 0x05, 0x4c, 0xa7, 0xc1, 0xa5, 0x21, 0x51},
1369 {0xe4, 0xf1, 0x23, 0x84, 0xe1, 0xb5, 0x9d, 0xf2,
1370 0xb8, 0x73, 0x8b, 0x45, 0x2b, 0x35, 0x46, 0x38,
1371 0x10, 0x2b, 0x50, 0xf8, 0x8b, 0x35, 0xcd, 0x34,
1372 0xc8, 0x0e, 0xf6, 0xdb, 0x09, 0x35, 0xf0, 0xda}}
1375 for (i = 0; i < 32; i++) {
1390 #if defined(USE_SCALAR_INV_NUM) 1414 unsigned char bin[32];
1424 unsigned char bin[32];
1435 while (--tries >= 0) {
1470 static const unsigned char b32[32] = {
1471 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1472 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
1473 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29,
1474 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x40
1477 0x00010203UL, 0x04050607UL, 0x11121314UL, 0x15161718UL,
1478 0x22232425UL, 0x26272829UL, 0x33343536UL, 0x37383940UL
1481 0x00010203UL, 0x04050607UL, 0x11121314UL, 0x15161718UL,
1482 0x22232425UL, 0x26272829UL, 0x33343536UL, 0x37383940UL
1485 unsigned char b322[32];
1494 CHECK(memcmp(b322, b32, 32) == 0);
1496 CHECK(memcmp(&fes2, &fes,
sizeof(fes)) == 0);
1502 t.magnitude = a->magnitude;
1503 t.normalized = a->normalized;
1515 for (i = 0; i < 5*
count; i++) {
1527 VERIFY_CHECK(!x.normalized && x.magnitude == z.magnitude);
1532 VERIFY_CHECK(!q.normalized && q.magnitude == z.magnitude);
1540 for (j = 0; j < 6; j++) {
1553 CHECK(memcmp(&xs, &zs,
sizeof(xs)) != 0);
1555 CHECK(memcmp(&xs, &ys,
sizeof(xs)) == 0);
1583 for (i = 0; i < 10*
count; i++) {
1595 for (i = 0; i < 10*
count; i++) {
1609 for (i = 0; i <
count; i++) {
1612 for (j = 0; j < len; j++) {
1616 for (j = 0; j < len; j++) {
1620 for (j = 0; j < len; j++) {
1634 for (i = 1; i <= 512; ++i) {
1645 CHECK((v == 0) == (k == NULL));
1666 for (i = 1; i <= 100; i++) {
1675 for (i = 0; i < 10; i++) {
1678 for (j = 0; j <
count; j++) {
1742 #ifdef USE_ENDOMORPHISM 1763 for (i = 0; i < runs; i++) {
1767 #ifdef USE_ENDOMORPHISM 1768 if (i >= runs - 2) {
1769 secp256k1_ge_mul_lambda(&g, &ge[1]);
1771 if (i >= runs - 1) {
1772 secp256k1_ge_mul_lambda(&g, &g);
1783 for (j = 0; j < 4; j++) {
1795 for (i = 0; i < 4 * runs + 1; i++) {
1818 for (i1 = 0; i1 < 1 + 4 * runs; i1++) {
1820 for (i2 = 0; i2 < 1 + 4 * runs; i2++) {
1860 if ((i1 == 0 && i2 == 0) || ((i1 + 3)/4 == (i2 + 3)/4 && ((i1 + 3)%4)/2 == ((i2 + 3)%4)/2)) {
1874 if ((i1 == 0 && i2 == 0) || ((i1 + 3)/4 == (i2 + 3)/4 && ((i1 + 3)%4)/2 != ((i2 + 3)%4)/2)) {
1896 for (i = 0; i < 4 * runs + 1; i++) {
1897 gej_shuffled[i] = gej[i];
1899 for (i = 0; i < 4 * runs + 1; i++) {
1903 gej_shuffled[i] = gej_shuffled[swap];
1904 gej_shuffled[swap] = t;
1907 for (i = 0; i < 4 * runs + 1; i++) {
1919 for (i = 0; i < 4 * runs + 1; i++) {
1927 for (i = 0; i < 4 * runs + 1; i++) {
1976 0x8d24cd95, 0x0a355af1, 0x3c543505, 0x44238d30,
1977 0x0643d79f, 0x05a59614, 0x2f8ec030, 0xd58977cb,
1978 0x001e337a, 0x38093dcd, 0x6c0f386d, 0x0b1293a8,
1979 0x4d72c879, 0xd7681924, 0x44e6d2f3, 0x9190117d
1982 0xc7b74206, 0x1f788cd9, 0xabd0937d, 0x164a0d86,
1983 0x95f6ff75, 0xf19a4ce9, 0xd013bd7b, 0xbf92d2a7,
1984 0xffe1cc85, 0xc7f6c232, 0x93f0c792, 0xf4ed6c57,
1985 0xb28d3786, 0x2897e6db, 0xbb192d0b, 0x6e6feab2
1988 0x671a63c0, 0x3efdad4c, 0x389a7798, 0x24356027,
1989 0xb3d69010, 0x278625c3, 0x5c86d390, 0x184a8f7a,
1990 0x5f6409c2, 0x2ce01f2b, 0x511fd375, 0x25071d08,
1991 0xda651801, 0x70e95caf, 0x8f0d893c, 0xbed8fbbe
2013 for (i = 0; i <
count * 32; i++) {
2028 for (i = 1; i <= 6; i++) {
2035 d[i - 1] = &
data[i - 1];
2040 CHECK(memcmp(&sd, &sd2,
sizeof(sd)) == 0);
2046 for (i = 0; i <
count * 8; i++) {
2058 int res_quad, res_even, res_odd;
2066 CHECK(res_quad == res_even);
2067 CHECK(res_quad == res_odd);
2100 for (i = 0; i <
count * 4; i++) {
2112 0x8b30bbe9, 0xae2a9906, 0x96b22f67, 0x0709dff3,
2113 0x727fd8bc, 0x04d3362c, 0x6c7bf458, 0xe2846004,
2114 0xa357ae91, 0x5c4a6528, 0x1309edf2, 0x0504740f,
2115 0x0eb33439, 0x90216b4f, 0x81063cb6, 0x5f2f7e0f
2119 0x84cc5452, 0xf7fde1ed, 0xb4d38a8c, 0xe9b1b84c,
2120 0xcef31f14, 0x6e569be9, 0x705d357a, 0x42985407
2123 0xa1e58d22, 0x553dcd42, 0xb2398062, 0x5d4c57a9,
2124 0x6e9323d4, 0x2b3152e5, 0xca2c3990, 0xedc7c9de
2139 for (i = 0; i < 200*
count; i++) {
2155 0xD6E96687, 0xF9B10D09, 0x2A6F3543, 0x9D86CEBE,
2156 0xA4535D0D, 0x409F5358, 0x6440BD74, 0xB933E830,
2157 0xB95CBCA2, 0xC77DA786, 0x539BE8FD, 0x53354D2D,
2158 0x3B4F566A, 0xE6580454, 0x07ED6015, 0xEE1B2A88
2181 unsigned char pub[65];
2212 0x7603CB59, 0xB0EF6C63, 0xFE608479, 0x2A0C378C,
2213 0xDB3233A8, 0x0F8A9A09, 0xA877DEAD, 0x31B38C45
2215 for (i = 0; i < 500; i++) {
2233 0x6d986544, 0x57ff52b8, 0xcf1b8126, 0x5b802a5b,
2234 0xa97f9263, 0xb1e88044, 0x93351325, 0x91bc450a,
2235 0x535c59f7, 0x325e5d2b, 0xc391fbe8, 0x3c12787c,
2236 0x337e4a98, 0xe82a9011, 0x0123ba37, 0xdd769c7d
2240 0x649d4f77, 0xc4242df7, 0x7f2079c9, 0x14530327,
2241 0xa31b876a, 0xd2d8ce2a, 0x2236d5c6, 0xd7b2029b
2245 0x23773684, 0x4d209dc7, 0x098a786f, 0x20d06fcd,
2246 0x070a38bf, 0xc11ac651, 0x03004319, 0x1e2a8786,
2247 0xed8c3b8e, 0xc06dd57b, 0xd06ea66e, 0x45492b0f,
2248 0xb84e4e1b, 0xfb77e21f, 0x96baae2a, 0x63dec956
2303 0x4968d524, 0x2abf9b7a, 0x466abbcf, 0x34b11b6d,
2304 0xcd83d307, 0x827bed62, 0x05fad0ce, 0x18fae63b
2307 0x5494c15d, 0x32099706, 0xc2395f94, 0x348745fd,
2308 0x757ce30e, 0x4e8c90fb, 0xa2bad184, 0xf883c69f,
2309 0x5d195d20, 0xe191bf7f, 0x1be3e55f, 0x56a80196,
2310 0x6071ad01, 0xf1462f66, 0xc997fa94, 0xdb858435
2317 for (i = 0; i < 100; ++i) {
2343 for (i = bits-1; i >= 0; i--) {
2347 CHECK(zeroes == -1 || zeroes >= w-1);
2349 CHECK((v & 1) == 1);
2350 CHECK(v <= (1 << (w-1)) - 1);
2351 CHECK(v >= -(1 << (w-1)) - 1);
2353 CHECK(zeroes != -1);
2378 CHECK(sign1 == sign2);
2384 int wnaf[256] = {0};
2386 #ifdef USE_ENDOMORPHISM 2394 #ifdef USE_ENDOMORPHISM 2395 for (i = 0; i < 16; ++i) {
2408 CHECK(v > -(1 << w));
2409 CHECK(v < (1 << w));
2420 #ifdef USE_ENDOMORPHISM 2438 for (i = 0; i <
count; i++) {
2459 for (i = 0; i < 36; i++ ) {
2462 for (j = 0; j < i; j++) {
2470 for (i = 1; i <= 36; i++ ) {
2474 for (j = 0; j < i; j++) {
2492 unsigned char seed32[32];
2526 for (i = 0; i < 10; i++) {
2531 #ifdef USE_ENDOMORPHISM 2533 void test_scalar_split(
void) {
2536 const unsigned char zero[32] = {0};
2537 unsigned char tmp[32];
2540 secp256k1_scalar_split_lambda(&s1, &slam, &full);
2551 CHECK(memcmp(zero, tmp, 16) == 0);
2553 CHECK(memcmp(zero, tmp, 16) == 0);
2556 void run_endomorphism_tests(
void) {
2557 test_scalar_split();
2562 unsigned char pubkeyc[65];
2569 for (pubkeyclen = 3; pubkeyclen <= 65; pubkeyclen++) {
2572 memcpy(&pubkeyc[1], input, 64);
2573 VG_UNDEF(&pubkeyc[pubkeyclen], 65 - pubkeyclen);
2574 for (i = 0; i < 256; i++) {
2581 ysign = (input[63] & 1) + 2;
2583 xpass = xvalid && (pubkeyclen == 33) && ((i & 254) == 2);
2585 ypass = xvalid && yvalid && ((i & 4) == ((pubkeyclen == 65) << 2)) &&
2586 ((i == 4) || ((i & 251) == ysign)) && ((pubkeyclen == 33) || (pubkeyclen == 65));
2587 if (xpass || ypass) {
2589 unsigned char pubkeyo[65];
2591 memset(&pubkey, 0,
sizeof(pubkey));
2601 CHECK(memcmp(&pubkeyo[1], &pubkeyc[1], 32) == 0);
2602 CHECK((pubkeyclen != 33) || (pubkeyo[0] == pubkeyc[0]));
2605 CHECK(pubkeyo[0] == ysign);
2607 memset(&pubkey, 0,
sizeof(pubkey));
2616 CHECK(pubkeyo[0] == 4);
2617 CHECK(memcmp(&pubkeyo[1], input, 64) == 0);
2622 memset(&pubkey, 0xfe,
sizeof(pubkey));
2637 #define SECP256K1_EC_PARSE_TEST_NVALID (12) 2641 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x52,
2642 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2643 0x00, 0x00, 0x64, 0xef, 0xa1, 0x7b, 0x77, 0x61, 0xe1, 0xe4, 0x27, 0x06, 0x98, 0x9f, 0xb4, 0x83,
2644 0xb8, 0xd2, 0xd4, 0x9b, 0xf7, 0x8f, 0xae, 0x98, 0x03, 0xf0, 0x99, 0xb8, 0x34, 0xed, 0xeb, 0x00
2648 0x7a, 0xe9, 0x6a, 0x2b, 0x65, 0x7c, 0x07, 0x10, 0x6e, 0x64, 0x47, 0x9e, 0xac, 0x34, 0x34, 0xe9,
2649 0x9c, 0xf0, 0x49, 0x75, 0x12, 0xf5, 0x89, 0x95, 0xc1, 0x39, 0x6c, 0x28, 0x71, 0x95, 0x01, 0xee,
2650 0x42, 0x18, 0xf2, 0x0a, 0xe6, 0xc6, 0x46, 0xb3, 0x63, 0xdb, 0x68, 0x60, 0x58, 0x22, 0xfb, 0x14,
2651 0x26, 0x4c, 0xa8, 0xd2, 0x58, 0x7f, 0xdd, 0x6f, 0xbc, 0x75, 0x0d, 0x58, 0x7e, 0x76, 0xa7, 0xee,
2655 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
2656 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x2c,
2657 0x0e, 0x99, 0x4b, 0x14, 0xea, 0x72, 0xf8, 0xc3, 0xeb, 0x95, 0xc7, 0x1e, 0xf6, 0x92, 0x57, 0x5e,
2658 0x77, 0x50, 0x58, 0x33, 0x2d, 0x7e, 0x52, 0xd0, 0x99, 0x5c, 0xf8, 0x03, 0x88, 0x71, 0xb6, 0x7d,
2662 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
2663 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x2c,
2664 0xf1, 0x66, 0xb4, 0xeb, 0x15, 0x8d, 0x07, 0x3c, 0x14, 0x6a, 0x38, 0xe1, 0x09, 0x6d, 0xa8, 0xa1,
2665 0x88, 0xaf, 0xa7, 0xcc, 0xd2, 0x81, 0xad, 0x2f, 0x66, 0xa3, 0x07, 0xfb, 0x77, 0x8e, 0x45, 0xb2,
2669 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2670 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
2671 0x42, 0x18, 0xf2, 0x0a, 0xe6, 0xc6, 0x46, 0xb3, 0x63, 0xdb, 0x68, 0x60, 0x58, 0x22, 0xfb, 0x14,
2672 0x26, 0x4c, 0xa8, 0xd2, 0x58, 0x7f, 0xdd, 0x6f, 0xbc, 0x75, 0x0d, 0x58, 0x7e, 0x76, 0xa7, 0xee,
2676 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2677 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
2678 0xbd, 0xe7, 0x0d, 0xf5, 0x19, 0x39, 0xb9, 0x4c, 0x9c, 0x24, 0x97, 0x9f, 0xa7, 0xdd, 0x04, 0xeb,
2679 0xd9, 0xb3, 0x57, 0x2d, 0xa7, 0x80, 0x22, 0x90, 0x43, 0x8a, 0xf2, 0xa6, 0x81, 0x89, 0x54, 0x41,
2683 0x1f, 0xe1, 0xe5, 0xef, 0x3f, 0xce, 0xb5, 0xc1, 0x35, 0xab, 0x77, 0x41, 0x33, 0x3c, 0xe5, 0xa6,
2684 0xe8, 0x0d, 0x68, 0x16, 0x76, 0x53, 0xf6, 0xb2, 0xb2, 0x4b, 0xcb, 0xcf, 0xaa, 0xaf, 0xf5, 0x07,
2685 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
2686 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x2e,
2690 0xcb, 0xb0, 0xde, 0xab, 0x12, 0x57, 0x54, 0xf1, 0xfd, 0xb2, 0x03, 0x8b, 0x04, 0x34, 0xed, 0x9c,
2691 0xb3, 0xfb, 0x53, 0xab, 0x73, 0x53, 0x91, 0x12, 0x99, 0x94, 0xa5, 0x35, 0xd9, 0x25, 0xf6, 0x73,
2692 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
2693 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x2e,
2697 0x14, 0x6d, 0x3b, 0x65, 0xad, 0xd9, 0xf5, 0x4c, 0xcc, 0xa2, 0x85, 0x33, 0xc8, 0x8e, 0x2c, 0xbc,
2698 0x63, 0xf7, 0x44, 0x3e, 0x16, 0x58, 0x78, 0x3a, 0xb4, 0x1f, 0x8e, 0xf9, 0x7c, 0x2a, 0x10, 0xb5,
2699 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
2700 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x2e,
2704 0x1f, 0xe1, 0xe5, 0xef, 0x3f, 0xce, 0xb5, 0xc1, 0x35, 0xab, 0x77, 0x41, 0x33, 0x3c, 0xe5, 0xa6,
2705 0xe8, 0x0d, 0x68, 0x16, 0x76, 0x53, 0xf6, 0xb2, 0xb2, 0x4b, 0xcb, 0xcf, 0xaa, 0xaf, 0xf5, 0x07,
2706 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2707 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
2711 0xcb, 0xb0, 0xde, 0xab, 0x12, 0x57, 0x54, 0xf1, 0xfd, 0xb2, 0x03, 0x8b, 0x04, 0x34, 0xed, 0x9c,
2712 0xb3, 0xfb, 0x53, 0xab, 0x73, 0x53, 0x91, 0x12, 0x99, 0x94, 0xa5, 0x35, 0xd9, 0x25, 0xf6, 0x73,
2713 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2714 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
2718 0x14, 0x6d, 0x3b, 0x65, 0xad, 0xd9, 0xf5, 0x4c, 0xcc, 0xa2, 0x85, 0x33, 0xc8, 0x8e, 0x2c, 0xbc,
2719 0x63, 0xf7, 0x44, 0x3e, 0x16, 0x58, 0x78, 0x3a, 0xb4, 0x1f, 0x8e, 0xf9, 0x7c, 0x2a, 0x10, 0xb5,
2720 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2721 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01
2724 #define SECP256K1_EC_PARSE_TEST_NXVALID (4) 2728 0x1f, 0xe1, 0xe5, 0xef, 0x3f, 0xce, 0xb5, 0xc1, 0x35, 0xab, 0x77, 0x41, 0x33, 0x3c, 0xe5, 0xa6,
2729 0xe8, 0x0d, 0x68, 0x16, 0x76, 0x53, 0xf6, 0xb2, 0xb2, 0x4b, 0xcb, 0xcf, 0xaa, 0xaf, 0xf5, 0x07,
2730 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
2731 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x30,
2735 0xcb, 0xb0, 0xde, 0xab, 0x12, 0x57, 0x54, 0xf1, 0xfd, 0xb2, 0x03, 0x8b, 0x04, 0x34, 0xed, 0x9c,
2736 0xb3, 0xfb, 0x53, 0xab, 0x73, 0x53, 0x91, 0x12, 0x99, 0x94, 0xa5, 0x35, 0xd9, 0x25, 0xf6, 0x73,
2737 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
2738 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x30,
2742 0x14, 0x6d, 0x3b, 0x65, 0xad, 0xd9, 0xf5, 0x4c, 0xcc, 0xa2, 0x85, 0x33, 0xc8, 0x8e, 0x2c, 0xbc,
2743 0x63, 0xf7, 0x44, 0x3e, 0x16, 0x58, 0x78, 0x3a, 0xb4, 0x1f, 0x8e, 0xf9, 0x7c, 0x2a, 0x10, 0xb5,
2744 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
2745 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x30,
2749 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2750 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
2751 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2752 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03
2755 #define SECP256K1_EC_PARSE_TEST_NINVALID (7) 2759 0x0a, 0x2d, 0x2b, 0xa9, 0x35, 0x07, 0xf1, 0xdf, 0x23, 0x37, 0x70, 0xc2, 0xa7, 0x97, 0x96, 0x2c,
2760 0xc6, 0x1f, 0x6d, 0x15, 0xda, 0x14, 0xec, 0xd4, 0x7d, 0x8d, 0x27, 0xae, 0x1c, 0xd5, 0xf8, 0x53,
2761 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2762 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
2766 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
2767 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x30,
2768 0x42, 0x18, 0xf2, 0x0a, 0xe6, 0xc6, 0x46, 0xb3, 0x63, 0xdb, 0x68, 0x60, 0x58, 0x22, 0xfb, 0x14,
2769 0x26, 0x4c, 0xa8, 0xd2, 0x58, 0x7f, 0xdd, 0x6f, 0xbc, 0x75, 0x0d, 0x58, 0x7e, 0x76, 0xa7, 0xee,
2773 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
2774 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x30,
2775 0xbd, 0xe7, 0x0d, 0xf5, 0x19, 0x39, 0xb9, 0x4c, 0x9c, 0x24, 0x97, 0x9f, 0xa7, 0xdd, 0x04, 0xeb,
2776 0xd9, 0xb3, 0x57, 0x2d, 0xa7, 0x80, 0x22, 0x90, 0x43, 0x8a, 0xf2, 0xa6, 0x81, 0x89, 0x54, 0x41,
2780 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
2781 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x2e,
2782 0xf4, 0x84, 0x14, 0x5c, 0xb0, 0x14, 0x9b, 0x82, 0x5d, 0xff, 0x41, 0x2f, 0xa0, 0x52, 0xa8, 0x3f,
2783 0xcb, 0x72, 0xdb, 0x61, 0xd5, 0x6f, 0x37, 0x70, 0xce, 0x06, 0x6b, 0x73, 0x49, 0xa2, 0xaa, 0x28,
2787 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
2788 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x2e,
2789 0x0b, 0x7b, 0xeb, 0xa3, 0x4f, 0xeb, 0x64, 0x7d, 0xa2, 0x00, 0xbe, 0xd0, 0x5f, 0xad, 0x57, 0xc0,
2790 0x34, 0x8d, 0x24, 0x9e, 0x2a, 0x90, 0xc8, 0x8f, 0x31, 0xf9, 0x94, 0x8b, 0xb6, 0x5d, 0x52, 0x07,
2794 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2795 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2796 0x8f, 0x53, 0x7e, 0xef, 0xdf, 0xc1, 0x60, 0x6a, 0x07, 0x27, 0xcd, 0x69, 0xb4, 0xa7, 0x33, 0x3d,
2797 0x38, 0xed, 0x44, 0xe3, 0x93, 0x2a, 0x71, 0x79, 0xee, 0xcb, 0x4b, 0x6f, 0xba, 0x93, 0x60, 0xdc,
2801 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2802 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2803 0x70, 0xac, 0x81, 0x10, 0x20, 0x3e, 0x9f, 0x95, 0xf8, 0xd8, 0x32, 0x96, 0x4b, 0x58, 0xcc, 0xc2,
2804 0xc7, 0x12, 0xbb, 0x1c, 0x6c, 0xd5, 0x8e, 0x86, 0x11, 0x34, 0xb4, 0x8f, 0x45, 0x6c, 0x9b, 0x53
2807 const unsigned char pubkeyc[66] = {
2809 0x04, 0x79, 0xBE, 0x66, 0x7E, 0xF9, 0xDC, 0xBB, 0xAC, 0x55, 0xA0, 0x62, 0x95, 0xCE, 0x87, 0x0B,
2810 0x07, 0x02, 0x9B, 0xFC, 0xDB, 0x2D, 0xCE, 0x28, 0xD9, 0x59, 0xF2, 0x81, 0x5B, 0x16, 0xF8, 0x17,
2811 0x98, 0x48, 0x3A, 0xDA, 0x77, 0x26, 0xA3, 0xC4, 0x65, 0x5D, 0xA4, 0xFB, 0xFC, 0x0E, 0x11, 0x08,
2812 0xA8, 0xFD, 0x17, 0xB4, 0x48, 0xA6, 0x85, 0x54, 0x19, 0x9C, 0x47, 0xD0, 0x8F, 0xFB, 0x10, 0xD4,
2815 unsigned char sout[65];
2816 unsigned char shortkey[2];
2828 memset(&pubkey, 0xfe,
sizeof(pubkey));
2838 for (i = 0; i < 256 ; i++) {
2839 memset(&pubkey, 0xfe,
sizeof(pubkey));
2851 for (i = 0; i < 65536 ; i++) {
2852 memset(&pubkey, 0xfe,
sizeof(pubkey));
2854 shortkey[0] = i & 255;
2855 shortkey[1] = i >> 8;
2863 memset(&pubkey, 0xfe,
sizeof(pubkey));
2876 memset(&pubkey, 0xfe,
sizeof(pubkey));
2885 memset(&pubkey, 0xfe,
sizeof(pubkey));
2894 memset(&pubkey, 0xfe,
sizeof(pubkey));
2903 memset(&pubkey, 0,
sizeof(pubkey));
2949 CHECK(ecount2 == 10);
2964 const unsigned char orderc[32] = {
2965 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
2966 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe,
2967 0xba, 0xae, 0xdc, 0xe6, 0xaf, 0x48, 0xa0, 0x3b,
2968 0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41, 0x41
2971 unsigned char ctmp[33];
2972 unsigned char ctmp2[33];
2987 memset(ctmp, 255, 32);
2989 memset(&pubkey, 1,
sizeof(pubkey));
2995 memset(ctmp, 0, 32);
2997 memset(&pubkey, 1,
sizeof(pubkey));
3005 memset(&pubkey, 0,
sizeof(pubkey));
3010 pubkey_one = pubkey;
3012 memcpy(ctmp, orderc, 32);
3015 memset(&pubkey, 1,
sizeof(pubkey));
3023 memset(&pubkey, 0,
sizeof(pubkey));
3028 pubkey_negone = pubkey;
3030 memset(ctmp2, 0, 32);
3032 CHECK(memcmp(orderc, ctmp, 31) == 0 && ctmp[31] == 0x40);
3033 memcpy(&pubkey2, &pubkey,
sizeof(pubkey));
3035 CHECK(memcmp(&pubkey, &pubkey2,
sizeof(pubkey)) == 0);
3038 CHECK(memcmp(zeros, ctmp, 32) == 0);
3040 CHECK(memcmp(&pubkey, zeros,
sizeof(pubkey)) == 0);
3041 memcpy(&pubkey, &pubkey2,
sizeof(pubkey));
3043 memcpy(ctmp, orderc, 32);
3046 CHECK(memcmp(zeros, ctmp, 32) == 0);
3047 memcpy(ctmp, orderc, 32);
3050 CHECK(memcmp(zeros, ctmp, 32) == 0);
3051 memcpy(ctmp, orderc, 32);
3054 CHECK(memcmp(&pubkey, zeros,
sizeof(pubkey)) == 0);
3055 memcpy(&pubkey, &pubkey2,
sizeof(pubkey));
3057 CHECK(memcmp(&pubkey, zeros,
sizeof(pubkey)) == 0);
3058 memcpy(&pubkey, &pubkey2,
sizeof(pubkey));
3062 CHECK(memcmp(zeros, ctmp2, 32) == 0);
3065 CHECK(memcmp(&pubkey, zeros,
sizeof(pubkey)) == 0);
3066 memcpy(&pubkey, &pubkey2,
sizeof(pubkey));
3070 CHECK(memcmp(ctmp2, zeros, 31) == 0 && ctmp2[31] == 1);
3075 CHECK(memcmp(&pubkey, &pubkey2,
sizeof(pubkey)) == 0);
3080 CHECK(memcmp(&pubkey, &pubkey2,
sizeof(pubkey)) == 0);
3086 memset(&pubkey, 0, 32);
3089 CHECK(memcmp(&pubkey, zeros,
sizeof(pubkey)) == 0);
3090 memcpy(&pubkey, &pubkey2,
sizeof(pubkey));
3091 memset(&pubkey2, 0, 32);
3094 CHECK(memcmp(&pubkey2, zeros,
sizeof(pubkey2)) == 0);
3102 memset(ctmp2, 0, 32);
3109 memset(ctmp2, 0, 32);
3116 memset(ctmp2, 0, 32);
3122 memset(ctmp2, 0, 32);
3131 memset(&pubkey, 1,
sizeof(pubkey));
3137 pubkeys[0] = &pubkey_one;
3156 pubkeys[0] = &pubkey_negone;
3166 CHECK(memcmp(ctmp, ctmp2, 33) == 0);
3168 pubkeys[0] = &pubkey_one;
3169 pubkeys[1] = &pubkey_negone;
3177 pubkeys[2] = &pubkey_one;
3187 CHECK(memcmp(ctmp, ctmp2, 33) == 0);
3189 pubkeys[1] = &pubkey_one;
3221 CHECK(recid >= 0 && recid < 4);
3231 for (i = 0; i < 10*
count; i++) {
3237 static int precomputed_nonce_function(
unsigned char *nonce32,
const unsigned char *msg32,
const unsigned char *key32,
const unsigned char *algo16,
void *
data,
unsigned int counter) {
3242 return (counter == 0);
3245 static int nonce_function_test_fail(
unsigned char *nonce32,
const unsigned char *msg32,
const unsigned char *key32,
const unsigned char *algo16,
void *
data,
unsigned int counter) {
3253 static int nonce_function_test_retry(
unsigned char *nonce32,
const unsigned char *msg32,
const unsigned char *key32,
const unsigned char *algo16,
void *
data,
unsigned int counter) {
3256 memset(nonce32, counter==0 ? 0 : 255, 32);
3263 static const unsigned char order[] = {
3264 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
3265 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,
3266 0xBA,0xAE,0xDC,0xE6,0xAF,0x48,0xA0,0x3B,
3267 0xBF,0xD2,0x5E,0x8C,0xD0,0x36,0x41,0x41
3269 memcpy(nonce32, order, 32);
3289 unsigned char extra[32] = {0x00};
3290 unsigned char privkey[32];
3291 unsigned char message[32];
3292 unsigned char privkey2[32];
3295 unsigned char sig[74];
3297 unsigned char pubkeyc[65];
3298 size_t pubkeyclen = 65;
3300 unsigned char seckey[300];
3301 size_t seckeylen = 300;
3318 memset(&pubkey, 0,
sizeof(pubkey));
3324 CHECK(memcmp(privkey, privkey2, 32) == 0);
3330 unsigned char rnd[32];
3335 CHECK(ret1 == ret2);
3340 CHECK(memcmp(&pubkey, &pubkey2,
sizeof(pubkey)) == 0);
3347 unsigned char rnd[32];
3352 CHECK(ret1 == ret2);
3357 CHECK(memcmp(&pubkey, &pubkey2,
sizeof(pubkey)) == 0);
3369 CHECK(memcmp(&signature[0], &signature[4],
sizeof(signature[0])) == 0);
3370 CHECK(memcmp(&signature[0], &signature[1],
sizeof(signature[0])) != 0);
3371 CHECK(memcmp(&signature[0], &signature[2],
sizeof(signature[0])) != 0);
3372 CHECK(memcmp(&signature[0], &signature[3],
sizeof(signature[0])) != 0);
3373 CHECK(memcmp(&signature[1], &signature[2],
sizeof(signature[0])) != 0);
3374 CHECK(memcmp(&signature[1], &signature[3],
sizeof(signature[0])) != 0);
3375 CHECK(memcmp(&signature[2], &signature[3],
sizeof(signature[0])) != 0);
3396 CHECK(memcmp(&signature[5], &signature[0], 64) == 0);
3400 memset(&signature[0], 0,
sizeof(signature[0]));
3414 unsigned char in[65];
3435 unsigned char out[65];
3436 unsigned char firstb;
3443 CHECK(memcmp(&in[1], &
out[1], len-1) == 0);
3445 if ((in[0] != 6) && (in[0] != 7)) {
3456 if (firstb == 2 || firstb == 3) {
3457 if (in[0] == firstb + 4) {
3466 CHECK(memcmp(&in[1], &
out[1], 64) == 0);
3473 for (i = 0; i < 10*
count; i++) {
3480 for (i = 0; i < 64*
count; i++) {
3486 static const unsigned char zeroes[32] = {0};
3487 static const unsigned char max_scalar[32] = {
3488 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
3489 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe,
3490 0xba, 0xae, 0xdc, 0xe6, 0xaf, 0x48, 0xa0, 0x3b,
3491 0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41, 0x40
3497 unsigned char roundtrip_der[2048];
3498 unsigned char compact_der[64];
3499 size_t len_der = 2048;
3500 int parsed_der = 0, valid_der = 0, roundtrips_der = 0;
3503 unsigned char roundtrip_der_lax[2048];
3504 unsigned char compact_der_lax[64];
3505 size_t len_der_lax = 2048;
3506 int parsed_der_lax = 0, valid_der_lax = 0, roundtrips_der_lax = 0;
3508 #ifdef ENABLE_OPENSSL_TESTS 3509 ECDSA_SIG *sig_openssl;
3510 const unsigned char *sigptr;
3511 unsigned char roundtrip_openssl[2048];
3512 int len_openssl = 2048;
3513 int parsed_openssl, valid_openssl = 0, roundtrips_openssl = 0;
3519 valid_der = (memcmp(compact_der, zeroes, 32) != 0) && (memcmp(compact_der + 32, zeroes, 32) != 0);
3523 roundtrips_der = (len_der == siglen) && memcmp(roundtrip_der, sig, siglen) == 0;
3527 if (parsed_der_lax) {
3529 valid_der_lax = (memcmp(compact_der_lax, zeroes, 32) != 0) && (memcmp(compact_der_lax + 32, zeroes, 32) != 0);
3531 if (valid_der_lax) {
3533 roundtrips_der_lax = (len_der_lax == siglen) && memcmp(roundtrip_der_lax, sig, siglen) == 0;
3536 if (certainly_der) {
3537 ret |= (!parsed_der) << 2;
3539 if (certainly_not_der) {
3540 ret |= (parsed_der) << 17;
3543 ret |= (!roundtrips_der) << 3;
3547 ret |= (!roundtrips_der_lax) << 12;
3548 ret |= (len_der != len_der_lax) << 13;
3549 ret |= (memcmp(roundtrip_der_lax, roundtrip_der, len_der) != 0) << 14;
3551 ret |= (roundtrips_der != roundtrips_der_lax) << 15;
3553 ret |= (!parsed_der_lax) << 16;
3556 #ifdef ENABLE_OPENSSL_TESTS 3557 sig_openssl = ECDSA_SIG_new();
3559 parsed_openssl = (d2i_ECDSA_SIG(&sig_openssl, &sigptr, siglen) != NULL);
3560 if (parsed_openssl) {
3561 valid_openssl = !BN_is_negative(sig_openssl->r) && !BN_is_negative(sig_openssl->s) && BN_num_bits(sig_openssl->r) > 0 && BN_num_bits(sig_openssl->r) <= 256 && BN_num_bits(sig_openssl->s) > 0 && BN_num_bits(sig_openssl->s) <= 256;
3562 if (valid_openssl) {
3563 unsigned char tmp[32] = {0};
3564 BN_bn2bin(sig_openssl->r, tmp + 32 - BN_num_bytes(sig_openssl->r));
3565 valid_openssl = memcmp(tmp, max_scalar, 32) < 0;
3567 if (valid_openssl) {
3568 unsigned char tmp[32] = {0};
3569 BN_bn2bin(sig_openssl->s, tmp + 32 - BN_num_bytes(sig_openssl->s));
3570 valid_openssl = memcmp(tmp, max_scalar, 32) < 0;
3573 len_openssl = i2d_ECDSA_SIG(sig_openssl, NULL);
3574 if (len_openssl <= 2048) {
3575 unsigned char *ptr = roundtrip_openssl;
3576 CHECK(i2d_ECDSA_SIG(sig_openssl, &ptr) == len_openssl);
3577 roundtrips_openssl = valid_openssl && ((size_t)len_openssl == siglen) && (memcmp(roundtrip_openssl, sig, siglen) == 0);
3581 ECDSA_SIG_free(sig_openssl);
3583 ret |= (parsed_der && !parsed_openssl) << 4;
3584 ret |= (valid_der && !valid_openssl) << 5;
3585 ret |= (roundtrips_openssl && !parsed_der) << 6;
3586 ret |= (roundtrips_der != roundtrips_openssl) << 7;
3587 if (roundtrips_openssl) {
3588 ret |= (len_der != (size_t)len_openssl) << 8;
3589 ret |= (memcmp(roundtrip_der, roundtrip_openssl, len_der) != 0) << 9;
3597 for (i = 0; i < ptrlen; i++) {
3598 int shift = ptrlen - 1 - i;
3602 ptr[i] = (val >> shift) & 0xFF;
3613 memmove(sig + pos, sig + pos + 1, *len - pos - 1);
3616 }
else if (action < 2) {
3619 memmove(sig + pos + 1, sig + pos, *len - pos);
3623 }
else if (action < 4) {
3636 int nlow[2], nlen[2], nlenlen[2], nhbit[2], nhbyte[2], nzlen[2];
3637 size_t tlen, elen, glen;
3643 *certainly_der = der;
3644 *certainly_not_der = 0;
3647 for (
n = 0;
n < 2;
n++) {
3659 if (nzlen[
n] > ((nlen[
n] == 0 || nhbit[
n]) ? 1 : 0)) {
3660 *certainly_not_der = 1;
3662 CHECK(nlen[
n] + nzlen[
n] <= 300);
3664 nlenlen[
n] = nlen[
n] + nzlen[
n] < 128 ? 0 : (nlen[
n] + nzlen[
n] < 256 ? 1 : 2);
3670 *certainly_not_der = 1;
3673 CHECK(nlen[
n] + nzlen[
n] + nlenlen[
n] <= 427);
3677 tlen = 2 + nlenlen[0] + nlen[0] + nzlen[0] + 2 + nlenlen[1] + nlen[1] + nzlen[1];
3683 *certainly_not_der = 1;
3691 *certainly_not_der = 1;
3693 CHECK(tlen + glen <= 990);
3696 sig[(*len)++] = 0x30;
3699 sig[(*len)++] = 0x80;
3700 *certainly_not_der = 1;
3702 int tlenlen = tlen < 128 ? 0 : (tlen < 256 ? 1 : 2);
3707 *certainly_not_der = 1;
3712 sig[(*len)++] = tlen;
3715 sig[(*len)++] = 128 + tlenlen;
3722 CHECK(tlen + glen <= 1119);
3724 for (
n = 0;
n < 2;
n++) {
3726 sig[(*len)++] = 0x02;
3727 if (nlenlen[
n] == 0) {
3729 sig[(*len)++] = nlen[
n] + nzlen[
n];
3732 sig[(*len)++] = 128 + nlenlen[
n];
3737 while (nzlen[
n] > 0) {
3738 sig[(*len)++] = 0x00;
3741 if (nlen[
n] == 32 && !nlow[
n]) {
3744 for (i = 0; i < 16; i++) {
3745 sig[(*len)++] = 0xFF;
3751 sig[(*len)++] = nhbyte[
n];
3770 CHECK(tlen + glen <= 1121);
3776 CHECK(tlen <= 1121);
3777 CHECK(tlen == *len);
3782 for (i = 0; i < 200 *
count; i++) {
3783 unsigned char buffer[2048];
3785 int certainly_der = 0;
3786 int certainly_not_der = 0;
3788 for (j = 0; j < 16; j++) {
3794 certainly_not_der = 0;
3799 fprintf(
stderr,
"Failure %x on ", ret);
3800 for (k = 0; k < buflen; k++) {
3801 fprintf(
stderr,
"%02x ", buffer[k]);
3833 const unsigned char pubkey_mods_zero[33] = {
3834 0x02, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
3835 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
3836 0xfe, 0xba, 0xae, 0xdc, 0xe6, 0xaf, 0x48, 0xa0,
3837 0x3b, 0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41,
3852 const unsigned char pubkey[33] = {
3853 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3854 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3855 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3856 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3871 const unsigned char pubkey[33] = {
3872 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3873 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3874 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3875 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3878 const unsigned char pubkey2[33] = {
3879 0x02, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
3880 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
3881 0xfe, 0xba, 0xae, 0xdc, 0xe6, 0xaf, 0x48, 0xa0,
3882 0x3b, 0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41,
3906 const unsigned char pubkey[33] = {
3907 0x02, 0x14, 0x4e, 0x5a, 0x58, 0xef, 0x5b, 0x22,
3908 0x6f, 0xd2, 0xe2, 0x07, 0x6a, 0x77, 0xcf, 0x05,
3909 0xb4, 0x1d, 0xe7, 0x4a, 0x30, 0x98, 0x27, 0x8c,
3910 0x93, 0xe6, 0xe6, 0x3c, 0x0b, 0xc4, 0x73, 0x76,
3913 const unsigned char pubkey2[33] = {
3914 0x02, 0x8a, 0xd5, 0x37, 0xed, 0x73, 0xd9, 0x40,
3915 0x1d, 0xa0, 0x33, 0xd2, 0xdc, 0xf0, 0xaf, 0xae,
3916 0x34, 0xcf, 0x5f, 0x96, 0x4c, 0x73, 0x28, 0x0f,
3917 0x92, 0xc0, 0xf6, 0x9d, 0xd9, 0xb2, 0x09, 0x10,
3920 const unsigned char csr[32] = {
3921 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3922 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
3923 0x45, 0x51, 0x23, 0x19, 0x50, 0xb7, 0x5f, 0xc4,
3924 0x40, 0x2d, 0xa1, 0x72, 0x2f, 0xc9, 0xba, 0xeb
3948 const unsigned char pubkey[33] = {
3949 0x03, 0xaf, 0x97, 0xff, 0x7d, 0x3a, 0xf6, 0xa0,
3950 0x02, 0x94, 0xbd, 0x9f, 0x4b, 0x2e, 0xd7, 0x52,
3951 0x28, 0xdb, 0x49, 0x2a, 0x65, 0xcb, 0x1e, 0x27,
3952 0x57, 0x9c, 0xba, 0x74, 0x20, 0xd5, 0x1d, 0x20,
3955 const unsigned char csr[32] = {
3956 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3957 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
3958 0x45, 0x51, 0x23, 0x19, 0x50, 0xb7, 0x5f, 0xc4,
3959 0x40, 0x2d, 0xa1, 0x72, 0x2f, 0xc9, 0xba, 0xee
3982 unsigned char signature[72];
3983 static const unsigned char nonce[32] = {
3984 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3985 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3986 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3987 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
3989 static const unsigned char nonce2[32] = {
3990 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
3991 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,
3992 0xBA,0xAE,0xDC,0xE6,0xAF,0x48,0xA0,0x3B,
3993 0xBF,0xD2,0x5E,0x8C,0xD0,0x36,0x41,0x40
3995 const unsigned char key[32] = {
3996 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3997 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3998 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3999 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
4001 unsigned char msg[32] = {
4002 0x86, 0x41, 0x99, 0x81, 0x06, 0x23, 0x44, 0x53,
4003 0xaa, 0x5f, 0x9d, 0x6a, 0x31, 0x78, 0xf4, 0xf7,
4004 0xb8, 0x12, 0xe0, 0x0b, 0x81, 0x7a, 0x77, 0x62,
4005 0x65, 0xdf, 0xdd, 0x31, 0xb9, 0x3e, 0x29, 0xa9,
4039 CHECK(ecount == 10);
4041 CHECK(ecount == 11);
4043 CHECK(ecount == 11);
4045 CHECK(ecount == 12);
4047 CHECK(ecount == 13);
4049 CHECK(ecount == 13);
4053 CHECK(ecount == 13);
4069 memset(signature, 255, 64);
4076 for (t = 0; t < 2; t++) {
4077 static const unsigned char zero[32] = {0x00};
4079 unsigned char key[32];
4080 unsigned char msg[32];
4083 const unsigned char *extra;
4084 extra = t == 0 ? NULL : zero;
4088 memset(
key, 0xFF, 32);
4104 CHECK(memcmp(&sig, &sig2,
sizeof(sig)) == 0);
4108 CHECK(memcmp(&sig, &sig2,
sizeof(sig)) == 0);
4110 for(i = 0; i < 256; i++) {
4116 for (j = 0; j < i; j++) {
4123 for(i = 256; i < 512; i++) {
4129 for (j = 0; j < i; j++) {
4138 const unsigned char zeros[32] = {0};
4139 unsigned char nonce[32];
4140 unsigned char nonce2[32];
4141 unsigned char nonce3[32];
4142 unsigned char nonce4[32];
4155 CHECK(memcmp(nonce, nonce2, 32) != 0);
4156 CHECK(memcmp(nonce, nonce3, 32) != 0);
4157 CHECK(memcmp(nonce, nonce4, 32) != 0);
4158 CHECK(memcmp(nonce2, nonce3, 32) != 0);
4159 CHECK(memcmp(nonce2, nonce4, 32) != 0);
4160 CHECK(memcmp(nonce3, nonce4, 32) != 0);
4166 unsigned char privkey[300];
4167 unsigned char seckey[32] = {
4168 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
4169 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe,
4170 0xba, 0xae, 0xdc, 0xe6, 0xaf, 0x48, 0xa0, 0x3b,
4171 0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41, 0x41,
4173 size_t outlen = 300;
4184 #ifdef ENABLE_OPENSSL_TESTS 4185 EC_KEY *get_openssl_key(
const unsigned char *key32) {
4186 unsigned char privkey[300];
4188 const unsigned char* pbegin = privkey;
4192 CHECK(d2i_ECPrivateKey(&ec_key, &pbegin, privkeylen));
4193 CHECK(EC_KEY_check_key(ec_key));
4197 void test_ecdsa_openssl(
void) {
4205 unsigned int sigsize = 80;
4206 size_t secp_sigsize = 80;
4207 unsigned char message[32];
4208 unsigned char signature[80];
4209 unsigned char key32[32];
4216 ec_key = get_openssl_key(key32);
4217 CHECK(ec_key != NULL);
4218 CHECK(ECDSA_sign(0, message,
sizeof(message), signature, &sigsize, ec_key));
4227 CHECK(ECDSA_verify(0, message,
sizeof(message), signature, secp_sigsize, ec_key) == 1);
4229 EC_KEY_free(ec_key);
4232 void run_ecdsa_openssl(
void) {
4234 for (i = 0; i < 10*
count; i++) {
4235 test_ecdsa_openssl();
4240 #ifdef ENABLE_MODULE_ECDH 4244 #ifdef ENABLE_MODULE_SCHNORR 4248 #ifdef ENABLE_MODULE_RECOVERY 4253 unsigned char seed16[16] = {0};
4254 unsigned char run32[32] = {0};
4257 count = strtol(argv[1], NULL, 0);
4263 const char* ch = argv[2];
4264 while (pos < 16 && ch[0] != 0 && ch[1] != 0) {
4266 if (sscanf(ch,
"%2hx", &sh)) {
4275 FILE *frand = fopen(
"/dev/urandom",
"r");
4276 if ((frand == NULL) || !fread(&seed16,
sizeof(seed16), 1, frand)) {
4277 uint64_t t = time(NULL) * (uint64_t)1337;
4279 seed16[1] ^= t >> 8;
4280 seed16[2] ^= t >> 16;
4281 seed16[3] ^= t >> 24;
4282 seed16[4] ^= t >> 32;
4283 seed16[5] ^= t >> 40;
4284 seed16[6] ^= t >> 48;
4285 seed16[7] ^= t >> 56;
4291 printf(
"test count = %i\n",
count);
4292 printf(
"random seed = %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n", seed16[0], seed16[1], seed16[2], seed16[3], seed16[4], seed16[5], seed16[6], seed16[7], seed16[8], seed16[9], seed16[10], seed16[11], seed16[12], seed16[13], seed16[14], seed16[15]);
4309 #ifndef USE_NUM_NONE 4340 #ifdef USE_ENDOMORPHISM 4341 run_endomorphism_tests();
4350 #ifdef ENABLE_MODULE_ECDH 4361 #ifdef ENABLE_OPENSSL_TESTS 4362 run_ecdsa_openssl();
4365 #ifdef ENABLE_MODULE_SCHNORR 4370 #ifdef ENABLE_MODULE_RECOVERY 4376 printf(
"random run = %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n", run32[0], run32[1], run32[2], run32[3], run32[4], run32[5], run32[6], run32[7], run32[8], run32[9], run32[10], run32[11], run32[12], run32[13], run32[14], run32[15]);
4381 printf(
"no problems found\n");
static int secp256k1_scalar_eq(const secp256k1_scalar *a, const secp256k1_scalar *b)
static void secp256k1_scalar_mul(secp256k1_scalar *r, const secp256k1_scalar *a, const secp256k1_scalar *b)
static int secp256k1_ge_is_infinity(const secp256k1_ge *a)
#define VERIFY_CHECK(cond)
static SECP256K1_INLINE int secp256k1_scalar_check_overflow(const secp256k1_scalar *a)
void run_hmac_sha256_tests(void)
static int secp256k1_gej_is_infinity(const secp256k1_gej *a)
int check_fe_equal(const secp256k1_fe *a, const secp256k1_fe *b)
static int secp256k1_num_eq(const secp256k1_num *a, const secp256k1_num *b)
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_tweak_add(const secp256k1_context *ctx, secp256k1_pubkey *pubkey, const unsigned char *tweak) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
static SECP256K1_INLINE void secp256k1_fe_clear(secp256k1_fe *a)
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_privkey_tweak_mul(const secp256k1_context *ctx, unsigned char *seckey, const unsigned char *tweak) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
static void secp256k1_rand_bytes_test(unsigned char *bytes, size_t len)
static void secp256k1_gej_add_var(secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_gej *b, secp256k1_fe *rzr)
static int secp256k1_fe_is_zero(const secp256k1_fe *a)
void random_fe(secp256k1_fe *x)
SECP256K1_API void secp256k1_context_set_illegal_callback(secp256k1_context *ctx, void(*fun)(const char *message, void *data), const void *data) SECP256K1_ARG_NONNULL(1)
void test_add_neg_y_diff_x(void)
static int secp256k1_scalar_is_even(const secp256k1_scalar *a)
void run_ecmult_const_tests(void)
SECP256K1_API int secp256k1_ecdsa_signature_serialize_compact(const secp256k1_context *ctx, unsigned char *output64, const secp256k1_ecdsa_signature *sig) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
void test_point_times_order(const secp256k1_gej *point)
#define SECP256K1_GEJ_CONST(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p)
static void secp256k1_ge_neg(secp256k1_ge *r, const secp256k1_ge *a)
SECP256K1_API int secp256k1_ecdsa_signature_normalize(const secp256k1_context *ctx, secp256k1_ecdsa_signature *sigout, const secp256k1_ecdsa_signature *sigin) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(3)
void run_group_decompress(void)
static void secp256k1_fe_mul(secp256k1_fe *r, const secp256k1_fe *a, const secp256k1_fe *SECP256K1_RESTRICT b)
static void secp256k1_ecmult_gen(const secp256k1_ecmult_gen_context *ctx, secp256k1_gej *r, const secp256k1_scalar *a)
static void secp256k1_fe_normalize_var(secp256k1_fe *r)
static void secp256k1_num_set_bin(secp256k1_num *r, const unsigned char *a, unsigned int alen)
static void secp256k1_rfc6979_hmac_sha256_initialize(secp256k1_rfc6979_hmac_sha256_t *rng, const unsigned char *key, size_t keylen)
int fe_memcmp(const secp256k1_fe *a, const secp256k1_fe *b)
static int secp256k1_ecdsa_sig_sign(const secp256k1_ecmult_gen_context *ctx, secp256k1_scalar *r, secp256k1_scalar *s, const secp256k1_scalar *seckey, const secp256k1_scalar *message, const secp256k1_scalar *nonce, int *recid)
void run_scalar_tests(void)
void test_sqrt(const secp256k1_fe *a, const secp256k1_fe *k)
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_context_randomize(secp256k1_context *ctx, const unsigned char *seed32) SECP256K1_ARG_NONNULL(1)
static int nonce_function_test_fail(unsigned char *nonce32, const unsigned char *msg32, const unsigned char *key32, const unsigned char *algo16, void *data, unsigned int counter)
static int nonce_function_rfc6979(unsigned char *nonce32, const unsigned char *msg32, const unsigned char *key32, const unsigned char *algo16, void *data, unsigned int counter)
static void secp256k1_ge_set_gej_var(secp256k1_ge *r, secp256k1_gej *a)
void test_random_pubkeys(void)
static void secp256k1_fe_negate(secp256k1_fe *r, const secp256k1_fe *a, int m)
static void secp256k1_scalar_get_num(secp256k1_num *r, const secp256k1_scalar *a)
static int nonce_function_test_retry(unsigned char *nonce32, const unsigned char *msg32, const unsigned char *key32, const unsigned char *algo16, void *data, unsigned int counter)
static void assign_big_endian(unsigned char *ptr, size_t ptrlen, uint32_t val)
static void secp256k1_fe_from_storage(secp256k1_fe *r, const secp256k1_fe_storage *a)
void test_ecmult_constants(void)
static void secp256k1_num_copy(secp256k1_num *r, const secp256k1_num *a)
#define SECP256K1_CONTEXT_NONE
static unsigned int secp256k1_scalar_get_bits(const secp256k1_scalar *a, unsigned int offset, unsigned int count)
void run_field_misc(void)
static int secp256k1_ecdsa_sig_parse(secp256k1_scalar *r, secp256k1_scalar *s, const unsigned char *sig, size_t size)
static void secp256k1_scalar_negate(secp256k1_scalar *r, const secp256k1_scalar *a)
static void secp256k1_fe_storage_cmov(secp256k1_fe_storage *r, const secp256k1_fe_storage *a, int flag)
static uint32_t secp256k1_rand_int(uint32_t range)
static int ec_privkey_export_der(const secp256k1_context *ctx, unsigned char *privkey, size_t *privkeylen, const unsigned char *key32, int compressed)
static void secp256k1_ecmult_gen_blind(secp256k1_ecmult_gen_context *ctx, const unsigned char *seed32)
static int secp256k1_eckey_pubkey_serialize(secp256k1_ge *elem, unsigned char *pub, size_t *size, int compressed)
static int secp256k1_scalar_is_zero(const secp256k1_scalar *a)
void run_random_pubkeys(void)
static int secp256k1_scalar_shr_int(secp256k1_scalar *r, int n)
static void secp256k1_gej_neg(secp256k1_gej *r, const secp256k1_gej *a)
static void secp256k1_pubkey_save(secp256k1_pubkey *pubkey, secp256k1_ge *ge)
static void secp256k1_fe_cmov(secp256k1_fe *r, const secp256k1_fe *a, int flag)
void test_wnaf(const secp256k1_scalar *number, int w)
static void secp256k1_gej_add_zinv_var(secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_ge *b, const secp256k1_fe *bzinv)
void random_scalar_order(secp256k1_scalar *num)
#define SECP256K1_GEJ_CONST_INFINITY
void random_fe_non_zero(secp256k1_fe *nz)
SECP256K1_API int secp256k1_ec_pubkey_serialize(const secp256k1_context *ctx, unsigned char *output, size_t *outputlen, const secp256k1_pubkey *pubkey, unsigned int flags) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4)
static void secp256k1_rfc6979_hmac_sha256_generate(secp256k1_rfc6979_hmac_sha256_t *rng, unsigned char *out, size_t outlen)
static void secp256k1_ecmult_const(secp256k1_gej *r, const secp256k1_ge *a, const secp256k1_scalar *q)
void run_ecmult_constants(void)
static void secp256k1_ecmult(const secp256k1_ecmult_context *ctx, secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_scalar *na, const secp256k1_scalar *ng)
void(* fn)(const char *text, void *data)
static void secp256k1_scalar_set_b32(secp256k1_scalar *r, const unsigned char *bin, int *overflow)
static void secp256k1_fe_set_int(secp256k1_fe *r, int a)
static void secp256k1_fe_to_storage(secp256k1_fe_storage *r, const secp256k1_fe *a)
void ge_equals_ge(const secp256k1_ge *a, const secp256k1_ge *b)
static void secp256k1_ecmult_gen_context_build(secp256k1_ecmult_gen_context *ctx, const secp256k1_callback *cb)
static void secp256k1_num_mod_inverse(secp256k1_num *r, const secp256k1_num *a, const secp256k1_num *m)
static void secp256k1_hmac_sha256_initialize(secp256k1_hmac_sha256_t *hash, const unsigned char *key, size_t size)
#define SECP256K1_CONTEXT_SIGN
void test_num_add_sub(void)
void run_ecdsa_sign_verify(void)
void random_field_element_test(secp256k1_fe *fe)
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_privkey_tweak_add(const secp256k1_context *ctx, unsigned char *seckey, const unsigned char *tweak) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
void test_ec_combine(void)
void test_num_negate(void)
void random_sign(secp256k1_scalar *sigr, secp256k1_scalar *sigs, const secp256k1_scalar *key, const secp256k1_scalar *msg, int *recid)
static void secp256k1_ecdsa_signature_save(secp256k1_ecdsa_signature *sig, const secp256k1_scalar *r, const secp256k1_scalar *s)
#define SECP256K1_FE_CONST(d7, d6, d5, d4, d3, d2, d1, d0)
void test_ecmult_gen_blind_reset(void)
static int secp256k1_gej_is_valid_var(const secp256k1_gej *a)
static void secp256k1_gej_set_infinity(secp256k1_gej *r)
static int secp256k1_eckey_pubkey_parse(secp256k1_ge *elem, const unsigned char *pub, size_t size)
static void secp256k1_fe_add(secp256k1_fe *r, const secp256k1_fe *a)
static void damage_array(unsigned char *sig, size_t *len)
static void secp256k1_fe_mul_int(secp256k1_fe *r, int a)
void ge_equals_gej(const secp256k1_ge *a, const secp256k1_gej *b)
static int secp256k1_fe_is_odd(const secp256k1_fe *a)
static void secp256k1_gej_add_ge_var(secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_ge *b, secp256k1_fe *rzr)
void run_eckey_edge_case_test(void)
void run_context_tests(void)
static void secp256k1_gej_double_var(secp256k1_gej *r, const secp256k1_gej *a, secp256k1_fe *rzr)
SECP256K1_API void secp256k1_context_destroy(secp256k1_context *ctx)
int test_ecdsa_der_parse(const unsigned char *sig, size_t siglen, int certainly_der, int certainly_not_der)
void run_ecdh_tests(void)
static const secp256k1_ge secp256k1_ge_const_g
void run_field_inv_all_var(void)
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_create(const secp256k1_context *ctx, secp256k1_pubkey *pubkey, const unsigned char *seckey) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
void test_rand_int(uint32_t range, uint32_t subrange)
#define SECP256K1_EC_UNCOMPRESSED
#define SECP256K1_EC_COMPRESSED
static void secp256k1_scalar_mul_shift_var(secp256k1_scalar *r, const secp256k1_scalar *a, const secp256k1_scalar *b, unsigned int shift)
void run_rfc6979_hmac_sha256_tests(void)
void run_field_inv_var(void)
void random_num_order(secp256k1_num *num)
static void secp256k1_rfc6979_hmac_sha256_finalize(secp256k1_rfc6979_hmac_sha256_t *rng)
static void secp256k1_sha256_finalize(secp256k1_sha256_t *hash, unsigned char *out32)
void run_ec_pubkey_parse_test(void)
static void secp256k1_scalar_inverse(secp256k1_scalar *r, const secp256k1_scalar *a)
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_seckey_verify(const secp256k1_context *ctx, const unsigned char *seckey) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2)
void run_ecmult_gen_blind(void)
void run_ecdsa_der_parse(void)
static void secp256k1_sha256_write(secp256k1_sha256_t *hash, const unsigned char *data, size_t size)
static void secp256k1_num_sub(secp256k1_num *r, const secp256k1_num *a, const secp256k1_num *b)
static void secp256k1_ge_set_table_gej_var(size_t len, secp256k1_ge *r, const secp256k1_gej *a, const secp256k1_fe *zr)
secp256k1_ecmult_gen_context ecmult_gen_ctx
void run_field_convert(void)
#define SECP256K1_SCALAR_CONST(d7, d6, d5, d4, d3, d2, d1, d0)
void run_num_smalltests(void)
void ecmult_const_mult_zero_one(void)
static int secp256k1_ge_set_xquad_var(secp256k1_ge *r, const secp256k1_fe *x)
static secp256k1_context * ctx
void run_ecmult_chain(void)
int is_empty_signature(const secp256k1_ecdsa_signature *sig)
SECP256K1_API int secp256k1_ecdsa_sign(const secp256k1_context *ctx, secp256k1_ecdsa_signature *sig, const unsigned char *msg32, const unsigned char *seckey, secp256k1_nonce_function noncefp, const void *ndata) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4)
static void secp256k1_ge_set_gej(secp256k1_ge *r, secp256k1_gej *a)
static int secp256k1_scalar_is_high(const secp256k1_scalar *a)
static void secp256k1_num_add(secp256k1_num *r, const secp256k1_num *a, const secp256k1_num *b)
static void secp256k1_hmac_sha256_write(secp256k1_hmac_sha256_t *hash, const unsigned char *data, size_t size)
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_tweak_mul(const secp256k1_context *ctx, secp256k1_pubkey *pubkey, const unsigned char *tweak) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
static void secp256k1_num_shift(secp256k1_num *r, int bits)
static void secp256k1_scalar_sqr(secp256k1_scalar *r, const secp256k1_scalar *a)
static void secp256k1_hmac_sha256_finalize(secp256k1_hmac_sha256_t *hash, unsigned char *out32)
static void secp256k1_sha256_initialize(secp256k1_sha256_t *hash)
void test_group_decompress(const secp256k1_fe *x)
void run_ecdsa_end_to_end(void)
static void secp256k1_num_mul(secp256k1_num *r, const secp256k1_num *a, const secp256k1_num *b)
void test_constant_wnaf_negate(const secp256k1_scalar *number)
static int secp256k1_fe_sqrt_var(secp256k1_fe *r, const secp256k1_fe *a)
void ec_pubkey_parse_pointtest(const unsigned char *input, int xvalid, int yvalid)
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_parse(const secp256k1_context *ctx, secp256k1_pubkey *pubkey, const unsigned char *input, size_t inputlen) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
static void secp256k1_scalar_cadd_bit(secp256k1_scalar *r, unsigned int bit, int flag)
secp256k1_ecmult_context ecmult_ctx
static void secp256k1_fe_inv_all_var(size_t len, secp256k1_fe *r, const secp256k1_fe *a)
static void secp256k1_fe_normalize_weak(secp256k1_fe *r)
static uint32_t secp256k1_rand32(void)
static void secp256k1_ge_clear(secp256k1_ge *r)
static int ec_privkey_import_der(const secp256k1_context *ctx, unsigned char *out32, const unsigned char *privkey, size_t privkeylen)
#define SECP256K1_EC_PARSE_TEST_NINVALID
static void secp256k1_num_negate(secp256k1_num *r)
SECP256K1_API void secp256k1_context_set_error_callback(secp256k1_context *ctx, void(*fun)(const char *message, void *data), const void *data) SECP256K1_ARG_NONNULL(1)
static int secp256k1_scalar_cond_negate(secp256k1_scalar *a, int flag)
int main(int argc, char **argv)
static void secp256k1_ecdsa_signature_load(const secp256k1_context *ctx, secp256k1_scalar *r, secp256k1_scalar *s, const secp256k1_ecdsa_signature *sig)
SECP256K1_API int secp256k1_ecdsa_signature_parse_der(const secp256k1_context *ctx, secp256k1_ecdsa_signature *sig, const unsigned char *input, size_t inputlen) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
void run_sha256_tests(void)
static void secp256k1_scalar_get_b32(unsigned char *bin, const secp256k1_scalar *a)
static int secp256k1_ge_set_xo_var(secp256k1_ge *r, const secp256k1_fe *x, int odd)
void test_ecdsa_edge_cases(void)
static void secp256k1_fe_sqr(secp256k1_fe *r, const secp256k1_fe *a)
#define SECP256K1_GE_CONST(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p)
static int secp256k1_fe_set_b32(secp256k1_fe *r, const unsigned char *a)
static int secp256k1_fe_cmp_var(const secp256k1_fe *a, const secp256k1_fe *b)
#define SECP256K1_CONTEXT_VERIFY
SECP256K1_API secp256k1_context * secp256k1_context_clone(const secp256k1_context *ctx) SECP256K1_ARG_NONNULL(1) SECP256K1_WARN_UNUSED_RESULT
static int secp256k1_fe_equal_var(const secp256k1_fe *a, const secp256k1_fe *b)
void random_group_element_jacobian_test(secp256k1_gej *gej, const secp256k1_ge *ge)
void run_schnorr_tests(void)
static int secp256k1_num_cmp(const secp256k1_num *a, const secp256k1_num *b)
SECP256K1_API int secp256k1_ecdsa_signature_serialize_der(const secp256k1_context *ctx, unsigned char *output, size_t *outputlen, const secp256k1_ecdsa_signature *sig) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4)
void random_scalar_order_test(secp256k1_scalar *num)
static void secp256k1_gej_rescale(secp256k1_gej *r, const secp256k1_fe *b)
static int secp256k1_scalar_add(secp256k1_scalar *r, const secp256k1_scalar *a, const secp256k1_scalar *b)
static uint32_t secp256k1_rand_bits(int bits)
void random_group_element_test(secp256k1_ge *ge)
static void secp256k1_scalar_set_int(secp256k1_scalar *r, unsigned int v)
SECP256K1_API int secp256k1_ecdsa_signature_parse_compact(const secp256k1_context *ctx, secp256k1_ecdsa_signature *sig, const unsigned char *input64) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
static void secp256k1_scalar_inverse_var(secp256k1_scalar *r, const secp256k1_scalar *a)
void ecmult_const_random_mult(void)
static void random_ber_signature(unsigned char *sig, size_t *len, int *certainly_der, int *certainly_not_der)
#define SECP256K1_EC_PARSE_TEST_NVALID
static void secp256k1_ge_set_all_gej_var(size_t len, secp256k1_ge *r, const secp256k1_gej *a, const secp256k1_callback *cb)
void * memcpy(void *a, const void *b, size_t c)
void random_fe_test(secp256k1_fe *x)
static void secp256k1_fe_normalize(secp256k1_fe *r)
#define SECP256K1_FE_STORAGE_CONST(d7, d6, d5, d4, d3, d2, d1, d0)
void test_ecdsa_sign_verify(void)
static int secp256k1_ecdsa_sig_verify(const secp256k1_ecmult_context *ctx, const secp256k1_scalar *r, const secp256k1_scalar *s, const secp256k1_ge *pubkey, const secp256k1_scalar *message)
static int secp256k1_num_is_zero(const secp256k1_num *a)
static int precomputed_nonce_function(unsigned char *nonce32, const unsigned char *msg32, const unsigned char *key32, const unsigned char *algo16, void *data, unsigned int counter)
static void secp256k1_rand256(unsigned char *b32)
static unsigned int secp256k1_scalar_get_bits_var(const secp256k1_scalar *a, unsigned int offset, unsigned int count)
void test_ecdsa_end_to_end(void)
static void secp256k1_fe_get_b32(unsigned char *r, const secp256k1_fe *a)
static void secp256k1_gej_add_ge(secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_ge *b)
static int secp256k1_pubkey_load(const secp256k1_context *ctx, secp256k1_ge *ge, const secp256k1_pubkey *pubkey)
secp256k1_callback error_callback
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_combine(const secp256k1_context *ctx, secp256k1_pubkey *out, const secp256k1_pubkey *const *ins, size_t n) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
void test_constant_wnaf(const secp256k1_scalar *number, int w)
static void secp256k1_num_mod(secp256k1_num *r, const secp256k1_num *m)
void random_num_negate(secp256k1_num *num)
void random_field_element_magnitude(secp256k1_fe *fe)
static void secp256k1_gej_set_ge(secp256k1_gej *r, const secp256k1_ge *a)
void ecmult_const_commutativity(void)
static void counting_illegal_callback_fn(const char *str, void *data)
void random_num_order_test(secp256k1_num *num)
void ecmult_const_chain_multiply(void)
static int secp256k1_ecmult_wnaf(int *wnaf, int len, const secp256k1_scalar *a, int w)
static void secp256k1_scalar_order_get_num(secp256k1_num *r)
void test_ecmult_gen_blind(void)
int gej_xyz_equals_gej(const secp256k1_gej *a, const secp256k1_gej *b)
static int secp256k1_ge_is_valid_var(const secp256k1_ge *a)
static void secp256k1_ecmult_context_build(secp256k1_ecmult_context *ctx, const secp256k1_callback *cb)
static SECP256K1_INLINE void secp256k1_rand_seed(const unsigned char *seed16)
void random_fe_non_square(secp256k1_fe *ns)
void * memmove(void *a, const void *b, size_t c)
static void secp256k1_fe_inv_var(secp256k1_fe *r, const secp256k1_fe *a)
static void secp256k1_num_get_bin(unsigned char *r, unsigned int rlen, const secp256k1_num *a)
static void secp256k1_fe_inv(secp256k1_fe *r, const secp256k1_fe *a)
SECP256K1_API secp256k1_context * secp256k1_context_create(unsigned int flags) SECP256K1_WARN_UNUSED_RESULT
void run_ec_combine(void)
static int secp256k1_wnaf_const(int *wnaf, secp256k1_scalar s, int w)
static void uncounting_illegal_callback_fn(const char *str, void *data)
void run_ecdsa_edge_cases(void)
static int secp256k1_scalar_is_one(const secp256k1_scalar *a)
void test_rand_bits(int rand32, int bits)
void run_recovery_tests(void)
static int secp256k1_num_is_neg(const secp256k1_num *a)
int check_fe_inverse(const secp256k1_fe *a, const secp256k1_fe *ai)
#define SECP256K1_EC_PARSE_TEST_NXVALID
static int ecdsa_signature_parse_der_lax(const secp256k1_context *ctx, secp256k1_ecdsa_signature *sig, const unsigned char *input, size_t inputlen)
static int secp256k1_ecdsa_sig_serialize(unsigned char *sig, size_t *size, const secp256k1_scalar *r, const secp256k1_scalar *s)
void run_point_times_order(void)
static void secp256k1_rand256_test(unsigned char *b32)
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ecdsa_verify(const secp256k1_context *ctx, const secp256k1_ecdsa_signature *sig, const unsigned char *msg32, const secp256k1_pubkey *pubkey) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4)