2 * @file diffie_hellman.h
4 * @brief Class to represent a diffie hellman exchange.
9 * Copyright (C) 2005 Jan Hutter, Martin Willi
10 * Hochschule fuer Technik Rapperswil
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23 #ifndef DIFFIE_HELLMAN_H_
24 #define DIFFIE_HELLMAN_H_
29 * Object representing a diffie hellman exchange
32 typedef struct diffie_hellman_s diffie_hellman_t
;
34 struct diffie_hellman_s
{
37 * @brief Returns the shared secret of this diffie hellman exchange
39 * @warning Space for returned secret is allocated and has to get freed by the caller
41 * @param this calling diffie_hellman_t object
42 * @param[out] secret shared secret will be written into this chunk
45 * - FAILED if not both DH values are set
46 * - OUT_OF_RES if out of ressources
48 status_t (*get_shared_secret
) (diffie_hellman_t
*this, chunk_t
*secret
);
51 * @brief Sets the public value of partner
53 * @warning chunk gets copied
55 * @param this calling diffie_hellman_t object
56 * @param public_value public value of partner
59 * - OUT_OF_RES if out of ressources
61 status_t (*set_other_public_value
) (diffie_hellman_t
*this, chunk_t public_value
);
64 * @brief Gets the public value of partner
66 * @warning chunk gets copied
68 * @param this calling diffie_hellman_t object
69 * @param[out] public_value public value of partner is stored at this location
72 * - OUT_OF_RES if out of ressources
73 * - FAILED if other public value not set
75 status_t (*get_other_public_value
) (diffie_hellman_t
*this, chunk_t
*public_value
);
78 * @brief Gets the public value of caller
80 * @warning chunk gets copied
82 * @param this calling diffie_hellman_t object
83 * @param[out] public_value public value of caller is stored at this location
86 * - OUT_OF_RES if out of ressources
88 status_t (*get_my_public_value
) (diffie_hellman_t
*this, chunk_t
*public_value
);
91 * @brief Destroys an diffie_hellman_t object.
93 * @param this diffie_hellman_t object to destroy
97 status_t (*destroy
) (diffie_hellman_t
*this);
101 * Creates a new diffie_hellman_t object
103 * The first diffie hellman public value gets automatically created
105 * @param dh_group_number Diffie Hellman group number to use
107 * - diffie_hellman_t if successfully
108 * - NULL if out of ressources or dh_group not supported
110 diffie_hellman_t
*diffie_hellman_create(u_int16_t dh_group_number
);
112 #endif /*DIFFIE_HELLMAN_H_*/