Giter Club home page Giter Club logo

libent's Introduction

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

It uses meson. meson ./build && ninja -C build should do the trick.

The main intended way to use this library is to depend on it from another meson project, i.e., to pull libent_dep out from this library as a subproject. It's also possible to install it as a regular library if you want to for some reason โ€” just run meson with -Dent_install=true and add on a sudo ninja -C build install.

If you want to release a binary distribution of your program, you may want to build with -Dent_compat=true. This tells libent not to try to use getentropy, which might result in a program that can run against an older libc version on some platforms. (ent_compat does nothing on OpenBSD; we claim that 5.6 is old enough for anyone's purposes who wants to use this library. If you want it to work on older systems, compile it against them.)

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

libent's People

Contributors

abliss avatar ixv avatar mrdomino avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

urbit abliss

libent's Issues

"Function not implemented" on Linux 3.8.11

$ meson ./build && ninja -C build
The Meson build system
Version: 0.29.0
Source dir: /home/abliss/proj/urbit/subprojects/libent
Build dir: /home/abliss/proj/urbit/subprojects/libent/build
Build type: native build
Build machine cpu family: x86_64
Build machine cpu: x86_64
Project name: libent
Native c compiler: ccache cc (gcc 5.4.0-6ubuntu1)
Checking if "getentropy in sys/random.h" links : NO
Checking if "getentropy in unistd.h" links : NO
Checking if "getrandom syscall available" links : YES
Build targets in project: 2
ninja: Entering directory `build'
[4/4] Linking target sample

$ build/sample
getentropy: Function not implemented
$ uname -a
Linux localhost 3.8.11 #1 SMP Wed Oct 3 23:30:23 PDT 2018 x86_64 x86_64 x86_64 GNU/Linux
$ strace build/sample
...
getrandom(0x7ffdee63ed90, 256, 0)       = -1 ENOSYS (Function not implemented)
...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.