updated integrity algorithm identifiers
[strongswan.git] / src / libstrongswan / crypto / prf_plus.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
17 /**
18 * @defgroup prf_plus prf_plus
19 * @{ @ingroup crypto
20 */
21
22 #ifndef PRF_PLUS_H_
23 #define PRF_PLUS_H_
24
25 typedef struct prf_plus_t prf_plus_t;
26
27 #include <crypto/prfs/prf.h>
28
29 /**
30 * Implementation of the prf+ function described in IKEv2 RFC.
31 *
32 * This class implements the prf+ algorithm. Internally it uses a pseudo random
33 * function, which implements the prf_t interface.
34 * See IKEv2 RFC 2.13.
35 */
36 struct prf_plus_t {
37 /**
38 * Get pseudo random bytes.
39 *
40 * Get the next few bytes of the prf+ output. Space
41 * must be allocated by the caller.
42 *
43 * @param length number of bytes to get
44 * @param buffer pointer where the generated bytes will be written
45 */
46 void (*get_bytes) (prf_plus_t *this, size_t length, u_int8_t *buffer);
47
48 /**
49 * Allocate pseudo random bytes.
50 *
51 * Get the next few bytes of the prf+ output. This function
52 * will allocate the required space.
53 *
54 * @param length number of bytes to get
55 * @param chunk chunk which will hold generated bytes
56 */
57 void (*allocate_bytes) (prf_plus_t *this, size_t length, chunk_t *chunk);
58
59 /**
60 * Destroys a prf_plus_t object.
61 */
62 void (*destroy) (prf_plus_t *this);
63 };
64
65 /**
66 * Creates a new prf_plus_t object.
67 *
68 * Seed will be cloned. prf will
69 * not be cloned, must be destroyed outside after
70 * prf_plus_t usage.
71 *
72 * @param prf prf object to use
73 * @param seed input seed for prf
74 * @return prf_plus_t object
75 */
76 prf_plus_t *prf_plus_create(prf_t *prf, chunk_t seed);
77
78 #endif /** PRF_PLUS_H_ @}*/