ROOT
CLING_PROFILE
Reference Guide
Loading...
Searching...
No Matches
RCryptoRandom.cxx
Go to the documentation of this file.
1
#include "
ROOT/RConfig.hxx
"
2
#include "
ROOT/RCryptoRandom.hxx
"
3
4
#ifdef WIN32
5
#include "
Windows4Root.h
"
6
#include <bcrypt.h>
7
#else
8
#if defined(R__ARC4_STDLIB)
9
#include <cstdlib>
10
#elif defined(R__ARC4_BSDLIB)
11
#include <bsd/stdlib.h>
12
#elif defined(R__GETRANDOM_CLIB)
13
#include <sys/random.h>
14
#elif defined(R__USE_URANDOM)
15
#include <fstream>
16
#endif
17
#endif
18
19
bool
ROOT::Internal::GetCryptoRandom
(
void
*buf,
unsigned
int
len
)
20
{
21
if
(
len
> 256)
22
return
false
;
23
24
#ifdef WIN32
25
26
return
BCryptGenRandom((BCRYPT_ALG_HANDLE)NULL, (PUCHAR)buf, (ULONG)
len
, BCRYPT_USE_SYSTEM_PREFERRED_RNG) == 0;
27
28
#else
// UNIX
29
30
#if defined(R__ARC4_STDLIB) || defined(R__ARC4_BSDLIB)
31
arc4random_buf(buf,
len
);
32
return
true
;
33
#elif defined(R__GETRANDOM_CLIB)
34
return
getrandom(buf,
len
, GRND_NONBLOCK) ==
len
;
35
#elif defined(R__USE_URANDOM)
36
std::ifstream urandom{
"/dev/urandom"
};
37
if
(!urandom)
38
return
false
;
39
urandom.read(
reinterpret_cast<
char
*
>
(buf),
len
);
40
return
urandom.good();
41
#else
42
#error "Reliable cryptographic random function not defined"
43
return
false
;
44
#endif
45
46
#endif
47
}
RConfig.hxx
RCryptoRandom.hxx
len
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Definition
TGWin32VirtualXProxy.cxx:249
Windows4Root.h
ROOT::Internal::GetCryptoRandom
bool GetCryptoRandom(void *buf, unsigned int len)
Get random bytes from the operating system's cryptographic random number generator The requested numb...
Definition
RCryptoRandom.cxx:19
core
base
src
RCryptoRandom.cxx
ROOTCLING_PROFILE - Reference Guide Generated on
(GVA Time) using Doxygen 1.16.1