1#ifndef _ELLIPTIC_TEST_H
2#define _ELLIPTIC_TEST_H
48#define BASE(...) { __VA_ARGS__ }
51#define BASE_GENERATOR BASE()
54#define SCALAR(...) { __VA_ARGS__ }
57#define ADDEND(...) { __VA_ARGS__ }
60#define AUGEND(...) { __VA_ARGS__ }
63#define EXPECTED(...) { __VA_ARGS__ }
66#define EXPECTED_FAIL EXPECTED()
78#define ELLIPTIC_MULTIPLY_TEST( name, CURVE, BASE, SCALAR, EXPECTED ) \
79 static const uint8_t name ## _base[] = BASE; \
80 static const uint8_t name ## _scalar[] = SCALAR; \
81 static const uint8_t name ## _expected[] = EXPECTED; \
82 static struct elliptic_multiply_test name = { \
84 .base = name ## _base, \
85 .base_len = sizeof ( name ## _base ), \
86 .scalar = name ## _scalar, \
87 .scalar_len = sizeof ( name ## _scalar ), \
88 .expected = name ## _expected, \
89 .expected_len = sizeof ( name ## _expected ), \
102#define ELLIPTIC_ADD_TEST( name, CURVE, ADDEND, AUGEND, EXPECTED ) \
103 static const uint8_t name ## _addend[] = ADDEND; \
104 static const uint8_t name ## _augend[] = AUGEND; \
105 static const uint8_t name ## _expected[] = EXPECTED; \
106 static struct elliptic_add_test name = { \
108 .addend = name ## _addend, \
109 .addend_len = sizeof ( name ## _addend ), \
110 .augend = name ## _augend, \
111 .augend_len = sizeof ( name ## _augend ), \
112 .expected = name ## _expected, \
113 .expected_len = sizeof ( name ## _expected ), \
117 const char *file,
unsigned int line );
119 const char *file,
unsigned int line );
121 const char *file,
unsigned int line );
128#define elliptic_curve_ok( curve ) \
129 elliptic_curve_okx ( curve, __FILE__, __LINE__ )
136#define elliptic_multiply_ok( test ) \
137 elliptic_multiply_okx ( test, __FILE__, __LINE__ )
144#define elliptic_add_ok( test ) \
145 elliptic_add_okx ( test, __FILE__, __LINE__ )
void elliptic_curve_okx(struct elliptic_curve *curve, const char *file, unsigned int line)
Report elliptic curve sanity test result.
void elliptic_multiply_okx(struct elliptic_multiply_test *test, const char *file, unsigned int line)
Report elliptic curve point multiplication test result.
void elliptic_add_okx(struct elliptic_add_test *test, const char *file, unsigned int line)
Report elliptic curve point addition test result.
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
An elliptic curve point addition test.
struct elliptic_curve * curve
Elliptic curve.
const void * augend
Augend point.
const void * addend
Addend point.
size_t expected_len
Length of expected result point (or 0 to expect failure).
const void * expected
Expected result point.
size_t addend_len
Length of addend point.
size_t augend_len
Length of augend point.
An elliptic curve point multiplication test.
const void * scalar
Scalar multiple.
size_t expected_len
Length of expected result point (or 0 to expect failure).
size_t scalar_len
Length of scalar multiple.
const void * base
Base point.
const void * expected
Expected result point.
struct elliptic_curve * curve
Elliptic curve.
size_t base_len
Length of base point (or 0 to use generator).
Self-test infrastructure.