- wrote diffie_hellman_t but not tested
[strongswan.git] / Source / charon / transforms / diffie_hellman.h
1 /**
2 * @file diffie_hellman.h
3 *
4 * @brief Class to represent a diffie hellman exchange.
5 *
6 */
7
8 /*
9 * Copyright (C) 2005 Jan Hutter, Martin Willi
10 * Hochschule fuer Technik Rapperswil
11 *
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>.
16 *
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
20 * for more details.
21 */
22
23 #ifndef DIFFIE_HELLMAN_H_
24 #define DIFFIE_HELLMAN_H_
25
26 #include "../types.h"
27
28 /**
29 * Object representing a diffie hellman exchange
30 *
31 */
32 typedef struct diffie_hellman_s diffie_hellman_t;
33
34 struct diffie_hellman_s {
35
36 /**
37 * @brief Returns the shared secret of this diffie hellman exchange
38 *
39 * @warning Space for returned secret is allocated and has to get freed by the caller
40 *
41 * @param this calling diffie_hellman_t object
42 * @param[out] secret shared secret will be written into this chunk
43 * @return
44 * - SUCCESS
45 * - FAILED if not both DH values are set
46 * - OUT_OF_RES if out of ressources
47 */
48 status_t (*get_shared_secret) (diffie_hellman_t *this, chunk_t *secret);
49
50 /**
51 * @brief Sets the public value of partner
52 *
53 * @warning chunk gets copied
54 *
55 * @param this calling diffie_hellman_t object
56 * @param public_value public value of partner
57 * @return
58 * - SUCCESS
59 * - OUT_OF_RES if out of ressources
60 */
61 status_t (*set_other_public_value) (diffie_hellman_t *this, chunk_t public_value);
62
63 /**
64 * @brief Gets the public value of partner
65 *
66 * @warning chunk gets copied
67 *
68 * @param this calling diffie_hellman_t object
69 * @param[out] public_value public value of partner is stored at this location
70 * @return
71 * - SUCCESS
72 * - OUT_OF_RES if out of ressources
73 * - FAILED if other public value not set
74 */
75 status_t (*get_other_public_value) (diffie_hellman_t *this, chunk_t *public_value);
76
77 /**
78 * @brief Gets the public value of caller
79 *
80 * @warning chunk gets copied
81 *
82 * @param this calling diffie_hellman_t object
83 * @param[out] public_value public value of caller is stored at this location
84 * @return
85 * - SUCCESS
86 * - OUT_OF_RES if out of ressources
87 */
88 status_t (*get_my_public_value) (diffie_hellman_t *this, chunk_t *public_value);
89
90 /**
91 * @brief Destroys an diffie_hellman_t object.
92 *
93 * @param this diffie_hellman_t object to destroy
94 * @return
95 * SUCCESS in any case
96 */
97 status_t (*destroy) (diffie_hellman_t *this);
98 };
99
100 /**
101 * Creates a new diffie_hellman_t object
102 *
103 * The first diffie hellman public value gets automatically created
104 *
105 * @param dh_group_number Diffie Hellman group number to use
106 * @return
107 * - diffie_hellman_t if successfully
108 * - NULL if out of ressources or dh_group not supported
109 */
110 diffie_hellman_t *diffie_hellman_create(u_int16_t dh_group_number);
111
112 #endif /*DIFFIE_HELLMAN_H_*/