1 #ifndef _ELLIPTIC_TEST_H 2 #define _ELLIPTIC_TEST_H 47 #define BASE(...) { __VA_ARGS__ } 50 #define BASE_GENERATOR BASE() 53 #define SCALAR(...) { __VA_ARGS__ } 56 #define ADDEND(...) { __VA_ARGS__ } 59 #define AUGEND(...) { __VA_ARGS__ } 62 #define EXPECTED(...) { __VA_ARGS__ } 65 #define EXPECTED_FAIL EXPECTED() 77 #define ELLIPTIC_MULTIPLY_TEST( name, CURVE, BASE, SCALAR, EXPECTED ) \ 78 static const uint8_t name ## _base[] = BASE; \ 79 static const uint8_t name ## _scalar[] = SCALAR; \ 80 static const uint8_t name ## _expected[] = EXPECTED; \ 81 static struct elliptic_multiply_test name = { \ 83 .base = name ## _base, \ 84 .base_len = sizeof ( name ## _base ), \ 85 .scalar = name ## _scalar, \ 86 .scalar_len = sizeof ( name ## _scalar ), \ 87 .expected = name ## _expected, \ 88 .expected_len = sizeof ( name ## _expected ), \ 101 #define ELLIPTIC_ADD_TEST( name, CURVE, ADDEND, AUGEND, EXPECTED ) \ 102 static const uint8_t name ## _addend[] = ADDEND; \ 103 static const uint8_t name ## _augend[] = AUGEND; \ 104 static const uint8_t name ## _expected[] = EXPECTED; \ 105 static struct elliptic_add_test name = { \ 107 .addend = name ## _addend, \ 108 .addend_len = sizeof ( name ## _addend ), \ 109 .augend = name ## _augend, \ 110 .augend_len = sizeof ( name ## _augend ), \ 111 .expected = name ## _expected, \ 112 .expected_len = sizeof ( name ## _expected ), \ 116 const char *file,
unsigned int line );
118 const char *file,
unsigned int line );
120 const char *file,
unsigned int line );
127 #define elliptic_curve_ok( curve ) \ 128 elliptic_curve_okx ( curve, __FILE__, __LINE__ ) 135 #define elliptic_multiply_ok( test ) \ 136 elliptic_multiply_okx ( test, __FILE__, __LINE__ ) 143 #define elliptic_add_ok( test ) \ 144 elliptic_add_okx ( test, __FILE__, __LINE__ ) size_t expected_len
Length of expected result point (or 0 to expect failure)
size_t scalar_len
Length of scalar multiple.
size_t expected_len
Length of expected result point (or 0 to expect failure)
An elliptic curve point multiplication test.
const void * expected
Expected result point.
Self-test infrastructure.
void elliptic_multiply_okx(struct elliptic_multiply_test *test, const char *file, unsigned int line)
Report elliptic curve point multiplication test result.
size_t base_len
Length of base point (or 0 to use generator)
const void * addend
Addend point.
const void * expected
Expected result point.
const void * augend
Augend point.
size_t addend_len
Length of addend point.
const void * base
Base point.
An elliptic curve point addition test.
struct elliptic_curve * curve
Elliptic curve.
void elliptic_curve_okx(struct elliptic_curve *curve, const char *file, unsigned int line)
Report elliptic curve sanity test result.
const void * scalar
Scalar multiple.
size_t augend_len
Length of augend point.
void elliptic_add_okx(struct elliptic_add_test *test, const char *file, unsigned int line)
Report elliptic curve point addition test result.
struct elliptic_curve * curve
Elliptic curve.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)