jedisct1 / libsodium

A modern, portable, easy to use crypto library.
https://libsodium.org
Other
12.15k stars 1.73k forks source link

Define HAVE_LINUX_COMPATIBLE_GETRANDOM for Genode #1006

Closed ehmry closed 3 years ago

ehmry commented 3 years ago

Genode does not expose a /dev/random by default, which would trigger a silent crash in sodium_init. Use getrandom() which is guaranteed to be present.

ehmry commented 3 years ago

Genode is a post-UNIX OS with a compatibility libc derived from FreeBSD.

jedisct1 commented 3 years ago

Thanks!

Did you test this?

Genode seems to have a get_random() function, that has not only a different name than the Linux function, but accepts 2 parameters, not 3.

getrandom() is also used by the internal RNG, so that one needs patching, too.

ehmry commented 3 years ago

Sorry, I meant getrandom, not get_random. Its the same as the FreeBSD getrandom. Genode has no explicitly defined interface for randomness, but a grep of the sources for get_random may turn up some internal procedures in drivers and such.

jedisct1 commented 3 years ago

Thanks!

Does the entire test suite pass, even the ones using the internal RNG that wasn't patched?

Unless you can directly send a PR to get it tested on CI, would you mind helping me compile this for Genode and run the test suite?

I gave it a try using their toolchain, but couldn't get the correct command line to do it. The compilers have a prefix that doesn't match the standard triple, and even by manually trying to override the tool names, I didn't go very far :(

ehmry commented 3 years ago

Yea, the official toolchain isn't compatible with anything beyond the internal build system.

I'm cross-compling so I haven't run the test suite, only tested an application compiled against libsodium.

If there is a Make target to compile the test suite without running it, I could the test the binaries in a VM and try to work that into CI.

Build log

jedisct1 commented 3 years ago

I'm really awfully sorry, but this is a target that is very unlikely to receive much testing, and looks a little bit too complicated to add to CI.

It would probably be better to keep Genode-specific changes separately.

ehmry commented 3 years ago

cough security theatre cough