Hi,
We are using the following API from sys/random.h to generate entropy in our module.
int getentropy(void* buffer, size_t size);
Could you confirm if this API internally uses a non-physical entropy source and adhere to SP800-90B as the following document says:
https://csrc.nist.gov/CSRC/media/projects/cryptographic-module-validation-program/documents/entropy/E181_PublicUse.pdf
OK, now that’s a question I can answer. Except that I can’t, because “best” is very subjective. But there are, at least, technical trade-offs to be made.
macOS has a wide range of random number generates. In general, it’s pretty clear as to whether they are suited for cryptographic use or not.
The best option depends on what layer your most comfortable with. I generally use SecRandomCopyBytes
or Apple CryptoKit’s SymmetricKey
, because a) it’s absolutely clear that these are expected to be cryptographically sound, and b) that’s the level of the system that I like working at. However, if you want to go lower there’s CCRandomGenerateBytes
[1]. And if you love you some BSD, there’s arc4random
and /dev/random
.
The one I don’t use is getentropy
, because the getentropy
man page makes it clear that it’s not intended to be used for bulk random data. Rather, we expect it to be used to seed an in-process random number generator, and I’m not interested in building one of those.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
[1] This is from CommonCrypto, which is effectively the API to CoreCrypto.