Map auth_class to auth method and IKEv1 proposal attribute
[strongswan.git] / src / libcharon / sa / authenticators / authenticator.h
1 /*
2 * Copyright (C) 2005-2009 Martin Willi
3 * Copyright (C) 2008 Tobias Brunner
4 * Copyright (C) 2005 Jan Hutter
5 * Hochschule fuer Technik Rapperswil
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * for more details.
16 */
17
18 /**
19 * @defgroup authenticator authenticator
20 * @{ @ingroup authenticators
21 */
22
23 #ifndef AUTHENTICATOR_H_
24 #define AUTHENTICATOR_H_
25
26 typedef enum auth_method_t auth_method_t;
27 typedef struct authenticator_t authenticator_t;
28
29 #include <library.h>
30 #include <credentials/auth_cfg.h>
31 #include <sa/ike_sa.h>
32
33 /**
34 * Method to use for authentication, as defined in IKEv2.
35 */
36 enum auth_method_t {
37
38 /**
39 * No authentication used.
40 */
41 AUTH_NONE = 0,
42
43 /**
44 * Computed as specified in section 2.15 of RFC using
45 * an RSA private key over a PKCS#1 padded hash.
46 */
47 AUTH_RSA = 1,
48
49 /**
50 * Computed as specified in section 2.15 of RFC using the
51 * shared key associated with the identity in the ID payload
52 * and the negotiated prf function
53 */
54 AUTH_PSK = 2,
55
56 /**
57 * Computed as specified in section 2.15 of RFC using a
58 * DSS private key over a SHA-1 hash.
59 */
60 AUTH_DSS = 3,
61
62 /**
63 * ECDSA with SHA-256 on the P-256 curve as specified in RFC 4754
64 */
65 AUTH_ECDSA_256 = 9,
66
67 /**
68 * ECDSA with SHA-384 on the P-384 curve as specified in RFC 4754
69 */
70 AUTH_ECDSA_384 = 10,
71
72 /**
73 * ECDSA with SHA-512 on the P-521 curve as specified in RFC 4754
74 */
75 AUTH_ECDSA_521 = 11,
76
77 /**
78 * IKEv1 initiator XAUTH with PSK, outside of IANA range
79 */
80 AUTH_XAUTH_INIT_PSK = 256,
81
82 /**
83 * IKEv1 initiator XAUTH with RSA, outside of IANA range
84 */
85 AUTH_XAUTH_INIT_RSA,
86 };
87
88 /**
89 * enum names for auth_method_t.
90 */
91 extern enum_name_t *auth_method_names;
92
93 /**
94 * Authenticator interface implemented by the various authenticators.
95 *
96 * An authenticator implementation handles AUTH and EAP payloads. Received
97 * messages are passed to the process() method, to send authentication data
98 * the message is passed to the build() method.
99 */
100 struct authenticator_t {
101
102 /**
103 * Process an incoming message using the authenticator.
104 *
105 * @param message message containing authentication payloads
106 * @return
107 * - SUCCESS if authentication successful
108 * - FAILED if authentication failed
109 * - NEED_MORE if another exchange required
110 */
111 status_t (*process)(authenticator_t *this, message_t *message);
112
113 /**
114 * Attach authentication data to an outgoing message.
115 *
116 * @param message message to add authentication data to
117 * @return
118 * - SUCCESS if authentication successful
119 * - FAILED if authentication failed
120 * - NEED_MORE if another exchange required
121 */
122 status_t (*build)(authenticator_t *this, message_t *message);
123
124 /**
125 * Check if the authenticator is capable of mutual authentication.
126 *
127 * Some authenticator authenticate both peers, e.g. EAP. To support
128 * mutual authentication with only a single authenticator (EAP-only
129 * authentication), it must be mutual. This method is invoked in ike_auth
130 * to check if the given authenticator is capable of doing so.
131 */
132 bool (*is_mutual)(authenticator_t *this);
133
134 /**
135 * Destroy authenticator instance.
136 */
137 void (*destroy) (authenticator_t *this);
138 };
139
140 /**
141 * Create an authenticator to build signatures.
142 *
143 * @param ike_sa associated ike_sa
144 * @param cfg authentication configuration
145 * @param received_nonce nonce received in IKE_SA_INIT
146 * @param sent_nonce nonce sent in IKE_SA_INIT
147 * @param received_init received IKE_SA_INIT message data
148 * @param sent_init sent IKE_SA_INIT message data
149 * @param reserved reserved bytes of the ID payload
150 * @return authenticator, NULL if not supported
151 */
152 authenticator_t *authenticator_create_builder(
153 ike_sa_t *ike_sa, auth_cfg_t *cfg,
154 chunk_t received_nonce, chunk_t sent_nonce,
155 chunk_t received_init, chunk_t sent_init,
156 char reserved[3]);
157
158 /**
159 * Create an authenticator to verify signatures.
160 *
161 * @param ike_sa associated ike_sa
162 * @param message message containing authentication data
163 * @param received_nonce nonce received in IKE_SA_INIT
164 * @param sent_nonce nonce sent in IKE_SA_INIT
165 * @param received_init received IKE_SA_INIT message data
166 * @param sent_init sent IKE_SA_INIT message data
167 * @param reserved reserved bytes of the ID payload
168 * @return authenticator, NULL if not supported
169 */
170 authenticator_t *authenticator_create_verifier(
171 ike_sa_t *ike_sa, message_t *message,
172 chunk_t received_nonce, chunk_t sent_nonce,
173 chunk_t received_init, chunk_t sent_init,
174 char reserved[3]);
175
176 #endif /** AUTHENTICATOR_H_ @}*/