]>
Commit | Line | Data |
---|---|---|
1071642c MW |
1 | /** |
2 | * @file nonce_payload.h | |
3 | * | |
3fe05870 | 4 | * @brief Interface of nonce_payload_t. |
1071642c MW |
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 | ||
696be022 | 26 | #include <types.h> |
4a962238 | 27 | #include <encoding/payloads/payload.h> |
1071642c | 28 | |
2a489f33 | 29 | /** |
3fe05870 JH |
30 | * Length of a nonce payload without a nonce in bytes. |
31 | * | |
32 | * @ingroup payloads | |
2a489f33 JH |
33 | */ |
34 | #define NONCE_PAYLOAD_HEADER_LENGTH 4 | |
1071642c | 35 | |
95c61cb9 JH |
36 | typedef struct nonce_payload_t nonce_payload_t; |
37 | ||
1071642c | 38 | /** |
3fe05870 | 39 | * Object representing an IKEv2 Nonce payload. |
1071642c MW |
40 | * |
41 | * The Nonce payload format is described in draft section 3.3. | |
42 | * | |
3fe05870 JH |
43 | * @ingroup payloads |
44 | * | |
1071642c | 45 | */ |
95c61cb9 | 46 | struct nonce_payload_t { |
1071642c | 47 | /** |
3fe05870 | 48 | * The payload_t interface. |
1071642c MW |
49 | */ |
50 | payload_t payload_interface; | |
51 | ||
52 | /** | |
53 | * @brief Set the nonce value. | |
b722736c | 54 | * |
3fe05870 | 55 | * The nonce must have length between 16 and 256 bytes. |
1071642c MW |
56 | * |
57 | * @param this calling nonce_payload_t object | |
74d8414c | 58 | * @param nonce chunk containing the nonce, will be cloned |
b722736c MW |
59 | * @return |
60 | * - SUCCESS or | |
61 | * - INVALID_ARG, if nonce has an invalid size | |
1071642c MW |
62 | */ |
63 | status_t (*set_nonce) (nonce_payload_t *this, chunk_t nonce); | |
64 | ||
65 | /** | |
66 | * @brief Get the nonce value. | |
67 | * | |
68 | * @param this calling nonce_payload_t object | |
74d8414c | 69 | * @param[out] nonce chunk where nonce data is located (cloned) |
1071642c | 70 | */ |
3fe05870 | 71 | void (*get_nonce) (nonce_payload_t *this, chunk_t *nonce); |
74d8414c | 72 | |
1071642c MW |
73 | /** |
74 | * @brief Destroys an nonce_payload_t object. | |
75 | * | |
76 | * @param this nonce_payload_t object to destroy | |
1071642c | 77 | */ |
3fe05870 | 78 | void (*destroy) (nonce_payload_t *this); |
1071642c MW |
79 | }; |
80 | ||
81 | /** | |
82 | * @brief Creates an empty nonce_payload_t object | |
83 | * | |
3fe05870 JH |
84 | * @return created nonce_payload_t object |
85 | * | |
86 | * @ingroup payloads | |
1071642c MW |
87 | */ |
88 | ||
89 | nonce_payload_t *nonce_payload_create(); | |
90 | ||
91 | ||
92 | #endif /*NONCE_PAYLOAD_H_*/ |