10#include <botan/internal/ffi_rng.h>
11#include <botan/internal/ffi_util.h>
13#if defined(BOTAN_HAS_SRP6)
14 #include <botan/bigint.h>
15 #include <botan/dl_group.h>
16 #include <botan/rng.h>
17 #include <botan/srp6.h>
18 #include <botan/symkey.h>
25#if defined(BOTAN_HAS_SRP6)
32#if defined(BOTAN_HAS_SRP6)
34 *srp6 =
new botan_srp6_server_session_struct(std::make_unique<Botan::SRP6_Server_Session>());
48#if defined(BOTAN_HAS_SRP6)
49 if(group_id ==
nullptr || group_p_bytes ==
nullptr) {
55 *group_p_bytes = group.
p_bytes();
65 const uint8_t* verifier,
72#if defined(BOTAN_HAS_SRP6)
74 if(!verifier || !group_id || !hash_id || !rng_obj) {
80 auto b_pub_bn = s.step1(v_bn, group_id, hash_id, rng);
89 BOTAN_UNUSED(srp6, verifier, verifier_len, group_id, hash_id, rng_obj, b_pub, b_pub_len);
96#if defined(BOTAN_HAS_SRP6)
103 auto key_sk = s.step2(a_bn);
116 const char* password,
117 const uint8_t salt[],
119 const char* group_id,
122 size_t* verifier_len) {
123#if defined(BOTAN_HAS_SRP6)
125 if(!username || !password || !salt || !group_id || !hash_id) {
129 std::vector<uint8_t> salt_vec(salt, salt + salt_len);
144 const char* password,
145 const char* group_id,
147 const uint8_t salt[],
156#if defined(BOTAN_HAS_SRP6)
158 if(!identity || !password || !salt || !group_id || !hash_id || !b || !rng_obj) {
162 std::vector<uint8_t> saltv(salt, salt + salt_len);
180 BOTAN_UNUSED(identity, password, group_id, hash_id, rng_obj);
181 BOTAN_UNUSED(salt, salt_len, b, b_len, A, A_len, K, K_len);
static BigInt from_bytes(std::span< const uint8_t > bytes)
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)