| //===-- Windows implementation of getentropy ------------------------------===// | |
| // | |
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| // See https://llvm.org/LICENSE.txt for license information. | |
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| // | |
| //===----------------------------------------------------------------------===// | |
| namespace LIBC_NAMESPACE_DECL { | |
| LLVM_LIBC_FUNCTION(int, getentropy, (void *buffer, size_t length)) { | |
| __try { | |
| // check the length limit | |
| if (length > 256) | |
| __leave; | |
| NTSTATUS result = ::BCryptGenRandom(nullptr, static_cast<PUCHAR>(buffer), | |
| static_cast<ULONG>(length), | |
| BCRYPT_USE_SYSTEM_PREFERRED_RNG); | |
| if (result == STATUS_SUCCESS) | |
| return 0; | |
| } __except (EXCEPTION_EXECUTE_HANDLER) { | |
| // no need to handle exceptions specially | |
| } | |
| libc_errno = EIO; | |
| return -1; | |
| } | |
| } // namespace LIBC_NAMESPACE_DECL | |
Xet Storage Details
- Size:
- 1.25 kB
- Xet hash:
- fef4e71506efdb84b10ebf009701e55871466d8e7f8cb1821cc230e19cd5eddd
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.