TLSPOOL_PRNG(3)
π TLSPOOL_PRNG π
okay so bestie, you're in the Library Calls section (that's the manual name btw, slay) and this page is all about tlspool_prng β pulling pseudo-random bytes out of a TLS master secret like it's nothing. let's go π
β¨ NAME β¨
tlspool_prng β Pseudo-Random Number Generation from TLS master secret
πΈ SYNOPSIS πΈ
#include <stdint.h>
#include <tlspool/commands.h>
#include <tlspool/starttls.h>
int tlspool_prng (char *label,
uint16_t ctxvalue_len, uint8_t *opt_ctxvalue,
uint16_t prng_len, uint8_t *prng_buf,
uint8_t *ctlkey);
π¦ DESCRIPTION π¦
tlspool_prng() generates a pseudo-random sequence based on session cryptographic keys. and in the case of TLS? it adheres to RFC 5705, periodt β¨ other protocols may or may not support a similar mechanism β and if they don't, you get an error back. no cap.
this whole thing leans on access privileges to an existing connection at a meta-level, and for that we use the customary ctlkey verification mechanism introduced with tlspool_starttls(). and like, heads up bestie: random material may be used for security purposes, such as finding the same session key for both sides deriving from prior key negotiation β so the protection of a ctlkey for these applications is important. fr fr. π₯
the inputs to this function must adhere to the following restrictions:
labelmust not be aNULLpointer, butopt_ctxvaluemay be set toNULLto bypass the use of a context value. not me pointing out the nuance but: note that passing an empty string inopt_ctxvalueis different from not providing the string at all by setting it toNULL. only whenopt_ctxvalueis notNULLwill the value ofctxvalue_lenbe used. πlabelrefers to an ASCII string with printable characters, terminated with aNULcharacter. the maximum string length is 254 bytes and its value is subject to limitations as per RFC 5705.- if not
NULL,opt_ctxvaluerefers to an arbitrary sequence of octets. it too has an upper limit of 254 bytes. constraints may be imposed on the contents as a result of the registration of thelabelstring. prng_lenholds the requested number of pseudo-random bytesprng_bufpoints is a non-NULLpointer to a buffer that can holdprng_lenbytes.
if the operation succeeds, then prng_buf holds prng_len bytes of random material. if the operation fails, then prng_buf is filled with zero bytes β to make it stand out as a rather rare case of a random byte string. iconic π«Ά
now, note a few restrictions to the generality of this function, as a result of the underlying packet format for the communication with the TLS Pool. but the dimensions have been choosen such that these restrictions would not typically be a problem in practice:
- it constrains the string lengths of
labelandopt_ctxvalue - it constrains
prng_lento a maximum value ofTLSPOOL_PRNGBUFLEN
the TLS Pool may limit certain TLS PRNG labels, in adherence to the IANA-maintained TLS Exporter Label Registry. it additionally supports the EXPERIMENTAL label prefix specified in RFC 5705. π
be advised that the maximum size of buffer may increase in future releases. so, be sure to use TLSPOOL_PRNGBUFLEN which holds the header-file defined size. don't hardcode it, i'm begging π
π RETURN VALUE π
the function returns 0 on success. if an error occurs, the function returns -1 and errno is set appropriately. and in addition to this behaviour, an error situation resets the prng_len bytes in prng_buf to zero β that is just to make it obvious that it is not random material. you should be really cautious about not missing the error reports from this function, and these zeroes are there to help you with that. like, they're literally doing you a solid. π
π§ AUTHOR π§
Written by Rick van Rein of OpenFortress.nl, for the ARPA2.net project. π
π REPORTING BUGS π
for any discussion, including about bugs, please use the mailing list found on http://lists.arpa2.org/mailman/listinfo/tls-pool.
please read the software distribution's README, INSTALL and TODO files for information about the tlspool-daemon implementation status. β¨
π COPYRIGHT π
Copyright Β© 2015 Rick van Rein, ARPA2.net.
ARPA2 is funded from InternetWide.org, which in turns receives donations from various funding sources with an interest in a private and secure Internet that gives users control over their online presence. this particular project has been sponsored in part by NCSC. πΈ
β SEE ALSO β
the TLS Pool API is documented in the include file <tlspool/commands.h> and <tlspool/starttls.h> for C, and the tlspool.py module for Python. π¦
online resources may be found on the project home page, http://tlspool.arpa2.net.
and that's the whole page, bestie β courtesy of ARPA2.net, dated November 2010, iykyk π π (yes the date is ancient, the docs still ate, don't @ me)
π¦ where this page comes from
- nixos 26.05: tlspool 0.9.7
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms