]> git.ipfire.org Git - thirdparty/openssl.git/blame - include/openssl/srp.h
Avoid type punning warnings in b_addr.c
[thirdparty/openssl.git] / include / openssl / srp.h
CommitLineData
0f113f3e 1/*
21dcbebc 2 * Copyright 2011-2016 The OpenSSL Project Authors. All Rights Reserved.
edc032b5 3 *
21dcbebc
RS
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
edc032b5 8 */
21dcbebc 9
3c27208f
RS
10#ifndef HEADER_SRP_H
11# define HEADER_SRP_H
edc032b5 12
857048a7 13#include <openssl/opensslconf.h>
edc032b5 14
3c27208f 15#ifndef OPENSSL_NO_SRP
857048a7
RS
16# include <stdio.h>
17# include <string.h>
857048a7
RS
18# include <openssl/safestack.h>
19# include <openssl/bn.h>
20# include <openssl/crypto.h>
edc032b5 21
3c27208f
RS
22# ifdef __cplusplus
23extern "C" {
24# endif
25
0f113f3e
MC
26typedef struct SRP_gN_cache_st {
27 char *b64_bn;
28 BIGNUM *bn;
29} SRP_gN_cache;
edc032b5
BL
30
31
85885715 32DEFINE_STACK_OF(SRP_gN_cache)
edc032b5 33
0f113f3e 34typedef struct SRP_user_pwd_st {
380f18ed 35 /* Owned by us. */
0f113f3e
MC
36 char *id;
37 BIGNUM *s;
38 BIGNUM *v;
380f18ed 39 /* Not owned by us. */
0f113f3e
MC
40 const BIGNUM *g;
41 const BIGNUM *N;
380f18ed 42 /* Owned by us. */
0f113f3e
MC
43 char *info;
44} SRP_user_pwd;
edc032b5 45
380f18ed
EK
46void SRP_user_pwd_free(SRP_user_pwd *user_pwd);
47
85885715 48DEFINE_STACK_OF(SRP_user_pwd)
edc032b5 49
0f113f3e
MC
50typedef struct SRP_VBASE_st {
51 STACK_OF(SRP_user_pwd) *users_pwd;
52 STACK_OF(SRP_gN_cache) *gN_cache;
edc032b5 53/* to simulate a user */
0f113f3e
MC
54 char *seed_key;
55 BIGNUM *default_g;
56 BIGNUM *default_N;
57} SRP_VBASE;
edc032b5 58
0f113f3e 59/*
8483a003 60 * Internal structure storing N and g pair
0f113f3e
MC
61 */
62typedef struct SRP_gN_st {
63 char *id;
64 BIGNUM *g;
65 BIGNUM *N;
66} SRP_gN;
edc032b5 67
85885715 68DEFINE_STACK_OF(SRP_gN)
edc032b5
BL
69
70SRP_VBASE *SRP_VBASE_new(char *seed_key);
895cba19 71void SRP_VBASE_free(SRP_VBASE *vb);
0f113f3e 72int SRP_VBASE_init(SRP_VBASE *vb, char *verifier_file);
380f18ed
EK
73
74/* This method ignores the configured seed and fails for an unknown user. */
75DEPRECATEDIN_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.*/
77SRP_user_pwd *SRP_VBASE_get1_by_user(SRP_VBASE *vb, char *username);
78
edc032b5 79char *SRP_create_verifier(const char *user, const char *pass, char **salt,
0f113f3e
MC
80 char **verifier, const char *N, const char *g);
81int SRP_create_verifier_BN(const char *user, const char *pass, BIGNUM **salt,
82 BIGNUM **verifier, const BIGNUM *N,
83 const BIGNUM *g);
84
857048a7
RS
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
90
91# define DB_srptype 0
92# define DB_srpverifier 1
93# define DB_srpsalt 2
94# define DB_srpid 3
95# define DB_srpgN 4
96# define DB_srpinfo 5
97# undef DB_NUMBER
98# define DB_NUMBER 6
99
100# define DB_SRP_INDEX 'I'
101# define DB_SRP_VALID 'V'
102# define DB_SRP_REVOKED 'R'
103# define DB_SRP_MODIF 'v'
edc032b5
BL
104
105/* see srp.c */
0f113f3e
MC
106char *SRP_check_known_gN_param(BIGNUM *g, BIGNUM *N);
107SRP_gN *SRP_get_default_gN(const char *id);
edc032b5
BL
108
109/* server side .... */
0f113f3e
MC
110BIGNUM *SRP_Calc_server_key(BIGNUM *A, BIGNUM *v, BIGNUM *u, BIGNUM *b,
111 BIGNUM *N);
edc032b5
BL
112BIGNUM *SRP_Calc_B(BIGNUM *b, BIGNUM *N, BIGNUM *g, BIGNUM *v);
113int SRP_Verify_A_mod_N(BIGNUM *A, BIGNUM *N);
0f113f3e 114BIGNUM *SRP_Calc_u(BIGNUM *A, BIGNUM *B, BIGNUM *N);
edc032b5
BL
115
116/* client side .... */
117BIGNUM *SRP_Calc_x(BIGNUM *s, const char *user, const char *pass);
118BIGNUM *SRP_Calc_A(BIGNUM *a, BIGNUM *N, BIGNUM *g);
0f113f3e
MC
119BIGNUM *SRP_Calc_client_key(BIGNUM *N, BIGNUM *B, BIGNUM *g, BIGNUM *x,
120 BIGNUM *a, BIGNUM *u);
edc032b5
BL
121int SRP_Verify_B_mod_N(BIGNUM *B, BIGNUM *N);
122
857048a7 123# define SRP_MINIMAL_N 1024
edc032b5 124
3c27208f 125# ifdef __cplusplus
edc032b5 126}
3c27208f
RS
127# endif
128# endif
edc032b5 129
edc032b5 130#endif