RAND_EGD(3ossl)
π RAND_EGD π
okay so this is the RAND_EGD(3ossl) page from the OpenSSL fam β yes bestie, the 3ossl part is the manual section, we love a labeled moment β¨
πΈ NAME πΈ
RAND_egd, RAND_egd_bytes, RAND_query_egd_bytes β the trio that goes and asks an entropy gathering daemon for some randomness, fr fr π
β SYNOPSIS β
#include <openssl/rand.h>
int RAND_egd_bytes(const char *path, int num);
int RAND_egd(const char *path);
int RAND_query_egd_bytes(const char *path, unsigned char *buf, int num);
three little functions, one big vibe check on your randomness situation π
π¦ DESCRIPTION π¦
So picture this: you're on an older platform that doesn't have a good source of randomness β like, no "/dev/urandom" to be found π β and you still need to seed the OpenSSL RNG. The move? Query an Entropy Gathering Daemon (EGD) over a local socket and borrow some randomness from it. iconic behavior honestly π
The protocol in play is defined by the EGDs you can find at <http://egd.sourceforge.net/> or <http://prngd.sourceforge.net>. iykyk π
RAND_egd_bytes()β asks fornumbytes of randomness from an EGD sitting at the socketpathyou specify, then takes the data it gets back and hands it straight toRAND_add(). chef's kiss πRAND_egd()β literally the same thing asRAND_egd_bytes()exceptnumis set to255. that's it, that's the whole difference πRAND_query_egd_bytes()β asks fornumbytes of randomness from the EGD atpath, and heads up:nummust be less than 256. IfbufisNULL, it's equivalent toRAND_egd_bytes(). But ifbufis notNULL, the data gets copied into that buffer instead andRAND_add()is not called. choose your fighter π«Ά
Also, fun fact: OpenSSL can be configured at build time to try to use the EGD for seeding automatically. convenient much? β¨
π₯ RETURN VALUES π₯
RAND_egd()andRAND_egd_bytes()β on success they return the number of bytes read from the daemon π but if the connection failed, or the daemon didn't return enough data to fully seed the PRNG, you get-1. sad girl hours πRAND_query_egd_bytes()β returns the number of bytes read from the daemon on success, or-1if the connection failed. no fully-seeded-PRNG drama here, just connection vibes π
π SEE ALSO π
RAND_add(3), RAND_bytes(3), RAND(7) β go read these next, bestie, they're the main characters of this friend group π
π COPYRIGHT π
Copyright 2000-2018 The OpenSSL Project Authors. All Rights Reserved. π«Ά
Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>. read the license, it's giving responsible queen behavior π
and that's the whole page, bestie! this one's from OpenSSL 3.5.0, dated 2026-09-25 β slay, go seed something responsibly πβ¨π
π¦ where this page comes from
- opensuse-leap 16.0: openssl-3-doc 3.5.0-160000.11.1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms