RAND_EGD(3ossl)

πŸ“¦
version 15.1 Β· 2 versions
, in freebsd 15.1

πŸ’œ RAND_EGD πŸ’œ

okay so bestie, this is the OpenSSL manual page for RAND_egd, RAND_egd_bytes, and RAND_query_egd_bytes β€” the trio that goes and asks an Entropy Gathering Daemon for some randomness. yes, that's a real thing. no cap. πŸŽ€


✨ NAME ✨

RAND_egd, RAND_egd_bytes, RAND_query_egd_bytes β€” literally just "go query the entropy gathering daemon bestie" πŸ’…


🌸 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);

πŸ¦‹ DESCRIPTION πŸ¦‹

so picture this: it's an older platform, and it does not have a good source of randomness β€” think stuff like "/dev/urandom" being missing from the vibe check 😭. in that situation you can still query an Entropy Gathering Daemon (EGD) over a local socket to get randomness and seed the OpenSSL RNG. that's the whole plot. the protocol used is the one defined by the EGDs you can find at <http://egd.sourceforge.net/> or <http://prngd.sourceforge.net>.

  • RAND_egd_bytes() β€” requests num bytes of randomness from an EGD at the socket path you gave it, and then passes the data it receives into RAND_add(). 🫢
  • RAND_egd() β€” literally equivalent to RAND_egd_bytes() but with num set to 255. that's it, that's the whole difference.
  • RAND_query_egd_bytes() β€” requests num bytes of randomness from an EGD at the specified socket path, and heads up: num must be less than 256. if buf is NULL, it's equivalent to RAND_egd_bytes(). if buf is not NULL, then the data gets copied to the buffer and RAND_add() is not called. noted. πŸ’€

also, lowkey important: OpenSSL can be configured at build time to try to use the EGD for seeding automatically. so it can just do it on its own, main character energy. ✨


πŸ‘‘ RETURN VALUES πŸ‘‘

  • RAND_egd() and RAND_egd_bytes() return the number of bytes read from the daemon on success, or -1 if the connection failed or the daemon did not return enough data to fully seed the PRNG. πŸ™ˆ
  • RAND_query_egd_bytes() returns the number of bytes read from the daemon on success, or -1 if the connection failed. πŸ“

🌈 SEE ALSO 🌈


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>.


fr fr, read the license before you go copying this around. it's giving "respect the paperwork." 🧚

and that's the page bestie, mwah πŸ’‹ β€” this was the OpenSSL 3.5.6 version, dated 2026-04-07, filed under RAND_EGD(3ossl). slay. ⭐

πŸ“¦ where this page comes from