From 4dd35d6e3ed863aad41987f33d0fea3699bcc1e7 Mon Sep 17 00:00:00 2001 From: grothoff Date: Tue, 5 Feb 2013 13:06:36 +0000 Subject: -ECDH test git-svn-id: https://gnunet.org/svn/gnunet@26017 140774ce-b5e7-0310-ab8b-a85725594a96 --- src/util/test_crypto_ecc.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src') diff --git a/src/util/test_crypto_ecc.c b/src/util/test_crypto_ecc.c index d8329a0ae5..6dac1763fd 100644 --- a/src/util/test_crypto_ecc.c +++ b/src/util/test_crypto_ecc.c @@ -179,6 +179,29 @@ test_async_creation (void *cls, } +static void +test_ecdh () +{ + struct GNUNET_CRYPTO_EccPrivateKey *priv1; + struct GNUNET_CRYPTO_EccPrivateKey *priv2; + struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pub1; + struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pub2; + struct GNUNET_HashCode ecdh1; + struct GNUNET_HashCode ecdh2; + + priv1 = GNUNET_CRYPTO_ecc_key_create (); + priv2 = GNUNET_CRYPTO_ecc_key_create (); + GNUNET_CRYPTO_ecc_key_get_public (priv1, &pub1); + GNUNET_CRYPTO_ecc_key_get_public (priv2, &pub2); + GNUNET_CRYPTO_ecc_ecdh (priv1, &pub2, &ecdh1); + GNUNET_CRYPTO_ecc_ecdh (priv2, &pub1, &ecdh2); + GNUNET_CRYPTO_ecc_key_free (priv1); + GNUNET_CRYPTO_ecc_key_free (priv2); + GNUNET_assert (0 == memcmp (&ecdh1, &ecdh2, + sizeof (struct GNUNET_HashCode))); +} + + int main (int argc, char *argv[]) { @@ -205,6 +228,7 @@ main (int argc, char *argv[]) failureCount++; GNUNET_CRYPTO_ecc_key_free (key); GNUNET_assert (0 == UNLINK (KEYFILE)); + test_ecdh (); if (failureCount != 0) { -- cgit v1.2.3-18-g5258