4 * @brief Interface prf_t.
9 * Copyright (C) 2005 Jan Hutter, Martin Willi
10 * Hochschule fuer Technik Rapperswil
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>.
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
28 typedef enum pseudo_random_function_t pseudo_random_function_t
;
31 * @brief Pseudo random function, as in IKEv2 RFC 3.3.2.
33 * Currently only the following algorithms are implemented and therefore supported:
39 enum pseudo_random_function_t
{
42 * Implemented in class hmac_prf_t.
46 * Implemented in class hmac_prf_t.
54 * String mappings for encryption_algorithm_t.
56 extern mapping_t pseudo_random_function_m
[];
59 typedef struct prf_t prf_t
;
62 * @brief Generic interface for pseudo-random-functions.
68 * @todo Implement more prf algorithms
74 * @brief Generates pseudo random bytes and writes them
77 * @param this calling object
78 * @param seed a chunk containing the seed for the next bytes
79 * @param[out] buffer pointer where the generated bytes will be written
81 void (*get_bytes
) (prf_t
*this, chunk_t seed
, u_int8_t
*buffer
);
84 * @brief Generates pseudo random bytes and allocate space for them.
86 * @param this calling object
87 * @param seed a chunk containing the seed for the next bytes
88 * @param[out] chunk chunk which will hold generated bytes
90 void (*allocate_bytes
) (prf_t
*this, chunk_t seed
, chunk_t
*chunk
);
93 * @brief Get the block size of this prf_t object.
95 * @param this calling object
96 * @return block size in bytes
98 size_t (*get_block_size
) (prf_t
*this);
101 * @brief Get the key size of this prf_t object.
103 * @param this calling object
104 * @return key size in bytes
106 size_t (*get_key_size
) (prf_t
*this);
109 * @brief Set the key for this prf_t object.
111 * @param this calling object
112 * @param key key to set
114 void (*set_key
) (prf_t
*this, chunk_t key
);
117 * @brief Destroys a prf object.
119 * @param this calling object
121 void (*destroy
) (prf_t
*this);
125 * @brief Generic constructor for a prf_t oject.
127 * @param pseudo_random_function Algorithm to use
130 * - NULL if prf algorithm not supported
134 prf_t
*prf_create(pseudo_random_function_t pseudo_random_function
);