fb0e4cac056f22fad9b6c1332cb02089d26d4f75
[strongswan.git] / Source / charon / transforms / prf_plus.h
1 /**
2 * @file prf_plus.h
3 *
4 * @brief Implements the prf+ function described in IKEv2 draft.
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 PRF_PLUS_H_
24 #define PRF_PLUS_H_
25
26
27 #include <transforms/prfs/prf.h>
28
29
30 typedef struct prf_plus_t prf_plus_t;
31
32 /**
33 * Object representing a prf_plus
34 */
35 struct prf_plus_t {
36 /**
37 * @brief Get pseudo random bytes.
38 *
39 * @param this calling prf_plus
40 * @param length number of bytes to get
41 * @param [out]buffer pointer where the generated bytes will be written
42 * @return
43 * - SUCCESS in any case
44 */
45 status_t (*get_bytes) (prf_plus_t *this, size_t length, u_int8_t *buffer);
46
47 /**
48 * @brief Allocate pseudo random bytes.
49 *
50 * @param this calling prf_plus
51 * @param length number of bytes to get
52 * @param [out]chunk chunk which will hold generated bytes
53 * @return
54 * - SUCCESS in any case
55 * - OUT_OF_RES if space could not be allocated
56 */
57 status_t (*allocate_bytes) (prf_plus_t *this, size_t length, chunk_t *chunk);
58
59 /**
60 * @brief Destroys a prf_plus object.
61 *
62 * @param this prf_plus_t object to destroy
63 * @return
64 * - SUCCESS in any case
65 */
66 status_t (*destroy) (prf_plus_t *this);
67 };
68
69 /**
70 * Creates a new prf_plus_t object
71 *
72 * Seed will be cloned. prf will
73 * not be cloned, must be destroyed outside after
74 * prf_plus usage.
75 *
76 * @param prf prf object to use
77 * @param seed input seed for prf
78 * @return
79 * - prf_plus_t if successfully
80 * - NULL if out of ressources or hash not supported
81 */
82 prf_plus_t *prf_plus_create(prf_t *prf, chunk_t seed);
83
84 #endif /*PRF_PLUS_H_*/