43 #define MULTIPLICAND(...) { __VA_ARGS__ } 46 #define MULTIPLIER(...) { __VA_ARGS__ } 49 #define INVERTEND(...) { __VA_ARGS__ } 52 #define BASE(...) { __VA_ARGS__ } 55 #define SCALAR(...) { __VA_ARGS__ } 58 #define EXPECTED(...) { __VA_ARGS__ } 85 #define X25519_MULTIPLY_TEST( name, MULTIPLICAND, MULTIPLIER, \ 87 static const uint8_t name ## _multiplicand[] = MULTIPLICAND; \ 88 static const uint8_t name ## _multiplier[] = MULTIPLIER; \ 89 static const uint8_t name ## _expected[] = EXPECTED; \ 90 static struct x25519_multiply_test name = { \ 91 .multiplicand = name ## _multiplicand, \ 92 .multiplicand_len = sizeof ( name ## _multiplicand ), \ 93 .multiplier = name ## _multiplier, \ 94 .multiplier_len = sizeof ( name ## _multiplier ), \ 95 .expected = name ## _expected, \ 96 .expected_len = sizeof ( name ## _expected ), \ 119 #define X25519_INVERT_TEST( name, INVERTEND, EXPECTED ) \ 120 static const uint8_t name ## _invertend[] = INVERTEND; \ 121 static const uint8_t name ## _expected[] = EXPECTED; \ 122 static struct x25519_invert_test name = { \ 123 .invertend = name ## _invertend, \ 124 .invertend_len = sizeof ( name ## _invertend ), \ 125 .expected = name ## _expected, \ 126 .expected_len = sizeof ( name ## _expected ), \ 154 #define X25519_KEY_TEST( name, COUNT, FAIL, BASE, SCALAR, EXPECTED ) \ 155 static struct x25519_key_test name = { \ 158 .base = { .raw = BASE }, \ 159 .scalar = { .raw = SCALAR }, \ 160 .expected = { .raw = EXPECTED }, \ 171 const char *file,
unsigned int line ) {
179 test->multiplicand_len );
180 DBGC (
test,
"X25519 multiplicand:\n" );
181 DBGC_HDA (
test, 0, &multiplicand,
sizeof ( multiplicand ) );
183 test->multiplier_len );
184 DBGC (
test,
"X25519 multiplier:\n" );
187 DBGC (
test,
"X25519 expected product:\n" );
195 DBGC (
test,
"X25519 actual product:\n" );
199 okx (
memcmp ( &actual, &expected,
sizeof ( expected ) ) == 0,
202 #define x25519_multiply_ok( test ) \ 203 x25519_multiply_okx ( test, __FILE__, __LINE__ ) 213 const char *file,
unsigned int line ) {
214 static const uint8_t one[] = { 1 };
223 DBGC (
test,
"X25519 invertend:\n" );
226 DBGC (
test,
"X25519 expected inverse:\n" );
238 DBGC (
test,
"X25519 actual inverse:\n" );
241 DBGC (
test,
"X25519 actual product:\n" );
245 okx (
memcmp ( &actual, &expected,
sizeof ( expected ) ) == 0,
250 #define x25519_invert_ok( test ) \ 251 x25519_invert_okx ( test, __FILE__, __LINE__ ) 261 const char *file,
unsigned int line ) {
275 DBGC (
test,
"X25519 expected result (x%d):\n",
test->count );
279 for ( i = 0 ; i <
test->count ; i++ ) {
282 okx (
rc != 0, file, line );
284 okx (
rc == 0, file, line );
287 memcpy ( &scalar, &actual,
sizeof ( scalar ) );
289 DBGC (
test,
"X25519 actual result (x%d):\n",
test->count );
294 sizeof (
test->expected ) ) == 0, file, line );
296 #define x25519_key_ok( test ) \ 297 x25519_key_okx ( test, __FILE__, __LINE__ ) 305 MULTIPLICAND ( 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
306 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
307 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
308 0xff, 0xff, 0xff, 0xff, 0xed ),
309 MULTIPLIER ( 0x00, 0xe8, 0x0d, 0x83, 0xd4, 0xe9, 0x1e, 0xdd, 0x7a,
310 0x45, 0x14, 0x87, 0xb7, 0xfc, 0x62, 0x54, 0x1f, 0xb2,
311 0x97, 0x24, 0xde, 0xfa, 0xd3, 0xe7, 0x3e, 0x83, 0x93,
312 0x60, 0xbc, 0x20, 0x97, 0x9b, 0x22 ),
320 MULTIPLICAND ( 0x02, 0x23, 0xb8, 0xc1, 0xe9, 0x39, 0x24, 0x56, 0xde,
321 0x3e, 0xb1, 0x3b, 0x90, 0x46, 0x68, 0x52, 0x57, 0xbd,
322 0xd6, 0x40, 0xfb, 0x06, 0x67, 0x1a, 0xd1, 0x1c, 0x80,
323 0x31, 0x7f, 0xa3, 0xb1, 0x79, 0x9d ),
324 MULTIPLIER ( 0x00, 0x6c, 0x03, 0x11, 0x99, 0x97, 0x2a, 0x84, 0x69,
325 0x16, 0x41, 0x9f, 0x82, 0x8b, 0x9d, 0x24, 0x34, 0xe4,
326 0x65, 0xe1, 0x50, 0xbd, 0x9c, 0x66, 0xb3, 0xad, 0x3c,
327 0x2d, 0x6d, 0x1a, 0x3d, 0x1f, 0xa7 ),
328 EXPECTED ( 0x1b, 0xa8, 0x7e, 0x98, 0x2f, 0x7c, 0x47, 0x76, 0x16, 0xb4,
329 0xd5, 0x13, 0x6b, 0xa5, 0x47, 0x33, 0xe4, 0x00, 0x81, 0xc1,
330 0xc2, 0xe2, 0x7d, 0x86, 0x4a, 0xa1, 0x78, 0xce, 0x89, 0x3d,
338 MULTIPLICAND ( 0x00, 0x8f, 0xad, 0xc1, 0xa6, 0x06, 0xcb, 0x0f, 0xb3,
339 0x9a, 0x1d, 0xe6, 0x44, 0x81, 0x5e, 0xf6, 0xd1, 0x3b,
340 0x8f, 0xaa, 0x18, 0x37, 0xf8, 0xa8, 0x8b, 0x17, 0xfc,
341 0x69, 0x5a, 0x07, 0xa0, 0xca, 0x6e ),
342 MULTIPLIER ( 0x01, 0x96, 0xda, 0x1d, 0xac, 0x72, 0xff, 0x5d, 0x2a,
343 0x38, 0x6e, 0xcb, 0xe0, 0x6b, 0x65, 0xa6, 0xa4, 0x8b,
344 0x81, 0x48, 0xf6, 0xb3, 0x8a, 0x08, 0x8c, 0xa6, 0x5e,
345 0xd3, 0x89, 0xb7, 0x4d, 0x0f, 0xb1 ),
346 EXPECTED ( 0x35, 0x1f, 0x7b, 0xf7, 0x5e, 0xf5, 0x80, 0x24, 0x9e, 0xd6,
347 0xf9, 0xff, 0x39, 0x96, 0x46, 0x3b, 0x07, 0x30, 0xa1, 0xd4,
348 0x9b, 0x5d, 0x36, 0xb8, 0x63, 0xe1, 0x92, 0x59, 0x11, 0x57,
356 MULTIPLICAND ( 0x01, 0x6c, 0x30, 0x75, 0x11, 0xb2, 0xb9, 0x43, 0x7a,
357 0x28, 0xdf, 0x6e, 0xc4, 0xce, 0x4a, 0x2b, 0xbd, 0xc2,
358 0x41, 0x33, 0x0b, 0x01, 0xa9, 0xe7, 0x1f, 0xde, 0x8a,
359 0x77, 0x4b, 0xcf, 0x36, 0xd5, 0x8b ),
360 MULTIPLIER ( 0x01, 0x17, 0xbe, 0x31, 0x11, 0x1a, 0x2a, 0x73, 0xed,
361 0x56, 0x2b, 0x0f, 0x79, 0xc3, 0x74, 0x59, 0xee, 0xf5,
362 0x0b, 0xea, 0x63, 0x37, 0x1e, 0xcd, 0x7b, 0x27, 0xcd,
363 0x81, 0x30, 0x47, 0x22, 0x93, 0x89 ),
364 EXPECTED ( 0x6b, 0x43, 0xb5, 0x18, 0x59, 0x65, 0xf8, 0xf0, 0x92, 0x0f,
365 0x31, 0xae, 0x1b, 0x2c, 0xef, 0xad, 0xd7, 0xb0, 0x78, 0xfe,
366 0xcf, 0x68, 0xdb, 0xea, 0xa1, 0x7b, 0x9c, 0x38, 0x5b, 0x55,
374 MULTIPLICAND ( 0x02, 0x0b, 0x1f, 0x91, 0x63, 0xce, 0x9f, 0xf5, 0x7f,
375 0x43, 0xb7, 0xa3, 0xa6, 0x9a, 0x8d, 0xca, 0x03, 0x58,
376 0x0d, 0x7b, 0x71, 0xd8, 0xf5, 0x64, 0x13, 0x5b, 0xe6,
377 0x12, 0x8e, 0x18, 0xc2, 0x67, 0x97 ),
378 MULTIPLIER ( 0x01, 0x8d, 0x52, 0x88, 0xf1, 0x14, 0x2c, 0x3f, 0xe8,
379 0x60, 0xe7, 0xa1, 0x13, 0xec, 0x1b, 0x8c, 0xa1, 0xf9,
380 0x1e, 0x1d, 0x4c, 0x1f, 0xf4, 0x9b, 0x78, 0x89, 0x46,
381 0x3e, 0x85, 0x75, 0x9c, 0xde, 0x66 ),
382 EXPECTED ( 0x28, 0xa7, 0x7d, 0x3c, 0x8a, 0x14, 0x32, 0x3d, 0x63, 0xb2,
383 0x88, 0xdb, 0xd4, 0x03, 0x15, 0xb3, 0xf1, 0x92, 0xb8, 0x48,
384 0x5d, 0x86, 0xa0, 0x2c, 0xb8, 0x7d, 0x3d, 0xfb, 0x7a, 0x0b,
392 MULTIPLICAND ( 0x02, 0x31, 0x39, 0xd3, 0x2c, 0x93, 0xcd, 0x59, 0xbf,
393 0x5c, 0x94, 0x1c, 0xf0, 0xdc, 0x98, 0xd2, 0xc1, 0xe2,
394 0xac, 0xf7, 0x2f, 0x9e, 0x57, 0x4f, 0x7a, 0xa0, 0xee,
395 0x89, 0xae, 0xd4, 0x53, 0xdd, 0x32 ),
396 MULTIPLIER ( 0x03, 0x14, 0x6d, 0x3f, 0x31, 0xfc, 0x37, 0x7a, 0x4c,
397 0x4a, 0x15, 0x54, 0x4d, 0xc5, 0xe7, 0xce, 0x8a, 0x3a,
398 0x57, 0x8a, 0x8e, 0xa9, 0x48, 0x8d, 0x99, 0x0b, 0xbb,
399 0x25, 0x99, 0x11, 0xce, 0x5d, 0xd2 ),
400 EXPECTED ( 0x4b, 0xdb, 0x7a, 0x35, 0xc0, 0xa5, 0x18, 0x20, 0x00, 0xaa,
401 0x67, 0x55, 0x47, 0x41, 0xe8, 0x8c, 0xfd, 0xf4, 0x60, 0xa7,
402 0x8c, 0x6f, 0xae, 0x07, 0xad, 0xf8, 0x3d, 0x2f, 0x00, 0x5d,
409 INVERTEND ( 0x01, 0xd5, 0x88, 0x42, 0xde, 0xa2, 0xbc, 0x37, 0x2f,
410 0x74, 0x12, 0xb2, 0x93, 0x47, 0x29, 0x47, 0x39, 0x61,
411 0x4f, 0xf3, 0xd7, 0x19, 0xdb, 0x3a, 0xd0, 0xdd, 0xd1,
412 0xdf, 0xb2, 0x3b, 0x98, 0x2e, 0xf8 ),
413 EXPECTED ( 0x09, 0x3f, 0xf5, 0x17, 0x50, 0x80, 0x9d, 0x18, 0x1a, 0x9a,
414 0x54, 0x81, 0xc5, 0x64, 0xe3, 0x7c, 0xff, 0x61, 0x8d, 0xef,
415 0x8e, 0xc4, 0x5f, 0x46, 0x4b, 0x1a, 0x6e, 0x24, 0xf8, 0xb8,
422 INVERTEND ( 0x02, 0xef, 0xc8, 0x98, 0x49, 0xb3, 0xaa, 0x7e, 0xfe,
423 0x44, 0x58, 0xa8, 0x85, 0xab, 0x90, 0x99, 0xa4, 0x35,
424 0xa2, 0x40, 0xae, 0x5a, 0xf3, 0x05, 0x53, 0x5e, 0xc4,
425 0x2e, 0x08, 0x29, 0xa3, 0xb2, 0xe9 ),
426 EXPECTED ( 0x59, 0x16, 0x07, 0xb1, 0x63, 0xe8, 0x9d, 0x0a, 0xc3, 0x3a,
427 0x62, 0xc8, 0x81, 0xe9, 0x84, 0xa2, 0x5d, 0x38, 0x26, 0xe3,
428 0xdb, 0x5c, 0xe2, 0x29, 0xaf, 0x24, 0x0d, 0xc5, 0x8e, 0x5b,
435 INVERTEND ( 0x00, 0x3e, 0xab, 0xed, 0xcb, 0xba, 0xa8, 0x0d, 0xd4,
436 0x88, 0xbd, 0x64, 0x07, 0x2b, 0xcf, 0xbe, 0x01, 0xa2,
437 0x8d, 0xef, 0xe3, 0x9b, 0xf0, 0x02, 0x73, 0x12, 0x47,
438 0x6f, 0x57, 0xa5, 0xe5, 0xa5, 0xab ),
439 EXPECTED ( 0x7d, 0x87, 0xc2, 0xe5, 0x65, 0xb2, 0x7c, 0x50, 0x38, 0x18,
440 0x1a, 0x0a, 0x7c, 0xae, 0x9e, 0xbe, 0x82, 0x6c, 0x8a, 0xfc,
441 0x1f, 0x77, 0x12, 0x8a, 0x4d, 0x62, 0xcc, 0xe9, 0x6d, 0x27,
448 INVERTEND ( 0x00, 0x8e, 0x94, 0x42, 0x39, 0xb0, 0x2b, 0x61, 0xc4,
449 0xa3, 0xd7, 0x06, 0x28, 0xec, 0xe6, 0x6f, 0xa2, 0xfd,
450 0x51, 0x66, 0xe6, 0x45, 0x1b, 0x4c, 0xf3, 0x61, 0x23,
451 0xfd, 0xf7, 0x76, 0x56, 0xaf, 0x72 ),
452 EXPECTED ( 0x08, 0xe9, 0x61, 0x61, 0xa0, 0xee, 0xe1, 0xb2, 0x9a, 0xf3,
453 0x96, 0xf1, 0x54, 0x95, 0x0d, 0x5c, 0x71, 0x5d, 0xc6, 0x1a,
454 0xff, 0x66, 0xee, 0x97, 0x37, 0x7a, 0xb2, 0x2a, 0xdf, 0x33,
461 INVERTEND ( 0x00, 0xd2, 0x61, 0xa7, 0xab, 0x3a, 0xa2, 0xe4, 0xf9,
462 0x0e, 0x51, 0xf3, 0x0d, 0xc6, 0xa7, 0xee, 0x39, 0xc4,
463 0xb0, 0x32, 0xcc, 0xd7, 0xc5, 0x24, 0xa5, 0x53, 0x04,
464 0x31, 0x7f, 0xaf, 0x42, 0xe1, 0x2f ),
465 EXPECTED ( 0x07, 0x38, 0x78, 0x1c, 0x0a, 0xea, 0xbf, 0xbe, 0x6e, 0x84,
466 0x0c, 0x85, 0xbd, 0x30, 0x99, 0x6e, 0xf7, 0x1b, 0xc5, 0x49,
467 0x88, 0xce, 0x16, 0xce, 0xdd, 0x5a, 0xb4, 0xf3, 0x0c, 0x28,
475 BASE ( 0xe6, 0xdb, 0x68, 0x67, 0x58, 0x30, 0x30, 0xdb, 0x35, 0x94,
476 0xc1, 0xa4, 0x24, 0xb1, 0x5f, 0x7c, 0x72, 0x66, 0x24, 0xec,
477 0x26, 0xb3, 0x35, 0x3b, 0x10, 0xa9, 0x03, 0xa6, 0xd0, 0xab,
479 SCALAR ( 0xa5, 0x46, 0xe3, 0x6b, 0xf0, 0x52, 0x7c, 0x9d, 0x3b, 0x16,
480 0x15, 0x4b, 0x82, 0x46, 0x5e, 0xdd, 0x62, 0x14, 0x4c, 0x0a,
481 0xc1, 0xfc, 0x5a, 0x18, 0x50, 0x6a, 0x22, 0x44, 0xba, 0x44,
483 EXPECTED ( 0xc3, 0xda, 0x55, 0x37, 0x9d, 0xe9, 0xc6, 0x90, 0x8e, 0x94,
484 0xea, 0x4d, 0xf2, 0x8d, 0x08, 0x4f, 0x32, 0xec, 0xcf, 0x03,
485 0x49, 0x1c, 0x71, 0xf7, 0x54, 0xb4, 0x07, 0x55, 0x77, 0xa2,
493 BASE ( 0xe5, 0x21, 0x0f, 0x12, 0x78, 0x68, 0x11, 0xd3, 0xf4, 0xb7,
494 0x95, 0x9d, 0x05, 0x38, 0xae, 0x2c, 0x31, 0xdb, 0xe7, 0x10,
495 0x6f, 0xc0, 0x3c, 0x3e, 0xfc, 0x4c, 0xd5, 0x49, 0xc7, 0x15,
497 SCALAR ( 0x4b, 0x66, 0xe9, 0xd4, 0xd1, 0xb4, 0x67, 0x3c, 0x5a, 0xd2,
498 0x26, 0x91, 0x95, 0x7d, 0x6a, 0xf5, 0xc1, 0x1b, 0x64, 0x21,
499 0xe0, 0xea, 0x01, 0xd4, 0x2c, 0xa4, 0x16, 0x9e, 0x79, 0x18,
501 EXPECTED ( 0x95, 0xcb, 0xde, 0x94, 0x76, 0xe8, 0x90, 0x7d, 0x7a, 0xad,
502 0xe4, 0x5c, 0xb4, 0xb8, 0x73, 0xf8, 0x8b, 0x59, 0x5a, 0x68,
503 0x79, 0x9f, 0xa1, 0x52, 0xe6, 0xf8, 0xf7, 0x64, 0x7a, 0xac,
511 BASE ( 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
512 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
513 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
515 SCALAR ( 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
516 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
517 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
519 EXPECTED ( 0x42, 0x2c, 0x8e, 0x7a, 0x62, 0x27, 0xd7, 0xbc, 0xa1, 0x35,
520 0x0b, 0x3e, 0x2b, 0xb7, 0x27, 0x9f, 0x78, 0x97, 0xb8, 0x7b,
521 0xb6, 0x85, 0x4b, 0x78, 0x3c, 0x60, 0xe8, 0x03, 0x11, 0xae,
535 BASE ( 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
536 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
537 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
539 SCALAR ( 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
540 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
541 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
543 EXPECTED ( 0xb1, 0xa5, 0xa7, 0x31, 0x58, 0x90, 0x4c, 0x02, 0x08, 0x66,
544 0xc1, 0x39, 0x39, 0xdd, 0x7e, 0x1a, 0xa2, 0x68, 0x52, 0xee,
545 0x1d, 0x26, 0x09, 0xc9, 0x2e, 0x5a, 0x8f, 0x1d, 0xeb, 0xe2,
553 BASE ( 0xee, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
554 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
555 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
557 SCALAR ( 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
558 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x00, 0x01, 0x02, 0x03,
559 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d,
561 EXPECTED ( 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
562 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
563 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
static void x25519_multiply_okx(struct x25519_multiply_test *test, const char *file, unsigned int line)
Report an X25519 multiplication test result.
struct arbelprm_rc_send_wqe rc
int x25519_key(const struct x25519_value *base, const struct x25519_value *scalar, struct x25519_value *result)
Calculate X25519 key.
void x25519_reduce(union x25519_quad257 *value)
Reduce big integer to canonical range.
#define x25519_multiply_ok(test)
struct x25519_value base
Base.
void x25519_multiply(const union x25519_oct258 *multiplicand, const union x25519_oct258 *multiplier, union x25519_quad257 *result)
Multiply big integers modulo field prime.
const union x25519_oct258 oct258
X25519 unsigned 258-bit integer.
#define EXPECTED(...)
Define inline expected result.
An X25519 unsigned 257-bit integer.
size_t multiplier_len
Length of multiplier.
const void * invertend
Invertend.
An X25519 unsigned 258-bit integer.
#define bigint_init(value, data, len)
Initialise big integer.
#define MULTIPLICAND(...)
Define inline multiplicand.
Self-test infrastructure.
const char * name
Test set name.
#define X25519_KEY_TEST(name, COUNT, FAIL, BASE, SCALAR, EXPECTED)
Define an X25519 key exchange test.
size_t expected_len
Length of expected result.
uint8_t multiplier
Port multiplier number.
#define SCALAR(...)
Define inline scalar multiple.
struct x25519_value scalar
Scalar.
#define MULTIPLIER(...)
Define inline multiplier.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define okx(success, file, line)
Report test result.
An X25519 key exchange self-test.
#define BASE(...)
Define inline base point.
x25519_t value
Big integer value.
const void * multiplicand
Multiplicand.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
const void * expected
Expected result.
An X25519 multiplicative inversion self-test.
int fail
Key exchange is expected to fail (i.e.
unsigned int count
Number of iterations.
#define x25519_invert_ok(test)
const void * multiplier
Multiplier.
size_t multiplicand_len
Length of multiplicand.
An X25519 multiplication self-test.
#define x25519_key_ok(test)
struct x25519_value expected
Expected result.
size_t invertend_len
Length of invertend.
uint8_t product
Product string.
void x25519_invert(const union x25519_oct258 *invertend, union x25519_quad257 *result)
Compute multiplicative inverse.
#define X25519_INVERT_TEST(name, INVERTEND, EXPECTED)
Define an X25519 multiplicative inversion test.
#define X25519_MULTIPLY_TEST(name, MULTIPLICAND, MULTIPLIER, EXPECTED)
Define an X25519 multiplication test.
static void x25519_key_okx(struct x25519_key_test *test, const char *file, unsigned int line)
Report an X25519 key exchange test result.
static void x25519_invert_okx(struct x25519_invert_test *test, const char *file, unsigned int line)
Report an X25519 multiplicative inversion test result.
#define INVERTEND(...)
Define inline invertend.
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
size_t expected_len
Length of expected result.
struct self_test x25519_test __self_test
X25519 self-test.
const void * expected
Expected result.
static void x25519_test_exec(void)
Perform X25519 self-tests.
x25519_t value
Big integer value.