1 /*******************************************************************************
2 
3     D bindings to libgcrypt random generating functions.
4 
5     Requires linking with libgcrypt:
6 
7         -L-lgcrypt
8 
9     Copyright:
10         Copyright (c) 2009-2016 dunnhumby Germany GmbH.
11         All rights reserved.
12 
13     License:
14         Boost Software License Version 1.0. See LICENSE_BOOST.txt for details.
15         Alternatively, this file may be distributed under the terms of the Tango
16         3-Clause BSD License (see LICENSE_BSD.txt for details).
17 
18         Bear in mind this module provides bindings to an external library that
19         has its own license, which might be more restrictive. Please check the
20         external library license to see which conditions apply for linking.
21 
22 *******************************************************************************/
23 
24 module ocean.util.cipher.gcrypt.c.random;
25 
26 import ocean.util.cipher.gcrypt.c.general;
27 
28 extern (C):
29 
30 /// See original's library documentation for details.
31 enum gcry_random_level
32 {
33     GCRY_WEAK_RANDOM = 0,
34     GCRY_STRONG_RANDOM = 1,
35     GCRY_VERY_STRONG_RANDOM = 2
36 }
37 
38 
39 /// See original's library documentation for details.
40 void gcry_randomize (void* buffer, size_t length,
41                      gcry_random_level level);
42 
43 /// See original's library documentation for details.
44 gcry_error_t gcry_random_add_bytes (const(void)* buffer, size_t length,
45                                     int quality = -1);
46 
47 /// See original's library documentation for details.
48 gcry_error_t gcry_fast_random_poll ( )
49 {
50     return gcry_control(gcry_ctl_cmds.GCRYCTL_FAST_POLL, null);
51 }
52 
53 
54 /// See original's library documentation for details.
55 void* gcry_random_bytes (size_t nbytes, gcry_random_level level);
56 
57 /// See original's library documentation for details.
58 void* gcry_random_bytes_secure (size_t nbytes, gcry_random_level level);
59 
60 
61 /// See original's library documentation for details.
62 void gcry_create_nonce (void* buffer, size_t length);