mirror of
https://git.sr.ht/~thestr4ng3r/chiaki
synced 2025-08-21 14:03:11 -07:00
Finish ECDH test
This commit is contained in:
parent
eaf88afd2d
commit
efc26ec16c
4 changed files with 42 additions and 40 deletions
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include <chiaki/ecdh.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
static MunitResult test_ecdh(const MunitParameter params[], void *user)
|
||||
{
|
||||
|
@ -39,9 +40,29 @@ static MunitResult test_ecdh(const MunitParameter params[], void *user)
|
|||
if(err != CHIAKI_ERR_SUCCESS)
|
||||
return MUNIT_ERROR;
|
||||
|
||||
//uint8_t local_public_key_result[128];
|
||||
//uint8_t local_public_key_sig_result[32];
|
||||
//chiaki_ecdh_get_local_pub_key()
|
||||
uint8_t local_public_key_result[128];
|
||||
size_t local_public_key_result_size = sizeof(local_public_key_result);
|
||||
uint8_t local_public_key_sig_result[32];
|
||||
size_t local_public_key_sig_result_size = sizeof(local_public_key_sig_result);
|
||||
chiaki_ecdh_get_local_pub_key(&ecdh, local_public_key_result, &local_public_key_result_size, handshake_key, local_public_key_sig_result, &local_public_key_sig_result_size);
|
||||
|
||||
munit_assert_size(local_public_key_result_size, ==, sizeof(local_public_key));
|
||||
munit_assert_memory_equal(sizeof(local_public_key), local_public_key_result, local_public_key);
|
||||
|
||||
munit_assert_size(local_public_key_sig_result_size, ==, sizeof(local_public_key_sig));
|
||||
munit_assert_memory_equal(sizeof(local_public_key_sig), local_public_key_sig_result, local_public_key_sig);
|
||||
|
||||
uint8_t secret_result[128];
|
||||
size_t secret_result_size = sizeof(secret_result);
|
||||
chiaki_ecdh_derive_secret(&ecdh, secret_result, &secret_result_size,
|
||||
remote_public_key, sizeof(remote_public_key),
|
||||
handshake_key,
|
||||
remote_public_key_sig, sizeof(remote_public_key_sig));
|
||||
|
||||
munit_assert_size(secret_result_size, ==, sizeof(secret));
|
||||
munit_assert_memory_equal(sizeof(secret), secret_result, secret);
|
||||
|
||||
chiaki_ecdh_fini(&ecdh);
|
||||
|
||||
return MUNIT_OK;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue