2 * Copyright (C) 2008 Tobias Brunner
3 * Copyright (C) 2005-2008 Martin Willi
4 * Copyright (C) 2005 Jan Hutter
5 * Hochschule fuer Technik Rapperswil
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>.
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
21 * @defgroup authenticator authenticator
22 * @{ @ingroup authenticators
25 #ifndef AUTHENTICATOR_H_
26 #define AUTHENTICATOR_H_
28 typedef enum auth_method_t auth_method_t
;
29 typedef enum auth_class_t auth_class_t
;
30 typedef struct authenticator_t authenticator_t
;
33 #include <sa/ike_sa.h>
34 #include <config/peer_cfg.h>
35 #include <encoding/payloads/auth_payload.h>
38 * Method to use for authentication, as defined in IKEv2.
42 * Computed as specified in section 2.15 of RFC using
43 * an RSA private key over a PKCS#1 padded hash.
48 * Computed as specified in section 2.15 of RFC using the
49 * shared key associated with the identity in the ID payload
50 * and the negotiated prf function
55 * Computed as specified in section 2.15 of RFC using a
56 * DSS private key over a SHA-1 hash.
61 * ECDSA with SHA-256 on the P-256 curve as specified in RFC 4754
66 * ECDSA with SHA-384 on the P-384 curve as specified in RFC 4754
71 * ECDSA with SHA-512 on the P-521 curve as specified in RFC 4754
77 * enum names for auth_method_t.
79 extern enum_name_t
*auth_method_names
;
82 * Class of authentication to use. This is different to auth_method_t in that
83 * it does not specify a method, but a class of acceptable methods. The found
84 * certificate finally dictates wich method is used.
87 /** authentication using public keys (RSA, ECDSA) */
88 AUTH_CLASS_PUBKEY
= 1,
89 /** authentication using a pre-shared secrets */
91 /** authentication using EAP */
96 * enum strings for auth_class_t
98 extern enum_name_t
*auth_class_names
;
101 * Authenticator interface implemented by the various authenticators.
103 * Currently the following two AUTH methods are supported:
104 * - shared key message integrity code
105 * - RSA digital signature
106 * - EAP using the EAP framework and one of the EAP plugins
107 * - ECDSA is supported using OpenSSL
109 struct authenticator_t
{
112 * Verify a received authentication payload.
114 * @param ike_sa_init binary representation of received ike_sa_init
115 * @param my_nonce the sent nonce
116 * @param auth_payload authentication payload to verify
119 * - FAILED if verification failed
120 * - INVALID_ARG if auth_method does not match
121 * - NOT_FOUND if credentials not found
123 status_t (*verify
) (authenticator_t
*this, chunk_t ike_sa_init
,
124 chunk_t my_nonce
, auth_payload_t
*auth_payload
);
127 * Build an authentication payload to send to the other peer.
129 * @param ike_sa_init binary representation of sent ike_sa_init
130 * @param other_nonce the received nonce
131 * @param auth_payload the resulting authentication payload
134 * - NOT_FOUND if credentials not found
136 status_t (*build
) (authenticator_t
*this, chunk_t ike_sa_init
,
137 chunk_t other_nonce
, auth_payload_t
**auth_payload
);
140 * Destroys a authenticator_t object.
142 void (*destroy
) (authenticator_t
*this);
146 * Creates an authenticator for the specified auth class (as configured).
148 * @param ike_sa associated ike_sa
149 * @param class class of authentication to use
150 * @return authenticator_t object
152 authenticator_t
*authenticator_create_from_class(ike_sa_t
*ike_sa
,
156 * Creates an authenticator for method (as received in payload).
158 * @param ike_sa associated ike_sa
159 * @param method method as found in payload
160 * @return authenticator_t object
162 authenticator_t
*authenticator_create_from_method(ike_sa_t
*ike_sa
,
163 auth_method_t method
);
165 #endif /** AUTHENTICATOR_H_ @}*/