Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
third_party
dart-lang
sdk
runtime
bin
crypto_win.cc
Go to the documentation of this file.
1
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2
// for details. All rights reserved. Use of this source code is governed by a
3
// BSD-style license that can be found in the LICENSE file.
4
5
#include "
platform/globals.h
"
6
#if defined(DART_HOST_OS_WINDOWS)
7
8
#include <bcrypt.h>
9
#include "
bin/crypto.h
"
10
11
namespace
dart
{
12
namespace
bin {
13
14
// see https://docs.microsoft.com/en-us/windows/win32/api/bcrypt/nf-bcrypt-bcryptgenrandom
15
#ifndef NT_SUCCESS
16
#define NT_SUCCESS(Status) ((NTSTATUS)(Status) >= 0)
17
#endif
18
19
bool
Crypto::GetRandomBytes
(intptr_t
count
, uint8_t*
buffer
) {
20
if
(
count
<= 0) {
21
return
true
;
22
}
23
return
NT_SUCCESS(BCryptGenRandom(
/*hAlgorithm=*/
nullptr
,
buffer
,
24
(
ULONG
)
count
,
25
BCRYPT_USE_SYSTEM_PREFERRED_RNG));
26
}
27
28
}
// namespace bin
29
}
// namespace dart
30
31
#endif
// defined(DART_HOST_OS_WINDOWS)
count
int count
Definition
FontMgrTest.cpp:50
dart::bin::Crypto::GetRandomBytes
static bool GetRandomBytes(intptr_t count, uint8_t *buffer)
crypto.h
buffer
static const uint8_t buffer[]
Definition
fl_pixel_buffer_texture_test.cc:44
dart
Definition
dart_vm.cc:33
globals.h
ULONG
DWORD ULONG
Definition
windows_types.h:40
Generated on Fri Apr 26 2024 06:14:40 for Flutter Engine by
1.9.8