dimanche 1 décembre 2019

Where does Random in PyCrypto module get its random bytes from?

During WinAPI programming with C++, I noticed that we can call the function CryptGenRandom to generate random bytes in context of the Windows CryptoAPI. If we drill down to system details, these bytes are actually generated from the advapi32.dll on Windows.

In Python, we have two ways that I know of to generate random bytes that can be used for cryptography:

  • from Crypto.Random import get_random_bytes
  • from secrets import token_bytes

I would like to know if these modules deep down somewhere still call the advapi32.dllon Windows to generate the needed random bytes. Or, do they have a way of generating random bytes that is completely independent of Windows dynamic libraries (or DLLs)?




Aucun commentaire:

Enregistrer un commentaire