9cb7583250c4c3168a018409572c4fef45996163
[strongswan.git] / src / charon / encoding / payloads / nonce_payload.h
1 /*
2 * Copyright (C) 2005-2006 Martin Willi
3 * Copyright (C) 2005 Jan Hutter
4 * Hochschule fuer Technik Rapperswil
5 *
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>.
10 *
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
14 * for more details.
15 *
16 * $Id$
17 */
18
19 /**
20 * @defgroup nonce_payload nonce_payload
21 * @{ @ingroup payloads
22 */
23
24 #ifndef NONCE_PAYLOAD_H_
25 #define NONCE_PAYLOAD_H_
26
27 typedef struct nonce_payload_t nonce_payload_t;
28
29 #include <library.h>
30 #include <encoding/payloads/payload.h>
31
32 /**
33 * Nonce size in bytes for nonces sending to other peer.
34 */
35 #define NONCE_SIZE 32
36
37 /**
38 * Length of a nonce payload without a nonce in bytes.
39 */
40 #define NONCE_PAYLOAD_HEADER_LENGTH 4
41
42 /**
43 * Object representing an IKEv2 Nonce payload.
44 *
45 * The Nonce payload format is described in RFC section 3.3.
46 */
47 struct nonce_payload_t {
48 /**
49 * The payload_t interface.
50 */
51 payload_t payload_interface;
52
53 /**
54 * Set the nonce value.
55 *
56 * @param nonce chunk containing the nonce, will be cloned
57 */
58 void (*set_nonce) (nonce_payload_t *this, chunk_t nonce);
59
60 /**
61 * Get the nonce value.
62 *
63 * @return a chunk containing the cloned nonce
64 */
65 chunk_t (*get_nonce) (nonce_payload_t *this);
66
67 /**
68 * Destroys an nonce_payload_t object.
69 */
70 void (*destroy) (nonce_payload_t *this);
71 };
72
73 /**
74 * Creates an empty nonce_payload_t object
75 *
76 * @return nonce_payload_t object
77 */
78 nonce_payload_t *nonce_payload_create(void);
79
80 #endif /*NONCE_PAYLOAD_H_ @} */