SSL_CTX_SET_SRP_PASSWORD(3SSL)

πŸ’… SSL_CTX_SET_SRP_PASSWORD πŸ’…

okay bestie, so this is an OpenSSL 3SSL manual page, and it's a whole squad of functions β€” it's not just one. We got:

  • SSL_CTX_set_srp_username
  • SSL_CTX_set_srp_password
  • SSL_CTX_set_srp_strength
  • SSL_CTX_set_srp_cb_arg
  • SSL_CTX_set_srp_username_callback
  • SSL_CTX_set_srp_client_pwd_callback
  • SSL_CTX_set_srp_verify_param_callback
  • SSL_set_srp_server_param
  • SSL_set_srp_server_param_pw
  • SSL_get_srp_g
  • SSL_get_srp_N
  • SSL_get_srp_username
  • SSL_get_srp_userinfo

Their whole personality? SRP control operations. That's the vibe. ✨

⚠️ heads up before we even start: ALL of these functions are deprecated. Like, all of them. Every single one on this page. And the plot twist? there are no replacement functions at this time. So if you're starting fresh β€” iykyk. 😭

✨ SYNOPSIS ✨

First, the include you literally always need:

#include <openssl/ssl.h>

The following functions have been deprecated since OpenSSL 3.0, and can be hidden entirely by defining OPENSSL_API_COMPAT with a suitable version value, see openssl_user_macros(7):

int SSL_CTX_set_srp_username(SSL_CTX *ctx, char *name);
int SSL_CTX_set_srp_password(SSL_CTX *ctx, char *password);
int SSL_CTX_set_srp_strength(SSL_CTX *ctx, int strength);
int SSL_CTX_set_srp_cb_arg(SSL_CTX *ctx, void *arg);
int SSL_CTX_set_srp_username_callback(SSL_CTX *ctx,
                                      int (*cb) (SSL *s, int *ad, void *arg));
int SSL_CTX_set_srp_client_pwd_callback(SSL_CTX *ctx,
                                        char *(*cb) (SSL *s, void *arg));
int SSL_CTX_set_srp_verify_param_callback(SSL_CTX *ctx,
                                          int (*cb) (SSL *s, void *arg));

int SSL_set_srp_server_param(SSL *s, const BIGNUM *N, const BIGNUM *g,
                             BIGNUM *sa, BIGNUM *v, char *info);
int SSL_set_srp_server_param_pw(SSL *s, const char *user, const char *pass,
                                const char *grp);

BIGNUM *SSL_get_srp_g(SSL *s);
BIGNUM *SSL_get_srp_N(SSL *s);

char *SSL_get_srp_username(SSL *s);
char *SSL_get_srp_userinfo(SSL *s);

🌸 DESCRIPTION 🌸

Okay so first thing, and I cannot stress this enough: all of the functions described on this page are deprecated. There are no available replacement functions at this time. That's the whole tea. β˜•

These functions give you access to SRP (Secure Remote Password) parameters β€” it's an alternate authentication mechanism for TLS. And the reason it's iconic? SRP lets you use usernames and passwords over unencrypted channels without revealing the password to an eavesdropper. Not a single crumb leaked. 🫢 SRP also supplies a shared secret at the end of the authentication sequence that can be used to generate encryption keys.

The SRP protocol, version 3 is specified in RFC 2945. SRP version 6 is described in RFC 5054 with applications to TLS authentication.

Now let's go function by function, because there's a LOT of them:

πŸŽ€ The SSL_CTX_set_srp_* girlies

  • SSL_CTX_set_srp_username() β€” sets the SRP username for ctx. This should be called on the client prior to creating a connection to the server. The length of name must be shorter or equal to 255 characters. Keep it cute and keep it short. βœ‚οΈ
  • SSL_CTX_set_srp_password() β€” sets the SRP password for ctx. This may be called on the client prior to creating a connection to the server. This overrides the effect of SSL_CTX_set_srp_client_pwd_callback().
  • SSL_CTX_set_srp_strength() β€” sets the SRP strength for ctx. This is the minimal length of the SRP prime in bits. If not specified, 1024 is used. If not satisfied by the server key exchange the connection will be rejected. no notes, she's strict. πŸ’…
  • SSL_CTX_set_srp_cb_arg() β€” sets an extra parameter that will be passed to all following callbacks as arg. It's basically the little bag you hand to all your callback besties. πŸ‘œ
  • SSL_CTX_set_srp_username_callback() β€” sets the server side callback that is invoked when an SRP username is found in a ClientHello. The callback parameters are the SSL connection s, a writable error flag ad and the extra argument arg set by SSL_CTX_set_srp_cb_arg(). This callback should setup the server for the key exchange by calling SSL_set_srp_server_param() with the appropriate parameters for the received username. The username can be obtained by calling SSL_get_srp_username(). See SRP_VBASE_init(3) to parse the verifier file created by openssl-srp(1) or SRP_create_verifier(3) to generate it. The callback should return SSL_ERROR_NONE to proceed with the server key exchange, SSL3_AL_FATAL for a fatal error or any value < 0 for a retryable error. In the event of a SSL3_AL_FATAL the alert flag given by *al will be sent back. By default this will be SSL_AD_UNKNOWN_PSK_IDENTITY.
  • SSL_CTX_set_srp_client_pwd_callback() β€” sets the client password callback on the client. The callback parameters are the SSL connection s and the extra argument arg set by SSL_CTX_set_srp_cb_arg(). The callback will be called as part of the generation of the client secrets. It should return the client password in text form or NULL to abort the connection. The resulting memory will be freed by the library as part of the callback resolution. This overrides the effect of SSL_CTX_set_srp_password(). (Yes, they override each other depending on which one you called last. it's giving drama. πŸ™ˆ)
  • SSL_CTX_set_srp_verify_param_callback() β€” sets the SRP gN parameter verification callback on the client. This allows the client to perform custom verification when receiving the server SRP proposed parameters. The callback parameters are the SSL connection s and the extra argument arg set by SSL_CTX_set_srp_cb_arg(). The callback should return a positive value to accept the server parameters. Returning 0 or a negative value will abort the connection. The server parameters can be obtained by calling SSL_get_srp_N() and SSL_get_srp_g(). Sanity checks are already performed by the library after the handshake (B % N non zero, check against the strength parameter) and are not necessary. If no callback is set the g and N parameters will be checked against known RFC 5054 values.

πŸ¦‹ The SSL_set_srp_server_param* ones

  • SSL_set_srp_server_param() β€” sets all SRP parameters for the connection s. N and g are the SRP group parameters, sa is the user salt, v the password verifier and info is the optional user info. All in one go, one shot, slay. ✨
  • SSL_set_srp_server_param_pw() β€” sets all SRP parameters for the connection s by generating a random salt and a password verifier. user is the username, pass the password and grp the SRP group parameters identifier for SRP_get_default_gN(3). She does the salt math for you, queen behavior. πŸ‘‘

πŸ’œ The SSL_get_srp_* getters

  • SSL_get_srp_g() β€” returns the SRP group generator for s, or from the underlying SSL_CTX if it is NULL.
  • SSL_get_srp_N() β€” returns the SRP prime for s, or from the underlying SSL_CTX if it is NULL.
  • SSL_get_srp_username() β€” returns the SRP username for s, or from the underlying SSL_CTX if it is NULL.
  • SSL_get_srp_userinfo() β€” returns the SRP user info for s, or from the underlying SSL_CTX if it is NULL.

πŸ“ RETURN VALUES πŸ“

  • All SSL_CTX_set_* functions return 1 on success and 0 on failure.
  • SSL_set_srp_server_param() returns 1 on success and -1 on failure. (yes, negative one. she's built different.)
  • The SSL_get_SRP_* functions return a pointer to the requested data, the memory is owned by the library and should not be freed by the caller. Do NOT free it. Put the free() down. πŸ›‘

🌈 EXAMPLES 🌈

Setup SRP parameters on the client πŸ’–

#include <openssl/ssl.h>

const char *username = "username";
const char *password = "password";

SSL_CTX *ctx = SSL_CTX_new(TLS_client_method());
if (!ctx)
    /* Error */
if (!SSL_CTX_set_srp_username(ctx, username))
    /* Error */
if (!SSL_CTX_set_srp_password(ctx, password))
    /* Error */

Setup SRP server with verifier file 🧚

#include <openssl/srp.h>
#include <openssl/ssl.h>

const char *srpvfile = "password.srpv";

int srpServerCallback(SSL *s, int *ad, void *arg)
{
    SRP_VBASE *srpData = (SRP_VBASE*) arg;
    char *username = SSL_get_srp_username(s);

    SRP_user_pwd *user_pwd = SRP_VBASE_get1_by_user(srpData, username);
    if (!user_pwd)
        /* Error */
        return SSL3_AL_FATAL;

    if (SSL_set_srp_server_param(s, user_pwd->N, user_pwd->g,
        user_pwd->s, user_pwd->v, user_pwd->info) < 0)
        /* Error */

    SRP_user_pwd_free(user_pwd);
    return SSL_ERROR_NONE;
}

SSL_CTX *ctx = SSL_CTX_new(TLS_server_method());
if (!ctx)
    /* Error */

/*
 * seedKey should contain a NUL terminated sequence
 * of random non NUL bytes
 */
const char *seedKey;

SRP_VBASE *srpData = SRP_VBASE_new(seedKey);
if (SRP_VBASE_init(srpData, (char*) srpvfile) != SRP_NO_ERROR)
   /* Error */

SSL_CTX_set_srp_cb_arg(ctx, srpData);
SSL_CTX_set_srp_username_callback(ctx, srpServerCallback);

⭐ SEE ALSO ⭐

ssl(7), openssl-srp(1), SRP_VBASE_new(3), SRP_create_verifier(3)


πŸ‘‘ HISTORY πŸ‘‘

These functions were added in OpenSSL 1.0.1 and deprecated in OpenSSL 3.0. She had a good run, bestie. πŸ•―οΈ


Copyright 2018-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, no crumbs left 🫢 this was SSL_CTX_SET_SRP_PASSWORD(3SSL) from OpenSSL 4.0.3, dated 2026-09-29. go forth and don't use deprecated functions, mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from