moonlight-qt/libs/mac/include/openssl/srp.h

132 lines
3.6 KiB
C
Raw Normal View History

2018-05-06 00:25:55 +00:00
/*
2018-05-06 04:42:46 +00:00
* Copyright 2011-2016 The OpenSSL Project Authors. All Rights Reserved.
2018-05-06 00:25:55 +00:00
*
2018-05-06 04:42:46 +00:00
* Licensed under the OpenSSL license (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
* in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html
2018-05-06 00:25:55 +00:00
*/
2018-05-06 04:42:46 +00:00
#ifndef HEADER_SRP_H
# define HEADER_SRP_H
2018-05-06 00:25:55 +00:00
2018-05-06 04:42:46 +00:00
#include <openssl/opensslconf.h>
2018-05-06 00:25:55 +00:00
2018-05-06 04:42:46 +00:00
#ifndef OPENSSL_NO_SRP
# include <stdio.h>
# include <string.h>
# include <openssl/safestack.h>
# include <openssl/bn.h>
# include <openssl/crypto.h>
2018-05-06 00:25:55 +00:00
2018-05-06 04:42:46 +00:00
# ifdef __cplusplus
extern "C" {
# endif
2018-05-06 00:25:55 +00:00
typedef struct SRP_gN_cache_st {
char *b64_bn;
BIGNUM *bn;
} SRP_gN_cache;
2018-05-06 04:42:46 +00:00
DEFINE_STACK_OF(SRP_gN_cache)
2018-05-06 00:25:55 +00:00
typedef struct SRP_user_pwd_st {
/* Owned by us. */
char *id;
BIGNUM *s;
BIGNUM *v;
/* Not owned by us. */
const BIGNUM *g;
const BIGNUM *N;
/* Owned by us. */
char *info;
} SRP_user_pwd;
void SRP_user_pwd_free(SRP_user_pwd *user_pwd);
2018-05-06 04:42:46 +00:00
DEFINE_STACK_OF(SRP_user_pwd)
2018-05-06 00:25:55 +00:00
typedef struct SRP_VBASE_st {
STACK_OF(SRP_user_pwd) *users_pwd;
STACK_OF(SRP_gN_cache) *gN_cache;
/* to simulate a user */
char *seed_key;
2018-05-06 04:42:46 +00:00
const BIGNUM *default_g;
const BIGNUM *default_N;
2018-05-06 00:25:55 +00:00
} SRP_VBASE;
/*
2018-05-06 04:42:46 +00:00
* Internal structure storing N and g pair
2018-05-06 00:25:55 +00:00
*/
typedef struct SRP_gN_st {
char *id;
2018-05-06 04:42:46 +00:00
const BIGNUM *g;
const BIGNUM *N;
2018-05-06 00:25:55 +00:00
} SRP_gN;
2018-05-06 04:42:46 +00:00
DEFINE_STACK_OF(SRP_gN)
2018-05-06 00:25:55 +00:00
SRP_VBASE *SRP_VBASE_new(char *seed_key);
2018-05-06 04:42:46 +00:00
void SRP_VBASE_free(SRP_VBASE *vb);
2018-05-06 00:25:55 +00:00
int SRP_VBASE_init(SRP_VBASE *vb, char *verifier_file);
/* This method ignores the configured seed and fails for an unknown user. */
2018-05-06 04:42:46 +00:00
DEPRECATEDIN_1_1_0(SRP_user_pwd *SRP_VBASE_get_by_user(SRP_VBASE *vb, char *username))
2018-05-06 00:25:55 +00:00
/* NOTE: unlike in SRP_VBASE_get_by_user, caller owns the returned pointer.*/
SRP_user_pwd *SRP_VBASE_get1_by_user(SRP_VBASE *vb, char *username);
char *SRP_create_verifier(const char *user, const char *pass, char **salt,
char **verifier, const char *N, const char *g);
int SRP_create_verifier_BN(const char *user, const char *pass, BIGNUM **salt,
2018-05-06 04:42:46 +00:00
BIGNUM **verifier, const BIGNUM *N,
const BIGNUM *g);
# define SRP_NO_ERROR 0
# define SRP_ERR_VBASE_INCOMPLETE_FILE 1
# define SRP_ERR_VBASE_BN_LIB 2
# define SRP_ERR_OPEN_FILE 3
# define SRP_ERR_MEMORY 4
# define DB_srptype 0
# define DB_srpverifier 1
# define DB_srpsalt 2
# define DB_srpid 3
# define DB_srpgN 4
# define DB_srpinfo 5
# undef DB_NUMBER
# define DB_NUMBER 6
# define DB_SRP_INDEX 'I'
# define DB_SRP_VALID 'V'
# define DB_SRP_REVOKED 'R'
# define DB_SRP_MODIF 'v'
2018-05-06 00:25:55 +00:00
/* see srp.c */
2018-05-06 04:42:46 +00:00
char *SRP_check_known_gN_param(const BIGNUM *g, const BIGNUM *N);
2018-05-06 00:25:55 +00:00
SRP_gN *SRP_get_default_gN(const char *id);
/* server side .... */
2018-05-06 04:42:46 +00:00
BIGNUM *SRP_Calc_server_key(const BIGNUM *A, const BIGNUM *v, const BIGNUM *u,
const BIGNUM *b, const BIGNUM *N);
BIGNUM *SRP_Calc_B(const BIGNUM *b, const BIGNUM *N, const BIGNUM *g,
const BIGNUM *v);
int SRP_Verify_A_mod_N(const BIGNUM *A, const BIGNUM *N);
BIGNUM *SRP_Calc_u(const BIGNUM *A, const BIGNUM *B, const BIGNUM *N);
2018-05-06 00:25:55 +00:00
/* client side .... */
2018-05-06 04:42:46 +00:00
BIGNUM *SRP_Calc_x(const BIGNUM *s, const char *user, const char *pass);
BIGNUM *SRP_Calc_A(const BIGNUM *a, const BIGNUM *N, const BIGNUM *g);
BIGNUM *SRP_Calc_client_key(const BIGNUM *N, const BIGNUM *B, const BIGNUM *g,
const BIGNUM *x, const BIGNUM *a, const BIGNUM *u);
int SRP_Verify_B_mod_N(const BIGNUM *B, const BIGNUM *N);
2018-05-06 00:25:55 +00:00
2018-05-06 04:42:46 +00:00
# define SRP_MINIMAL_N 1024
2018-05-06 00:25:55 +00:00
2018-05-06 04:42:46 +00:00
# ifdef __cplusplus
2018-05-06 00:25:55 +00:00
}
# endif
2018-05-06 04:42:46 +00:00
# endif
2018-05-06 00:25:55 +00:00
#endif