An operating function (Prototype)
Go to file
2019-02-01 16:10:43 -08:00
.gitignore Meson tries to hard to be "smart". Replaced with a Makefile. 2019-02-01 16:10:43 -08:00
configure Meson tries to hard to be "smart". Replaced with a Makefile. 2019-02-01 16:10:43 -08:00
ent.c Meson tries to hard to be "smart". Replaced with a Makefile. 2019-02-01 16:10:43 -08:00
ent.h Meson tries to hard to be "smart". Replaced with a Makefile. 2019-02-01 16:10:43 -08:00
LICENSE Simplify 2019-01-02 10:07:03 -08:00
Makefile Meson tries to hard to be "smart". Replaced with a Makefile. 2019-02-01 16:10:43 -08:00
README.md Meson tries to hard to be "smart". Replaced with a Makefile. 2019-02-01 16:10:43 -08:00
test.c Meson tries to hard to be "smart". Replaced with a Makefile. 2019-02-01 16:10:43 -08:00

libent

libent is a cross-platform wrapper around getentropy(2). It exports one symbol, ent_getentropy. If getentropy is available, then it's just a shim around that. Otherwise, it uses getrandom(2) (available since kernel 3.17) on Linux, or /dev/urandom on other *nix.

Building and Testing

To build, set the IMPL variable to one of the folling values, and run make.

  • ENT_DEV_URANDOM
  • ENT_GETENTROPY_UNISTD
  • ENT_GETENTROPY_SYSRANDOM
  • ENT_GETRANDOM

For example:

export IMPL=ENT_GETENTROPY_SYSRANDOM
make
make test

Installing

To install, you'll need to set PREFIX to where you want this to be installed.

export PREFIX=/usr/local
export IMPL=ENT_GETENTROPY_SYSRANDOM
make install

Why?

getentropy is the wave of the future. It's the correct API for generating small amounts of entropy to create cryptographic keys or seed PRNGs. It's good and reasonable and true, it's on Linux, *BSD, and OS X, and it only took us fifty years of UNIX to get here.

Sadly, it only just arrived, so nobody has it yet. It didn't land in Linux until glibc 2.25, which seems to only have made it into Debian 10.

Once getentropy is everywhere you care about, you can just do a s/ent_//g on all the call sites and discard this shim.

This project began because Urbit's entropy-generation function was bothering me. Then it got out of hand.

References