annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/include/openssl/srp.h @ 69:33d812a61356

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