dh_test.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 dh2k_test() {
  25. zrtp_pk_scheme_t *pks = zrtp_comp_find(ZRTP_CC_PKT, ZRTP_PKTYPE_DH2048, zrtp);
  26. assert_non_null(pks);
  27. pks->self_test(pks);
  28. }
  29. static void dh3k_test() {
  30. zrtp_pk_scheme_t *pks = zrtp_comp_find(ZRTP_CC_PKT, ZRTP_PKTYPE_DH3072, zrtp);
  31. assert_non_null(pks);
  32. pks->self_test(pks);
  33. }
  34. int main(void) {
  35. const UnitTest tests[] = {
  36. unit_test_setup_teardown(dh2k_test, setup, teardown),
  37. unit_test_setup_teardown(dh3k_test, setup, teardown),
  38. };
  39. return run_tests(tests);
  40. }