Annotation of embedaddon/strongswan/src/charon-tkm/tests/diffie_hellman_tests.c, revision 1.1.1.1

1.1       misho       1: /*
                      2:  * Copyright (C) 2012 Reto Buerki
                      3:  * Copyright (C) 2012 Adrian-Ken Rueegsegger
                      4:  * HSR Hochschule fuer Technik Rapperswil
                      5:  *
                      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>.
                     10:  *
                     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
                     14:  * for more details.
                     15:  */
                     16: 
                     17: #include <daemon.h>
                     18: #include <tests/test_suite.h>
                     19: 
                     20: #include "tkm_diffie_hellman.h"
                     21: 
                     22: START_TEST(test_dh_creation)
                     23: {
                     24:        tkm_diffie_hellman_t *dh = NULL;
                     25: 
                     26:        dh = tkm_diffie_hellman_create(MODP_768_BIT);
                     27:        fail_if(dh, "MODP_768 created");
                     28: 
                     29:        dh = tkm_diffie_hellman_create(MODP_4096_BIT);
                     30:        fail_if(!dh, "MODP_4096 not created");
                     31:        fail_if(!dh->get_id(dh), "Invalid context id (0)");
                     32: 
                     33:        dh->dh.destroy(&dh->dh);
                     34: }
                     35: END_TEST
                     36: 
                     37: START_TEST(test_dh_get_my_pubvalue)
                     38: {
                     39:        tkm_diffie_hellman_t *dh = tkm_diffie_hellman_create(MODP_4096_BIT);
                     40:        fail_if(!dh, "Unable to create DH");
                     41: 
                     42:        chunk_t value;
                     43:        ck_assert(dh->dh.get_my_public_value(&dh->dh, &value));
                     44:        dh->dh.destroy(&dh->dh);
                     45: 
                     46:        fail_if(value.ptr == NULL, "Pubvalue is NULL");
                     47:        fail_if(value.len != 512, "Pubvalue size mismatch");
                     48: 
                     49:        chunk_free(&value);
                     50: }
                     51: END_TEST
                     52: 
                     53: Suite *make_diffie_hellman_tests()
                     54: {
                     55:        Suite *s;
                     56:        TCase *tc;
                     57: 
                     58:        s = suite_create("Diffie-Hellman");
                     59: 
                     60:        tc = tcase_create("creation");
                     61:        tcase_add_test(tc, test_dh_creation);
                     62:        suite_add_tcase(s, tc);
                     63: 
                     64:        tc = tcase_create("get_my_pubvalue");
                     65:        tcase_add_test(tc, test_dh_get_my_pubvalue);
                     66:        suite_add_tcase(s, tc);
                     67: 
                     68:        return s;
                     69: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>