]> git.ipfire.org Git - thirdparty/strongswan.git/blob - src/libstrongswan/crypto/nonce_gen.h
Update copyright headers after acquisition by secunet
[thirdparty/strongswan.git] / src / libstrongswan / crypto / nonce_gen.h
1 /*
2 * Copyright (C) 2012 Adrian-Ken Rueegsegger
3 *
4 * Copyright (C) secunet Security Networks AG
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
17 /**
18 * @defgroup nonce_gen nonce_gen
19 * @{ @ingroup crypto
20 */
21
22 #ifndef NONCE_GEN_H_
23 #define NONCE_GEN_H_
24
25 typedef struct nonce_gen_t nonce_gen_t;
26
27 #include <library.h>
28
29 /**
30 * Generic interface for nonce generators.
31 */
32 struct nonce_gen_t {
33
34 /**
35 * Generates a nonce and writes it into the buffer.
36 *
37 * @param size size of nonce in bytes
38 * @param buffer pointer where the generated nonce will be written
39 * @return TRUE if nonce allocation was successful, FALSE otherwise
40 */
41 bool (*get_nonce)(nonce_gen_t *this, size_t size,
42 uint8_t *buffer) __attribute__((warn_unused_result));
43
44 /**
45 * Generates a nonce and allocates space for it.
46 *
47 * @param size size of nonce in bytes
48 * @param chunk chunk which will hold the generated nonce
49 * @return TRUE if nonce allocation was successful, FALSE otherwise
50 */
51 bool (*allocate_nonce)(nonce_gen_t *this, size_t size,
52 chunk_t *chunk) __attribute__((warn_unused_result));
53
54 /**
55 * Destroys a nonce generator object.
56 */
57 void (*destroy)(nonce_gen_t *this);
58 };
59
60 #endif /** NONCE_GEN_H_ @}*/