2 * Copyright (C) 2012 Reto Buerki
3 * Copyright (C) 2012 Adrian-Ken Rueegsegger
4 * Hochschule fuer Technik Rapperswil
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19 #include "tkm_diffie_hellman.h"
21 START_TEST(test_dh_creation
)
23 tkm_diffie_hellman_t
*dh
= NULL
;
25 dh
= tkm_diffie_hellman_create(MODP_768_BIT
);
26 fail_if(dh
, "MODP_768 created");
28 dh
= tkm_diffie_hellman_create(MODP_4096_BIT
);
29 fail_if(!dh
, "MODP_4096 not created");
31 dh
->dh
.destroy(&dh
->dh
);
35 START_TEST(test_dh_get_my_pubvalue
)
37 tkm_diffie_hellman_t
*dh
= tkm_diffie_hellman_create(MODP_4096_BIT
);
38 fail_if(!dh
, "Unable to create DH");
41 dh
->dh
.get_my_public_value(&dh
->dh
, &value
);
42 dh
->dh
.destroy(&dh
->dh
);
44 fail_if(value
.ptr
== NULL
, "Pubvalue is NULL");
45 fail_if(value
.len
!= 512, "Pubvalue size mismatch");
51 TCase
*make_diffie_hellman_tests(void)
53 TCase
*tc
= tcase_create("Diffie-Hellman tests");
54 tcase_add_test(tc
, test_dh_creation
);
55 tcase_add_test(tc
, test_dh_get_my_pubvalue
);