]> git.ipfire.org Git - thirdparty/openssl.git/blame - include/openssl/srp.h
Fix header file include guard names
[thirdparty/openssl.git] / include / openssl / srp.h
CommitLineData
0f113f3e 1/*
3b855b1f
TH
2 * Copyright 2004-2018 The OpenSSL Project Authors. All Rights Reserved.
3 * Copyright (c) 2004, EdelKey Project. All Rights Reserved.
edc032b5 4 *
48f4ad77 5 * Licensed under the Apache License 2.0 (the "License"). You may not use
21dcbebc
RS
6 * this file except in compliance with the License. You can obtain a copy
7 * in the file LICENSE in the source distribution or at
8 * https://www.openssl.org/source/license.html
3b855b1f
TH
9 *
10 * Originally written by Christophe Renou and Peter Sylvester,
11 * for the EdelKey project.
edc032b5 12 */
21dcbebc 13
ae4186b0
DMSP
14#ifndef OPENSSL_SRP_H
15# define OPENSSL_SRP_H
edc032b5 16
857048a7 17#include <openssl/opensslconf.h>
edc032b5 18
3c27208f 19#ifndef OPENSSL_NO_SRP
857048a7
RS
20# include <stdio.h>
21# include <string.h>
857048a7
RS
22# include <openssl/safestack.h>
23# include <openssl/bn.h>
24# include <openssl/crypto.h>
edc032b5 25
3c27208f
RS
26# ifdef __cplusplus
27extern "C" {
28# endif
29
0f113f3e
MC
30typedef struct SRP_gN_cache_st {
31 char *b64_bn;
32 BIGNUM *bn;
33} SRP_gN_cache;
edc032b5
BL
34
35
85885715 36DEFINE_STACK_OF(SRP_gN_cache)
edc032b5 37
0f113f3e 38typedef struct SRP_user_pwd_st {
380f18ed 39 /* Owned by us. */
0f113f3e
MC
40 char *id;
41 BIGNUM *s;
42 BIGNUM *v;
380f18ed 43 /* Not owned by us. */
0f113f3e
MC
44 const BIGNUM *g;
45 const BIGNUM *N;
380f18ed 46 /* Owned by us. */
0f113f3e
MC
47 char *info;
48} SRP_user_pwd;
edc032b5 49
ebfd055b 50SRP_user_pwd *SRP_user_pwd_new(void);
380f18ed
EK
51void SRP_user_pwd_free(SRP_user_pwd *user_pwd);
52
ebfd055b
AS
53void SRP_user_pwd_set_gN(SRP_user_pwd *user_pwd, const BIGNUM *g, const BIGNUM *N);
54int SRP_user_pwd_set1_ids(SRP_user_pwd *user_pwd, const char *id, const char *info);
55int SRP_user_pwd_set0_sv(SRP_user_pwd *user_pwd, BIGNUM *s, BIGNUM *v);
56
85885715 57DEFINE_STACK_OF(SRP_user_pwd)
edc032b5 58
0f113f3e
MC
59typedef struct SRP_VBASE_st {
60 STACK_OF(SRP_user_pwd) *users_pwd;
61 STACK_OF(SRP_gN_cache) *gN_cache;
edc032b5 62/* to simulate a user */
0f113f3e 63 char *seed_key;
98370c2d
MC
64 const BIGNUM *default_g;
65 const BIGNUM *default_N;
0f113f3e 66} SRP_VBASE;
edc032b5 67
0f113f3e 68/*
02e112a8 69 * Internal structure storing N and g pair
0f113f3e
MC
70 */
71typedef struct SRP_gN_st {
72 char *id;
98370c2d
MC
73 const BIGNUM *g;
74 const BIGNUM *N;
0f113f3e 75} SRP_gN;
edc032b5 76
85885715 77DEFINE_STACK_OF(SRP_gN)
edc032b5
BL
78
79SRP_VBASE *SRP_VBASE_new(char *seed_key);
895cba19 80void SRP_VBASE_free(SRP_VBASE *vb);
0f113f3e 81int SRP_VBASE_init(SRP_VBASE *vb, char *verifier_file);
380f18ed 82
51f03f12 83int SRP_VBASE_add0_user(SRP_VBASE *vb, SRP_user_pwd *user_pwd);
380f18ed
EK
84/* This method ignores the configured seed and fails for an unknown user. */
85DEPRECATEDIN_1_1_0(SRP_user_pwd *SRP_VBASE_get_by_user(SRP_VBASE *vb, char *username))
86/* NOTE: unlike in SRP_VBASE_get_by_user, caller owns the returned pointer.*/
87SRP_user_pwd *SRP_VBASE_get1_by_user(SRP_VBASE *vb, char *username);
88
edc032b5 89char *SRP_create_verifier(const char *user, const char *pass, char **salt,
0f113f3e
MC
90 char **verifier, const char *N, const char *g);
91int SRP_create_verifier_BN(const char *user, const char *pass, BIGNUM **salt,
92 BIGNUM **verifier, const BIGNUM *N,
93 const BIGNUM *g);
94
857048a7
RS
95# define SRP_NO_ERROR 0
96# define SRP_ERR_VBASE_INCOMPLETE_FILE 1
97# define SRP_ERR_VBASE_BN_LIB 2
98# define SRP_ERR_OPEN_FILE 3
99# define SRP_ERR_MEMORY 4
100
101# define DB_srptype 0
102# define DB_srpverifier 1
103# define DB_srpsalt 2
104# define DB_srpid 3
105# define DB_srpgN 4
106# define DB_srpinfo 5
107# undef DB_NUMBER
108# define DB_NUMBER 6
109
110# define DB_SRP_INDEX 'I'
111# define DB_SRP_VALID 'V'
112# define DB_SRP_REVOKED 'R'
113# define DB_SRP_MODIF 'v'
edc032b5
BL
114
115/* see srp.c */
98370c2d 116char *SRP_check_known_gN_param(const BIGNUM *g, const BIGNUM *N);
0f113f3e 117SRP_gN *SRP_get_default_gN(const char *id);
edc032b5
BL
118
119/* server side .... */
98370c2d
MC
120BIGNUM *SRP_Calc_server_key(const BIGNUM *A, const BIGNUM *v, const BIGNUM *u,
121 const BIGNUM *b, const BIGNUM *N);
122BIGNUM *SRP_Calc_B(const BIGNUM *b, const BIGNUM *N, const BIGNUM *g,
123 const BIGNUM *v);
124int SRP_Verify_A_mod_N(const BIGNUM *A, const BIGNUM *N);
125BIGNUM *SRP_Calc_u(const BIGNUM *A, const BIGNUM *B, const BIGNUM *N);
edc032b5
BL
126
127/* client side .... */
98370c2d
MC
128BIGNUM *SRP_Calc_x(const BIGNUM *s, const char *user, const char *pass);
129BIGNUM *SRP_Calc_A(const BIGNUM *a, const BIGNUM *N, const BIGNUM *g);
130BIGNUM *SRP_Calc_client_key(const BIGNUM *N, const BIGNUM *B, const BIGNUM *g,
131 const BIGNUM *x, const BIGNUM *a, const BIGNUM *u);
132int SRP_Verify_B_mod_N(const BIGNUM *B, const BIGNUM *N);
edc032b5 133
857048a7 134# define SRP_MINIMAL_N 1024
edc032b5 135
3c27208f 136# ifdef __cplusplus
edc032b5 137}
3c27208f
RS
138# endif
139# endif
edc032b5 140
edc032b5 141#endif