Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/sodium/randombytes.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 
0002 #ifndef randombytes_H
0003 #define randombytes_H
0004 
0005 #include <stddef.h>
0006 #include <stdint.h>
0007 
0008 #include <sys/types.h>
0009 
0010 #include "export.h"
0011 
0012 #ifdef __cplusplus
0013 # ifdef __GNUC__
0014 #  pragma GCC diagnostic ignored "-Wlong-long"
0015 # endif
0016 extern "C" {
0017 #endif
0018 
0019 typedef struct randombytes_implementation {
0020     const char *(*implementation_name)(void); /* required */
0021     uint32_t    (*random)(void);              /* required */
0022     void        (*stir)(void);                /* optional */
0023     uint32_t    (*uniform)(const uint32_t upper_bound); /* optional, a default implementation will be used if NULL */
0024     void        (*buf)(void * const buf, const size_t size); /* required */
0025     int         (*close)(void);               /* optional */
0026 } randombytes_implementation;
0027 
0028 #define randombytes_BYTES_MAX SODIUM_MIN(SODIUM_SIZE_MAX, 0xffffffffUL)
0029 
0030 #define randombytes_SEEDBYTES 32U
0031 SODIUM_EXPORT
0032 size_t randombytes_seedbytes(void);
0033 
0034 SODIUM_EXPORT
0035 void randombytes_buf(void * const buf, const size_t size)
0036             __attribute__ ((nonnull));
0037 
0038 SODIUM_EXPORT
0039 void randombytes_buf_deterministic(void * const buf, const size_t size,
0040                                    const unsigned char seed[randombytes_SEEDBYTES])
0041             __attribute__ ((nonnull));
0042 
0043 SODIUM_EXPORT
0044 uint32_t randombytes_random(void);
0045 
0046 SODIUM_EXPORT
0047 uint32_t randombytes_uniform(const uint32_t upper_bound);
0048 
0049 SODIUM_EXPORT
0050 void randombytes_stir(void);
0051 
0052 SODIUM_EXPORT
0053 int randombytes_close(void);
0054 
0055 SODIUM_EXPORT
0056 int randombytes_set_implementation(const randombytes_implementation *impl)
0057             __attribute__ ((nonnull));
0058 
0059 SODIUM_EXPORT
0060 const char *randombytes_implementation_name(void);
0061 
0062 /* -- NaCl compatibility interface -- */
0063 
0064 SODIUM_EXPORT
0065 void randombytes(unsigned char * const buf, const unsigned long long buf_len)
0066             __attribute__ ((nonnull));
0067 
0068 #ifdef __cplusplus
0069 }
0070 #endif
0071 
0072 #endif