diff options
author | grothoff <grothoff@140774ce-b5e7-0310-ab8b-a85725594a96> | 2013-02-05 13:06:36 +0000 |
---|---|---|
committer | grothoff <grothoff@140774ce-b5e7-0310-ab8b-a85725594a96> | 2013-02-05 13:06:36 +0000 |
commit | 4dd35d6e3ed863aad41987f33d0fea3699bcc1e7 (patch) | |
tree | c6ad3d4d6c787242754e72610ad31d695089fff2 /src | |
parent | 97cabd74c84b8a92da6453cb293897cbe3c42abe (diff) |
-ECDH test
git-svn-id: https://gnunet.org/svn/gnunet@26017 140774ce-b5e7-0310-ab8b-a85725594a96
Diffstat (limited to 'src')
-rw-r--r-- | src/util/test_crypto_ecc.c | 24 |
1 files changed, 24 insertions, 0 deletions
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) { |