44 CX_TEST_HMAC_RIPEMD160_ID,
45 CX_TEST_HMAC_SHA256_ID,
46 CX_TEST_HMAC_SHA512_ID,
50 CX_TEST_ECDSA_RFC6979_ID,
70 typedef struct cx_selftest_s {
73 int _cx_failure_counter;
74 int _cx_results[CX_TEST_COUNT];
77 #define G_HAVE_SELFTESTS ((cx_selftest_t *) 0x0020000800)
78 #define IN G_HAVE_SELFTESTS->_in
79 #define OUT G_HAVE_SELFTESTS->_out
80 #define cx_failure_counter G_HAVE_SELFTESTS->_cx_failure_counter
81 #define cx_results G_HAVE_SELFTESTS->_cx_results
87 void cx_printa(
char *prefix,
const unsigned char *r,
unsigned short len)
102 int cx_st_onefail(
void)
116 void cx_st_check_result(
int r,
int ID,
int c)
119 cx_results[ID] |= 1 << c;
120 cx_failure_counter++;
128 static void cx_clr_inout(
void)
130 memset(IN, 0,
sizeof(IN));
131 memset(OUT, 0,
sizeof(OUT));
167 static const unsigned char rfc6979_sha256_order1[] = {
168 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
169 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x2f};
170 static const unsigned char rfc6979_sha256_key1[] = {
171 0xc4, 0x8b, 0x5c, 0x4c, 0x5b, 0x2a, 0xe3, 0x3d, 0xf9, 0x41, 0x92, 0xf6, 0x26, 0x9d, 0x55, 0x92,
172 0x1f, 0xb0, 0xf0, 0x95, 0xbe, 0x4d, 0x84, 0x3b, 0x50, 0x7a, 0x2a, 0x71, 0x69, 0x54, 0xee, 0xa7};
173 static const unsigned char rfc6979_sha256_hash1[] = {
174 0xef, 0x84, 0xda, 0xe8, 0xcb, 0x46, 0x95, 0x13, 0x14, 0x92, 0x05, 0x00, 0xec, 0x18, 0xa3, 0x86,
175 0x70, 0xcd, 0xa4, 0x37, 0xb4, 0x5c, 0x7a, 0xea, 0xa7, 0x36, 0x62, 0x16, 0x66, 0x38, 0xf7, 0x4d};
212 static const unsigned char rfc6979_sha256_order2[] = {
213 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
214 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
215 static const unsigned char rfc6979_sha256_key2[] = {
216 0x00, 0x03, 0xf8, 0x31, 0x1e, 0xec, 0xe8, 0xca, 0xfe, 0xa3, 0xbf, 0x56, 0x8a, 0xa9, 0x04, 0x57,
217 0xad, 0x6b, 0xbc, 0x47, 0xde, 0xed, 0x0e, 0x3c, 0x44, 0xe0, 0xaa, 0x94, 0xb9, 0x8a, 0xc4, 0x1f};
218 static const unsigned char rfc6979_sha256_hash2[] = {
219 0xe5, 0x11, 0xc5, 0x43, 0x2e, 0xa4, 0xf8, 0x0a, 0xa4, 0x34, 0xb8, 0x42, 0xfe, 0x53, 0x98, 0xec,
220 0x23, 0xd6, 0x2f, 0x3e, 0x0d, 0xa0, 0x6c, 0x24, 0x00, 0x00, 0x5e, 0xf9, 0xc7, 0xac, 0x1b, 0x4b};
224 cx_rng_rfc6979(CX_SHA256,
226 sizeof(rfc6979_sha256_key1),
227 rfc6979_sha256_hash1,
228 sizeof(rfc6979_sha256_hash1),
229 rfc6979_sha256_order1,
230 sizeof(rfc6979_sha256_order1),
232 sizeof(rfc6979_sha256_order1));
234 cx_rng_rfc6979(CX_SHA256,
236 sizeof(rfc6979_sha256_key2),
237 rfc6979_sha256_hash2,
238 sizeof(rfc6979_sha256_hash2),
239 rfc6979_sha256_order2,
240 sizeof(rfc6979_sha256_order2),
242 sizeof(rfc6979_sha256_order1));
252 memset(G_HAVE_SELFTESTS, 0,
sizeof(cx_selftest_t));
256 return cx_failure_counter;
void cx_printa(char *prefix, const unsigned char *r, unsigned short len)
#define HAVE_SELFTESTS_START_LOOP