- described constructors
[strongswan.git] / Source / charon / utils / randomizer.h
index b5dc378..509b7d5 100644 (file)
 
 #include <types.h>
 
+
+/**
+ * Default random device used when no device is given.
+ */
+#define DEFAULT_RANDOM_DEVICE "/dev/random"
+
+/**
+ * Pseudo random device used when no device is given.
+ */
+#define DEFAULT_PSEUDO_RANDOM_DEVICE "/dev/urandom"
+
 typedef struct randomizer_t randomizer_t;
 
 /**
@@ -32,6 +43,10 @@ typedef struct randomizer_t randomizer_t;
  *
  * This class is thread save as file system read calls are thread save.
  * 
+ * @b Constructors:
+ *  - randomizer_create()
+ *  - randomizer_create_on_devices()
+ * 
  * @ingroup utils
  */
 struct randomizer_t {
@@ -43,11 +58,8 @@ struct randomizer_t {
         * @param bytes                                 number of bytes to read
         * @param[out] buffer                   pointer to buffer where to write the data in.
         *                                                              Size of buffer has to be at least bytes.
-        * @return
-        *                                                              - SUCCESS
-        *                                                              - FAILED if random device could not be opened
         */
-       status_t (*get_random_bytes) (randomizer_t *this,size_t bytes, u_int8_t *buffer);
+       void (*get_random_bytes) (randomizer_t *this,size_t bytes, u_int8_t *buffer);
        
        /**
         * @brief Allocates space and writes in random bytes.
@@ -55,11 +67,8 @@ struct randomizer_t {
         * @param this                                  calling randomizer_t object
         * @param bytes                                 number of bytes to allocate
         * @param[out] chunk                    chunk which will hold the allocated random bytes
-        * @return
-        *                                                              - SUCCESS
-        *                                                              - FAILED if random device could not be opened
         */     
-       status_t (*allocate_random_bytes) (randomizer_t *this, size_t bytes, chunk_t *chunk);
+       void (*allocate_random_bytes) (randomizer_t *this, size_t bytes, chunk_t *chunk);
        
        /**
         * @brief Reads a specific number of bytes from pseudo random device.
@@ -68,11 +77,8 @@ struct randomizer_t {
         * @param bytes                                 number of bytes to read
         * @param[out] buffer                   pointer to buffer where to write the data in.
         *                                                              size of buffer has to be at least bytes.
-        * @return
-        *                                                              - SUCCESS
-        *                                                              - FAILED if random device could not be opened
         */
-       status_t (*get_pseudo_random_bytes) (randomizer_t *this,size_t bytes, u_int8_t *buffer);
+       void (*get_pseudo_random_bytes) (randomizer_t *this,size_t bytes, u_int8_t *buffer);
        
        /**
         * @brief Allocates space and writes in pseudo random bytes.
@@ -80,11 +86,8 @@ struct randomizer_t {
         * @param this                                  calling randomizer_t object
         * @param bytes                                 number of bytes to allocate
         * @param[out] chunk                            chunk which will hold the allocated random bytes
-        * @return
-        *                                                              - SUCCESS
-        *                                                              - FAILED if random device could not be opened
         */     
-       status_t (*allocate_pseudo_random_bytes) (randomizer_t *this, size_t bytes, chunk_t *chunk);
+       void (*allocate_pseudo_random_bytes) (randomizer_t *this, size_t bytes, chunk_t *chunk);
 
        /**
         * @brief Destroys a randomizer_t object.
@@ -110,9 +113,7 @@ randomizer_t *randomizer_create();
  * 
  * @param random_dev_name      device name for random values, etc /dev/random
  * @param prandom_dev_name     device name for pseudo random values, etc /dev/urandom
- * @return                                     
- *                                                     - created randomizer_t
- *                                                     - NULL if failed
+ * @return                                     randomizer_t object
  * 
  * @ingroup utils
  */