RAND_EGD(3ossl)

πŸ“¦ version 3.5.0, in opensuse-leap 16.0

πŸ’œ 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 for num bytes of randomness from an EGD sitting at the socket path you specify, then takes the data it gets back and hands it straight to RAND_add(). chef's kiss πŸ“
  • RAND_egd() β€” literally the same thing as RAND_egd_bytes() except num is set to 255. that's it, that's the whole difference πŸ’€
  • RAND_query_egd_bytes() β€” asks for num bytes of randomness from the EGD at path, and heads up: num must be less than 256. If buf is NULL, it's equivalent to RAND_egd_bytes(). But if buf is not NULL, the data gets copied into that buffer instead and RAND_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() and RAND_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 -1 if 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 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