Cryptography.cpp 982 B

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