diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2014-03-19 17:53:57 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-03-21 12:03:13 -0700 |
| commit | d2e99a0b33c25dee2c1b3c113b5c67bfed1bff1d (patch) | |
| tree | 48d5cf48c11ef48c1ec892ddc01e837baf8673ee /src/rt | |
| parent | ab1dd09d736fd443883ea4c1d8ec73ff285f6308 (diff) | |
| download | rust-d2e99a0b33c25dee2c1b3c113b5c67bfed1bff1d.tar.gz rust-d2e99a0b33c25dee2c1b3c113b5c67bfed1bff1d.zip | |
rand: Rewrite OsRng in Rust for windows
This removes even more rust_builtin.c code, and allows us to more gracefully handle errors (not a process panic, but a task failure).
Diffstat (limited to 'src/rt')
| -rw-r--r-- | src/rt/rust_builtin.c | 59 |
1 files changed, 0 insertions, 59 deletions
diff --git a/src/rt/rust_builtin.c b/src/rt/rust_builtin.c index 8ab8636aa3a..9c27fe1c5e4 100644 --- a/src/rt/rust_builtin.c +++ b/src/rt/rust_builtin.c @@ -387,65 +387,6 @@ rust_unset_sigprocmask() { #endif -#if defined(__WIN32__) -void -win32_require(LPCTSTR fn, BOOL ok) { - if (!ok) { - LPTSTR buf; - DWORD err = GetLastError(); - FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, err, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPTSTR) &buf, 0, NULL ); - fprintf(stderr, "%s failed with error %ld: %s", fn, err, buf); - LocalFree((HLOCAL)buf); - abort(); - } -} - -void -rust_win32_rand_acquire(HCRYPTPROV* phProv) { - win32_require - (_T("CryptAcquireContext"), - // changes to the parameters here should be reflected in the docs of - // rand::os::OSRng - CryptAcquireContext(phProv, NULL, NULL, PROV_RSA_FULL, - CRYPT_VERIFYCONTEXT|CRYPT_SILENT)); - -} -void -rust_win32_rand_gen(HCRYPTPROV hProv, DWORD dwLen, BYTE* pbBuffer) { - win32_require - (_T("CryptGenRandom"), CryptGenRandom(hProv, dwLen, pbBuffer)); -} -void -rust_win32_rand_release(HCRYPTPROV hProv) { - win32_require - (_T("CryptReleaseContext"), CryptReleaseContext(hProv, 0)); -} - -#else - -// these symbols are listed in rustrt.def.in, so they need to exist; but they -// should never be called. - -void -rust_win32_rand_acquire() { - abort(); -} -void -rust_win32_rand_gen() { - abort(); -} -void -rust_win32_rand_release() { - abort(); -} - -#endif - // // Local Variables: // mode: C++ |
