- added and tested auth_payload_t class
[strongswan.git] / Source / charon / encoding / payloads / auth_payload.h
1 /**
2 * @file auth_payload.h
3 *
4 * @brief Interface of auth_payload_t.
5 *
6 */
7
8 /*
9 * Copyright (C) 2005 Jan Hutter, Martin Willi
10 * Hochschule fuer Technik Rapperswil
11 *
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>.
16 *
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
20 * for more details.
21 */
22
23
24 #ifndef _AUTH_PAYLOAD_H_
25 #define _AUTH_PAYLOAD_H_
26
27 #include <types.h>
28 #include <encoding/payloads/payload.h>
29
30 /**
31 * Length of a auth payload without the auth data in bytes.
32 *
33 * @ingroup payloads
34 */
35 #define AUTH_PAYLOAD_HEADER_LENGTH 8
36
37
38 typedef enum auth_method_t auth_method_t;
39
40 /**
41 * AUTH Method of a AUTH payload.
42 *
43 * @ingroup payloads
44 */
45 enum auth_method_t {
46 /**
47 * Computed as specified in section 2.15 of draft using
48 * an RSA private key over a PKCS#1 padded hash.
49 */
50 RSA_DIGITAL_SIGNATURE = 1,
51
52 /* Computed as specified in
53 * section 2.15 of draft using the shared key associated with the identity
54 * in the ID payload and the negotiated prf function
55 */
56 SHARED_KEY_MESSAGE_INTEGRITY_CODE = 2,
57
58 /* Computed as specified in section
59 * 2.15 of draft using a DSS private key over a SHA-1 hash.
60 */
61 DSS_DIGITAL_SIGNATURE = 3,
62 };
63
64 extern mapping_t auth_method_m[];
65
66
67 typedef struct auth_payload_t auth_payload_t;
68
69 /**
70 * Object representing an IKEv2 AUTH payload.
71 *
72 * The AUTH payload format is described in draft section 3.8.
73 *
74 * @ingroup payloads
75 *
76 */
77 struct auth_payload_t {
78 /**
79 * The payload_t interface.
80 */
81 payload_t payload_interface;
82
83 /**
84 * @brief Set the AUTH method.
85 *
86 *
87 * @param this calling auth_payload_t object
88 * @param method Method of AUTH
89 */
90 void (*set_auth_method) (auth_payload_t *this, auth_method_t method);
91
92 /**
93 * @brief Get the AUTH method.
94 *
95 * @param this calling auth_payload_t object
96 * @return Method of the AUTH
97 */
98 auth_method_t (*get_auth_method) (auth_payload_t *this);
99
100 /**
101 * @brief Set the AUTH data.
102 *
103 * Data are getting cloned.
104 *
105 * @param this calling auth_payload_t object
106 * @param data AUTH data as chunk_t
107 */
108 void (*set_data) (auth_payload_t *this, chunk_t data);
109
110 /**
111 * @brief Get the AUTH data.
112 *
113 * Returned data are a copy of the internal one
114 *
115 * @param this calling auth_payload_t object
116 * @return AUTH data as chunk_t
117 */
118 chunk_t (*get_data) (auth_payload_t *this);
119
120 /**
121 * @brief Destroys an auth_payload_t object.
122 *
123 * @param this auth_payload_t object to destroy
124 */
125 void (*destroy) (auth_payload_t *this);
126 };
127
128 /**
129 * @brief Creates an empty auth_payload_t object.
130 *
131 * @return created auth_payload_t object
132 *
133 * @ingroup payloads
134 */
135 auth_payload_t *auth_payload_create();
136
137
138 #endif //_AUTH_PAYLOAD_H_