2 * Copyright (C) 2005-2007 Martin Willi
3 * Copyright (C) 2005 Jan Hutter
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
20 * @defgroup diffie_hellman diffie_hellman
24 #ifndef DIFFIE_HELLMAN_H_
25 #define DIFFIE_HELLMAN_H_
27 typedef enum diffie_hellman_group_t diffie_hellman_group_t
;
28 typedef struct diffie_hellman_t diffie_hellman_t
;
33 * Diffie-Hellman group.
35 * The modulus (or group) to use for a Diffie-Hellman calculation.
36 * See IKEv2 RFC 3.3.2 and RFC 3526.
38 * ECP groups are defined in RFC 4753.
40 enum diffie_hellman_group_t
{
57 * enum name for diffie_hellman_group_t.
59 extern enum_name_t
*diffie_hellman_group_names
;
62 * Implementation of the Diffie-Hellman algorithm, as in RFC2631.
64 struct diffie_hellman_t
{
67 * Returns the shared secret of this diffie hellman exchange.
69 * Space for returned secret is allocated and must be
70 * freed by the caller.
72 * @param secret shared secret will be written into this chunk
73 * @return SUCCESS, FAILED if not both DH values are set
75 status_t (*get_shared_secret
) (diffie_hellman_t
*this, chunk_t
*secret
);
78 * Sets the public value of partner.
80 * Chunk gets cloned and can be destroyed afterwards.
82 * @param value public value of partner
84 void (*set_other_public_value
) (diffie_hellman_t
*this, chunk_t value
);
87 * Gets the public value of partner.
89 * Space for returned chunk is allocated and must be freed by the caller.
91 * @param value public value of partner is stored at this location
92 * @return SUCCESS, FAILED if other public value not set
94 status_t (*get_other_public_value
) (diffie_hellman_t
*this, chunk_t
*value
);
97 * Gets the own public value to transmit.
99 * Space for returned chunk is allocated and must be freed by the caller.
101 * @param value public value of caller is stored at this location
103 void (*get_my_public_value
) (diffie_hellman_t
*this, chunk_t
*value
);
106 * Get the DH group used.
108 * @return DH group set in construction
110 diffie_hellman_group_t (*get_dh_group
) (diffie_hellman_t
*this);
113 * Destroys an diffie_hellman_t object.
115 void (*destroy
) (diffie_hellman_t
*this);
118 #endif /*DIFFIE_HELLMAN_H_ @} */