Overview
Comment: | Support CryptGenRandom() on Windows |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
0037d247686da39dfee250463b44a7cf |
User & Date: | rkeene on 2019-01-23 06:41:11 |
Other Links: | manifest | tags |
Context
2019-01-23
| ||
06:53 | Remove possible OpenMP flag that conflicts with output check-in: 6fe1f8ccea user: rkeene tags: trunk | |
06:41 | Support CryptGenRandom() on Windows check-in: 0037d24768 user: rkeene tags: trunk | |
06:16 | Check in more depth for OpenMP support check-in: 08306ae2ee user: rkeene tags: trunk | |
Changes
Modified configure.ac from [6ebc468745] to [ffea90f4d2].
︙ | ︙ | |||
117 118 119 120 121 122 123 | AC_DEFINE([NANO_TCL_HAVE_OPENMP], [1], [Define if you have support for OpenMP]) fi dnl Random number generation mechanisms AC_CHECK_FUNCS(getrandom,, [ AC_CHECK_FUNCS(getentropy,, [ | > > > > > > > > > > > > > > > > > > | > > > > > > > | 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | AC_DEFINE([NANO_TCL_HAVE_OPENMP], [1], [Define if you have support for OpenMP]) fi dnl Random number generation mechanisms AC_CHECK_FUNCS(getrandom,, [ AC_CHECK_FUNCS(getentropy,, [ AC_CACHE_CHECK([for CryptGenRandom], nanotcl_cv_func_CryptGenRandom, [ save_LIBS="${LIBS}" LIBS="${save_LIBS} -ladvapi32" AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <windows.h> #include <wincrypt.h> ]], [[ HCRYPTPROV provider; BOOL ret; ret = CryptGenRandom(provider, 0, NULL); if (ret) { return(0); } else { return(1); } ]])], [ nanotcl_cv_func_CryptGenRandom='yes' ], [ nanotcl_cv_func_CryptGenRandom='no' ]) LIBS="${save_LIBS}" ]) if test "x$nanotcl_cv_func_CryptGenRandom" = 'xyes'; then LIBS="${LIBS} -ladvapi32" AC_DEFINE(HAVE_CRYPTGENRANDOM, [1], [Define if we have CryptGenRandom]) fi ]) ]) dnl Check for name resolution capabilities AC_CHECK_FUNCS(getaddrinfo, [ AC_CHECK_FUNCS(getnameinfo, [ AC_CHECK_HEADERS(sys/types.h sys/socket.h netdb.h) |
︙ | ︙ |
Modified randombytes.c from [65704d63f8] to [8953776351].
︙ | ︙ | |||
69 70 71 72 73 74 75 | ge_ret = getentropy(buf, buflen); if (ge_ret != 0) { return(-1); } return(buflen); } | | | > > > | > > > > > > > > > > > > > > | 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> |
︙ | ︙ |