diff options
Diffstat (limited to 'src/lib/util/test_crypto_elligator.c')
-rw-r--r-- | src/lib/util/test_crypto_elligator.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/lib/util/test_crypto_elligator.c b/src/lib/util/test_crypto_elligator.c index 463cb0a0c..c42e1de3a 100644 --- a/src/lib/util/test_crypto_elligator.c +++ b/src/lib/util/test_crypto_elligator.c | |||
@@ -223,6 +223,34 @@ testTimeDecoding (void) | |||
223 | } | 223 | } |
224 | 224 | ||
225 | 225 | ||
226 | static int | ||
227 | elligatorKEM () | ||
228 | { | ||
229 | struct GNUNET_CRYPTO_EddsaPrivateKey pk; | ||
230 | struct GNUNET_CRYPTO_EddsaPublicKey pub; | ||
231 | GNUNET_CRYPTO_eddsa_key_create (&pk); | ||
232 | GNUNET_CRYPTO_eddsa_key_get_public (&pk,&pub); | ||
233 | |||
234 | struct GNUNET_CRYPTO_ElligatorRepresentative r; | ||
235 | |||
236 | // Sender side | ||
237 | struct GNUNET_HashCode key_material_encaps; | ||
238 | GNUNET_CRYPTO_eddsa_elligator_kem_encaps (&pub, &r, &key_material_encaps); | ||
239 | |||
240 | // Receiving side | ||
241 | struct GNUNET_HashCode key_material_decaps; | ||
242 | GNUNET_CRYPTO_eddsa_elligator_kem_decaps (&pk,&r,&key_material_decaps); | ||
243 | |||
244 | if (memcmp (&(key_material_encaps.bits),&(key_material_decaps.bits), | ||
245 | sizeof(key_material_encaps.bits)) != 0) | ||
246 | { | ||
247 | return GNUNET_SYSERR; | ||
248 | } | ||
249 | |||
250 | return GNUNET_OK; | ||
251 | } | ||
252 | |||
253 | |||
226 | /* | 254 | /* |
227 | *More tests to implement: | 255 | *More tests to implement: |
228 | * Adding more test vectors from different sources for inverse and direct map | 256 | * Adding more test vectors from different sources for inverse and direct map |
@@ -268,6 +296,12 @@ main (int argc, char *argv[]) | |||
268 | failure_count++; | 296 | failure_count++; |
269 | } | 297 | } |
270 | 298 | ||
299 | if (GNUNET_OK != elligatorKEM ()) | ||
300 | { | ||
301 | printf ("Elligator KEM failed!"); | ||
302 | failure_count++; | ||
303 | } | ||
304 | |||
271 | if (0 != failure_count) | 305 | if (0 != failure_count) |
272 | { | 306 | { |
273 | fprintf (stderr, | 307 | fprintf (stderr, |