RAND_EGD(3SSL)

πŸ’– RAND_EGD πŸ’–

okay bestie, gather round, because this one is a little vintage. This is the OpenSSL manpage for RAND_egd, RAND_egd_bytes and RAND_query_egd_bytes β€” three functions whose whole job is sliding into a daemon's DMs and asking it for some randomness. (Manual section: 3SSL, iykyk. πŸ¦‹)


🌸 NAME 🌸

RAND_egd, RAND_egd_bytes, RAND_query_egd_bytes β€” query entropy gathering daemon


✨ SYNOPSIS ✨

no cap, here's the vibe:

#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 on older platforms where there's no good source of randomness lying around β€” think no "/dev/urandom" β€” you can still hit up an Entropy Gathering Daemon (EGD, king of the socket era πŸ’…) over a local socket, grab some randomness, and use it to seed the OpenSSL RNG. The protocol it speaks is the one defined by the EGDs that live at <http://egd.sourceforge.net/> or <http://prngd.sourceforge.net>. periodt.

  • RAND_egd_bytes() β€” asks for num bytes of randomness from an EGD sitting at the socket path, then takes whatever data comes back and hands it straight to RAND_add(). ✨
  • RAND_egd() β€” literally the same thing as RAND_egd_bytes() but with num set to 255. that's the whole difference, bestie.
  • RAND_query_egd_bytes() β€” also requests num bytes of randomness from an EGD at the socket path, except here num must be less than 256. If buf is NULL, it's just RAND_egd_bytes() in a trench coat. If buf is not NULL, then the data gets copied into the buffer and RAND_add() is not called. noted. πŸ“

also, fun fact: OpenSSL can be configured at build time to try to use the EGD for seeding automatically. fancy.


🌈 RETURN VALUES 🌈

  • RAND_egd() and RAND_egd_bytes() return the number of bytes read from the daemon when things go right πŸ”₯ β€” or -1 if the connection failed, or if the daemon didn't return enough data to fully seed the PRNG. (rude of it, honestly.)
  • RAND_query_egd_bytes() returns the number of bytes read from the daemon on success, or -1 if the connection failed.
πŸ’€ heads up: that -1 is the "something went wrong" flag for all three of them. check it. always check it.

πŸŽ€ 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>.


and that's the whole page, bestie 🫢 tysm for reading, this was RAND_EGD(3SSL) from OpenSSL 4.0.3, dated 2026-09-29. slay, stay random, and go check your return values πŸ’…βœ¨

πŸ“¦ where this page comes from