From 9c6cf787576f18d935febe568fe1c84d847f29bd Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Mon, 22 Jan 2018 12:06:31 +0100 Subject: shared: Add missing ecc_valid_public_key function --- unit/test-ecc.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'unit') diff --git a/unit/test-ecc.c b/unit/test-ecc.c index 9b48d0b3a..98400a253 100644 --- a/unit/test-ecc.c +++ b/unit/test-ecc.c @@ -243,6 +243,39 @@ static void test_sample_3(const void *data) tester_test_passed(); } +static void test_invalid_pub(const void *data) +{ + uint8_t priv_a[32] = { 0xbd, 0x1a, 0x3c, 0xcd, 0xa6, 0xb8, 0x99, 0x58, + 0x99, 0xb7, 0x40, 0xeb, 0x7b, 0x60, 0xff, 0x4a, + 0x50, 0x3f, 0x10, 0xd2, 0xe3, 0xb3, 0xc9, 0x74, + 0x38, 0x5f, 0xc5, 0xa3, 0xd4, 0xf6, 0x49, 0x3f, + }; + uint8_t pub_a[64] = { 0xe6, 0x9d, 0x35, 0x0e, 0x48, 0x01, 0x03, 0xcc, + 0xdb, 0xfd, 0xf4, 0xac, 0x11, 0x91, 0xf4, 0xef, + 0xb9, 0xa5, 0xf9, 0xe9, 0xa7, 0x83, 0x2c, 0x5e, + 0x2c, 0xbe, 0x97, 0xf2, 0xd2, 0x03, 0xb0, 0x20, + + 0x8b, 0xd2, 0x89, 0x15, 0xd0, 0x8e, 0x1c, 0x74, + 0x24, 0x30, 0xed, 0x8f, 0xc2, 0x45, 0x63, 0x76, + 0x5c, 0x15, 0x52, 0x5a, 0xbf, 0x9a, 0x32, 0x63, + 0x6d, 0xeb, 0x2a, 0x65, 0x49, 0x9c, 0x80, 0xdc, + }; + uint8_t dhkey[32] = { 0x2d, 0xab, 0x00, 0x48, 0xcb, 0xb3, 0x7b, 0xda, + 0x55, 0x7b, 0x8b, 0x72, 0xa8, 0x57, 0x87, 0xc3, + 0x87, 0x27, 0x99, 0x32, 0xfc, 0x79, 0x5f, 0xae, + 0x7c, 0x1c, 0xf9, 0x49, 0xe6, 0xd7, 0xaa, 0x70, + }; + int fails; + + memset(pub_a + 32, 0x42, 32); + + fails = test_sample(priv_a, priv_a, pub_a, pub_a, dhkey); + + g_assert(fails >= 1); + + tester_test_passed(); +} + int main(int argc, char *argv[]) { tester_init(&argc, &argv); @@ -253,5 +286,7 @@ int main(int argc, char *argv[]) tester_add("/ecdh/sample/2", NULL, NULL, test_sample_2, NULL); tester_add("/ecdh/sample/3", NULL, NULL, test_sample_3, NULL); + tester_add("/ecdh/invalid", NULL, NULL, test_invalid_pub, NULL); + return tester_run(); } -- cgit v1.2.1