|
| 1 | +/* LibTomCrypt, modular cryptographic library -- Tom St Denis */ |
| 2 | +/* SPDX-License-Identifier: Unlicense */ |
| 3 | +#define LTC_DEPRECATED(x) |
| 4 | +#include <tomcrypt_test.h> |
| 5 | + |
| 6 | +#ifdef LTC_MECC |
| 7 | +static void s_ecc_test(void) |
| 8 | +{ |
| 9 | + const ltc_ecc_curve* dp; |
| 10 | + unsigned char buf[128]; |
| 11 | + unsigned long len; |
| 12 | + ecc_key key; |
| 13 | + int stat; |
| 14 | + unsigned char data16[16] = { 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1 }; |
| 15 | + |
| 16 | + ENSURE(ltc_ecc_curves[0].OID != NULL); |
| 17 | + |
| 18 | + DO(ecc_find_curve(ltc_ecc_curves[0].OID, &dp)); |
| 19 | + DO(ecc_make_key_ex(&yarrow_prng, find_prng ("yarrow"), &key, dp)); |
| 20 | + |
| 21 | + len = sizeof(buf); |
| 22 | + DO(ecc_sign_hash(data16, 16, buf, &len, &yarrow_prng, find_prng ("yarrow"), &key)); |
| 23 | + stat = 0; |
| 24 | + DO(ecc_verify_hash(buf, len, data16, 16, &stat, &key)); |
| 25 | + |
| 26 | + SHOULD_FAIL(ecc_verify_hash_rfc7518(buf, len, data16, 16, &stat, &key)); |
| 27 | + |
| 28 | + len = sizeof(buf); |
| 29 | + DO(ecc_sign_hash_rfc7518(data16, 16, buf, &len, &yarrow_prng, find_prng ("yarrow"), &key)); |
| 30 | + stat = 0; |
| 31 | + DO(ecc_verify_hash_rfc7518(buf, len, data16, 16, &stat, &key)); |
| 32 | + |
| 33 | + SHOULD_FAIL(ecc_verify_hash(buf, len, data16, 16, &stat, &key)); |
| 34 | +} |
| 35 | +#endif |
| 36 | + |
| 37 | +int deprecated_test(void) |
| 38 | +{ |
| 39 | +#ifdef LTC_MECC |
| 40 | + s_ecc_test(); |
| 41 | +#endif |
| 42 | + return 0; |
| 43 | +} |
0 commit comments