ecdh_test.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * libZRTP SDK library, implements the ZRTP secure VoIP protocol.
  3. * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved.
  4. * Contact: http://philzimmermann.com
  5. * For licensing and other legal details, see the file zrtp_legal.c.
  6. *
  7. * Viktor Krykun <v.krikun at zfoneproject.com>
  8. */
  9. #include <setjmp.h>
  10. #include <stdio.h>
  11. #include "zrtp.h"
  12. #include "cmockery/cmockery.h"
  13. zrtp_global_t *zrtp;
  14. void setup() {
  15. zrtp_status_t s;
  16. zrtp_config_t zrtp_config;
  17. zrtp_config_defaults(&zrtp_config);
  18. s = zrtp_init(&zrtp_config, &zrtp);
  19. assert_int_equal(s, zrtp_status_ok);
  20. }
  21. void teardown() {
  22. zrtp_down(zrtp);
  23. }
  24. static void ecdh256_test() {
  25. zrtp_pk_scheme_t *pks = zrtp_comp_find(ZRTP_CC_PKT, ZRTP_PKTYPE_EC256P, zrtp);
  26. assert_non_null(pks);
  27. pks->self_test(pks);
  28. }
  29. static void ecdh384_test() {
  30. zrtp_pk_scheme_t *pks = zrtp_comp_find(ZRTP_CC_PKT, ZRTP_PKTYPE_EC384P, zrtp);
  31. assert_non_null(pks);
  32. pks->self_test(pks);
  33. }
  34. static void ecdh512_test() {
  35. zrtp_pk_scheme_t *pks = zrtp_comp_find(ZRTP_CC_PKT, ZRTP_PKTYPE_EC521P, zrtp);
  36. assert_non_null(pks);
  37. pks->self_test(pks);
  38. }
  39. int main(void) {
  40. const UnitTest tests[] = {
  41. unit_test_setup_teardown(ecdh256_test, setup, teardown),
  42. unit_test_setup_teardown(ecdh384_test, setup, teardown),
  43. unit_test_setup_teardown(ecdh512_test, setup, teardown),
  44. };
  45. return run_tests(tests);
  46. }