- moved algorithm definitions from payloads to corresponding transforms
[strongswan.git] / Source / charon / transforms / prf_plus.h
1 /**
2 * @file prf_plus.h
3 *
4 * @brief Interface for prf_plus.h.
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 * @brief Implementation of the prf+ function described in IKEv2 draft.
34 *
35 * This class implements the prf+ algorithm. Internalliy it uses a pseudo random
36 * function, which implements the prf_t interface.
37 *
38 * @see IKEv2 draft 2.13
39 *
40 * @ingroup transforms
41 */
42 struct prf_plus_t {
43 /**
44 * @brief Get pseudo random bytes.
45 *
46 * Get the next few bytes of the prf+ output. Space
47 * must be allocated by the caller.
48 *
49 * @param this calling prf_plus
50 * @param length number of bytes to get
51 * @param[out] buffer pointer where the generated bytes will be written
52 * @return
53 * - SUCCESS in any case
54 */
55 status_t (*get_bytes) (prf_plus_t *this, size_t length, u_int8_t *buffer);
56
57 /**
58 * @brief Allocate pseudo random bytes.
59 *
60 * Get the next few bytes of the prf+ output. This function
61 * will allocate the required space.
62 *
63 * @param this calling prf_plus
64 * @param length number of bytes to get
65 * @param[out] chunk chunk which will hold generated bytes
66 * @return
67 * - SUCCESS in any case
68 * - OUT_OF_RES if space could not be allocated
69 */
70 status_t (*allocate_bytes) (prf_plus_t *this, size_t length, chunk_t *chunk);
71
72 /**
73 * @brief Destroys a prf_plus_t object.
74 *
75 * @param this prf_plus_t object to destroy
76 * @return
77 * - SUCCESS in any case
78 */
79 status_t (*destroy) (prf_plus_t *this);
80 };
81
82 /**
83 * @brief Creates a new prf_plus_t object.
84 *
85 * Seed will be cloned. prf will
86 * not be cloned, must be destroyed outside after
87 * prf_plus usage.
88 *
89 * @param prf prf object to use
90 * @param seed input seed for prf
91 * @return
92 * - prf_plus_t if successfully
93 * - NULL if out of ressources
94 *
95 * @ingroup transforms
96 */
97 prf_plus_t *prf_plus_create(prf_t *prf, chunk_t seed);
98
99 #endif /*PRF_PLUS_H_*/