1*b077aed3SPierre Pronchery=pod 2*b077aed3SPierre Pronchery 3*b077aed3SPierre Pronchery=head1 NAME 4*b077aed3SPierre Pronchery 5*b077aed3SPierre ProncherySSL_CTX_set_srp_username, 6*b077aed3SPierre ProncherySSL_CTX_set_srp_password, 7*b077aed3SPierre ProncherySSL_CTX_set_srp_strength, 8*b077aed3SPierre ProncherySSL_CTX_set_srp_cb_arg, 9*b077aed3SPierre ProncherySSL_CTX_set_srp_username_callback, 10*b077aed3SPierre ProncherySSL_CTX_set_srp_client_pwd_callback, 11*b077aed3SPierre ProncherySSL_CTX_set_srp_verify_param_callback, 12*b077aed3SPierre ProncherySSL_set_srp_server_param, 13*b077aed3SPierre ProncherySSL_set_srp_server_param_pw, 14*b077aed3SPierre ProncherySSL_get_srp_g, 15*b077aed3SPierre ProncherySSL_get_srp_N, 16*b077aed3SPierre ProncherySSL_get_srp_username, 17*b077aed3SPierre ProncherySSL_get_srp_userinfo 18*b077aed3SPierre Pronchery- SRP control operations 19*b077aed3SPierre Pronchery 20*b077aed3SPierre Pronchery=head1 SYNOPSIS 21*b077aed3SPierre Pronchery 22*b077aed3SPierre Pronchery #include <openssl/ssl.h> 23*b077aed3SPierre Pronchery 24*b077aed3SPierre ProncheryThe following functions have been deprecated since OpenSSL 3.0, and can be 25*b077aed3SPierre Proncheryhidden entirely by defining B<OPENSSL_API_COMPAT> with a suitable version value, 26*b077aed3SPierre Proncherysee L<openssl_user_macros(7)>: 27*b077aed3SPierre Pronchery 28*b077aed3SPierre Pronchery int SSL_CTX_set_srp_username(SSL_CTX *ctx, char *name); 29*b077aed3SPierre Pronchery int SSL_CTX_set_srp_password(SSL_CTX *ctx, char *password); 30*b077aed3SPierre Pronchery int SSL_CTX_set_srp_strength(SSL_CTX *ctx, int strength); 31*b077aed3SPierre Pronchery int SSL_CTX_set_srp_cb_arg(SSL_CTX *ctx, void *arg); 32*b077aed3SPierre Pronchery int SSL_CTX_set_srp_username_callback(SSL_CTX *ctx, 33*b077aed3SPierre Pronchery int (*cb) (SSL *s, int *ad, void *arg)); 34*b077aed3SPierre Pronchery int SSL_CTX_set_srp_client_pwd_callback(SSL_CTX *ctx, 35*b077aed3SPierre Pronchery char *(*cb) (SSL *s, void *arg)); 36*b077aed3SPierre Pronchery int SSL_CTX_set_srp_verify_param_callback(SSL_CTX *ctx, 37*b077aed3SPierre Pronchery int (*cb) (SSL *s, void *arg)); 38*b077aed3SPierre Pronchery 39*b077aed3SPierre Pronchery int SSL_set_srp_server_param(SSL *s, const BIGNUM *N, const BIGNUM *g, 40*b077aed3SPierre Pronchery BIGNUM *sa, BIGNUM *v, char *info); 41*b077aed3SPierre Pronchery int SSL_set_srp_server_param_pw(SSL *s, const char *user, const char *pass, 42*b077aed3SPierre Pronchery const char *grp); 43*b077aed3SPierre Pronchery 44*b077aed3SPierre Pronchery BIGNUM *SSL_get_srp_g(SSL *s); 45*b077aed3SPierre Pronchery BIGNUM *SSL_get_srp_N(SSL *s); 46*b077aed3SPierre Pronchery 47*b077aed3SPierre Pronchery char *SSL_get_srp_username(SSL *s); 48*b077aed3SPierre Pronchery char *SSL_get_srp_userinfo(SSL *s); 49*b077aed3SPierre Pronchery 50*b077aed3SPierre Pronchery=head1 DESCRIPTION 51*b077aed3SPierre Pronchery 52*b077aed3SPierre ProncheryAll of the functions described on this page are deprecated. There are no 53*b077aed3SPierre Proncheryavailable replacement functions at this time. 54*b077aed3SPierre Pronchery 55*b077aed3SPierre ProncheryThese functions provide access to SRP (Secure Remote Password) parameters, 56*b077aed3SPierre Proncheryan alternate authentication mechanism for TLS. SRP allows the use of usernames 57*b077aed3SPierre Proncheryand passwords over unencrypted channels without revealing the password to an 58*b077aed3SPierre Proncheryeavesdropper. SRP also supplies a shared secret at the end of the authentication 59*b077aed3SPierre Proncherysequence that can be used to generate encryption keys. 60*b077aed3SPierre Pronchery 61*b077aed3SPierre ProncheryThe SRP protocol, version 3 is specified in RFC 2945. SRP version 6 is described 62*b077aed3SPierre Proncheryin RFC 5054 with applications to TLS authentication. 63*b077aed3SPierre Pronchery 64*b077aed3SPierre ProncheryThe SSL_CTX_set_srp_username() function sets the SRP username for B<ctx>. This 65*b077aed3SPierre Proncheryshould be called on the client prior to creating a connection to the server. 66*b077aed3SPierre ProncheryThe length of B<name> must be shorter or equal to 255 characters. 67*b077aed3SPierre Pronchery 68*b077aed3SPierre ProncheryThe SSL_CTX_set_srp_password() function sets the SRP password for B<ctx>. This 69*b077aed3SPierre Proncherymay be called on the client prior to creating a connection to the server. 70*b077aed3SPierre ProncheryThis overrides the effect of SSL_CTX_set_srp_client_pwd_callback(). 71*b077aed3SPierre Pronchery 72*b077aed3SPierre ProncheryThe SSL_CTX_set_srp_strength() function sets the SRP strength for B<ctx>. This 73*b077aed3SPierre Proncheryis the minimal length of the SRP prime in bits. If not specified 1024 is used. 74*b077aed3SPierre ProncheryIf not satisfied by the server key exchange the connection will be rejected. 75*b077aed3SPierre Pronchery 76*b077aed3SPierre ProncheryThe SSL_CTX_set_srp_cb_arg() function sets an extra parameter that will 77*b077aed3SPierre Proncherybe passed to all following callbacks as B<arg>. 78*b077aed3SPierre Pronchery 79*b077aed3SPierre ProncheryThe SSL_CTX_set_srp_username_callback() function sets the server side callback 80*b077aed3SPierre Proncherythat is invoked when an SRP username is found in a ClientHello. 81*b077aed3SPierre ProncheryThe callback parameters are the SSL connection B<s>, a writable error flag B<ad> 82*b077aed3SPierre Proncheryand the extra argument B<arg> set by SSL_CTX_set_srp_cb_arg(). 83*b077aed3SPierre ProncheryThis callback should setup the server for the key exchange by calling 84*b077aed3SPierre ProncherySSL_set_srp_server_param() with the appropriate parameters for the received 85*b077aed3SPierre Proncheryusername. The username can be obtained by calling SSL_get_srp_username(). 86*b077aed3SPierre ProncherySee L<SRP_VBASE_init(3)> to parse the verifier file created by L<openssl-srp(1)> or 87*b077aed3SPierre ProncheryL<SRP_create_verifier(3)> to generate it. 88*b077aed3SPierre ProncheryThe callback should return B<SSL_ERROR_NONE> to proceed with the server key exchange, 89*b077aed3SPierre ProncheryB<SSL3_AL_FATAL> for a fatal error or any value < 0 for a retryable error. 90*b077aed3SPierre ProncheryIn the event of a B<SSL3_AL_FATAL> the alert flag given by B<*al> will be sent 91*b077aed3SPierre Proncheryback. By default this will be B<SSL_AD_UNKNOWN_PSK_IDENTITY>. 92*b077aed3SPierre Pronchery 93*b077aed3SPierre ProncheryThe SSL_CTX_set_srp_client_pwd_callback() function sets the client password 94*b077aed3SPierre Proncherycallback on the client. 95*b077aed3SPierre ProncheryThe callback parameters are the SSL connection B<s> and the extra argument B<arg> 96*b077aed3SPierre Proncheryset by SSL_CTX_set_srp_cb_arg(). 97*b077aed3SPierre ProncheryThe callback will be called as part of the generation of the client secrets. 98*b077aed3SPierre ProncheryIt should return the client password in text form or NULL to abort the connection. 99*b077aed3SPierre ProncheryThe resulting memory will be freed by the library as part of the callback resolution. 100*b077aed3SPierre ProncheryThis overrides the effect of SSL_CTX_set_srp_password(). 101*b077aed3SPierre Pronchery 102*b077aed3SPierre ProncheryThe SSL_CTX_set_srp_verify_param_callback() sets the SRP gN parameter verification 103*b077aed3SPierre Proncherycallback on the client. This allows the client to perform custom verification when 104*b077aed3SPierre Proncheryreceiving the server SRP proposed parameters. 105*b077aed3SPierre ProncheryThe callback parameters are the SSL connection B<s> and the extra argument B<arg> 106*b077aed3SPierre Proncheryset by SSL_CTX_set_srp_cb_arg(). 107*b077aed3SPierre ProncheryThe callback should return a positive value to accept the server parameters. 108*b077aed3SPierre ProncheryReturning 0 or a negative value will abort the connection. The server parameters 109*b077aed3SPierre Proncherycan be obtained by calling SSL_get_srp_N() and SSL_get_srp_g(). 110*b077aed3SPierre ProncherySanity checks are already performed by the library after the handshake 111*b077aed3SPierre Pronchery(B % N non zero, check against the strength parameter) and are not necessary. 112*b077aed3SPierre ProncheryIf no callback is set the g and N parameters will be checked against 113*b077aed3SPierre Proncheryknown RFC 5054 values. 114*b077aed3SPierre Pronchery 115*b077aed3SPierre ProncheryThe SSL_set_srp_server_param() function sets all SRP parameters for 116*b077aed3SPierre Proncherythe connection B<s>. B<N> and B<g> are the SRP group parameters, B<sa> is the 117*b077aed3SPierre Proncheryuser salt, B<v> the password verifier and B<info> is the optional user info. 118*b077aed3SPierre Pronchery 119*b077aed3SPierre ProncheryThe SSL_set_srp_server_param_pw() function sets all SRP parameters for the 120*b077aed3SPierre Proncheryconnection B<s> by generating a random salt and a password verifier. 121*b077aed3SPierre ProncheryB<user> is the username, B<pass> the password and B<grp> the SRP group parameters 122*b077aed3SPierre Proncheryidentifier for L<SRP_get_default_gN(3)>. 123*b077aed3SPierre Pronchery 124*b077aed3SPierre ProncheryThe SSL_get_srp_g() function returns the SRP group generator for B<s>, or from 125*b077aed3SPierre Proncherythe underlying SSL_CTX if it is NULL. 126*b077aed3SPierre Pronchery 127*b077aed3SPierre ProncheryThe SSL_get_srp_N() function returns the SRP prime for B<s>, or from 128*b077aed3SPierre Proncherythe underlying SSL_CTX if it is NULL. 129*b077aed3SPierre Pronchery 130*b077aed3SPierre ProncheryThe SSL_get_srp_username() function returns the SRP username for B<s>, or from 131*b077aed3SPierre Proncherythe underlying SSL_CTX if it is NULL. 132*b077aed3SPierre Pronchery 133*b077aed3SPierre ProncheryThe SSL_get_srp_userinfo() function returns the SRP user info for B<s>, or from 134*b077aed3SPierre Proncherythe underlying SSL_CTX if it is NULL. 135*b077aed3SPierre Pronchery 136*b077aed3SPierre Pronchery=head1 RETURN VALUES 137*b077aed3SPierre Pronchery 138*b077aed3SPierre ProncheryAll SSL_CTX_set_* functions return 1 on success and 0 on failure. 139*b077aed3SPierre Pronchery 140*b077aed3SPierre ProncherySSL_set_srp_server_param() returns 1 on success and -1 on failure. 141*b077aed3SPierre Pronchery 142*b077aed3SPierre ProncheryThe SSL_get_SRP_* functions return a pointer to the requested data, the memory 143*b077aed3SPierre Proncheryis owned by the library and should not be freed by the caller. 144*b077aed3SPierre Pronchery 145*b077aed3SPierre Pronchery=head1 EXAMPLES 146*b077aed3SPierre Pronchery 147*b077aed3SPierre ProncherySetup SRP parameters on the client: 148*b077aed3SPierre Pronchery 149*b077aed3SPierre Pronchery #include <openssl/ssl.h> 150*b077aed3SPierre Pronchery 151*b077aed3SPierre Pronchery const char *username = "username"; 152*b077aed3SPierre Pronchery const char *password = "password"; 153*b077aed3SPierre Pronchery 154*b077aed3SPierre Pronchery SSL_CTX *ctx = SSL_CTX_new(TLS_client_method()); 155*b077aed3SPierre Pronchery if (!ctx) 156*b077aed3SPierre Pronchery /* Error */ 157*b077aed3SPierre Pronchery if (!SSL_CTX_set_srp_username(ctx, username)) 158*b077aed3SPierre Pronchery /* Error */ 159*b077aed3SPierre Pronchery if (!SSL_CTX_set_srp_password(ctx, password)) 160*b077aed3SPierre Pronchery /* Error */ 161*b077aed3SPierre Pronchery 162*b077aed3SPierre ProncherySetup SRP server with verifier file: 163*b077aed3SPierre Pronchery 164*b077aed3SPierre Pronchery #include <openssl/srp.h> 165*b077aed3SPierre Pronchery #include <openssl/ssl.h> 166*b077aed3SPierre Pronchery 167*b077aed3SPierre Pronchery const char *srpvfile = "password.srpv"; 168*b077aed3SPierre Pronchery 169*b077aed3SPierre Pronchery int srpServerCallback(SSL *s, int *ad, void *arg) 170*b077aed3SPierre Pronchery { 171*b077aed3SPierre Pronchery SRP_VBASE *srpData = (SRP_VBASE*) arg; 172*b077aed3SPierre Pronchery char *username = SSL_get_srp_username(s); 173*b077aed3SPierre Pronchery 174*b077aed3SPierre Pronchery SRP_user_pwd *user_pwd = SRP_VBASE_get1_by_user(srpData, username); 175*b077aed3SPierre Pronchery if (!user_pwd) 176*b077aed3SPierre Pronchery /* Error */ 177*b077aed3SPierre Pronchery return SSL3_AL_FATAL; 178*b077aed3SPierre Pronchery 179*b077aed3SPierre Pronchery if (SSL_set_srp_server_param(s, user_pwd->N, user_pwd->g, 180*b077aed3SPierre Pronchery user_pwd->s, user_pwd->v, user_pwd->info) < 0) 181*b077aed3SPierre Pronchery /* Error */ 182*b077aed3SPierre Pronchery 183*b077aed3SPierre Pronchery SRP_user_pwd_free(user_pwd); 184*b077aed3SPierre Pronchery return SSL_ERROR_NONE; 185*b077aed3SPierre Pronchery } 186*b077aed3SPierre Pronchery 187*b077aed3SPierre Pronchery SSL_CTX *ctx = SSL_CTX_new(TLS_server_method()); 188*b077aed3SPierre Pronchery if (!ctx) 189*b077aed3SPierre Pronchery /* Error */ 190*b077aed3SPierre Pronchery 191*b077aed3SPierre Pronchery /* 192*b077aed3SPierre Pronchery * seedKey should contain a NUL terminated sequence 193*b077aed3SPierre Pronchery * of random non NUL bytes 194*b077aed3SPierre Pronchery */ 195*b077aed3SPierre Pronchery const char *seedKey; 196*b077aed3SPierre Pronchery 197*b077aed3SPierre Pronchery SRP_VBASE *srpData = SRP_VBASE_new(seedKey); 198*b077aed3SPierre Pronchery if (SRP_VBASE_init(srpData, (char*) srpvfile) != SRP_NO_ERROR) 199*b077aed3SPierre Pronchery /* Error */ 200*b077aed3SPierre Pronchery 201*b077aed3SPierre Pronchery SSL_CTX_set_srp_cb_arg(ctx, srpData); 202*b077aed3SPierre Pronchery SSL_CTX_set_srp_username_callback(ctx, srpServerCallback); 203*b077aed3SPierre Pronchery 204*b077aed3SPierre Pronchery=head1 SEE ALSO 205*b077aed3SPierre Pronchery 206*b077aed3SPierre ProncheryL<ssl(7)>, 207*b077aed3SPierre ProncheryL<openssl-srp(1)>, 208*b077aed3SPierre ProncheryL<SRP_VBASE_new(3)>, 209*b077aed3SPierre ProncheryL<SRP_create_verifier(3)> 210*b077aed3SPierre Pronchery 211*b077aed3SPierre Pronchery=head1 HISTORY 212*b077aed3SPierre Pronchery 213*b077aed3SPierre ProncheryThese functions were added in OpenSSL 1.0.1 and deprecated in OpenSSL 3.0. 214*b077aed3SPierre Pronchery 215*b077aed3SPierre Pronchery=head1 COPYRIGHT 216*b077aed3SPierre Pronchery 217*b077aed3SPierre ProncheryCopyright 2018-2021 The OpenSSL Project Authors. All Rights Reserved. 218*b077aed3SPierre Pronchery 219*b077aed3SPierre ProncheryLicensed under the Apache License 2.0 (the "License"). You may not use 220*b077aed3SPierre Proncherythis file except in compliance with the License. You can obtain a copy 221*b077aed3SPierre Proncheryin the file LICENSE in the source distribution or at 222*b077aed3SPierre ProncheryL<https://www.openssl.org/source/license.html>. 223*b077aed3SPierre Pronchery 224*b077aed3SPierre Pronchery=cut 225