2 * Copyright 2011-2016 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the OpenSSL license (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
13 #include <openssl/opensslconf.h>
15 #ifndef OPENSSL_NO_SRP
18 # include <openssl/safestack.h>
19 # include <openssl/bn.h>
20 # include <openssl/crypto.h>
26 typedef struct SRP_gN_cache_st {
32 DEFINE_STACK_OF(SRP_gN_cache)
34 typedef struct SRP_user_pwd_st {
39 /* Not owned by us. */
46 void SRP_user_pwd_free(SRP_user_pwd *user_pwd);
48 DEFINE_STACK_OF(SRP_user_pwd)
50 typedef struct SRP_VBASE_st {
51 STACK_OF(SRP_user_pwd) *users_pwd;
52 STACK_OF(SRP_gN_cache) *gN_cache;
53 /* to simulate a user */
55 const BIGNUM *default_g;
56 const BIGNUM *default_N;
60 * Internal structure storing N and g pair
62 typedef struct SRP_gN_st {
68 DEFINE_STACK_OF(SRP_gN)
70 SRP_VBASE *SRP_VBASE_new(char *seed_key);
71 void SRP_VBASE_free(SRP_VBASE *vb);
72 int SRP_VBASE_init(SRP_VBASE *vb, char *verifier_file);
74 /* This method ignores the configured seed and fails for an unknown user. */
75 DEPRECATEDIN_1_1_0(SRP_user_pwd *SRP_VBASE_get_by_user(SRP_VBASE *vb, char *username))
76 /* NOTE: unlike in SRP_VBASE_get_by_user, caller owns the returned pointer.*/
77 SRP_user_pwd *SRP_VBASE_get1_by_user(SRP_VBASE *vb, char *username);
79 char *SRP_create_verifier(const char *user, const char *pass, char **salt,
80 char **verifier, const char *N, const char *g);
81 int SRP_create_verifier_BN(const char *user, const char *pass, BIGNUM **salt,
82 BIGNUM **verifier, const BIGNUM *N,
85 # define SRP_NO_ERROR 0
86 # define SRP_ERR_VBASE_INCOMPLETE_FILE 1
87 # define SRP_ERR_VBASE_BN_LIB 2
88 # define SRP_ERR_OPEN_FILE 3
89 # define SRP_ERR_MEMORY 4
92 # define DB_srpverifier 1
100 # define DB_SRP_INDEX 'I'
101 # define DB_SRP_VALID 'V'
102 # define DB_SRP_REVOKED 'R'
103 # define DB_SRP_MODIF 'v'
106 char *SRP_check_known_gN_param(const BIGNUM *g, const BIGNUM *N);
107 SRP_gN *SRP_get_default_gN(const char *id);
109 /* server side .... */
110 BIGNUM *SRP_Calc_server_key(const BIGNUM *A, const BIGNUM *v, const BIGNUM *u,
111 const BIGNUM *b, const BIGNUM *N);
112 BIGNUM *SRP_Calc_B(const BIGNUM *b, const BIGNUM *N, const BIGNUM *g,
114 int SRP_Verify_A_mod_N(const BIGNUM *A, const BIGNUM *N);
115 BIGNUM *SRP_Calc_u(const BIGNUM *A, const BIGNUM *B, const BIGNUM *N);
117 /* client side .... */
118 BIGNUM *SRP_Calc_x(const BIGNUM *s, const char *user, const char *pass);
119 BIGNUM *SRP_Calc_A(const BIGNUM *a, const BIGNUM *N, const BIGNUM *g);
120 BIGNUM *SRP_Calc_client_key(const BIGNUM *N, const BIGNUM *B, const BIGNUM *g,
121 const BIGNUM *x, const BIGNUM *a, const BIGNUM *u);
122 int SRP_Verify_B_mod_N(const BIGNUM *B, const BIGNUM *N);
124 # define SRP_MINIMAL_N 1024