9365bb52b95911f5b947335d88f43e5f2c7829ab
[strongswan.git] / src / charon / encoding / payloads / nonce_payload.h
1 /**
2 * @file nonce_payload.h
3 *
4 * @brief Interface of nonce_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 #ifndef NONCE_PAYLOAD_H_
24 #define NONCE_PAYLOAD_H_
25
26 #include <types.h>
27 #include <encoding/payloads/payload.h>
28
29 /**
30 * Nonce size in bytes for nonces sending to other peer.
31 *
32 * @warning Nonce size MUST be between 16 and 256 bytes.
33 *
34 * @ingroup payloads
35 */
36 #define NONCE_SIZE 16
37
38 /**
39 * Length of a nonce payload without a nonce in bytes.
40 *
41 * @ingroup payloads
42 */
43 #define NONCE_PAYLOAD_HEADER_LENGTH 4
44
45 typedef struct nonce_payload_t nonce_payload_t;
46
47 /**
48 * Object representing an IKEv2 Nonce payload.
49 *
50 * The Nonce payload format is described in RFC section 3.3.
51 *
52 * @b Constructors:
53 * - nonce_payload_create()
54 *
55 * @ingroup payloads
56 */
57 struct nonce_payload_t {
58 /**
59 * The payload_t interface.
60 */
61 payload_t payload_interface;
62
63 /**
64 * @brief Set the nonce value.
65 *
66 * @param this calling nonce_payload_t object
67 * @param nonce chunk containing the nonce, will be cloned
68 */
69 void (*set_nonce) (nonce_payload_t *this, chunk_t nonce);
70
71 /**
72 * @brief Get the nonce value.
73 *
74 * @param this calling nonce_payload_t object
75 * @return a chunk containing the cloned nonce
76 */
77 chunk_t (*get_nonce) (nonce_payload_t *this);
78
79 /**
80 * @brief Destroys an nonce_payload_t object.
81 *
82 * @param this nonce_payload_t object to destroy
83 */
84 void (*destroy) (nonce_payload_t *this);
85 };
86
87 /**
88 * @brief Creates an empty nonce_payload_t object
89 *
90 * @return nonce_payload_t object
91 *
92 * @ingroup payloads
93 */
94
95 nonce_payload_t *nonce_payload_create(void);
96
97
98 #endif /*NONCE_PAYLOAD_H_*/