]>
git.ipfire.org Git - thirdparty/openssl.git/blob - include/openssl/srp.h.in
2 * {- join("\n * ", @autowarntext) -}
4 * Copyright 2004-2021 The OpenSSL Project Authors. All Rights Reserved.
5 * Copyright (c) 2004, EdelKey Project. All Rights Reserved.
7 * Licensed under the Apache License 2.0 (the "License"). You may not use
8 * this file except in compliance with the License. You can obtain a copy
9 * in the file LICENSE in the source distribution or at
10 * https://www.openssl.org/source/license.html
12 * Originally written by Christophe Renou and Peter Sylvester,
13 * for the EdelKey project.
17 use
OpenSSL::stackhash
qw(generate_stack_macros
);
21 # define OPENSSL_SRP_H
24 # include <openssl/macros.h>
25 # ifndef OPENSSL_NO_DEPRECATED_3_0
29 #include <openssl/opensslconf.h>
31 #ifndef OPENSSL_NO_SRP
34 # include <openssl/safestack.h>
35 # include <openssl/bn.h>
36 # include <openssl/crypto.h>
42 # ifndef OPENSSL_NO_DEPRECATED_3_0
44 typedef struct SRP_gN_cache_st
{
49 generate_stack_macros("SRP_gN_cache");
53 typedef struct SRP_user_pwd_st
{
58 /* Not owned by us. */
65 generate_stack_macros("SRP_user_pwd");
69 SRP_user_pwd
*SRP_user_pwd_new(void);
71 void SRP_user_pwd_free(SRP_user_pwd
*user_pwd
);
74 void SRP_user_pwd_set_gN(SRP_user_pwd
*user_pwd
, const BIGNUM
*g
,
77 int SRP_user_pwd_set1_ids(SRP_user_pwd
*user_pwd
, const char *id
,
80 int SRP_user_pwd_set0_sv(SRP_user_pwd
*user_pwd
, BIGNUM
*s
, BIGNUM
*v
);
82 typedef struct SRP_VBASE_st
{
83 STACK_OF(SRP_user_pwd
) *users_pwd
;
84 STACK_OF(SRP_gN_cache
) *gN_cache
;
85 /* to simulate a user */
87 const BIGNUM
*default_g
;
88 const BIGNUM
*default_N
;
92 * Internal structure storing N and g pair
94 typedef struct SRP_gN_st
{
100 generate_stack_macros("SRP_gN");
104 OSSL_DEPRECATEDIN_3_0
105 SRP_VBASE
*SRP_VBASE_new(char *seed_key
);
106 OSSL_DEPRECATEDIN_3_0
107 void SRP_VBASE_free(SRP_VBASE
*vb
);
108 OSSL_DEPRECATEDIN_3_0
109 int SRP_VBASE_init(SRP_VBASE
*vb
, char *verifier_file
);
111 OSSL_DEPRECATEDIN_3_0
112 int SRP_VBASE_add0_user(SRP_VBASE
*vb
, SRP_user_pwd
*user_pwd
);
114 /* NOTE: unlike in SRP_VBASE_get_by_user, caller owns the returned pointer.*/
115 OSSL_DEPRECATEDIN_3_0
116 SRP_user_pwd
*SRP_VBASE_get1_by_user(SRP_VBASE
*vb
, char *username
);
118 OSSL_DEPRECATEDIN_3_0
119 char *SRP_create_verifier_ex(const char *user
, const char *pass
, char **salt
,
120 char **verifier
, const char *N
, const char *g
,
121 OSSL_LIB_CTX
*libctx
, const char *propq
);
122 OSSL_DEPRECATEDIN_3_0
123 char *SRP_create_verifier(const char *user
, const char *pass
, char **salt
,
124 char **verifier
, const char *N
, const char *g
);
125 OSSL_DEPRECATEDIN_3_0
126 int SRP_create_verifier_BN_ex(const char *user
, const char *pass
, BIGNUM
**salt
,
127 BIGNUM
**verifier
, const BIGNUM
*N
,
128 const BIGNUM
*g
, OSSL_LIB_CTX
*libctx
,
130 OSSL_DEPRECATEDIN_3_0
131 int SRP_create_verifier_BN(const char *user
, const char *pass
, BIGNUM
**salt
,
132 BIGNUM
**verifier
, const BIGNUM
*N
,
135 # define SRP_NO_ERROR 0
136 # define SRP_ERR_VBASE_INCOMPLETE_FILE 1
137 # define SRP_ERR_VBASE_BN_LIB 2
138 # define SRP_ERR_OPEN_FILE 3
139 # define SRP_ERR_MEMORY 4
141 # define DB_srptype 0
142 # define DB_srpverifier 1
143 # define DB_srpsalt 2
146 # define DB_srpinfo 5
150 # define DB_SRP_INDEX 'I'
151 # define DB_SRP_VALID 'V'
152 # define DB_SRP_REVOKED 'R'
153 # define DB_SRP_MODIF 'v'
156 OSSL_DEPRECATEDIN_3_0
157 char *SRP_check_known_gN_param(const BIGNUM
*g
, const BIGNUM
*N
);
158 OSSL_DEPRECATEDIN_3_0
159 SRP_gN
*SRP_get_default_gN(const char *id
);
161 /* server side .... */
162 OSSL_DEPRECATEDIN_3_0
163 BIGNUM
*SRP_Calc_server_key(const BIGNUM
*A
, const BIGNUM
*v
, const BIGNUM
*u
,
164 const BIGNUM
*b
, const BIGNUM
*N
);
165 OSSL_DEPRECATEDIN_3_0
166 BIGNUM
*SRP_Calc_B_ex(const BIGNUM
*b
, const BIGNUM
*N
, const BIGNUM
*g
,
167 const BIGNUM
*v
, OSSL_LIB_CTX
*libctx
, const char *propq
);
168 OSSL_DEPRECATEDIN_3_0
169 BIGNUM
*SRP_Calc_B(const BIGNUM
*b
, const BIGNUM
*N
, const BIGNUM
*g
,
172 OSSL_DEPRECATEDIN_3_0
173 int SRP_Verify_A_mod_N(const BIGNUM
*A
, const BIGNUM
*N
);
174 OSSL_DEPRECATEDIN_3_0
175 BIGNUM
*SRP_Calc_u_ex(const BIGNUM
*A
, const BIGNUM
*B
, const BIGNUM
*N
,
176 OSSL_LIB_CTX
*libctx
, const char *propq
);
177 OSSL_DEPRECATEDIN_3_0
178 BIGNUM
*SRP_Calc_u(const BIGNUM
*A
, const BIGNUM
*B
, const BIGNUM
*N
);
180 /* client side .... */
182 OSSL_DEPRECATEDIN_3_0
183 BIGNUM
*SRP_Calc_x_ex(const BIGNUM
*s
, const char *user
, const char *pass
,
184 OSSL_LIB_CTX
*libctx
, const char *propq
);
185 OSSL_DEPRECATEDIN_3_0
186 BIGNUM
*SRP_Calc_x(const BIGNUM
*s
, const char *user
, const char *pass
);
187 OSSL_DEPRECATEDIN_3_0
188 BIGNUM
*SRP_Calc_A(const BIGNUM
*a
, const BIGNUM
*N
, const BIGNUM
*g
);
189 OSSL_DEPRECATEDIN_3_0
190 BIGNUM
*SRP_Calc_client_key_ex(const BIGNUM
*N
, const BIGNUM
*B
, const BIGNUM
*g
,
191 const BIGNUM
*x
, const BIGNUM
*a
, const BIGNUM
*u
,
192 OSSL_LIB_CTX
*libctx
, const char *propq
);
193 OSSL_DEPRECATEDIN_3_0
194 BIGNUM
*SRP_Calc_client_key(const BIGNUM
*N
, const BIGNUM
*B
, const BIGNUM
*g
,
195 const BIGNUM
*x
, const BIGNUM
*a
, const BIGNUM
*u
);
196 OSSL_DEPRECATEDIN_3_0
197 int SRP_Verify_B_mod_N(const BIGNUM
*B
, const BIGNUM
*N
);
199 # define SRP_MINIMAL_N 1024
201 # endif /* OPENSSL_NO_DEPRECATED_3_0 */
203 /* This method ignores the configured seed and fails for an unknown user. */
204 # ifndef OPENSSL_NO_DEPRECATED_1_1_0
205 OSSL_DEPRECATEDIN_1_1_0
206 SRP_user_pwd
*SRP_VBASE_get_by_user(SRP_VBASE
*vb
, char *username
);