d6107abc0a14ebbbf9f22760a3704fc45a049551
[strongswan.git] / src / libstrongswan / crypto / proposal / proposal_keywords.h
1 /*
2 * Copyright (C) 2012 Tobias Brunner
3 * Hochschule fuer Technik Rapperswil
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 */
15
16 /*
17 * Copyright (c) 2012 Nanoteq Pty Ltd
18 *
19 * Permission is hereby granted, free of charge, to any person obtaining a copy
20 * of this software and associated documentation files (the "Software"), to deal
21 * in the Software without restriction, including without limitation the rights
22 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
23 * copies of the Software, and to permit persons to whom the Software is
24 * furnished to do so, subject to the following conditions:
25 *
26 * The above copyright notice and this permission notice shall be included in
27 * all copies or substantial portions of the Software.
28 *
29 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
32 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
34 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
35 * THE SOFTWARE.
36 */
37
38 /**
39 * @defgroup proposal_keywords proposal_keywords
40 * @{ @ingroup crypto
41 */
42
43 #ifndef PROPOSAL_KEYWORDS_H_
44 #define PROPOSAL_KEYWORDS_H_
45
46 typedef struct proposal_token_t proposal_token_t;
47 typedef struct proposal_keywords_t proposal_keywords_t;
48
49 #include <library.h>
50 #include <crypto/transform.h>
51
52 /**
53 * Class representing a proposal token.
54 */
55 struct proposal_token_t {
56
57 /**
58 * The name of the token.
59 */
60 char *name;
61
62 /**
63 * The type of transform in the token.
64 */
65 transform_type_t type;
66
67 /**
68 * The IKE id of the algorithm.
69 */
70 u_int16_t algorithm;
71
72 /**
73 * The key size associated with the specific algorithm.
74 */
75 u_int16_t keysize;
76 };
77
78 /**
79 * Class to manage proposal keywords
80 */
81 struct proposal_keywords_t {
82
83 /**
84 * Returns the proposal token for the specified string if a token exists.
85 *
86 * @param str the string containing the name of the token
87 * @return proposal_token if found, NULL otherwise
88 */
89 const proposal_token_t *(*get_token)(proposal_keywords_t *this,
90 const char *str);
91
92 /**
93 * Register a new proposal token for an algorithm.
94 *
95 * @param name the string containing the name of the token
96 * @param type the transform_type_t for the token
97 * @param algorithm the IKE id of the algorithm
98 * @param keysize the key size associated with the specific algorithm
99 */
100 void (*register_token)(proposal_keywords_t *this, const char *name,
101 transform_type_t type, u_int16_t algorithm,
102 u_int16_t keysize);
103
104 /**
105 * Destroy a proposal_keywords_t instance.
106 */
107 void (*destroy)(proposal_keywords_t *this);
108 };
109
110 /**
111 * Create a proposal_keywords_t instance.
112 */
113 proposal_keywords_t *proposal_keywords_create();
114
115 #endif /** PROPOSAL_KEYWORDS_H_ @}*/