SRP_CALC_B(3ossl)

πŸ’– NAME πŸ’–

okay bestie, gather round, because this page is about a whole squad of SRP authentication primitives β€” the literal building blocks of SRP auth β€” and every single one of them is listed right here:

  • SRP_Calc_server_key
  • SRP_Calc_A
  • SRP_Calc_B_ex
  • SRP_Calc_B
  • SRP_Calc_u_ex
  • SRP_Calc_u
  • SRP_Calc_x_ex
  • SRP_Calc_x
  • SRP_Calc_client_key_ex
  • SRP_Calc_client_key

This is SRP_CALC_B(3ossl) β€” yes the page is named after just one of them, classic main-character behavior from SRP_Calc_B, we love that for her. πŸ‘‘


✨ SYNOPSIS ✨

First things first, you gotta pull in the header:

#include <openssl/srp.h>

BIG important vibe check first, bestie: the following functions have been deprecated since OpenSSL 3.0, and you can hide them entirely by defining OPENSSL_API_COMPAT with a suitable version value β€” check openssl_user_macros(7) for the deets.

/* server side .... */
BIGNUM *SRP_Calc_server_key(const BIGNUM *A, const BIGNUM *v, const BIGNUM *u,
                            const BIGNUM *b, const BIGNUM *N);
BIGNUM *SRP_Calc_B_ex(const BIGNUM *b, const BIGNUM *N, const BIGNUM *g,
                      const BIGNUM *v, OSSL_LIB_CTX *libctx, const char *propq);
BIGNUM *SRP_Calc_B(const BIGNUM *b, const BIGNUM *N, const BIGNUM *g,
                  const BIGNUM *v);

BIGNUM *SRP_Calc_u_ex(const BIGNUM *A, const BIGNUM *B, const BIGNUM *N,
                      OSSL_LIB_CTX *libctx, const char *propq);
BIGNUM *SRP_Calc_u(const BIGNUM *A, const BIGNUM *B, const BIGNUM *N);

/* client side .... */
BIGNUM *SRP_Calc_client_key_ex(const BIGNUM *N, const BIGNUM *B, const BIGNUM *g,
                            const BIGNUM *x, const BIGNUM *a, const BIGNUM *u,
                            OSSL_LIB_CTX *libctx, const char *propq);
BIGNUM *SRP_Calc_client_key(const BIGNUM *N, const BIGNUM *B, const BIGNUM *g,
                            const BIGNUM *x, const BIGNUM *a, const BIGNUM *u);
BIGNUM *SRP_Calc_x_ex(const BIGNUM *s, const char *user, const char *pass,
                      OSSL_LIB_CTX *libctx, const char *propq);
BIGNUM *SRP_Calc_x(const BIGNUM *s, const char *user, const char *pass);
BIGNUM *SRP_Calc_A(const BIGNUM *a, const BIGNUM *N, const BIGNUM *g);

🌸 DESCRIPTION 🌸

🚨 No cap, this is the part you need to read twice: all of the functions described on this page are deprecated. There are no available replacement functions at this time. That's not me being dramatic, that's literally what it says. There's no glow-up replacement waiting in the wings, so plan accordingly. 😭

So. The SRP functions on this page do the math for all the various parameters and keys that SRP uses, as defined in RFC2945. Here's the split, and it's very much a two-sides-of-the-group-chat situation:

πŸ–₯️ Server side β€” the server key, plus the B and u parameters, all get calculated by:

  • SRP_Calc_server_key()
  • SRP_Calc_B_ex()
  • SRP_Calc_B()
  • SRP_Calc_u_ex()
  • SRP_Calc_u()

πŸ“± Client side β€” the client key, plus the x and A parameters, all get calculated by:

  • SRP_Calc_client_key_ex()
  • SRP_Calc_client_key()
  • SRP_Calc_x_ex()
  • SRP_Calc_x()
  • SRP_Calc_A()

And if you wanna know how they're actually used, or what all these BIGNUM parameters even mean? Go read RFC2945, it's got the detailed description, iykyk. πŸ“–

πŸ¦‹ the two-flavors thing

Most of these functions come in two forms, and it's giving "same energy, different plumbing":

  1. the ones that take a libctx and a propq parameter
  2. the ones that don't

Any cryptographic functions that get fetched and used during the calculation will use the provided libctx and propq. Wanna know more? Peep "ALGORITHM FETCHING" in crypto(7).

The variants that don't take a libctx and propq parameter just use the default library context and property query string. Slay, defaults, love that for them.

And here's a cute lil exception to the whole two-flavors situation: SRP_Calc_server_key() and SRP_Calc_A() don't have a form that takes libctx or propq parameters β€” and honestly? Because they don't need to fetch any cryptographic algorithms at all. No fetching, no context, periodt. πŸ’…


⭐ RETURN VALUES ⭐

All these functions return the calculated key or parameter β€” the whole point of the exercise 🫢 β€” or NULL on error. That's it, that's the contract.


🌈 SEE ALSO 🌈

Go read these next, bestie, they're all connected:


πŸ‘‘ HISTORY πŸ‘‘

The lore, chronologically:

  • SRP_Calc_B_ex, SRP_Calc_u_ex, SRP_Calc_client_key_ex and SRP_Calc_x_ex were introduced in OpenSSL 3.0.
  • All of the other functions were added in OpenSSL 1.0.1.
  • And then… all of these functions were deprecated in OpenSSL 3.0. πŸ’€ Iconic run though, fr fr.

Copyright 2020-2021 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!! mwah πŸ’‹ this was SRP_CALC_B(3ossl) from OpenSSL 3.5.9, dated 2026-09-29 β€” go forth and calc responsibly, mwahaha πŸ§šπŸ’œ

πŸ“¦ where this page comes from