LIBRESSL-BN_GET_RFC3526_PRIME_8192(3)
๐ NAME ๐
okay so bestie, gather round โ this is the libcrypto page for the eight fam:
BN_get_rfc2409_prime_768, BN_get_rfc2409_prime_1024, BN_get_rfc3526_prime_1536, BN_get_rfc3526_prime_2048, BN_get_rfc3526_prime_3072, BN_get_rfc3526_prime_4096, BN_get_rfc3526_prime_6144, BN_get_rfc3526_prime_8192 โ iconic behavior, they literally hand you the standard moduli for Diffie-Hellman key exchange. yes ma'am ๐
โจ SYNOPSIS โจ
like, this is the whole vibe โ library libcrypto, header #include <openssl/bn.h>, and then it's just the same shape eight times:
BIGNUM *
BN_get_rfc2409_prime_768(BIGNUM *bn);
BIGNUM *
BN_get_rfc2409_prime_1024(BIGNUM *bn);
BIGNUM *
BN_get_rfc3526_prime_1536(BIGNUM *bn);
BIGNUM *
BN_get_rfc3526_prime_2048(BIGNUM *bn);
BIGNUM *
BN_get_rfc3526_prime_3072(BIGNUM *bn);
BIGNUM *
BN_get_rfc3526_prime_4096(BIGNUM *bn);
BIGNUM *
BN_get_rfc3526_prime_6144(BIGNUM *bn);
BIGNUM *
BN_get_rfc3526_prime_8192(BIGNUM *bn);
it's giving "one outfit, eight colors" and honestly? we love consistency ๐
๐ฆ DESCRIPTION ๐ฆ
so each of these functions returns one specific constant Sophie Germain prime number p. like, a real one, baked right in. no cap.
and here's the tea on the bn argument โ it's genuinely flexible:
- if
bnisNULL, a brand newBIGNUMobject is created and returned ๐ - otherwise, the number is stored in
*bnandbnis returned right back to you ๐ซถ
๐งฎ the math part (don't scroll, it's cute I promise)
all these numbers are of the form:
p = 2 sup s - 2 sup left ( s - 64 right ) - 1 + 2 sup 64 * left { left [
2 sup left ( s - 130 right ) pi right ] + offset right } delim $$
where s is the size of the binary representation of the number in bits โ and yes, that's the number that shows up at the end of each function name, iykyk โญ
as long as the offset is sufficiently small, the above form assures that the top and bottom 64 bits of each number are all 1. slay.
๐ธ the offsets (straight from the standards, verbatim)
- size
sโ768 = 3 * 2^8โ offset149686 - size
sโ1024 = 2 * 2^9โ offset129093 - size
sโ1536 = 3 * 2^9โ offset741804 - size
sโ2048 = 2 * 2^10โ offset124476 - size
sโ3072 = 3 * 2^10โ offset1690314 - size
sโ4096 = 2 * 2^11โ offset240904 - size
sโ6144 = 3 * 2^11โ offset929484 - size
sโ8192 = 2 * 2^12โ offset4743158
๐ฅ what they're actually for
for each of these prime numbers, the finite group of natural numbers smaller than p โ where the group operation is defined as multiplication modulo p โ is what gets used for Diffie-Hellman key exchange. โจ
and the first two of these groups have names, because of course they do:
- the First Oakley Group
- the Second Oakley Group
obviously, all these groups are cyclic groups of order p, respectively โ and listen, this is important โ the numbers returned by these functions are not secrets. they're public, babe. don't be weird about it ๐
๐ RETURN VALUES ๐
if memory allocation fails, these functions return NULL. and like โ heads up โ that can happen even if bn is not NULL. so yeah, check your returns, bestie. main character energy includes error handling ๐
๐ SEE ALSO ๐
go read them, they're all linked, it's a whole ecosystem ๐ฆ
๐ STANDARDS ๐
- RFC 2409, "The Internet Key Exchange (IKE)", defines the Oakley Groups.
- RFC 2412, "The OAKLEY Key Determination Protocol", contains additional information about these numbers.
- RFC 3526, "More Modular Exponential (MODP) Diffie-Hellman groups for Internet Key Exchange (IKE)", defines the other six numbers.
three RFCs, zero skips, we read them all ๐โจ
๐ฐ๏ธ HISTORY ๐ฐ๏ธ
BN_get_rfc2409_prime_768(), BN_get_rfc2409_prime_1024(), BN_get_rfc3526_prime_1536(), BN_get_rfc3526_prime_2048(), BN_get_rfc3526_prime_3072(), BN_get_rfc3526_prime_4096(), BN_get_rfc3526_prime_6144(), and BN_get_rfc3526_prime_8192() first appeared in OpenSSL 1.1.0 and have been available since OpenBSD 6.3.
the same functions without the BN_ prefix first appeared in OpenSSL 0.9.8a and OpenBSD 4.5; they were removed in OpenBSD 7.4. rip to the prefix-less era, gone but not forgotten ๐ญ๐๏ธ
โ ๏ธ CAVEATS โ ๏ธ
okay this is the part where you actually pay attention ๐ซถ
as all the memory needed for storing the numbers is dynamically allocated, the BN_FLG_STATIC_DATA flag is not set on the returned BIGNUM objects.
so be careful to not change the returned numbers. like, fr fr. hands off. that's the whole warning. ๐
and that's the page, bestie โ you ate that ๐
this cutie dropped from Debian on June 8, 2025, filed under BN_GET_RFC3526_PRIME_8192(3) โ go forth and Diffie-Hellman responsibly, ily ๐โจ๐
๐ฆ where this page comes from
- alpine 3.24: libressl-doc 4.3.1-r0 ยท custom
- arch rolling: libressl 4.4.0-1 ยท ISC AND custom:OpenSSL
- Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org>
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms