Odin icon indicating copy to clipboard operation
Odin copied to clipboard

add crypto.rand_bytes for Darwin and BSD

Open laytan opened this issue 2 years ago • 3 comments

arc4random_buf is implemented on Darwin, FreeBSD and OpenBSD with the same signature.

laytan avatar Dec 02 '23 20:12 laytan

Ok just updated the PR to add the error message using CoreFoundation.framework which does not require objective C or any of the vendor stuff. I think we can build on this for os2 later too.

One thing is that copying to an Odin string like this is kinda wasting bytes, for a string I tested that was 38 bytes long in the end it had to allocate a 228 bytes buffer.

laytan avatar Dec 03 '23 21:12 laytan

For what it's worth, this looks good to me. arc4random is kind of hard to avoid on non-Darwin BSDs, the getentropy systemcall is tailored around seeding a CSPRNG, and we don't have one presently. libc tends to be less of a trashfire there as well...

Yawning avatar Jan 25 '24 17:01 Yawning

Rebased this to fix conflicts, still ready for review

laytan avatar Feb 13 '24 16:02 laytan