log_certificates() now shows keyid and availability of matching private key
[strongswan.git] / src / libstrongswan / crypto / 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 <crypto/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 RFC.
34 *
35 * This class implements the prf+ algorithm. Internally it uses a pseudo random
36 * function, which implements the prf_t interface.
37 *
38 * See IKEv2 RFC 2.13.
39 *
40 * @b Constructors:
41 * - prf_plus_create()
42 *
43 * @ingroup transforms
44 */
45 struct prf_plus_t {
46 /**
47 * @brief Get pseudo random bytes.
48 *
49 * Get the next few bytes of the prf+ output. Space
50 * must be allocated by the caller.
51 *
52 * @param this calling object
53 * @param length number of bytes to get
54 * @param[out] buffer pointer where the generated bytes will be written
55 */
56 void (*get_bytes) (prf_plus_t *this, size_t length, u_int8_t *buffer);
57
58 /**
59 * @brief Allocate pseudo random bytes.
60 *
61 * Get the next few bytes of the prf+ output. This function
62 * will allocate the required space.
63 *
64 * @param this calling object
65 * @param length number of bytes to get
66 * @param[out] chunk chunk which will hold generated bytes
67 */
68 void (*allocate_bytes) (prf_plus_t *this, size_t length, chunk_t *chunk);
69
70 /**
71 * @brief Destroys a prf_plus_t object.
72 *
73 * @param this calling object
74 */
75 void (*destroy) (prf_plus_t *this);
76 };
77
78 /**
79 * @brief Creates a new prf_plus_t object.
80 *
81 * Seed will be cloned. prf will
82 * not be cloned, must be destroyed outside after
83 * prf_plus_t usage.
84 *
85 * @param prf prf object to use
86 * @param seed input seed for prf
87 * @return prf_plus_t object
88 *
89 * @ingroup transforms
90 */
91 prf_plus_t *prf_plus_create(prf_t *prf, chunk_t seed);
92
93 #endif /*PRF_PLUS_H_*/