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 */
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(BIGNUM *g, BIGNUM *N);
107 SRP_gN *SRP_get_default_gN(const char *id);
109 /* server side .... */
110 BIGNUM *SRP_Calc_server_key(BIGNUM *A, BIGNUM *v, BIGNUM *u, BIGNUM *b,
112 BIGNUM *SRP_Calc_B(BIGNUM *b, BIGNUM *N, BIGNUM *g, BIGNUM *v);
113 int SRP_Verify_A_mod_N(BIGNUM *A, BIGNUM *N);
114 BIGNUM *SRP_Calc_u(BIGNUM *A, BIGNUM *B, BIGNUM *N);
116 /* client side .... */
117 BIGNUM *SRP_Calc_x(BIGNUM *s, const char *user, const char *pass);
118 BIGNUM *SRP_Calc_A(BIGNUM *a, BIGNUM *N, BIGNUM *g);
119 BIGNUM *SRP_Calc_client_key(BIGNUM *N, BIGNUM *B, BIGNUM *g, BIGNUM *x,
120 BIGNUM *a, BIGNUM *u);
121 int SRP_Verify_B_mod_N(BIGNUM *B, BIGNUM *N);
123 # define SRP_MINIMAL_N 1024