2 * @file authenticator.h
4 * @brief Interface of authenticator_t.
9 * Copyright (C) 2005 Jan Hutter, Martin Willi
10 * Hochschule fuer Technik Rapperswil
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>.
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
24 #ifndef _AUTHENTICATOR_H_
25 #define _AUTHENTICATOR_H_
29 #include <encoding/payloads/auth_payload.h>
30 #include <encoding/payloads/id_payload.h>
31 #include <network/packet.h>
32 #include <sa/ike_sa.h>
35 typedef struct authenticator_t authenticator_t
;
39 * @brief Class authenticator_t. Used to authenticate a peer.
41 * Currently the following two AUTH methods are supported:
42 * - SHARED_KEY_MESSAGE_INTEGRITY_CODE
43 * - RSA_DIGITAL_SIGNATURE
45 * This class retrieves needed data for specific AUTH methods (RSA keys, shared secrets, etc.)
46 * over an internal stored protected_ike_sa_t object or directly from the configuration_manager_t.
50 struct authenticator_t
{
53 * @brief Verify's given authentication data.
55 * To verify a received AUTH payload the following data must be provided:
56 * - the last received IKEv2 Message from the other peer in binary form
57 * - the nonce value sent to the other peer
58 * - the ID payload of the other peer
60 * @param this authenticator_t object
61 * @param last_received_packet binary representation of the last received IKEv2-Message
62 * @param my_nonce The sent nonce (without payload header)
63 * @param other_id_payload The ID payload received from other peer
64 * @param initiator Type of other peer. TRUE, if it is original initiator, FALSE otherwise
65 * @param[out] verified
66 * - TRUE, if verification succeeded
67 * - FALSE, if verification data could not be verified
70 * - SUCCESS if verification could be processed (does not mean the data could be verified)
71 * - NOT_SUPPORTED if AUTH method not supported
72 * - NOT_FOUND if the data for specific AUTH method could not be found (e.g. shared secret, rsa key)
75 status_t (*verify_auth_data
) (authenticator_t
*this,
76 auth_payload_t
*auth_payload
,
77 chunk_t last_received_packet
,
79 id_payload_t
*other_id_payload
,
84 * @brief Computes authentication data and creates specific AUTH payload.
86 * To create an AUTH payload, the following data must be provided:
87 * - the last sent IKEv2 Message in binary form
88 * - the nonce value received from the other peer
89 * - the ID payload of myself
91 * @param this authenticator_t object
92 * @param[out] auth_payload The object of typee auth_payload_t will be created at pointing location
93 * @param last_sent_packet binary representation of the last sent IKEv2-Message
94 * @param other_nonce The received nonce (without payload header)
95 * @param my_id_payload The ID payload going to send to other peer
96 * @param initiator Type of myself. TRUE, if I'm original initiator, FALSE otherwise
99 * - SUCCESS if authentication data could be computed
100 * - NOT_SUPPORTED if AUTH method not supported
101 * - NOT_FOUND if the data for AUTH method could not be found
102 * - TODO rsa errors!!
104 status_t (*compute_auth_data
) (authenticator_t
*this,
105 auth_payload_t
**auth_payload
,
106 chunk_t last_sent_packet
,
108 id_payload_t
*my_id_payload
,
112 * @brief Destroys a authenticator_t object.
114 * @param this authenticator_t object
116 void (*destroy
) (authenticator_t
*this);
120 * @brief Creates an authenticator object.
122 * @warning: The following functions of the assigned protected_ike_sa_t object
123 * must return a valid value:
124 * - protected_ike_sa_t.get_sa_config
125 * - protected_ike_sa_t.get_prf
126 * - protected_ike_sa_t.get_logger
127 * This preconditions are not given in IKE_SA states INITIATOR_INIT or RESPONDER_INIT!
129 * @param ike_sa object of type protected_ike_sa_t
131 authenticator_t
*authenticator_create(protected_ike_sa_t
*ike_sa
);
133 #endif //_AUTHENTICATOR_H_