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