4 * @brief Interface of 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 draft 3.3.2.
33 enum pseudo_random_function_t
{
42 * string mappings for encryption_algorithm_t
44 extern mapping_t pseudo_random_function_m
[];
47 typedef struct prf_t prf_t
;
50 * @brief Generic interface for pseudo-random-functions.
56 * @brief generates pseudo random bytes and writes them
59 * @param this calling prf
60 * @param seed a chunk containing the seed for the next bytes
61 * @param[out] buffer pointer where the generated bytes will be written
63 * - SUCCESS in any case
65 status_t (*get_bytes
) (prf_t
*this, chunk_t seed
, u_int8_t
*buffer
);
68 * @brief generates pseudo random bytes and allocate space for them.
70 * @param this calling prf
71 * @param seed a chunk containing the seed for the next bytes
72 * @param[out] chunk chunk which will hold generated bytes
74 * - SUCCESS in any case
75 * - OUT_OF_RES if space could not be allocated
77 status_t (*allocate_bytes
) (prf_t
*this, chunk_t seed
, chunk_t
*chunk
);
80 * @brief get the block size of this prf.
82 * @param this calling prf
83 * @return block size in bytes
85 size_t (*get_block_size
) (prf_t
*this);
88 * @brief Set the key for this prf.
90 * @param this calling prf
91 * @param key key to set
93 * - SUCCESS in any case
95 status_t (*set_key
) (prf_t
*this, chunk_t key
);
98 * @brief Destroys a prf object..
100 * @param this prf_t object to destroy
102 * - SUCCESS in any case
104 status_t (*destroy
) (prf_t
*this);
108 * @brief Generic constructor for a prf_t.
110 * @param pseudo_random_function Algorithm to use
112 * - prf_t if successfully
113 * - NULL if out of ressources or prf not supported
117 prf_t
*prf_create(pseudo_random_function_t pseudo_random_function
);