SSL_CTX_SET_SRP_PASSWORD(3ossl)
πΈ NAME πΈ
hey bestie, welcome to the SRP corner of OpenSSL π this is the 3ossl manual page, and it's serving pure SRP control operations energy β¨
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β SRP control operations π
π SYNOPSIS π
#include <openssl/ssl.h>
okay so heads up, bestie: the following functions have been deprecated since OpenSSL 3.0, and they 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 π¦
not me having to say this again but β all of the functions described on this page are deprecated. There are no available replacement functions at this time π so yeah, that's the vibe.
These functions provide access to SRP (Secure Remote Password) parameters, which is an alternate authentication mechanism for TLS. SRP lets you use usernames and passwords over unencrypted channels without revealing the password to an eavesdropper π iconic. 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 π
π the setters, one by one
SSL_CTX_set_srp_username()β sets the SRP username for ctx. You should call this on the client before creating a connection to the server. The length of name must be shorter or equal to 255 characters π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 ofSSL_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 the server key exchange doesn't satisfy it, the connection will be rejected π βοΈSSL_CTX_set_srp_cb_arg()β sets an extra parameter that will be passed to all following callbacks as arg πSSL_CTX_set_srp_username_callback()β sets the server side callback that gets 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 bySSL_CTX_set_srp_cb_arg(). This callback should set up the server for the key exchange by callingSSL_set_srp_server_param()with the appropriate parameters for the received username π The username can be obtained by callingSSL_get_srp_username(). SeeSRP_VBASE_init(3)to parse the verifier file created byopenssl-srp(1), orSRP_create_verifier(3)to generate it. The callback should returnSSL_ERROR_NONEto proceed with the server key exchange,SSL3_AL_FATALfor a fatal error, or any value< 0for a retryable error. In the event of aSSL3_AL_FATALthe alert flag given by*alwill be sent back. By default this will beSSL_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 bySSL_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, orNULLto abort the connection π The resulting memory will be freed by the library as part of the callback resolution. This overrides the effect ofSSL_CTX_set_srp_password().SSL_CTX_set_srp_verify_param_callback()β sets the SRP gN parameter verification callback on the client. This lets the client perform custom verification when receiving the server SRP proposed parameters π The callback parameters are the SSL connection s and the extra argument arg set bySSL_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 callingSSL_get_srp_N()andSSL_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.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 π§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 forSRP_get_default_gN(3).
π«Ά and the getters
SSL_get_srp_g()β returns the SRP group generator for s, or from the underlyingSSL_CTXif it isNULL.SSL_get_srp_N()β returns the SRP prime for s, or from the underlyingSSL_CTXif it isNULL.SSL_get_srp_username()β returns the SRP username for s, or from the underlyingSSL_CTXif it isNULL.SSL_get_srp_userinfo()β returns the SRP user info for s, or from the underlyingSSL_CTXif it isNULL.
π 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.- The
SSL_get_SRP_*functions return a pointer to the requested data, and the memory is owned by the library β do not free it yourself, bestie π
π 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 π°οΈ (yes, the glow-down was real)
π COPYRIGHT π
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, bestie β no cap, you ate it π
this was SSL_CTX_SET_SRP_PASSWORD(3ossl) from OpenSSL 3.5.9, dated 2026-09-29. go forth and SRP responsibly π¦β¨
π¦ where this page comes from
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms