No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Cryptography.cpp 953B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include "il2cpp-config.h"
  2. #if IL2CPP_TARGET_WINDOWS
  3. #include "os/Win32/WindowsHeaders.h"
  4. #include "os/Cryptography.h"
  5. #include <bcrypt.h>
  6. namespace il2cpp
  7. {
  8. namespace os
  9. {
  10. // This has to be non-null value because the return value of NULL from GetCryptographyProvider means it failed
  11. void* const kCryptographyProvider = reinterpret_cast<void*>(0x12345678);
  12. void* Cryptography::GetCryptographyProvider()
  13. {
  14. return kCryptographyProvider;
  15. }
  16. bool Cryptography::OpenCryptographyProvider()
  17. {
  18. return true;
  19. }
  20. void Cryptography::ReleaseCryptographyProvider(void* provider)
  21. {
  22. // Do nothing, since we never allocated it
  23. }
  24. bool Cryptography::FillBufferWithRandomBytes(void* provider, intptr_t length, unsigned char* data)
  25. {
  26. NO_UNUSED_WARNING(provider);
  27. return SUCCEEDED(BCryptGenRandom(NULL, data, (ULONG)length, BCRYPT_USE_SYSTEM_PREFERRED_RNG));
  28. }
  29. }
  30. }
  31. #endif