updated copyright information
[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-2006 Martin Willi
10 * Copyright (C) 2005 Jan Hutter
11 * Hochschule fuer Technik Rapperswil
12 *
13 * This program is free software; you can redistribute it and/or modify it
14 * under the terms of the GNU General Public License as published by the
15 * Free Software Foundation; either version 2 of the License, or (at your
16 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
17 *
18 * This program is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 * for more details.
22 */
23
24 #ifndef NONCE_PAYLOAD_H_
25 #define NONCE_PAYLOAD_H_
26
27 #include <types.h>
28 #include <encoding/payloads/payload.h>
29
30 /**
31 * Nonce size in bytes for nonces sending to other peer.
32 *
33 * @warning Nonce size MUST be between 16 and 256 bytes.
34 *
35 * @ingroup payloads
36 */
37 #define NONCE_SIZE 16
38
39 /**
40 * Length of a nonce payload without a nonce in bytes.
41 *
42 * @ingroup payloads
43 */
44 #define NONCE_PAYLOAD_HEADER_LENGTH 4
45
46 typedef struct nonce_payload_t nonce_payload_t;
47
48 /**
49 * Object representing an IKEv2 Nonce payload.
50 *
51 * The Nonce payload format is described in RFC section 3.3.
52 *
53 * @b Constructors:
54 * - nonce_payload_create()
55 *
56 * @ingroup payloads
57 */
58 struct nonce_payload_t {
59 /**
60 * The payload_t interface.
61 */
62 payload_t payload_interface;
63
64 /**
65 * @brief Set the nonce value.
66 *
67 * @param this calling nonce_payload_t object
68 * @param nonce chunk containing the nonce, will be cloned
69 */
70 void (*set_nonce) (nonce_payload_t *this, chunk_t nonce);
71
72 /**
73 * @brief Get the nonce value.
74 *
75 * @param this calling nonce_payload_t object
76 * @return a chunk containing the cloned nonce
77 */
78 chunk_t (*get_nonce) (nonce_payload_t *this);
79
80 /**
81 * @brief Destroys an nonce_payload_t object.
82 *
83 * @param this nonce_payload_t object to destroy
84 */
85 void (*destroy) (nonce_payload_t *this);
86 };
87
88 /**
89 * @brief Creates an empty nonce_payload_t object
90 *
91 * @return nonce_payload_t object
92 *
93 * @ingroup payloads
94 */
95
96 nonce_payload_t *nonce_payload_create(void);
97
98
99 #endif /*NONCE_PAYLOAD_H_*/