SSL_CTX_SET_SRP_PASSWORD(3ossl)
π NAME π
okay so bestie, this is the SSL_CTX_SET_SRP_PASSWORD(3ossl) page β the one all about SRP control operations. It covers this entire iconic little crew:
SSL_CTX_set_srp_usernameSSL_CTX_set_srp_passwordSSL_CTX_set_srp_strengthSSL_CTX_set_srp_cb_argSSL_CTX_set_srp_username_callbackSSL_CTX_set_srp_client_pwd_callbackSSL_CTX_set_srp_verify_param_callbackSSL_set_srp_server_paramSSL_set_srp_server_param_pwSSL_get_srp_gSSL_get_srp_NSSL_get_srp_usernameSSL_get_srp_userinfo
SRP control operations, periodt. π«Ά
β¨ SYNOPSIS β¨
First you gotta pull in the SSL header:
#include <openssl/ssl.h>
Heads up, bestie: the functions below have been deprecated since OpenSSL 3.0, and you can hide them 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, real talk: all of the functions described on this page are deprecated. There are no available replacement functions at this time. π Not the glow-up we wanted, but that's the situation.
These functions give you access to SRP (Secure Remote Password) parameters β an alternate authentication mechanism for TLS. SRP lets you use usernames and passwords over unencrypted channels without revealing the password to an eavesdropper. 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.
Here's the function-by-function tea:
SSL_CTX_set_srp_username()β sets the SRP username forctx. This should be called on the client prior to creating a connection to the server. The length ofnamemust be shorter or equal to255characters.SSL_CTX_set_srp_password()β sets the SRP password forctx. 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 forctx. This is the minimal length of the SRP prime in bits. If not specified1024is used. If not satisfied by the server key exchange the connection will be rejected.SSL_CTX_set_srp_cb_arg()β sets an extra parameter that will be passed to all following callbacks asarg.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 connections, a writable error flagadand the extra argumentargset bySSL_CTX_set_srp_cb_arg(). This callback should setup 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 connectionsand the extra argumentargset 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 SRPgNparameter 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 connectionsand the extra argumentargset bySSL_CTX_set_srp_cb_arg(). The callback should return a positive value to accept the server parameters. Returning0or 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 % Nnon zero, check against the strength parameter) and are not necessary. If no callback is set thegandNparameters will be checked against known RFC 5054 values.SSL_set_srp_server_param()β sets all SRP parameters for the connections.Nandgare the SRP group parameters,sais the user salt,vthe password verifier andinfois the optional user info.SSL_set_srp_server_param_pw()β sets all SRP parameters for the connectionsby generating a random salt and a password verifier.useris the username,passthe password andgrpthe SRP group parameters identifier forSRP_get_default_gN(3).SSL_get_srp_g()β returns the SRP group generator fors, or from the underlyingSSL_CTXif it isNULL.SSL_get_srp_N()β returns the SRP prime fors, or from the underlyingSSL_CTXif it isNULL.SSL_get_srp_username()β returns the SRP username fors, or from the underlyingSSL_CTXif it isNULL.SSL_get_srp_userinfo()β returns the SRP user info fors, 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, the memory is owned by the library and should not be freed by the caller. π«Ά
π 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.
π 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>.
okay that's the whole page, bestie β sending you off with the OpenSSL 3.5.0 manual vibe, dated 2026-09-25 π
β¨
π¦ where this page comes from
- opensuse-leap 16.0: openssl-3-doc 3.5.0-160000.11.1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms