4 * @brief Class used to get random and pseudo random values
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
29 * Object representing an randomizer
31 * This class is thread save as file system read calls are thread save...
33 typedef struct randomizer_s randomizer_t
;
38 * @brief Reads a specific number of bytes from random device.
40 * @param this calling randomizer_t object
41 * @param bytes Number of bytes to read
42 * @param[out] buffer Pointer to buffer where to write the data in.
43 * Size of buffer has to be at least bytes.
48 status_t (*get_random_bytes
) (randomizer_t
*this,size_t bytes
, u_int8_t
*buffer
);
51 * @brief Allocates space and writes in random bytes
53 * @param this calling randomizer_t object
54 * @param bytes Number of bytes to allocate
55 * @param[out] chunk chunk which will hold the allocated random bytes
61 status_t (*allocate_random_bytes
) (randomizer_t
*this, size_t bytes
, chunk_t
*chunk
);
64 * @brief Reads a specific number of bytes from pseudo random device.
66 * @param this calling randomizer_t object
67 * @param bytes Number of bytes to read
68 * @param[out] buffer Pointer to buffer where to write the data in.
69 * Size of buffer has to be at least bytes.
74 status_t (*get_pseudo_random_bytes
) (randomizer_t
*this,size_t bytes
, u_int8_t
*buffer
);
77 * @brief Allocates space and writes in pseudo random bytes
79 * @param this calling randomizer_t object
80 * @param bytes Number of bytes to allocate
81 * @param[out] chunk chunk which will hold the allocated random bytes
87 status_t (*allocate_pseudo_random_bytes
) (randomizer_t
*this, size_t bytes
, chunk_t
*chunk
);
90 * @brief Destroys a randomizer_t object.
92 * @param this randomizer_t object to destroy
96 status_t (*destroy
) (randomizer_t
*this);
100 * @brief Create an randomizer_t object
103 * - created randomizer_t, or
106 randomizer_t
*randomizer_create();
109 * @brief Create an randomizer_t object with specific random device names
111 * @param random_dev_name Device name for random values, etc /dev/random
112 * @param prandom_dev_name Device name for pseudo random values, etc /dev/urandom
114 * - created randomizer_t, or
117 randomizer_t
*randomizer_create_on_devices(char * random_dev_name
,char * prandom_dev_name
);
119 #endif /*RANDOMIZER_H_*/