Annotation of embedaddon/strongswan/src/libcharon/tests/utils/mock_dh.c, revision 1.1

1.1     ! misho       1: /*
        !             2:  * Copyright (C) 2016 Tobias Brunner
        !             3:  * Copyright (C) 2008 Martin Willi
        !             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 "mock_dh.h"
        !            18: 
        !            19: typedef struct private_diffie_hellman_t private_diffie_hellman_t;
        !            20: 
        !            21: /**
        !            22:  * Private data
        !            23:  */
        !            24: struct private_diffie_hellman_t {
        !            25: 
        !            26:        /**
        !            27:         * Public interface
        !            28:         */
        !            29:        diffie_hellman_t public;
        !            30: 
        !            31:        /**
        !            32:         * Instantiated DH group
        !            33:         */
        !            34:        diffie_hellman_group_t group;
        !            35: };
        !            36: 
        !            37: METHOD(diffie_hellman_t, get_my_public_value, bool,
        !            38:        private_diffie_hellman_t *this, chunk_t *value)
        !            39: {
        !            40:        *value = chunk_empty;
        !            41:        return TRUE;
        !            42: }
        !            43: 
        !            44: METHOD(diffie_hellman_t, set_other_public_value, bool,
        !            45:        private_diffie_hellman_t *this, chunk_t value)
        !            46: {
        !            47:        return TRUE;
        !            48: }
        !            49: 
        !            50: METHOD(diffie_hellman_t, get_shared_secret, bool,
        !            51:        private_diffie_hellman_t *this, chunk_t *secret)
        !            52: {
        !            53:        *secret = chunk_empty;
        !            54:        return TRUE;
        !            55: }
        !            56: 
        !            57: METHOD(diffie_hellman_t, get_dh_group, diffie_hellman_group_t,
        !            58:        private_diffie_hellman_t *this)
        !            59: {
        !            60:        return this->group;
        !            61: }
        !            62: 
        !            63: METHOD(diffie_hellman_t, destroy, void,
        !            64:        private_diffie_hellman_t *this)
        !            65: {
        !            66:        free(this);
        !            67: }
        !            68: 
        !            69: /**
        !            70:  * See header
        !            71:  */
        !            72: diffie_hellman_t *mock_dh_create(diffie_hellman_group_t group)
        !            73: {
        !            74:        private_diffie_hellman_t *this;
        !            75: 
        !            76:        INIT(this,
        !            77:                .public = {
        !            78:                        .get_shared_secret = _get_shared_secret,
        !            79:                        .set_other_public_value = _set_other_public_value,
        !            80:                        .get_my_public_value = _get_my_public_value,
        !            81:                        .get_dh_group = _get_dh_group,
        !            82:                        .destroy = _destroy,
        !            83:                },
        !            84:                .group = group,
        !            85:        );
        !            86:        return &this->public;
        !            87: }

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