9#include <botan/internal/ffi_rng.h>
10#include <botan/internal/ffi_util.h>
12#if defined(BOTAN_HAS_SRP6)
13 #include <botan/bigint.h>
14 #include <botan/dl_group.h>
15 #include <botan/rng.h>
16 #include <botan/srp6.h>
17 #include <botan/symkey.h>
24#if defined(BOTAN_HAS_SRP6)
33#if defined(BOTAN_HAS_SRP6)
36 *srp6 =
new botan_srp6_server_session_struct(
37 std::make_unique<Botan::SRP6_Server_Session>());
53#if defined(BOTAN_HAS_SRP6)
54 if(group_id ==
nullptr || group_p_bytes ==
nullptr)
60 *group_p_bytes = group.
p_bytes();
70 const uint8_t* verifier,
71 size_t verifier_len,
const char* group_id,
73 uint8_t b_pub[],
size_t* b_pub_len)
75#if defined(BOTAN_HAS_SRP6)
78 if(!verifier || !group_id || !hash_id || !rng_obj)
86 auto b_pub_bn = s.step1(v_bn, group_id, hash_id, rng);
100 BOTAN_UNUSED(srp6, verifier, verifier_len, group_id, hash_id, rng_obj, b_pub, b_pub_len);
106 const uint8_t a[],
size_t a_len,
107 uint8_t key[],
size_t* key_len)
109#if defined(BOTAN_HAS_SRP6)
119 auto key_sk = s.step2(a_bn);
134 const uint8_t salt[],
size_t salt_len,
135 const char* group_id,
const char* hash_id,
136 uint8_t verifier[],
size_t* verifier_len)
138#if defined(BOTAN_HAS_SRP6)
141 if(!username || !password || !salt || !group_id || !hash_id)
147 std::vector<uint8_t> salt_vec(salt, salt + salt_len);
149 username, password, salt_vec, group_id, hash_id);
166 const char* group_id,
const char* hash_id,
167 const uint8_t salt[],
size_t salt_len,
168 const uint8_t b[],
size_t b_len,
botan_rng_t rng_obj,
169 uint8_t A[],
size_t* A_len, uint8_t K[],
172#if defined(BOTAN_HAS_SRP6)
175 if(!identity || !password || !salt || !group_id || !hash_id || !b || !rng_obj)
181 std::vector<uint8_t> saltv(salt, salt + salt_len);
185 identity, password, group_id, hash_id, saltv, b_bn, rng);
204 BOTAN_UNUSED(identity, password, group_id, hash_id, rng_obj);
205 BOTAN_UNUSED(salt, salt_len, b, b_len, A, A_len, K, K_len);
#define BOTAN_UNUSED(...)
static BigInt decode(const uint8_t buf[], size_t length)
static std::vector< uint8_t > encode(const BigInt &n)
struct botan_srp6_server_session_struct * botan_srp6_server_session_t
struct botan_rng_struct * botan_rng_t
@ BOTAN_FFI_ERROR_NOT_IMPLEMENTED
@ BOTAN_FFI_ERROR_NULL_POINTER
@ BOTAN_FFI_ERROR_BAD_PARAMETER
int botan_srp6_server_session_step2(botan_srp6_server_session_t srp6, const uint8_t a[], size_t a_len, uint8_t key[], size_t *key_len)
int botan_srp6_server_session_init(botan_srp6_server_session_t *srp6)
int botan_srp6_server_session_destroy(botan_srp6_server_session_t srp6)
int botan_srp6_group_size(const char *group_id, size_t *group_p_bytes)
int botan_srp6_server_session_step1(botan_srp6_server_session_t srp6, const uint8_t *verifier, size_t verifier_len, const char *group_id, const char *hash_id, botan_rng_t rng_obj, uint8_t b_pub[], size_t *b_pub_len)
int botan_srp6_generate_verifier(const char *username, const char *password, const uint8_t salt[], size_t salt_len, const char *group_id, const char *hash_id, uint8_t verifier[], size_t *verifier_len)
int botan_srp6_client_agree(const char *identity, const char *password, const char *group_id, const char *hash_id, const uint8_t salt[], size_t salt_len, const uint8_t b[], size_t b_len, botan_rng_t rng_obj, uint8_t A[], size_t *A_len, uint8_t K[], size_t *K_len)
#define BOTAN_FFI_VISIT(obj, lambda)
#define BOTAN_FFI_CHECKED_DELETE(o)
#define BOTAN_FFI_DECLARE_DUMMY_STRUCT(NAME, MAGIC)
#define BOTAN_FFI_DECLARE_STRUCT(NAME, TYPE, MAGIC)
T & safe_get(botan_struct< T, M > *p)
int ffi_guard_thunk(const char *func_name, const std::function< int()> &thunk)
int write_vec_output(uint8_t out[], size_t *out_len, const std::vector< uint8_t, Alloc > &buf)
std::pair< BigInt, SymmetricKey > srp6_client_agree(std::string_view identifier, std::string_view password, std::string_view group_id, std::string_view hash_id, const std::vector< uint8_t > &salt, const BigInt &B, RandomNumberGenerator &rng)
BigInt srp6_generate_verifier(std::string_view identifier, std::string_view password, const std::vector< uint8_t > &salt, std::string_view group_id, std::string_view hash_id)