69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
ge_ret = getentropy(buf, buflen);
if (ge_ret != 0) {
return(-1);
}
return(buflen);
}
#elif defined(HAVE_CRYPTGENRANDOM) && 0
#include <tcl.h>
static long getrandom_impl(void *buf, unsigned int buflen) {
Tcl_Panic("Incomplete CryptGenRandom");
}
#else
# ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
# endif
# ifdef HAVE_SYS_STAT_H
# include <sys/stat.h>
|
|
|
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
ge_ret = getentropy(buf, buflen);
if (ge_ret != 0) {
return(-1);
}
return(buflen);
}
#elif defined(HAVE_CRYPTGENRANDOM)
# include <windows.h>
# include <wincrypt.h>
static long getrandom_impl(void *buf, unsigned int buflen) {
HCRYPTPROV provider;
BOOL cac_ret, cgr_ret;
cac_ret = CryptAcquireContextA(&provider, NULL, NULL, PROV_RSA_FULL, CRYPT_SILENT);
if (cac_ret == FALSE) {
return(-1);
}
cgr_ret = CryptGenRandom(provider, buflen, (BYTE *) buf);
CryptReleaseContext(provider, 0);
if (cgr_ret == FALSE) {
return(-1);
}
return(buflen);
}
#else
# ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
# endif
# ifdef HAVE_SYS_STAT_H
# include <sys/stat.h>
|