iPXE
x25519_test.c File Reference

X25519 key exchange test. More...

#include <stdint.h>
#include <string.h>
#include <ipxe/x25519.h>
#include <ipxe/test.h>
#include "exchange_test.h"

Go to the source code of this file.

Data Structures

struct  x25519_multiply_test
 An X25519 multiplication self-test. More...
struct  x25519_invert_test
 An X25519 multiplicative inversion self-test. More...
struct  x25519_key_test
 An X25519 key exchange self-test. More...

Macros

#define MULTIPLICAND(...)
 Define inline multiplicand.
#define MULTIPLIER(...)
 Define inline multiplier.
#define INVERTEND(...)
 Define inline invertend.
#define BASE(...)
 Define inline base point.
#define SCALAR(...)
 Define inline scalar multiple.
#define EXPECTED(...)
 Define inline expected result.
#define X25519_MULTIPLY_TEST(name, MULTIPLICAND, MULTIPLIER, EXPECTED)
 Define an X25519 multiplication test.
#define X25519_INVERT_TEST(name, INVERTEND, EXPECTED)
 Define an X25519 multiplicative inversion test.
#define X25519_KEY_TEST(name, COUNT, FAIL, BASE, SCALAR, EXPECTED)
 Define an X25519 key exchange test.
#define x25519_multiply_ok(test)
#define x25519_invert_ok(test)
#define x25519_key_ok(test)

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
static void x25519_multiply_okx (struct x25519_multiply_test *test, const char *file, unsigned int line)
 Report an X25519 multiplication 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.
static void x25519_key_okx (struct x25519_key_test *test, const char *file, unsigned int line)
 Report an X25519 key exchange test result.
 X25519_MULTIPLY_TEST (multiply_small, MULTIPLICAND(6), MULTIPLIER(9), EXPECTED(6 *9))
 X25519_MULTIPLY_TEST (multiply_k_p, MULTIPLICAND(0x7f, 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, 0xed), MULTIPLIER(0x00, 0xe8, 0x0d, 0x83, 0xd4, 0xe9, 0x1e, 0xdd, 0x7a, 0x45, 0x14, 0x87, 0xb7, 0xfc, 0x62, 0x54, 0x1f, 0xb2, 0x97, 0x24, 0xde, 0xfa, 0xd3, 0xe7, 0x3e, 0x83, 0x93, 0x60, 0xbc, 0x20, 0x97, 0x9b, 0x22), EXPECTED(0x00))
 X25519_MULTIPLY_TEST (multiply_1, MULTIPLICAND(0x02, 0x23, 0xb8, 0xc1, 0xe9, 0x39, 0x24, 0x56, 0xde, 0x3e, 0xb1, 0x3b, 0x90, 0x46, 0x68, 0x52, 0x57, 0xbd, 0xd6, 0x40, 0xfb, 0x06, 0x67, 0x1a, 0xd1, 0x1c, 0x80, 0x31, 0x7f, 0xa3, 0xb1, 0x79, 0x9d), MULTIPLIER(0x00, 0x6c, 0x03, 0x11, 0x99, 0x97, 0x2a, 0x84, 0x69, 0x16, 0x41, 0x9f, 0x82, 0x8b, 0x9d, 0x24, 0x34, 0xe4, 0x65, 0xe1, 0x50, 0xbd, 0x9c, 0x66, 0xb3, 0xad, 0x3c, 0x2d, 0x6d, 0x1a, 0x3d, 0x1f, 0xa7), EXPECTED(0x1b, 0xa8, 0x7e, 0x98, 0x2f, 0x7c, 0x47, 0x76, 0x16, 0xb4, 0xd5, 0x13, 0x6b, 0xa5, 0x47, 0x33, 0xe4, 0x00, 0x81, 0xc1, 0xc2, 0xe2, 0x7d, 0x86, 0x4a, 0xa1, 0x78, 0xce, 0x89, 0x3d, 0x12, 0x97))
 X25519_MULTIPLY_TEST (multiply_2, MULTIPLICAND(0x00, 0x8f, 0xad, 0xc1, 0xa6, 0x06, 0xcb, 0x0f, 0xb3, 0x9a, 0x1d, 0xe6, 0x44, 0x81, 0x5e, 0xf6, 0xd1, 0x3b, 0x8f, 0xaa, 0x18, 0x37, 0xf8, 0xa8, 0x8b, 0x17, 0xfc, 0x69, 0x5a, 0x07, 0xa0, 0xca, 0x6e), MULTIPLIER(0x01, 0x96, 0xda, 0x1d, 0xac, 0x72, 0xff, 0x5d, 0x2a, 0x38, 0x6e, 0xcb, 0xe0, 0x6b, 0x65, 0xa6, 0xa4, 0x8b, 0x81, 0x48, 0xf6, 0xb3, 0x8a, 0x08, 0x8c, 0xa6, 0x5e, 0xd3, 0x89, 0xb7, 0x4d, 0x0f, 0xb1), EXPECTED(0x35, 0x1f, 0x7b, 0xf7, 0x5e, 0xf5, 0x80, 0x24, 0x9e, 0xd6, 0xf9, 0xff, 0x39, 0x96, 0x46, 0x3b, 0x07, 0x30, 0xa1, 0xd4, 0x9b, 0x5d, 0x36, 0xb8, 0x63, 0xe1, 0x92, 0x59, 0x11, 0x57, 0xe9, 0x50))
 X25519_MULTIPLY_TEST (multiply_3, MULTIPLICAND(0x01, 0x6c, 0x30, 0x75, 0x11, 0xb2, 0xb9, 0x43, 0x7a, 0x28, 0xdf, 0x6e, 0xc4, 0xce, 0x4a, 0x2b, 0xbd, 0xc2, 0x41, 0x33, 0x0b, 0x01, 0xa9, 0xe7, 0x1f, 0xde, 0x8a, 0x77, 0x4b, 0xcf, 0x36, 0xd5, 0x8b), MULTIPLIER(0x01, 0x17, 0xbe, 0x31, 0x11, 0x1a, 0x2a, 0x73, 0xed, 0x56, 0x2b, 0x0f, 0x79, 0xc3, 0x74, 0x59, 0xee, 0xf5, 0x0b, 0xea, 0x63, 0x37, 0x1e, 0xcd, 0x7b, 0x27, 0xcd, 0x81, 0x30, 0x47, 0x22, 0x93, 0x89), EXPECTED(0x6b, 0x43, 0xb5, 0x18, 0x59, 0x65, 0xf8, 0xf0, 0x92, 0x0f, 0x31, 0xae, 0x1b, 0x2c, 0xef, 0xad, 0xd7, 0xb0, 0x78, 0xfe, 0xcf, 0x68, 0xdb, 0xea, 0xa1, 0x7b, 0x9c, 0x38, 0x5b, 0x55, 0x83, 0x29))
 X25519_MULTIPLY_TEST (multiply_4, MULTIPLICAND(0x02, 0x0b, 0x1f, 0x91, 0x63, 0xce, 0x9f, 0xf5, 0x7f, 0x43, 0xb7, 0xa3, 0xa6, 0x9a, 0x8d, 0xca, 0x03, 0x58, 0x0d, 0x7b, 0x71, 0xd8, 0xf5, 0x64, 0x13, 0x5b, 0xe6, 0x12, 0x8e, 0x18, 0xc2, 0x67, 0x97), MULTIPLIER(0x01, 0x8d, 0x52, 0x88, 0xf1, 0x14, 0x2c, 0x3f, 0xe8, 0x60, 0xe7, 0xa1, 0x13, 0xec, 0x1b, 0x8c, 0xa1, 0xf9, 0x1e, 0x1d, 0x4c, 0x1f, 0xf4, 0x9b, 0x78, 0x89, 0x46, 0x3e, 0x85, 0x75, 0x9c, 0xde, 0x66), EXPECTED(0x28, 0xa7, 0x7d, 0x3c, 0x8a, 0x14, 0x32, 0x3d, 0x63, 0xb2, 0x88, 0xdb, 0xd4, 0x03, 0x15, 0xb3, 0xf1, 0x92, 0xb8, 0x48, 0x5d, 0x86, 0xa0, 0x2c, 0xb8, 0x7d, 0x3d, 0xfb, 0x7a, 0x0b, 0x54, 0x47))
 X25519_MULTIPLY_TEST (multiply_5, MULTIPLICAND(0x02, 0x31, 0x39, 0xd3, 0x2c, 0x93, 0xcd, 0x59, 0xbf, 0x5c, 0x94, 0x1c, 0xf0, 0xdc, 0x98, 0xd2, 0xc1, 0xe2, 0xac, 0xf7, 0x2f, 0x9e, 0x57, 0x4f, 0x7a, 0xa0, 0xee, 0x89, 0xae, 0xd4, 0x53, 0xdd, 0x32), MULTIPLIER(0x03, 0x14, 0x6d, 0x3f, 0x31, 0xfc, 0x37, 0x7a, 0x4c, 0x4a, 0x15, 0x54, 0x4d, 0xc5, 0xe7, 0xce, 0x8a, 0x3a, 0x57, 0x8a, 0x8e, 0xa9, 0x48, 0x8d, 0x99, 0x0b, 0xbb, 0x25, 0x99, 0x11, 0xce, 0x5d, 0xd2), EXPECTED(0x4b, 0xdb, 0x7a, 0x35, 0xc0, 0xa5, 0x18, 0x20, 0x00, 0xaa, 0x67, 0x55, 0x47, 0x41, 0xe8, 0x8c, 0xfd, 0xf4, 0x60, 0xa7, 0x8c, 0x6f, 0xae, 0x07, 0xad, 0xf8, 0x3d, 0x2f, 0x00, 0x5d, 0x27, 0x67))
 X25519_INVERT_TEST (invert_1, INVERTEND(0x01, 0xd5, 0x88, 0x42, 0xde, 0xa2, 0xbc, 0x37, 0x2f, 0x74, 0x12, 0xb2, 0x93, 0x47, 0x29, 0x47, 0x39, 0x61, 0x4f, 0xf3, 0xd7, 0x19, 0xdb, 0x3a, 0xd0, 0xdd, 0xd1, 0xdf, 0xb2, 0x3b, 0x98, 0x2e, 0xf8), EXPECTED(0x09, 0x3f, 0xf5, 0x17, 0x50, 0x80, 0x9d, 0x18, 0x1a, 0x9a, 0x54, 0x81, 0xc5, 0x64, 0xe3, 0x7c, 0xff, 0x61, 0x8d, 0xef, 0x8e, 0xc4, 0x5f, 0x46, 0x4b, 0x1a, 0x6e, 0x24, 0xf8, 0xb8, 0x26, 0xbd))
 X25519_INVERT_TEST (invert_2, INVERTEND(0x02, 0xef, 0xc8, 0x98, 0x49, 0xb3, 0xaa, 0x7e, 0xfe, 0x44, 0x58, 0xa8, 0x85, 0xab, 0x90, 0x99, 0xa4, 0x35, 0xa2, 0x40, 0xae, 0x5a, 0xf3, 0x05, 0x53, 0x5e, 0xc4, 0x2e, 0x08, 0x29, 0xa3, 0xb2, 0xe9), EXPECTED(0x59, 0x16, 0x07, 0xb1, 0x63, 0xe8, 0x9d, 0x0a, 0xc3, 0x3a, 0x62, 0xc8, 0x81, 0xe9, 0x84, 0xa2, 0x5d, 0x38, 0x26, 0xe3, 0xdb, 0x5c, 0xe2, 0x29, 0xaf, 0x24, 0x0d, 0xc5, 0x8e, 0x5b, 0x57, 0x9a))
 X25519_INVERT_TEST (invert_3, INVERTEND(0x00, 0x3e, 0xab, 0xed, 0xcb, 0xba, 0xa8, 0x0d, 0xd4, 0x88, 0xbd, 0x64, 0x07, 0x2b, 0xcf, 0xbe, 0x01, 0xa2, 0x8d, 0xef, 0xe3, 0x9b, 0xf0, 0x02, 0x73, 0x12, 0x47, 0x6f, 0x57, 0xa5, 0xe5, 0xa5, 0xab), EXPECTED(0x7d, 0x87, 0xc2, 0xe5, 0x65, 0xb2, 0x7c, 0x50, 0x38, 0x18, 0x1a, 0x0a, 0x7c, 0xae, 0x9e, 0xbe, 0x82, 0x6c, 0x8a, 0xfc, 0x1f, 0x77, 0x12, 0x8a, 0x4d, 0x62, 0xcc, 0xe9, 0x6d, 0x27, 0x59, 0xa2))
 X25519_INVERT_TEST (invert_4, INVERTEND(0x00, 0x8e, 0x94, 0x42, 0x39, 0xb0, 0x2b, 0x61, 0xc4, 0xa3, 0xd7, 0x06, 0x28, 0xec, 0xe6, 0x6f, 0xa2, 0xfd, 0x51, 0x66, 0xe6, 0x45, 0x1b, 0x4c, 0xf3, 0x61, 0x23, 0xfd, 0xf7, 0x76, 0x56, 0xaf, 0x72), EXPECTED(0x08, 0xe9, 0x61, 0x61, 0xa0, 0xee, 0xe1, 0xb2, 0x9a, 0xf3, 0x96, 0xf1, 0x54, 0x95, 0x0d, 0x5c, 0x71, 0x5d, 0xc6, 0x1a, 0xff, 0x66, 0xee, 0x97, 0x37, 0x7a, 0xb2, 0x2a, 0xdf, 0x33, 0x21, 0xd7))
 X25519_INVERT_TEST (invert_5, INVERTEND(0x00, 0xd2, 0x61, 0xa7, 0xab, 0x3a, 0xa2, 0xe4, 0xf9, 0x0e, 0x51, 0xf3, 0x0d, 0xc6, 0xa7, 0xee, 0x39, 0xc4, 0xb0, 0x32, 0xcc, 0xd7, 0xc5, 0x24, 0xa5, 0x53, 0x04, 0x31, 0x7f, 0xaf, 0x42, 0xe1, 0x2f), EXPECTED(0x07, 0x38, 0x78, 0x1c, 0x0a, 0xea, 0xbf, 0xbe, 0x6e, 0x84, 0x0c, 0x85, 0xbd, 0x30, 0x99, 0x6e, 0xf7, 0x1b, 0xc5, 0x49, 0x88, 0xce, 0x16, 0xce, 0xdd, 0x5a, 0xb4, 0xf3, 0x0c, 0x28, 0x15, 0x97))
 X25519_KEY_TEST (rfc7748_1, 1, 0, BASE(0xe6, 0xdb, 0x68, 0x67, 0x58, 0x30, 0x30, 0xdb, 0x35, 0x94, 0xc1, 0xa4, 0x24, 0xb1, 0x5f, 0x7c, 0x72, 0x66, 0x24, 0xec, 0x26, 0xb3, 0x35, 0x3b, 0x10, 0xa9, 0x03, 0xa6, 0xd0, 0xab, 0x1c, 0x4c), SCALAR(0xa5, 0x46, 0xe3, 0x6b, 0xf0, 0x52, 0x7c, 0x9d, 0x3b, 0x16, 0x15, 0x4b, 0x82, 0x46, 0x5e, 0xdd, 0x62, 0x14, 0x4c, 0x0a, 0xc1, 0xfc, 0x5a, 0x18, 0x50, 0x6a, 0x22, 0x44, 0xba, 0x44, 0x9a, 0xc4), EXPECTED(0xc3, 0xda, 0x55, 0x37, 0x9d, 0xe9, 0xc6, 0x90, 0x8e, 0x94, 0xea, 0x4d, 0xf2, 0x8d, 0x08, 0x4f, 0x32, 0xec, 0xcf, 0x03, 0x49, 0x1c, 0x71, 0xf7, 0x54, 0xb4, 0x07, 0x55, 0x77, 0xa2, 0x85, 0x52))
 X25519_KEY_TEST (rfc7748_2, 1, 0, BASE(0xe5, 0x21, 0x0f, 0x12, 0x78, 0x68, 0x11, 0xd3, 0xf4, 0xb7, 0x95, 0x9d, 0x05, 0x38, 0xae, 0x2c, 0x31, 0xdb, 0xe7, 0x10, 0x6f, 0xc0, 0x3c, 0x3e, 0xfc, 0x4c, 0xd5, 0x49, 0xc7, 0x15, 0xa4, 0x93), SCALAR(0x4b, 0x66, 0xe9, 0xd4, 0xd1, 0xb4, 0x67, 0x3c, 0x5a, 0xd2, 0x26, 0x91, 0x95, 0x7d, 0x6a, 0xf5, 0xc1, 0x1b, 0x64, 0x21, 0xe0, 0xea, 0x01, 0xd4, 0x2c, 0xa4, 0x16, 0x9e, 0x79, 0x18, 0xba, 0x0d), EXPECTED(0x95, 0xcb, 0xde, 0x94, 0x76, 0xe8, 0x90, 0x7d, 0x7a, 0xad, 0xe4, 0x5c, 0xb4, 0xb8, 0x73, 0xf8, 0x8b, 0x59, 0x5a, 0x68, 0x79, 0x9f, 0xa1, 0x52, 0xe6, 0xf8, 0xf7, 0x64, 0x7a, 0xac, 0x79, 0x57))
 X25519_KEY_TEST (rfc7748_3, 1, 0, BASE(0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), SCALAR(0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), EXPECTED(0x42, 0x2c, 0x8e, 0x7a, 0x62, 0x27, 0xd7, 0xbc, 0xa1, 0x35, 0x0b, 0x3e, 0x2b, 0xb7, 0x27, 0x9f, 0x78, 0x97, 0xb8, 0x7b, 0xb6, 0x85, 0x4b, 0x78, 0x3c, 0x60, 0xe8, 0x03, 0x11, 0xae, 0x30, 0x79))
 X25519_KEY_TEST (rfc7748_4_100, 100, 0, BASE(0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), SCALAR(0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), EXPECTED(0xb1, 0xa5, 0xa7, 0x31, 0x58, 0x90, 0x4c, 0x02, 0x08, 0x66, 0xc1, 0x39, 0x39, 0xdd, 0x7e, 0x1a, 0xa2, 0x68, 0x52, 0xee, 0x1d, 0x26, 0x09, 0xc9, 0x2e, 0x5a, 0x8f, 0x1d, 0xeb, 0xe2, 0x15, 0x0a))
 X25519_KEY_TEST (malicious, 1, 1, BASE(0xee, 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, 0x7f), SCALAR(0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f), EXPECTED(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00))
 EXCHANGE_TEST (rfc7748_alice, &x25519_algorithm, PRIVATE(0x77, 0x07, 0x6d, 0x0a, 0x73, 0x18, 0xa5, 0x7d, 0x3c, 0x16, 0xc1, 0x72, 0x51, 0xb2, 0x66, 0x45, 0xdf, 0x4c, 0x2f, 0x87, 0xeb, 0xc0, 0x99, 0x2a, 0xb1, 0x77, 0xfb, 0xa5, 0x1d, 0xb9, 0x2c, 0x2a), PARTNER(0xde, 0x9e, 0xdb, 0x7d, 0x7b, 0x7d, 0xc1, 0xb4, 0xd3, 0x5b, 0x61, 0xc2, 0xec, 0xe4, 0x35, 0x37, 0x3f, 0x83, 0x43, 0xc8, 0x5b, 0x78, 0x67, 0x4d, 0xad, 0xfc, 0x7e, 0x14, 0x6f, 0x88, 0x2b, 0x4f), PUBLIC(0x85, 0x20, 0xf0, 0x09, 0x89, 0x30, 0xa7, 0x54, 0x74, 0x8b, 0x7d, 0xdc, 0xb4, 0x3e, 0xf7, 0x5a, 0x0d, 0xbf, 0x3a, 0x0d, 0x26, 0x38, 0x1a, 0xf4, 0xeb, 0xa4, 0xa9, 0x8e, 0xaa, 0x9b, 0x4e, 0x6a), SHARED(0x4a, 0x5d, 0x9d, 0x5b, 0xa4, 0xce, 0x2d, 0xe1, 0x72, 0x8e, 0x3b, 0xf4, 0x80, 0x35, 0x0f, 0x25, 0xe0, 0x7e, 0x21, 0xc9, 0x47, 0xd1, 0x9e, 0x33, 0x76, 0xf0, 0x9b, 0x3c, 0x1e, 0x16, 0x17, 0x42))
 EXCHANGE_TEST (rfc7748_bob, &x25519_algorithm, PRIVATE(0x5d, 0xab, 0x08, 0x7e, 0x62, 0x4a, 0x8a, 0x4b, 0x79, 0xe1, 0x7f, 0x8b, 0x83, 0x80, 0x0e, 0xe6, 0x6f, 0x3b, 0xb1, 0x29, 0x26, 0x18, 0xb6, 0xfd, 0x1c, 0x2f, 0x8b, 0x27, 0xff, 0x88, 0xe0, 0xeb), PARTNER(0x85, 0x20, 0xf0, 0x09, 0x89, 0x30, 0xa7, 0x54, 0x74, 0x8b, 0x7d, 0xdc, 0xb4, 0x3e, 0xf7, 0x5a, 0x0d, 0xbf, 0x3a, 0x0d, 0x26, 0x38, 0x1a, 0xf4, 0xeb, 0xa4, 0xa9, 0x8e, 0xaa, 0x9b, 0x4e, 0x6a), PUBLIC(0xde, 0x9e, 0xdb, 0x7d, 0x7b, 0x7d, 0xc1, 0xb4, 0xd3, 0x5b, 0x61, 0xc2, 0xec, 0xe4, 0x35, 0x37, 0x3f, 0x83, 0x43, 0xc8, 0x5b, 0x78, 0x67, 0x4d, 0xad, 0xfc, 0x7e, 0x14, 0x6f, 0x88, 0x2b, 0x4f), SHARED(0x4a, 0x5d, 0x9d, 0x5b, 0xa4, 0xce, 0x2d, 0xe1, 0x72, 0x8e, 0x3b, 0xf4, 0x80, 0x35, 0x0f, 0x25, 0xe0, 0x7e, 0x21, 0xc9, 0x47, 0xd1, 0x9e, 0x33, 0x76, 0xf0, 0x9b, 0x3c, 0x1e, 0x16, 0x17, 0x42))
 EXCHANGE_TEST (wycheproof_49, &x25519_algorithm, PRIVATE(0x10, 0x62, 0x21, 0xfe, 0x56, 0x94, 0xa7, 0x10, 0xd6, 0xe1, 0x47, 0x69, 0x6c, 0x5d, 0x5b, 0x93, 0xd6, 0x88, 0x7d, 0x58, 0x4f, 0x24, 0xf2, 0x28, 0x18, 0x2e, 0xbe, 0x1b, 0x1d, 0x2d, 0xb8, 0x5d), PARTNER(0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x0f), PUBLIC(0xec, 0xba, 0x34, 0x3f, 0x4a, 0x89, 0x01, 0x3f, 0xea, 0x83, 0xe8, 0x69, 0xea, 0x3f, 0x7a, 0x67, 0x07, 0x15, 0xd8, 0x33, 0xab, 0x0e, 0xc4, 0x3a, 0xdb, 0x3a, 0xcd, 0x4b, 0x48, 0x22, 0x96, 0x07), SHARED(0x5e, 0x64, 0x92, 0x4b, 0x91, 0x87, 0x3b, 0x49, 0x9a, 0x54, 0x02, 0xfa, 0x64, 0x33, 0x7c, 0x65, 0xd4, 0xb2, 0xed, 0x54, 0xbe, 0xeb, 0x3f, 0xa5, 0xd7, 0x34, 0x78, 0x09, 0xe4, 0x3a, 0xef, 0x1c))
 EXCHANGE_TEST (wycheproof_63, &x25519_algorithm, PRIVATE(0xe0, 0xf9, 0x78, 0xdf, 0xcd, 0x3a, 0x8f, 0x1a, 0x50, 0x93, 0x41, 0x8d, 0xe5, 0x41, 0x36, 0xa5, 0x84, 0xc2, 0x0b, 0x7b, 0x34, 0x9a, 0xfd, 0xf6, 0xc0, 0x52, 0x08, 0x86, 0xf9, 0x5b, 0x12, 0x72), PARTNER(0xe0, 0xeb, 0x7a, 0x7c, 0x3b, 0x41, 0xb8, 0xae, 0x16, 0x56, 0xe3, 0xfa, 0xf1, 0x9f, 0xc4, 0x6a, 0xda, 0x09, 0x8d, 0xeb, 0x9c, 0x32, 0xb1, 0xfd, 0x86, 0x62, 0x05, 0x16, 0x5f, 0x49, 0xb8, 0x00), PUBLIC(0x12, 0x4e, 0x0f, 0x14, 0x87, 0xc9, 0xb3, 0x8f, 0x1c, 0x7f, 0xd4, 0xa6, 0x51, 0x8a, 0x47, 0x69, 0x9d, 0x15, 0x8d, 0x44, 0xcc, 0x18, 0x66, 0x5c, 0x7b, 0xcc, 0xa0, 0x3b, 0xdc, 0x72, 0x6e, 0x5d), SHARED_FAIL)
 EXCHANGE_TEST (wycheproof_112, &x25519_algorithm, PRIVATE(0x60, 0xa3, 0xa4, 0xf1, 0x30, 0xb9, 0x8a, 0x5b, 0xe4, 0xb1, 0xce, 0xdb, 0x7c, 0xb8, 0x55, 0x84, 0xa3, 0x52, 0x0e, 0x14, 0x2d, 0x47, 0x4d, 0xc9, 0xcc, 0xb9, 0x09, 0xa0, 0x73, 0xa9, 0x76, 0x7f), PARTNER(0x8d, 0x61, 0x2c, 0x58, 0x31, 0xaa, 0x64, 0xb0, 0x57, 0x30, 0x0e, 0x7e, 0x31, 0x0f, 0x3a, 0xa3, 0x32, 0xaf, 0x34, 0x06, 0x6f, 0xef, 0xca, 0xb2, 0xb0, 0x89, 0xc9, 0x59, 0x28, 0x78, 0xf8, 0x32), PUBLIC(0x7c, 0x6c, 0xcb, 0xa9, 0x2f, 0xf0, 0x0a, 0x6e, 0x83, 0x38, 0x2c, 0xd0, 0x6b, 0x9e, 0xc9, 0xe6, 0x58, 0x1e, 0xaf, 0xe3, 0xc2, 0x43, 0xf0, 0xc5, 0x2c, 0xf6, 0x8e, 0x06, 0x78, 0x43, 0xe3, 0x7a), SHARED(0xe3, 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, 0x7f))
static void x25519_test_exec (void)
 Perform X25519 self-tests.

Variables

struct self_test x25519_test __self_test
 X25519 self-test.

Detailed Description

X25519 key exchange test.

Full key exchange test vectors are taken from RFC7748.

Definition in file x25519_test.c.

Macro Definition Documentation

◆ MULTIPLICAND

#define MULTIPLICAND ( ...)
Value:
{ __VA_ARGS__ }

Define inline multiplicand.

Definition at line 44 of file x25519_test.c.

Referenced by X25519_MULTIPLY_TEST(), X25519_MULTIPLY_TEST(), X25519_MULTIPLY_TEST(), X25519_MULTIPLY_TEST(), X25519_MULTIPLY_TEST(), X25519_MULTIPLY_TEST(), and X25519_MULTIPLY_TEST().

◆ MULTIPLIER

#define MULTIPLIER ( ...)

◆ INVERTEND

#define INVERTEND ( ...)
Value:
{ __VA_ARGS__ }

Define inline invertend.

Definition at line 50 of file x25519_test.c.

Referenced by X25519_INVERT_TEST(), X25519_INVERT_TEST(), X25519_INVERT_TEST(), X25519_INVERT_TEST(), and X25519_INVERT_TEST().

◆ BASE

#define BASE ( ...)
Value:
{ __VA_ARGS__ }

Define inline base point.

Definition at line 53 of file x25519_test.c.

◆ SCALAR

#define SCALAR ( ...)
Value:
{ __VA_ARGS__ }

Define inline scalar multiple.

Definition at line 56 of file x25519_test.c.

◆ EXPECTED

#define EXPECTED ( ...)
Value:
{ __VA_ARGS__ }

Define inline expected result.

Definition at line 59 of file x25519_test.c.

◆ X25519_MULTIPLY_TEST

#define X25519_MULTIPLY_TEST ( name,
MULTIPLICAND,
MULTIPLIER,
EXPECTED )
Value:
static const uint8_t name ## _multiplicand[] = MULTIPLICAND; \
static const uint8_t name ## _multiplier[] = MULTIPLIER; \
static const uint8_t name ## _expected[] = EXPECTED; \
static struct x25519_multiply_test name = { \
.multiplicand = name ## _multiplicand, \
.multiplicand_len = sizeof ( name ## _multiplicand ), \
.multiplier = name ## _multiplier, \
.multiplier_len = sizeof ( name ## _multiplier ), \
.expected = name ## _expected, \
.expected_len = sizeof ( name ## _expected ), \
}
unsigned char uint8_t
Definition stdint.h:10
static const uint32_t multiplier
Port multiplier number.
Definition bigint.h:195
const char * name
Definition ath9k_hw.c:1986
#define EXPECTED(...)
Define inline expected result point.
An X25519 multiplication self-test.
Definition x25519_test.c:62
#define MULTIPLIER(...)
Define inline multiplier.
Definition x25519_test.c:47
#define MULTIPLICAND(...)
Define inline multiplicand.
Definition x25519_test.c:44

Define an X25519 multiplication test.

Parameters
nameTest name
MULTIPLICAND258-bit multiplicand
MULTIPLIER258-bit multiplier
EXPECTED255-bit expected result
Return values
testX25519 multiplication test

Definition at line 86 of file x25519_test.c.

◆ X25519_INVERT_TEST

#define X25519_INVERT_TEST ( name,
INVERTEND,
EXPECTED )
Value:
static const uint8_t name ## _invertend[] = INVERTEND; \
static const uint8_t name ## _expected[] = EXPECTED; \
static struct x25519_invert_test name = { \
.invertend = name ## _invertend, \
.invertend_len = sizeof ( name ## _invertend ), \
.expected = name ## _expected, \
.expected_len = sizeof ( name ## _expected ), \
}
An X25519 multiplicative inversion self-test.
#define INVERTEND(...)
Define inline invertend.
Definition x25519_test.c:50

Define an X25519 multiplicative inversion test.

Parameters
nameTest name
INVERTEND258-bit invertend
EXPECTED255-bit expected result
Return values
testX25519 multiplicative inversion test

Definition at line 120 of file x25519_test.c.

120#define X25519_INVERT_TEST( name, INVERTEND, EXPECTED ) \
121 static const uint8_t name ## _invertend[] = INVERTEND; \
122 static const uint8_t name ## _expected[] = EXPECTED; \
123 static struct x25519_invert_test name = { \
124 .invertend = name ## _invertend, \
125 .invertend_len = sizeof ( name ## _invertend ), \
126 .expected = name ## _expected, \
127 .expected_len = sizeof ( name ## _expected ), \
128 }

◆ X25519_KEY_TEST

#define X25519_KEY_TEST ( name,
COUNT,
FAIL,
BASE,
SCALAR,
EXPECTED )
Value:
static struct x25519_key_test name = { \
.count = COUNT, \
.fail = FAIL, \
.base = { .raw = BASE }, \
.scalar = { .raw = SCALAR }, \
.expected = { .raw = EXPECTED }, \
}
#define BASE
Definition 3c595.h:69
#define SCALAR(...)
Define inline scalar multiple.
An X25519 key exchange self-test.

Define an X25519 key exchange test.

Parameters
nameTest name
COUNTNumber of iterations
FAILExpected failure status
BASEBase point
SCALARScalar multiple
EXPECTEDExpected result
Return values
testX25519 key exchange test

Definition at line 155 of file x25519_test.c.

155#define X25519_KEY_TEST( name, COUNT, FAIL, BASE, SCALAR, EXPECTED ) \
156 static struct x25519_key_test name = { \
157 .count = COUNT, \
158 .fail = FAIL, \
159 .base = { .raw = BASE }, \
160 .scalar = { .raw = SCALAR }, \
161 .expected = { .raw = EXPECTED }, \
162 }

◆ x25519_multiply_ok

#define x25519_multiply_ok ( test)
Value:
x25519_multiply_okx ( test, __FILE__, __LINE__ )
static int test
Definition epic100.c:73
static void x25519_multiply_okx(struct x25519_multiply_test *test, const char *file, unsigned int line)
Report an X25519 multiplication test result.

Definition at line 203 of file x25519_test.c.

203#define x25519_multiply_ok( test ) \
204 x25519_multiply_okx ( test, __FILE__, __LINE__ )

Referenced by x25519_test_exec().

◆ x25519_invert_ok

#define x25519_invert_ok ( test)
Value:
x25519_invert_okx ( test, __FILE__, __LINE__ )
static void x25519_invert_okx(struct x25519_invert_test *test, const char *file, unsigned int line)
Report an X25519 multiplicative inversion test result.

Definition at line 251 of file x25519_test.c.

251#define x25519_invert_ok( test ) \
252 x25519_invert_okx ( test, __FILE__, __LINE__ )

Referenced by x25519_test_exec().

◆ x25519_key_ok

#define x25519_key_ok ( test)
Value:
x25519_key_okx ( test, __FILE__, __LINE__ )
static void x25519_key_okx(struct x25519_key_test *test, const char *file, unsigned int line)
Report an X25519 key exchange test result.

Definition at line 296 of file x25519_test.c.

296#define x25519_key_ok( test ) \
297 x25519_key_okx ( test, __FILE__, __LINE__ )

Referenced by x25519_test_exec().

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ x25519_multiply_okx()

void x25519_multiply_okx ( struct x25519_multiply_test * test,
const char * file,
unsigned int line )
static

Report an X25519 multiplication test result.

Parameters
testX25519 multiplication test
fileTest code file
lineTest code line

Definition at line 171 of file x25519_test.c.

172 {
173 union x25519_oct258 multiplicand;
175 union x25519_quad257 expected;
176 union x25519_quad257 actual;
177
178 /* Construct big integers */
179 bigint_init ( &multiplicand.value, test->multiplicand,
180 test->multiplicand_len );
181 DBGC ( test, "X25519 multiplicand:\n" );
182 DBGC_HDA ( test, 0, &multiplicand, sizeof ( multiplicand ) );
183 bigint_init ( &multiplier.value, test->multiplier,
184 test->multiplier_len );
185 DBGC ( test, "X25519 multiplier:\n" );
186 DBGC_HDA ( test, 0, &multiplier, sizeof ( multiplier ) );
187 bigint_init ( &expected.value, test->expected, test->expected_len );
188 DBGC ( test, "X25519 expected product:\n" );
189 DBGC_HDA ( test, 0, &expected, sizeof ( expected ) );
190
191 /* Perform multiplication */
192 x25519_multiply ( &multiplicand, &multiplier, &actual );
193
194 /* Reduce result to allow for comparison */
195 x25519_reduce ( &actual );
196 DBGC ( test, "X25519 actual product:\n" );
197 DBGC_HDA ( test, 0, &actual, sizeof ( actual ) );
198
199 /* Compare against expected result */
200 okx ( memcmp ( &actual, &expected, sizeof ( expected ) ) == 0,
201 file, line );
202}
#define DBGC(...)
Definition compiler.h:530
#define DBGC_HDA(...)
Definition compiler.h:531
#define bigint_init(value, data, len)
Initialise big integer.
Definition bigint.h:63
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition string.c:115
#define okx(success, file, line)
Report test result.
Definition test.h:44
An X25519 unsigned 258-bit integer.
Definition x25519.h:46
An X25519 unsigned 257-bit integer.
Definition x25519.h:65
void x25519_multiply(const union x25519_oct258 *multiplicand, const union x25519_oct258 *multiplier, union x25519_quad257 *result)
Multiply big integers modulo field prime.
Definition x25519.c:427
void x25519_reduce(union x25519_quad257 *value)
Reduce big integer to canonical range.
Definition x25519.c:586

References bigint_init, DBGC, DBGC_HDA, memcmp(), multiplier, okx, test, x25519_oct258::value, x25519_quad257::value, x25519_multiply(), and x25519_reduce().

◆ x25519_invert_okx()

void x25519_invert_okx ( struct x25519_invert_test * test,
const char * file,
unsigned int line )
static

Report an X25519 multiplicative inversion test result.

Parameters
testX25519 multiplicative inversion test
fileTest code file
lineTest code line

Definition at line 213 of file x25519_test.c.

214 {
215 static const uint8_t one[] = { 1 };
216 union x25519_oct258 invertend;
217 union x25519_quad257 expected;
218 union x25519_quad257 actual;
220 union x25519_quad257 identity;
221
222 /* Construct big integers */
223 bigint_init ( &invertend.value, test->invertend, test->invertend_len );
224 DBGC ( test, "X25519 invertend:\n" );
225 DBGC_HDA ( test, 0, &invertend, sizeof ( invertend ) );
226 bigint_init ( &expected.value, test->expected, test->expected_len );
227 DBGC ( test, "X25519 expected inverse:\n" );
228 DBGC_HDA ( test, 0, &expected, sizeof ( expected ) );
229 bigint_init ( &identity.value, one, sizeof ( one ) );
230
231 /* Perform inversion */
232 x25519_invert ( &invertend, &actual );
233
234 /* Multiply invertend by inverse */
235 x25519_multiply ( &invertend, &actual.oct258, &product );
236
237 /* Reduce results to allow for comparison */
238 x25519_reduce ( &actual );
239 DBGC ( test, "X25519 actual inverse:\n" );
240 DBGC_HDA ( test, 0, &actual, sizeof ( actual ) );
242 DBGC ( test, "X25519 actual product:\n" );
243 DBGC_HDA ( test, 0, &product, sizeof ( product ) );
244
245 /* Compare against expected results */
246 okx ( memcmp ( &actual, &expected, sizeof ( expected ) ) == 0,
247 file, line );
248 okx ( memcmp ( &product, &identity, sizeof ( identity ) ) == 0,
249 file, line );
250}
uint8_t product
Product string.
Definition smbios.h:5
void x25519_invert(const union x25519_oct258 *invertend, union x25519_quad257 *result)
Compute multiplicative inverse.
Definition x25519.c:529

References bigint_init, DBGC, DBGC_HDA, memcmp(), x25519_quad257::oct258, okx, product, test, x25519_oct258::value, x25519_quad257::value, x25519_invert(), x25519_multiply(), and x25519_reduce().

◆ x25519_key_okx()

void x25519_key_okx ( struct x25519_key_test * test,
const char * file,
unsigned int line )
static

Report an X25519 key exchange test result.

Parameters
testX25519 key exchange test
fileTest code file
lineTest code line

Definition at line 261 of file x25519_test.c.

262 {
263 struct x25519_value base;
264 struct x25519_value scalar;
265 struct x25519_value actual;
266 unsigned int i;
267
268 /* Construct input values */
269 memcpy ( &base, &test->base, sizeof ( test->base ) );
270 memcpy ( &scalar, &test->scalar, sizeof ( test->scalar ) );
271 DBGC ( test, "X25519 base:\n" );
272 DBGC_HDA ( test, 0, &base, sizeof ( base ) );
273 DBGC ( test, "X25519 scalar:\n" );
274 DBGC_HDA ( test, 0, &scalar, sizeof ( scalar ) );
275 DBGC ( test, "X25519 expected result (x%d):\n", test->count );
276 DBGC_HDA ( test, 0, &test->expected, sizeof ( test->expected ) );
277
278 /* Calculate key */
279 for ( i = 0 ; i < test->count ; i++ ) {
280 x25519_key ( &base, &scalar, &actual );
281 if ( test->fail ) {
282 okx ( x25519_is_zero ( &actual ), file, line );
283 } else {
284 okx ( ( ! x25519_is_zero ( &actual ) ), file, line );
285 }
286 memcpy ( &base, &scalar, sizeof ( base ) );
287 memcpy ( &scalar, &actual, sizeof ( scalar ) );
288 }
289 DBGC ( test, "X25519 actual result (x%d):\n", test->count );
290 DBGC_HDA ( test, 0, &actual, sizeof ( actual ) );
291
292 /* Compare against expected result */
293 okx ( memcmp ( &actual, &test->expected,
294 sizeof ( test->expected ) ) == 0, file, line );
295}
void * memcpy(void *dest, const void *src, size_t len) __nonnull
uint32_t base
Base.
Definition librm.h:3
An X25519 32-byte value.
Definition x25519.h:78
int x25519_is_zero(const struct x25519_value *value)
Check if X25519 value is zero.
Definition x25519.c:793
void x25519_key(const struct x25519_value *base, const struct x25519_value *scalar, struct x25519_value *result)
Calculate X25519 key.
Definition x25519.c:808

References base, DBGC, DBGC_HDA, memcmp(), memcpy(), okx, test, x25519_is_zero(), and x25519_key().

◆ X25519_MULTIPLY_TEST() [1/7]

X25519_MULTIPLY_TEST ( multiply_small ,
MULTIPLICAND(6) ,
MULTIPLIER(9) ,
EXPECTED(6 *9)  )

References EXPECTED, MULTIPLICAND, and MULTIPLIER.

◆ X25519_MULTIPLY_TEST() [2/7]

X25519_MULTIPLY_TEST ( multiply_k_p ,
MULTIPLICAND(0x7f, 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, 0xed) ,
MULTIPLIER(0x00, 0xe8, 0x0d, 0x83, 0xd4, 0xe9, 0x1e, 0xdd, 0x7a, 0x45, 0x14, 0x87, 0xb7, 0xfc, 0x62, 0x54, 0x1f, 0xb2, 0x97, 0x24, 0xde, 0xfa, 0xd3, 0xe7, 0x3e, 0x83, 0x93, 0x60, 0xbc, 0x20, 0x97, 0x9b, 0x22) ,
EXPECTED(0x00)  )

References EXPECTED, MULTIPLICAND, and MULTIPLIER.

◆ X25519_MULTIPLY_TEST() [3/7]

X25519_MULTIPLY_TEST ( multiply_1 ,
MULTIPLICAND(0x02, 0x23, 0xb8, 0xc1, 0xe9, 0x39, 0x24, 0x56, 0xde, 0x3e, 0xb1, 0x3b, 0x90, 0x46, 0x68, 0x52, 0x57, 0xbd, 0xd6, 0x40, 0xfb, 0x06, 0x67, 0x1a, 0xd1, 0x1c, 0x80, 0x31, 0x7f, 0xa3, 0xb1, 0x79, 0x9d) ,
MULTIPLIER(0x00, 0x6c, 0x03, 0x11, 0x99, 0x97, 0x2a, 0x84, 0x69, 0x16, 0x41, 0x9f, 0x82, 0x8b, 0x9d, 0x24, 0x34, 0xe4, 0x65, 0xe1, 0x50, 0xbd, 0x9c, 0x66, 0xb3, 0xad, 0x3c, 0x2d, 0x6d, 0x1a, 0x3d, 0x1f, 0xa7) ,
EXPECTED(0x1b, 0xa8, 0x7e, 0x98, 0x2f, 0x7c, 0x47, 0x76, 0x16, 0xb4, 0xd5, 0x13, 0x6b, 0xa5, 0x47, 0x33, 0xe4, 0x00, 0x81, 0xc1, 0xc2, 0xe2, 0x7d, 0x86, 0x4a, 0xa1, 0x78, 0xce, 0x89, 0x3d, 0x12, 0x97)  )

References EXPECTED, MULTIPLICAND, and MULTIPLIER.

◆ X25519_MULTIPLY_TEST() [4/7]

X25519_MULTIPLY_TEST ( multiply_2 ,
MULTIPLICAND(0x00, 0x8f, 0xad, 0xc1, 0xa6, 0x06, 0xcb, 0x0f, 0xb3, 0x9a, 0x1d, 0xe6, 0x44, 0x81, 0x5e, 0xf6, 0xd1, 0x3b, 0x8f, 0xaa, 0x18, 0x37, 0xf8, 0xa8, 0x8b, 0x17, 0xfc, 0x69, 0x5a, 0x07, 0xa0, 0xca, 0x6e) ,
MULTIPLIER(0x01, 0x96, 0xda, 0x1d, 0xac, 0x72, 0xff, 0x5d, 0x2a, 0x38, 0x6e, 0xcb, 0xe0, 0x6b, 0x65, 0xa6, 0xa4, 0x8b, 0x81, 0x48, 0xf6, 0xb3, 0x8a, 0x08, 0x8c, 0xa6, 0x5e, 0xd3, 0x89, 0xb7, 0x4d, 0x0f, 0xb1) ,
EXPECTED(0x35, 0x1f, 0x7b, 0xf7, 0x5e, 0xf5, 0x80, 0x24, 0x9e, 0xd6, 0xf9, 0xff, 0x39, 0x96, 0x46, 0x3b, 0x07, 0x30, 0xa1, 0xd4, 0x9b, 0x5d, 0x36, 0xb8, 0x63, 0xe1, 0x92, 0x59, 0x11, 0x57, 0xe9, 0x50)  )

References EXPECTED, MULTIPLICAND, and MULTIPLIER.

◆ X25519_MULTIPLY_TEST() [5/7]

X25519_MULTIPLY_TEST ( multiply_3 ,
MULTIPLICAND(0x01, 0x6c, 0x30, 0x75, 0x11, 0xb2, 0xb9, 0x43, 0x7a, 0x28, 0xdf, 0x6e, 0xc4, 0xce, 0x4a, 0x2b, 0xbd, 0xc2, 0x41, 0x33, 0x0b, 0x01, 0xa9, 0xe7, 0x1f, 0xde, 0x8a, 0x77, 0x4b, 0xcf, 0x36, 0xd5, 0x8b) ,
MULTIPLIER(0x01, 0x17, 0xbe, 0x31, 0x11, 0x1a, 0x2a, 0x73, 0xed, 0x56, 0x2b, 0x0f, 0x79, 0xc3, 0x74, 0x59, 0xee, 0xf5, 0x0b, 0xea, 0x63, 0x37, 0x1e, 0xcd, 0x7b, 0x27, 0xcd, 0x81, 0x30, 0x47, 0x22, 0x93, 0x89) ,
EXPECTED(0x6b, 0x43, 0xb5, 0x18, 0x59, 0x65, 0xf8, 0xf0, 0x92, 0x0f, 0x31, 0xae, 0x1b, 0x2c, 0xef, 0xad, 0xd7, 0xb0, 0x78, 0xfe, 0xcf, 0x68, 0xdb, 0xea, 0xa1, 0x7b, 0x9c, 0x38, 0x5b, 0x55, 0x83, 0x29)  )

References EXPECTED, MULTIPLICAND, and MULTIPLIER.

◆ X25519_MULTIPLY_TEST() [6/7]

X25519_MULTIPLY_TEST ( multiply_4 ,
MULTIPLICAND(0x02, 0x0b, 0x1f, 0x91, 0x63, 0xce, 0x9f, 0xf5, 0x7f, 0x43, 0xb7, 0xa3, 0xa6, 0x9a, 0x8d, 0xca, 0x03, 0x58, 0x0d, 0x7b, 0x71, 0xd8, 0xf5, 0x64, 0x13, 0x5b, 0xe6, 0x12, 0x8e, 0x18, 0xc2, 0x67, 0x97) ,
MULTIPLIER(0x01, 0x8d, 0x52, 0x88, 0xf1, 0x14, 0x2c, 0x3f, 0xe8, 0x60, 0xe7, 0xa1, 0x13, 0xec, 0x1b, 0x8c, 0xa1, 0xf9, 0x1e, 0x1d, 0x4c, 0x1f, 0xf4, 0x9b, 0x78, 0x89, 0x46, 0x3e, 0x85, 0x75, 0x9c, 0xde, 0x66) ,
EXPECTED(0x28, 0xa7, 0x7d, 0x3c, 0x8a, 0x14, 0x32, 0x3d, 0x63, 0xb2, 0x88, 0xdb, 0xd4, 0x03, 0x15, 0xb3, 0xf1, 0x92, 0xb8, 0x48, 0x5d, 0x86, 0xa0, 0x2c, 0xb8, 0x7d, 0x3d, 0xfb, 0x7a, 0x0b, 0x54, 0x47)  )

References EXPECTED, MULTIPLICAND, and MULTIPLIER.

◆ X25519_MULTIPLY_TEST() [7/7]

X25519_MULTIPLY_TEST ( multiply_5 ,
MULTIPLICAND(0x02, 0x31, 0x39, 0xd3, 0x2c, 0x93, 0xcd, 0x59, 0xbf, 0x5c, 0x94, 0x1c, 0xf0, 0xdc, 0x98, 0xd2, 0xc1, 0xe2, 0xac, 0xf7, 0x2f, 0x9e, 0x57, 0x4f, 0x7a, 0xa0, 0xee, 0x89, 0xae, 0xd4, 0x53, 0xdd, 0x32) ,
MULTIPLIER(0x03, 0x14, 0x6d, 0x3f, 0x31, 0xfc, 0x37, 0x7a, 0x4c, 0x4a, 0x15, 0x54, 0x4d, 0xc5, 0xe7, 0xce, 0x8a, 0x3a, 0x57, 0x8a, 0x8e, 0xa9, 0x48, 0x8d, 0x99, 0x0b, 0xbb, 0x25, 0x99, 0x11, 0xce, 0x5d, 0xd2) ,
EXPECTED(0x4b, 0xdb, 0x7a, 0x35, 0xc0, 0xa5, 0x18, 0x20, 0x00, 0xaa, 0x67, 0x55, 0x47, 0x41, 0xe8, 0x8c, 0xfd, 0xf4, 0x60, 0xa7, 0x8c, 0x6f, 0xae, 0x07, 0xad, 0xf8, 0x3d, 0x2f, 0x00, 0x5d, 0x27, 0x67)  )

References EXPECTED, MULTIPLICAND, and MULTIPLIER.

◆ X25519_INVERT_TEST() [1/5]

X25519_INVERT_TEST ( invert_1 ,
INVERTEND(0x01, 0xd5, 0x88, 0x42, 0xde, 0xa2, 0xbc, 0x37, 0x2f, 0x74, 0x12, 0xb2, 0x93, 0x47, 0x29, 0x47, 0x39, 0x61, 0x4f, 0xf3, 0xd7, 0x19, 0xdb, 0x3a, 0xd0, 0xdd, 0xd1, 0xdf, 0xb2, 0x3b, 0x98, 0x2e, 0xf8) ,
EXPECTED(0x09, 0x3f, 0xf5, 0x17, 0x50, 0x80, 0x9d, 0x18, 0x1a, 0x9a, 0x54, 0x81, 0xc5, 0x64, 0xe3, 0x7c, 0xff, 0x61, 0x8d, 0xef, 0x8e, 0xc4, 0x5f, 0x46, 0x4b, 0x1a, 0x6e, 0x24, 0xf8, 0xb8, 0x26, 0xbd)  )

References EXPECTED, and INVERTEND.

◆ X25519_INVERT_TEST() [2/5]

X25519_INVERT_TEST ( invert_2 ,
INVERTEND(0x02, 0xef, 0xc8, 0x98, 0x49, 0xb3, 0xaa, 0x7e, 0xfe, 0x44, 0x58, 0xa8, 0x85, 0xab, 0x90, 0x99, 0xa4, 0x35, 0xa2, 0x40, 0xae, 0x5a, 0xf3, 0x05, 0x53, 0x5e, 0xc4, 0x2e, 0x08, 0x29, 0xa3, 0xb2, 0xe9) ,
EXPECTED(0x59, 0x16, 0x07, 0xb1, 0x63, 0xe8, 0x9d, 0x0a, 0xc3, 0x3a, 0x62, 0xc8, 0x81, 0xe9, 0x84, 0xa2, 0x5d, 0x38, 0x26, 0xe3, 0xdb, 0x5c, 0xe2, 0x29, 0xaf, 0x24, 0x0d, 0xc5, 0x8e, 0x5b, 0x57, 0x9a)  )

References EXPECTED, and INVERTEND.

◆ X25519_INVERT_TEST() [3/5]

X25519_INVERT_TEST ( invert_3 ,
INVERTEND(0x00, 0x3e, 0xab, 0xed, 0xcb, 0xba, 0xa8, 0x0d, 0xd4, 0x88, 0xbd, 0x64, 0x07, 0x2b, 0xcf, 0xbe, 0x01, 0xa2, 0x8d, 0xef, 0xe3, 0x9b, 0xf0, 0x02, 0x73, 0x12, 0x47, 0x6f, 0x57, 0xa5, 0xe5, 0xa5, 0xab) ,
EXPECTED(0x7d, 0x87, 0xc2, 0xe5, 0x65, 0xb2, 0x7c, 0x50, 0x38, 0x18, 0x1a, 0x0a, 0x7c, 0xae, 0x9e, 0xbe, 0x82, 0x6c, 0x8a, 0xfc, 0x1f, 0x77, 0x12, 0x8a, 0x4d, 0x62, 0xcc, 0xe9, 0x6d, 0x27, 0x59, 0xa2)  )

References EXPECTED, and INVERTEND.

◆ X25519_INVERT_TEST() [4/5]

X25519_INVERT_TEST ( invert_4 ,
INVERTEND(0x00, 0x8e, 0x94, 0x42, 0x39, 0xb0, 0x2b, 0x61, 0xc4, 0xa3, 0xd7, 0x06, 0x28, 0xec, 0xe6, 0x6f, 0xa2, 0xfd, 0x51, 0x66, 0xe6, 0x45, 0x1b, 0x4c, 0xf3, 0x61, 0x23, 0xfd, 0xf7, 0x76, 0x56, 0xaf, 0x72) ,
EXPECTED(0x08, 0xe9, 0x61, 0x61, 0xa0, 0xee, 0xe1, 0xb2, 0x9a, 0xf3, 0x96, 0xf1, 0x54, 0x95, 0x0d, 0x5c, 0x71, 0x5d, 0xc6, 0x1a, 0xff, 0x66, 0xee, 0x97, 0x37, 0x7a, 0xb2, 0x2a, 0xdf, 0x33, 0x21, 0xd7)  )

References EXPECTED, and INVERTEND.

◆ X25519_INVERT_TEST() [5/5]

X25519_INVERT_TEST ( invert_5 ,
INVERTEND(0x00, 0xd2, 0x61, 0xa7, 0xab, 0x3a, 0xa2, 0xe4, 0xf9, 0x0e, 0x51, 0xf3, 0x0d, 0xc6, 0xa7, 0xee, 0x39, 0xc4, 0xb0, 0x32, 0xcc, 0xd7, 0xc5, 0x24, 0xa5, 0x53, 0x04, 0x31, 0x7f, 0xaf, 0x42, 0xe1, 0x2f) ,
EXPECTED(0x07, 0x38, 0x78, 0x1c, 0x0a, 0xea, 0xbf, 0xbe, 0x6e, 0x84, 0x0c, 0x85, 0xbd, 0x30, 0x99, 0x6e, 0xf7, 0x1b, 0xc5, 0x49, 0x88, 0xce, 0x16, 0xce, 0xdd, 0x5a, 0xb4, 0xf3, 0x0c, 0x28, 0x15, 0x97)  )

References EXPECTED, and INVERTEND.

◆ X25519_KEY_TEST() [1/5]

X25519_KEY_TEST ( rfc7748_1 ,
1 ,
0 ,
BASE(0xe6, 0xdb, 0x68, 0x67, 0x58, 0x30, 0x30, 0xdb, 0x35, 0x94, 0xc1, 0xa4, 0x24, 0xb1, 0x5f, 0x7c, 0x72, 0x66, 0x24, 0xec, 0x26, 0xb3, 0x35, 0x3b, 0x10, 0xa9, 0x03, 0xa6, 0xd0, 0xab, 0x1c, 0x4c) ,
SCALAR(0xa5, 0x46, 0xe3, 0x6b, 0xf0, 0x52, 0x7c, 0x9d, 0x3b, 0x16, 0x15, 0x4b, 0x82, 0x46, 0x5e, 0xdd, 0x62, 0x14, 0x4c, 0x0a, 0xc1, 0xfc, 0x5a, 0x18, 0x50, 0x6a, 0x22, 0x44, 0xba, 0x44, 0x9a, 0xc4) ,
EXPECTED(0xc3, 0xda, 0x55, 0x37, 0x9d, 0xe9, 0xc6, 0x90, 0x8e, 0x94, 0xea, 0x4d, 0xf2, 0x8d, 0x08, 0x4f, 0x32, 0xec, 0xcf, 0x03, 0x49, 0x1c, 0x71, 0xf7, 0x54, 0xb4, 0x07, 0x55, 0x77, 0xa2, 0x85, 0x52)  )

References BASE, EXPECTED, and SCALAR.

◆ X25519_KEY_TEST() [2/5]

X25519_KEY_TEST ( rfc7748_2 ,
1 ,
0 ,
BASE(0xe5, 0x21, 0x0f, 0x12, 0x78, 0x68, 0x11, 0xd3, 0xf4, 0xb7, 0x95, 0x9d, 0x05, 0x38, 0xae, 0x2c, 0x31, 0xdb, 0xe7, 0x10, 0x6f, 0xc0, 0x3c, 0x3e, 0xfc, 0x4c, 0xd5, 0x49, 0xc7, 0x15, 0xa4, 0x93) ,
SCALAR(0x4b, 0x66, 0xe9, 0xd4, 0xd1, 0xb4, 0x67, 0x3c, 0x5a, 0xd2, 0x26, 0x91, 0x95, 0x7d, 0x6a, 0xf5, 0xc1, 0x1b, 0x64, 0x21, 0xe0, 0xea, 0x01, 0xd4, 0x2c, 0xa4, 0x16, 0x9e, 0x79, 0x18, 0xba, 0x0d) ,
EXPECTED(0x95, 0xcb, 0xde, 0x94, 0x76, 0xe8, 0x90, 0x7d, 0x7a, 0xad, 0xe4, 0x5c, 0xb4, 0xb8, 0x73, 0xf8, 0x8b, 0x59, 0x5a, 0x68, 0x79, 0x9f, 0xa1, 0x52, 0xe6, 0xf8, 0xf7, 0x64, 0x7a, 0xac, 0x79, 0x57)  )

References BASE, EXPECTED, and SCALAR.

◆ X25519_KEY_TEST() [3/5]

X25519_KEY_TEST ( rfc7748_3 ,
1 ,
0 ,
BASE(0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00) ,
SCALAR(0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00) ,
EXPECTED(0x42, 0x2c, 0x8e, 0x7a, 0x62, 0x27, 0xd7, 0xbc, 0xa1, 0x35, 0x0b, 0x3e, 0x2b, 0xb7, 0x27, 0x9f, 0x78, 0x97, 0xb8, 0x7b, 0xb6, 0x85, 0x4b, 0x78, 0x3c, 0x60, 0xe8, 0x03, 0x11, 0xae, 0x30, 0x79)  )

References BASE, EXPECTED, and SCALAR.

◆ X25519_KEY_TEST() [4/5]

X25519_KEY_TEST ( rfc7748_4_100 ,
100 ,
0 ,
BASE(0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00) ,
SCALAR(0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00) ,
EXPECTED(0xb1, 0xa5, 0xa7, 0x31, 0x58, 0x90, 0x4c, 0x02, 0x08, 0x66, 0xc1, 0x39, 0x39, 0xdd, 0x7e, 0x1a, 0xa2, 0x68, 0x52, 0xee, 0x1d, 0x26, 0x09, 0xc9, 0x2e, 0x5a, 0x8f, 0x1d, 0xeb, 0xe2, 0x15, 0x0a)  )

References BASE, EXPECTED, and SCALAR.

◆ X25519_KEY_TEST() [5/5]

X25519_KEY_TEST ( malicious ,
1 ,
1 ,
BASE(0xee, 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, 0x7f) ,
SCALAR(0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f) ,
EXPECTED(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)  )

References BASE, EXPECTED, and SCALAR.

◆ EXCHANGE_TEST() [1/5]

EXCHANGE_TEST ( rfc7748_alice ,
& x25519_algorithm,
PRIVATE(0x77, 0x07, 0x6d, 0x0a, 0x73, 0x18, 0xa5, 0x7d, 0x3c, 0x16, 0xc1, 0x72, 0x51, 0xb2, 0x66, 0x45, 0xdf, 0x4c, 0x2f, 0x87, 0xeb, 0xc0, 0x99, 0x2a, 0xb1, 0x77, 0xfb, 0xa5, 0x1d, 0xb9, 0x2c, 0x2a) ,
PARTNER(0xde, 0x9e, 0xdb, 0x7d, 0x7b, 0x7d, 0xc1, 0xb4, 0xd3, 0x5b, 0x61, 0xc2, 0xec, 0xe4, 0x35, 0x37, 0x3f, 0x83, 0x43, 0xc8, 0x5b, 0x78, 0x67, 0x4d, 0xad, 0xfc, 0x7e, 0x14, 0x6f, 0x88, 0x2b, 0x4f) ,
PUBLIC(0x85, 0x20, 0xf0, 0x09, 0x89, 0x30, 0xa7, 0x54, 0x74, 0x8b, 0x7d, 0xdc, 0xb4, 0x3e, 0xf7, 0x5a, 0x0d, 0xbf, 0x3a, 0x0d, 0x26, 0x38, 0x1a, 0xf4, 0xeb, 0xa4, 0xa9, 0x8e, 0xaa, 0x9b, 0x4e, 0x6a) ,
SHARED(0x4a, 0x5d, 0x9d, 0x5b, 0xa4, 0xce, 0x2d, 0xe1, 0x72, 0x8e, 0x3b, 0xf4, 0x80, 0x35, 0x0f, 0x25, 0xe0, 0x7e, 0x21, 0xc9, 0x47, 0xd1, 0x9e, 0x33, 0x76, 0xf0, 0x9b, 0x3c, 0x1e, 0x16, 0x17, 0x42)  )

◆ EXCHANGE_TEST() [2/5]

EXCHANGE_TEST ( rfc7748_bob ,
& x25519_algorithm,
PRIVATE(0x5d, 0xab, 0x08, 0x7e, 0x62, 0x4a, 0x8a, 0x4b, 0x79, 0xe1, 0x7f, 0x8b, 0x83, 0x80, 0x0e, 0xe6, 0x6f, 0x3b, 0xb1, 0x29, 0x26, 0x18, 0xb6, 0xfd, 0x1c, 0x2f, 0x8b, 0x27, 0xff, 0x88, 0xe0, 0xeb) ,
PARTNER(0x85, 0x20, 0xf0, 0x09, 0x89, 0x30, 0xa7, 0x54, 0x74, 0x8b, 0x7d, 0xdc, 0xb4, 0x3e, 0xf7, 0x5a, 0x0d, 0xbf, 0x3a, 0x0d, 0x26, 0x38, 0x1a, 0xf4, 0xeb, 0xa4, 0xa9, 0x8e, 0xaa, 0x9b, 0x4e, 0x6a) ,
PUBLIC(0xde, 0x9e, 0xdb, 0x7d, 0x7b, 0x7d, 0xc1, 0xb4, 0xd3, 0x5b, 0x61, 0xc2, 0xec, 0xe4, 0x35, 0x37, 0x3f, 0x83, 0x43, 0xc8, 0x5b, 0x78, 0x67, 0x4d, 0xad, 0xfc, 0x7e, 0x14, 0x6f, 0x88, 0x2b, 0x4f) ,
SHARED(0x4a, 0x5d, 0x9d, 0x5b, 0xa4, 0xce, 0x2d, 0xe1, 0x72, 0x8e, 0x3b, 0xf4, 0x80, 0x35, 0x0f, 0x25, 0xe0, 0x7e, 0x21, 0xc9, 0x47, 0xd1, 0x9e, 0x33, 0x76, 0xf0, 0x9b, 0x3c, 0x1e, 0x16, 0x17, 0x42)  )

◆ EXCHANGE_TEST() [3/5]

EXCHANGE_TEST ( wycheproof_49 ,
& x25519_algorithm,
PRIVATE(0x10, 0x62, 0x21, 0xfe, 0x56, 0x94, 0xa7, 0x10, 0xd6, 0xe1, 0x47, 0x69, 0x6c, 0x5d, 0x5b, 0x93, 0xd6, 0x88, 0x7d, 0x58, 0x4f, 0x24, 0xf2, 0x28, 0x18, 0x2e, 0xbe, 0x1b, 0x1d, 0x2d, 0xb8, 0x5d) ,
PARTNER(0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x0f) ,
PUBLIC(0xec, 0xba, 0x34, 0x3f, 0x4a, 0x89, 0x01, 0x3f, 0xea, 0x83, 0xe8, 0x69, 0xea, 0x3f, 0x7a, 0x67, 0x07, 0x15, 0xd8, 0x33, 0xab, 0x0e, 0xc4, 0x3a, 0xdb, 0x3a, 0xcd, 0x4b, 0x48, 0x22, 0x96, 0x07) ,
SHARED(0x5e, 0x64, 0x92, 0x4b, 0x91, 0x87, 0x3b, 0x49, 0x9a, 0x54, 0x02, 0xfa, 0x64, 0x33, 0x7c, 0x65, 0xd4, 0xb2, 0xed, 0x54, 0xbe, 0xeb, 0x3f, 0xa5, 0xd7, 0x34, 0x78, 0x09, 0xe4, 0x3a, 0xef, 0x1c)  )

◆ EXCHANGE_TEST() [4/5]

EXCHANGE_TEST ( wycheproof_63 ,
& x25519_algorithm,
PRIVATE(0xe0, 0xf9, 0x78, 0xdf, 0xcd, 0x3a, 0x8f, 0x1a, 0x50, 0x93, 0x41, 0x8d, 0xe5, 0x41, 0x36, 0xa5, 0x84, 0xc2, 0x0b, 0x7b, 0x34, 0x9a, 0xfd, 0xf6, 0xc0, 0x52, 0x08, 0x86, 0xf9, 0x5b, 0x12, 0x72) ,
PARTNER(0xe0, 0xeb, 0x7a, 0x7c, 0x3b, 0x41, 0xb8, 0xae, 0x16, 0x56, 0xe3, 0xfa, 0xf1, 0x9f, 0xc4, 0x6a, 0xda, 0x09, 0x8d, 0xeb, 0x9c, 0x32, 0xb1, 0xfd, 0x86, 0x62, 0x05, 0x16, 0x5f, 0x49, 0xb8, 0x00) ,
PUBLIC(0x12, 0x4e, 0x0f, 0x14, 0x87, 0xc9, 0xb3, 0x8f, 0x1c, 0x7f, 0xd4, 0xa6, 0x51, 0x8a, 0x47, 0x69, 0x9d, 0x15, 0x8d, 0x44, 0xcc, 0x18, 0x66, 0x5c, 0x7b, 0xcc, 0xa0, 0x3b, 0xdc, 0x72, 0x6e, 0x5d) ,
SHARED_FAIL  )

◆ EXCHANGE_TEST() [5/5]

EXCHANGE_TEST ( wycheproof_112 ,
& x25519_algorithm,
PRIVATE(0x60, 0xa3, 0xa4, 0xf1, 0x30, 0xb9, 0x8a, 0x5b, 0xe4, 0xb1, 0xce, 0xdb, 0x7c, 0xb8, 0x55, 0x84, 0xa3, 0x52, 0x0e, 0x14, 0x2d, 0x47, 0x4d, 0xc9, 0xcc, 0xb9, 0x09, 0xa0, 0x73, 0xa9, 0x76, 0x7f) ,
PARTNER(0x8d, 0x61, 0x2c, 0x58, 0x31, 0xaa, 0x64, 0xb0, 0x57, 0x30, 0x0e, 0x7e, 0x31, 0x0f, 0x3a, 0xa3, 0x32, 0xaf, 0x34, 0x06, 0x6f, 0xef, 0xca, 0xb2, 0xb0, 0x89, 0xc9, 0x59, 0x28, 0x78, 0xf8, 0x32) ,
PUBLIC(0x7c, 0x6c, 0xcb, 0xa9, 0x2f, 0xf0, 0x0a, 0x6e, 0x83, 0x38, 0x2c, 0xd0, 0x6b, 0x9e, 0xc9, 0xe6, 0x58, 0x1e, 0xaf, 0xe3, 0xc2, 0x43, 0xf0, 0xc5, 0x2c, 0xf6, 0x8e, 0x06, 0x78, 0x43, 0xe3, 0x7a) ,
SHARED(0xe3, 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, 0x7f)  )

◆ x25519_test_exec()

void x25519_test_exec ( void )
static

Perform X25519 self-tests.

Definition at line 682 of file x25519_test.c.

682 {
683
684 /* Perform multiplication tests */
685 x25519_multiply_ok ( &multiply_small );
686 x25519_multiply_ok ( &multiply_k_p );
687 x25519_multiply_ok ( &multiply_1 );
688 x25519_multiply_ok ( &multiply_2 );
689 x25519_multiply_ok ( &multiply_3 );
690 x25519_multiply_ok ( &multiply_4 );
691 x25519_multiply_ok ( &multiply_5 );
692
693 /* Perform multiplicative inversion tests */
694 x25519_invert_ok ( &invert_1 );
695 x25519_invert_ok ( &invert_2 );
696 x25519_invert_ok ( &invert_3 );
697 x25519_invert_ok ( &invert_4 );
698 x25519_invert_ok ( &invert_5 );
699
700 /* Perform key exchange tests */
701 x25519_key_ok ( &rfc7748_1 );
702 x25519_key_ok ( &rfc7748_2 );
703 x25519_key_ok ( &rfc7748_3 );
704 x25519_key_ok ( &rfc7748_4_100 );
705 x25519_key_ok ( &malicious );
706
707 /* Perform key exchange tests via generic key exchange algorithm */
708 exchange_ok ( &rfc7748_alice );
709 exchange_ok ( &rfc7748_bob );
710 exchange_ok ( &wycheproof_49 );
711 exchange_ok ( &wycheproof_63 );
712 exchange_ok ( &wycheproof_112 );
713}
#define exchange_ok(test)
Report a key exchange test result.
#define x25519_key_ok(test)
#define x25519_invert_ok(test)
#define x25519_multiply_ok(test)

References exchange_ok, x25519_invert_ok, x25519_key_ok, and x25519_multiply_ok.

Variable Documentation

◆ __self_test

struct self_test x25519_test __self_test
Initial value:
= {
.name = "x25519",
}
static void x25519_test_exec(void)
Perform X25519 self-tests.

X25519 self-test.

Definition at line 716 of file x25519_test.c.

716 {
717 .name = "x25519",
718 .exec = x25519_test_exec,
719};