2 * Copyright (C) 2005-2006 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 authenticator authenticator
21 * @{ @ingroup authenticators
24 #ifndef AUTHENTICATOR_H_
25 #define AUTHENTICATOR_H_
27 typedef enum auth_method_t auth_method_t
;
28 typedef struct authenticator_t authenticator_t
;
31 #include <sa/ike_sa.h>
32 #include <encoding/payloads/auth_payload.h>
35 * Method to use for authentication.
39 * Computed as specified in section 2.15 of RFC using
40 * an RSA private key over a PKCS#1 padded hash.
45 * Computed as specified in section 2.15 of RFC using the
46 * shared key associated with the identity in the ID payload
47 * and the negotiated prf function
52 * Computed as specified in section 2.15 of RFC using a
53 * DSS private key over a SHA-1 hash.
58 * EAP authentication. This value is never negotiated and therefore
59 * a value from private use.
65 * enum names for auth_method_t.
67 extern enum_name_t
*auth_method_names
;
70 * Authenticator interface implemented by the various authenticators.
72 * Currently the following two AUTH methods are supported:
73 * - shared key message integrity code (AUTH_PSK)
74 * - RSA digital signature (AUTH_RSA)
76 struct authenticator_t
{
79 * Verify a received authentication payload.
81 * @param ike_sa_init binary representation of received ike_sa_init
82 * @param my_nonce the sent nonce
83 * @param auth_payload authentication payload to verify
87 * - FAILED if verification failed
88 * - INVALID_ARG if auth_method does not match
89 * - NOT_FOUND if credentials not found
91 status_t (*verify
) (authenticator_t
*this, chunk_t ike_sa_init
,
92 chunk_t my_nonce
, auth_payload_t
*auth_payload
);
95 * Build an authentication payload to send to the other peer.
97 * @param ike_sa_init binary representation of sent ike_sa_init
98 * @param other_nonce the received nonce
99 * @param[out] auth_payload the resulting authentication payload
103 * - NOT_FOUND if the data for AUTH method could not be found
105 status_t (*build
) (authenticator_t
*this, chunk_t ike_sa_init
,
106 chunk_t other_nonce
, auth_payload_t
**auth_payload
);
109 * Destroys a authenticator_t object.
111 void (*destroy
) (authenticator_t
*this);
115 * Creates an authenticator for the specified auth method.
117 * @param ike_sa associated ike_sa
118 * @param auth_method authentication method to use for build()/verify()
120 * @return authenticator_t object
122 authenticator_t
*authenticator_create(ike_sa_t
*ike_sa
, auth_method_t auth_method
);
124 #endif /* AUTHENTICATOR_H_ @} */