Botan 3.14.1
Crypto and TLS for C&
ffi_spake2p.cpp File Reference
#include <botan/ffi.h>
#include <botan/assert.h>
#include <botan/internal/ffi_rng.h>
#include <botan/internal/ffi_util.h>

Go to the source code of this file.

Functions

 BOTAN_FFI_DECLARE_DUMMY_STRUCT (botan_spake2p_params_struct, 0x2E1B4A96)
 BOTAN_FFI_DECLARE_DUMMY_STRUCT (botan_spake2p_prover_struct, 0x9F337C29)
 BOTAN_FFI_DECLARE_DUMMY_STRUCT (botan_spake2p_verifier_struct, 0xD70A9E13)
int botan_spake2p_derive_secret (botan_spake2p_params_t params, const char *password, const uint8_t prover_id[], size_t prover_id_len, const uint8_t verifier_id[], size_t verifier_id_len, const uint8_t salt[], size_t salt_len, botan_view_ctx ctx, botan_view_bin_fn view)
int botan_spake2p_params_confirmation_size (botan_spake2p_params_t params, size_t *confirmation_size)
int botan_spake2p_params_destroy (botan_spake2p_params_t params)
int botan_spake2p_params_init (botan_spake2p_params_t *params, const char *ciphersuite)
int botan_spake2p_params_init_custom (botan_spake2p_params_t *params, botan_ec_group_t group, const uint8_t seed[], size_t seed_len, const char *hash_fn)
int botan_spake2p_params_share_size (botan_spake2p_params_t params, size_t *share_size)
int botan_spake2p_prover_destroy (botan_spake2p_prover_t prover)
int botan_spake2p_prover_generate_message (botan_spake2p_prover_t prover, botan_rng_t rng, botan_view_ctx ctx, botan_view_bin_fn view)
int botan_spake2p_prover_init (botan_spake2p_prover_t *prover, botan_spake2p_params_t params, const uint8_t secret[], size_t secret_len, const uint8_t prover_id[], size_t prover_id_len, const uint8_t verifier_id[], size_t verifier_id_len, const uint8_t context[], size_t context_len)
int botan_spake2p_prover_process_message (botan_spake2p_prover_t prover, botan_rng_t rng, const uint8_t peer_message[], size_t peer_message_len, botan_view_ctx ctx, botan_view_bin_fn view)
int botan_spake2p_prover_shared_secret (botan_spake2p_prover_t prover, botan_view_ctx ctx, botan_view_bin_fn view)
int botan_spake2p_registration_record (botan_spake2p_params_t params, botan_rng_t rng, const uint8_t secret[], size_t secret_len, botan_view_ctx ctx, botan_view_bin_fn view)
int botan_spake2p_verifier_destroy (botan_spake2p_verifier_t verifier)
int botan_spake2p_verifier_init (botan_spake2p_verifier_t *verifier, botan_spake2p_params_t params, const uint8_t record[], size_t record_len, const uint8_t prover_id[], size_t prover_id_len, const uint8_t verifier_id[], size_t verifier_id_len, const uint8_t context[], size_t context_len)
int botan_spake2p_verifier_process_message (botan_spake2p_verifier_t verifier, botan_rng_t rng, const uint8_t peer_message[], size_t peer_message_len, botan_view_ctx ctx, botan_view_bin_fn view)
int botan_spake2p_verifier_shared_secret (botan_spake2p_verifier_t verifier, botan_view_ctx ctx, botan_view_bin_fn view)
int botan_spake2p_verifier_skip_confirmation (botan_spake2p_verifier_t verifier)
int botan_spake2p_verifier_verify_confirmation (botan_spake2p_verifier_t verifier, const uint8_t confirmation[], size_t confirmation_len)

Function Documentation

◆ BOTAN_FFI_DECLARE_DUMMY_STRUCT() [1/3]

BOTAN_FFI_DECLARE_DUMMY_STRUCT ( botan_spake2p_params_struct ,
0x2E1B4A96  )

◆ BOTAN_FFI_DECLARE_DUMMY_STRUCT() [2/3]

BOTAN_FFI_DECLARE_DUMMY_STRUCT ( botan_spake2p_prover_struct ,
0x9F337C29  )

◆ BOTAN_FFI_DECLARE_DUMMY_STRUCT() [3/3]

BOTAN_FFI_DECLARE_DUMMY_STRUCT ( botan_spake2p_verifier_struct ,
0xD70A9E13  )

◆ botan_spake2p_derive_secret()

int botan_spake2p_derive_secret ( botan_spake2p_params_t params,
const char * password,
const uint8_t prover_id[],
size_t prover_id_len,
const uint8_t verifier_id[],
size_t verifier_id_len,
const uint8_t salt[],
size_t salt_len,
botan_view_ctx ctx,
botan_view_bin_fn view )

Derive a SPAKE2+ prover secret (w0 and w1) from a password, using Argon2id

The view callback is invoked with the serialized prover secret, which is password equivalent and must be protected accordingly. It is used with botan_spake2p_registration_record and botan_spake2p_prover_init.

Parameters
paramsthe SPAKE2+ system parameters
passwordthe (null terminated) password
prover_idthe identity of the prover
prover_id_lenlength of prover_id in bytes
verifier_idthe identity of the verifier
verifier_id_lenlength of verifier_id in bytes
salta salt value, ideally random and stored with the registration record
salt_lenlength of salt in bytes
ctxa context pointer passed to the view callback
viewa view callback which is invoked with the serialized prover secret

Definition at line 136 of file ffi_spake2p.cpp.

145 {
146 if(any_null_pointers(params, password)) {
148 }
149
150#if defined(BOTAN_HAS_PAKE_SPAKE2PLUS)
151 return ffi_guard_thunk(__func__, [=]() -> int {
153 password,
154 spake2p_opt_span(prover_id, prover_id_len),
155 spake2p_opt_span(verifier_id, verifier_id_len),
156 spake2p_opt_span(salt, salt_len));
157 return invoke_view_callback(view, ctx, sec.serialize());
158 });
159#else
160 BOTAN_UNUSED(params, password, prover_id, prover_id_len, verifier_id, verifier_id_len);
161 BOTAN_UNUSED(salt, salt_len, ctx, view);
163#endif
164}
#define BOTAN_UNUSED
Definition assert.h:151
static ProverSecret from_password(const SystemParameters &params, std::string_view password, std::span< const uint8_t > prover_id, std::span< const uint8_t > verifier_id, std::span< const uint8_t > salt)
Definition spake2p.cpp:288
@ BOTAN_FFI_ERROR_NOT_IMPLEMENTED
Definition ffi.h:138
@ BOTAN_FFI_ERROR_NULL_POINTER
Definition ffi.h:131
int invoke_view_callback(botan_view_bin_fn view, botan_view_ctx ctx, std::span< const uint8_t > buf)
Definition ffi_util.h:359
auto safe_get(T *p) -> typename T::element_type &
Definition ffi_util.h:191
int ffi_guard_thunk(const char *func_name, T thunk)
Definition ffi_util.h:229
bool any_null_pointers(Ptrs... ptr)
Definition mem_utils.h:54

References Botan_FFI::any_null_pointers(), BOTAN_FFI_ERROR_NOT_IMPLEMENTED, BOTAN_FFI_ERROR_NULL_POINTER, BOTAN_UNUSED, Botan_FFI::ffi_guard_thunk(), Botan::SPAKE2p::ProverSecret::from_password(), Botan_FFI::invoke_view_callback(), and Botan_FFI::safe_get().

◆ botan_spake2p_params_confirmation_size()

int botan_spake2p_params_confirmation_size ( botan_spake2p_params_t params,
size_t * confirmation_size )

Return the size in bytes of a SPAKE2+ key confirmation message (confirmP or confirmV)

Parameters
paramsthe SPAKE2+ system parameters
confirmation_sizeoutput parameter for the key confirmation size

Definition at line 120 of file ffi_spake2p.cpp.

120 {
121 if(any_null_pointers(params, confirmation_size)) {
123 }
124
125#if defined(BOTAN_HAS_PAKE_SPAKE2PLUS)
126 return BOTAN_FFI_VISIT(params, [=](const auto& p) -> int {
127 *confirmation_size = p.confirmation_size();
128 return BOTAN_FFI_SUCCESS;
129 });
130#else
131 BOTAN_UNUSED(params, confirmation_size);
133#endif
134}
@ BOTAN_FFI_SUCCESS
Definition ffi.h:114
#define BOTAN_FFI_VISIT(obj, lambda)
Definition ffi_util.h:327

References Botan_FFI::any_null_pointers(), BOTAN_FFI_ERROR_NOT_IMPLEMENTED, BOTAN_FFI_ERROR_NULL_POINTER, BOTAN_FFI_SUCCESS, BOTAN_FFI_VISIT, and BOTAN_UNUSED.

◆ botan_spake2p_params_destroy()

int botan_spake2p_params_destroy ( botan_spake2p_params_t params)

Frees all resources of SPAKE2+ system parameters

Definition at line 101 of file ffi_spake2p.cpp.

101 {
102 return BOTAN_FFI_CHECKED_DELETE(params);
103}
#define BOTAN_FFI_CHECKED_DELETE(o)
Definition ffi_util.h:357

References BOTAN_FFI_CHECKED_DELETE.

◆ botan_spake2p_params_init()

int botan_spake2p_params_init ( botan_spake2p_params_t * params,
const char * ciphersuite )

Create SPAKE2+ system parameters from an RFC 9383 ciphersuite name

Objects created from the system parameters hold their own copy, so the parameters may be destroyed at any time.

Parameters
paramsoutput parameter for the created system parameters
ciphersuitethe SPAKE2+ ciphersuite name

Definition at line 67 of file ffi_spake2p.cpp.

67 {
68 if(any_null_pointers(params, ciphersuite)) {
70 }
71
72#if defined(BOTAN_HAS_PAKE_SPAKE2PLUS)
73 return ffi_guard_thunk(__func__, [=]() -> int {
74 *params = nullptr;
75 auto p = std::make_unique<Botan::SPAKE2p::SystemParameters>(spake2p_params_from_name(ciphersuite));
76 return ffi_new_object(params, std::move(p));
77 });
78#else
80#endif
81}
BOTAN_FFI_ERROR ffi_new_object(T *obj, Args &&... args)
Definition ffi_util.h:347

References Botan_FFI::any_null_pointers(), BOTAN_FFI_ERROR_NOT_IMPLEMENTED, BOTAN_FFI_ERROR_NULL_POINTER, Botan_FFI::ffi_guard_thunk(), and Botan_FFI::ffi_new_object().

◆ botan_spake2p_params_init_custom()

int botan_spake2p_params_init_custom ( botan_spake2p_params_t * params,
botan_ec_group_t group,
const uint8_t seed[],
size_t seed_len,
const char * hash_fn )

Create custom SPAKE2+ system parameters for an arbitrary group

The M/N group elements are derived from the seed using hash to curve; returns BOTAN_FFI_ERROR_NOT_IMPLEMENTED if the group does not support hash to curve. Both peers must use the same group, seed, and hash.

If the seed includes the identities of the participants, this additionally makes the scheme "quantum annoying", in that an attacker with a discrete logarithm oracle must compute a new discrete log for each (prover, verifier) pair they wish to attack.

Parameters
paramsoutput parameter for the created system parameters
groupthe elliptic curve group to use
SEEDthe seed bytes used to derive the M/N group elements
seed_lenlength of seed in bytes
hash_fnthe hash function to use (eg "SHA-256")

Definition at line 83 of file ffi_spake2p.cpp.

84 {
85 if(any_null_pointers(params, group, hash_fn)) {
87 }
88
89#if defined(BOTAN_HAS_PAKE_SPAKE2PLUS)
90 return ffi_guard_thunk(__func__, [=]() -> int {
91 auto p = std::make_unique<Botan::SPAKE2p::SystemParameters>(
92 Botan::SPAKE2p::SystemParameters::custom(safe_get(group), spake2p_opt_span(seed, seed_len), hash_fn));
93 return ffi_new_object(params, std::move(p));
94 });
95#else
96 BOTAN_UNUSED(params, group, seed, seed_len, hash_fn);
98#endif
99}
static SystemParameters custom(const EC_Group &group, std::span< const uint8_t > seed, std::string_view hash_fn)
Definition spake2p.cpp:222

References Botan_FFI::any_null_pointers(), BOTAN_FFI_ERROR_NOT_IMPLEMENTED, BOTAN_FFI_ERROR_NULL_POINTER, BOTAN_UNUSED, Botan::SPAKE2p::SystemParameters::custom(), Botan_FFI::ffi_guard_thunk(), Botan_FFI::ffi_new_object(), and Botan_FFI::safe_get().

◆ botan_spake2p_params_share_size()

int botan_spake2p_params_share_size ( botan_spake2p_params_t params,
size_t * share_size )

Return the size in bytes of a SPAKE2+ key share (shareP or shareV)

Parameters
paramsthe SPAKE2+ system parameters
share_sizeoutput parameter for the key share size

Definition at line 105 of file ffi_spake2p.cpp.

105 {
106#if defined(BOTAN_HAS_PAKE_SPAKE2PLUS)
107 return BOTAN_FFI_VISIT(params, [=](const auto& p) -> int {
108 if(share_size == nullptr) {
110 }
111 *share_size = p.share_size();
112 return BOTAN_FFI_SUCCESS;
113 });
114#else
115 BOTAN_UNUSED(params, share_size);
117#endif
118}

References BOTAN_FFI_ERROR_NOT_IMPLEMENTED, BOTAN_FFI_ERROR_NULL_POINTER, BOTAN_FFI_SUCCESS, BOTAN_FFI_VISIT, and BOTAN_UNUSED.

◆ botan_spake2p_prover_destroy()

int botan_spake2p_prover_destroy ( botan_spake2p_prover_t prover)

Frees all resources of a SPAKE2+ prover

Definition at line 220 of file ffi_spake2p.cpp.

220 {
221 return BOTAN_FFI_CHECKED_DELETE(prover);
222}

References BOTAN_FFI_CHECKED_DELETE.

◆ botan_spake2p_prover_generate_message()

int botan_spake2p_prover_generate_message ( botan_spake2p_prover_t prover,
botan_rng_t rng,
botan_view_ctx ctx,
botan_view_bin_fn view )

Generate the prover's key share (shareP), which is sent to the verifier

This can be called only once per prover object.

Parameters
proverthe prover object
Random Number Generatorsa random number generator
ctxa context pointer passed to the view callback
viewa view callback which is invoked with the key share

Definition at line 224 of file ffi_spake2p.cpp.

227 {
228#if defined(BOTAN_HAS_PAKE_SPAKE2PLUS)
229 return BOTAN_FFI_VISIT(
230 prover, [=](auto& p) -> int { return invoke_view_callback(view, ctx, p.generate_message(safe_get(rng))); });
231#else
232 BOTAN_UNUSED(prover, rng, ctx, view);
234#endif
235}

References BOTAN_FFI_ERROR_NOT_IMPLEMENTED, BOTAN_FFI_VISIT, BOTAN_UNUSED, Botan_FFI::invoke_view_callback(), and Botan_FFI::safe_get().

◆ botan_spake2p_prover_init()

int botan_spake2p_prover_init ( botan_spake2p_prover_t * prover,
botan_spake2p_params_t params,
const uint8_t secret[],
size_t secret_len,
const uint8_t prover_id[],
size_t prover_id_len,
const uint8_t verifier_id[],
size_t verifier_id_len,
const uint8_t context[],
size_t context_len )

Initialize a SPAKE2+ prover

The identities and context must be agreed upon by both parties; the identities must additionally match the values used when deriving the prover secret.

Parameters
proveroutput parameter for the created prover object
paramsthe SPAKE2+ system parameters
secretthe serialized prover secret
secret_lenlength of secret in bytes
prover_idthe identity of the prover
prover_id_lenlength of prover_id in bytes
verifier_idthe identity of the verifier
verifier_id_lenlength of verifier_id in bytes
contextan application specific context string
context_lenlength of context in bytes

Definition at line 187 of file ffi_spake2p.cpp.

196 {
197#if defined(BOTAN_HAS_PAKE_SPAKE2PLUS)
198 if(any_null_pointers(prover, params, secret)) {
200 }
201
202 return ffi_guard_thunk(__func__, [=]() -> int {
203 *prover = nullptr;
204 const auto& p = safe_get(params);
205 const auto sec = Botan::SPAKE2p::ProverSecret::deserialize(p, {secret, secret_len});
206 auto ctx = std::make_unique<Botan::SPAKE2p::ProverContext>(p,
207 sec,
208 spake2p_opt_span(prover_id, prover_id_len),
209 spake2p_opt_span(verifier_id, verifier_id_len),
210 spake2p_opt_span(context, context_len));
211 return ffi_new_object(prover, std::move(ctx));
212 });
213#else
214 BOTAN_UNUSED(prover, params, secret, secret_len, prover_id, prover_id_len);
215 BOTAN_UNUSED(verifier_id, verifier_id_len, context, context_len);
217#endif
218}
static ProverSecret deserialize(const SystemParameters &params, std::span< const uint8_t > secret)
Definition spake2p.cpp:301

References Botan_FFI::any_null_pointers(), BOTAN_FFI_ERROR_NOT_IMPLEMENTED, BOTAN_FFI_ERROR_NULL_POINTER, BOTAN_UNUSED, Botan::SPAKE2p::ProverSecret::deserialize(), Botan_FFI::ffi_guard_thunk(), Botan_FFI::ffi_new_object(), and Botan_FFI::safe_get().

◆ botan_spake2p_prover_process_message()

int botan_spake2p_prover_process_message ( botan_spake2p_prover_t prover,
botan_rng_t rng,
const uint8_t peer_message[],
size_t peer_message_len,
botan_view_ctx ctx,
botan_view_bin_fn view )

Consume the verifier's response (shareV followed by confirmV) and produce the prover's key confirmation (confirmP), which is sent to the verifier.

Returns BOTAN_FFI_ERROR_BAD_MAC if the verifier's key confirmation is wrong, typically meaning the passwords do not match.

Parameters
proverthe prover object
Random Number Generatorsa random number generator
peer_messagethe verifier's response
peer_message_lenlength of peer_message in bytes
ctxa context pointer passed to the view callback
viewa view callback which is invoked with the prover's key confirmation

Definition at line 237 of file ffi_spake2p.cpp.

242 {
243 if(any_null_pointers(peer_message)) {
245 }
246#if defined(BOTAN_HAS_PAKE_SPAKE2PLUS)
247 return BOTAN_FFI_VISIT(prover, [=](auto& p) -> int {
248 return invoke_view_callback(view, ctx, p.process_message({peer_message, peer_message_len}, safe_get(rng)));
249 });
250#else
251 BOTAN_UNUSED(prover, rng, peer_message, peer_message_len, ctx, view);
253#endif
254}

References Botan_FFI::any_null_pointers(), BOTAN_FFI_ERROR_NOT_IMPLEMENTED, BOTAN_FFI_ERROR_NULL_POINTER, BOTAN_FFI_VISIT, BOTAN_UNUSED, Botan_FFI::invoke_view_callback(), and Botan_FFI::safe_get().

◆ botan_spake2p_prover_shared_secret()

int botan_spake2p_prover_shared_secret ( botan_spake2p_prover_t prover,
botan_view_ctx ctx,
botan_view_bin_fn view )

Return the prover's shared secret (K_shared)

This may be called only after botan_spake2p_prover_process_message has succeeded.

Parameters
proverthe prover object
ctxa context pointer passed to the view callback
viewa view callback which is invoked with the shared secret

Definition at line 256 of file ffi_spake2p.cpp.

256 {
257#if defined(BOTAN_HAS_PAKE_SPAKE2PLUS)
258 return BOTAN_FFI_VISIT(prover, [=](auto& p) -> int { return invoke_view_callback(view, ctx, p.shared_secret()); });
259#else
260 BOTAN_UNUSED(prover, ctx, view);
262#endif
263}

References BOTAN_FFI_ERROR_NOT_IMPLEMENTED, BOTAN_FFI_VISIT, BOTAN_UNUSED, and Botan_FFI::invoke_view_callback().

◆ botan_spake2p_registration_record()

int botan_spake2p_registration_record ( botan_spake2p_params_t params,
botan_rng_t rng,
const uint8_t secret[],
size_t secret_len,
botan_view_ctx ctx,
botan_view_bin_fn view )

Compute a SPAKE2+ registration record (w0 and L) from a prover secret

The registration record is provided to the verifier during registration. While it does not allow directly impersonating the prover, it does allow offline password guessing attacks, so it should be protected.

Parameters
paramsthe SPAKE2+ system parameters
Random Number Generatorsa random number generator
secretthe serialized prover secret
secret_lenlength of secret in bytes
ctxa context pointer passed to the view callback
viewa view callback which is invoked with the serialized registration record

Definition at line 166 of file ffi_spake2p.cpp.

171 {
172#if defined(BOTAN_HAS_PAKE_SPAKE2PLUS)
173 if(any_null_pointers(params, rng, secret)) {
175 }
176
177 return ffi_guard_thunk(__func__, [=]() -> int {
178 const auto sec = Botan::SPAKE2p::ProverSecret::deserialize(safe_get(params), {secret, secret_len});
179 return invoke_view_callback(view, ctx, sec.registration_record(safe_get(rng)).serialize());
180 });
181#else
182 BOTAN_UNUSED(params, rng, secret, secret_len, ctx, view);
184#endif
185}

References Botan_FFI::any_null_pointers(), BOTAN_FFI_ERROR_NOT_IMPLEMENTED, BOTAN_FFI_ERROR_NULL_POINTER, BOTAN_UNUSED, Botan::SPAKE2p::ProverSecret::deserialize(), Botan_FFI::ffi_guard_thunk(), Botan_FFI::invoke_view_callback(), and Botan_FFI::safe_get().

◆ botan_spake2p_verifier_destroy()

int botan_spake2p_verifier_destroy ( botan_spake2p_verifier_t verifier)

Frees all resources of a SPAKE2+ verifier

Definition at line 298 of file ffi_spake2p.cpp.

298 {
299 return BOTAN_FFI_CHECKED_DELETE(verifier);
300}

References BOTAN_FFI_CHECKED_DELETE.

◆ botan_spake2p_verifier_init()

int botan_spake2p_verifier_init ( botan_spake2p_verifier_t * verifier,
botan_spake2p_params_t params,
const uint8_t record[],
size_t record_len,
const uint8_t prover_id[],
size_t prover_id_len,
const uint8_t verifier_id[],
size_t verifier_id_len,
const uint8_t context[],
size_t context_len )

Initialize a SPAKE2+ verifier

The identities and context must be agreed upon by both parties; the identities must additionally match the values used when deriving the prover secret.

Parameters
verifieroutput parameter for the created verifier object
paramsthe SPAKE2+ system parameters
recordthe serialized registration record
record_lenlength of record in bytes
prover_idthe identity of the prover
prover_id_lenlength of prover_id in bytes
verifier_idthe identity of the verifier
verifier_id_lenlength of verifier_id in bytes
contextan application specific context string
context_lenlength of context in bytes

Definition at line 265 of file ffi_spake2p.cpp.

274 {
275 if(any_null_pointers(verifier, record)) {
277 }
278
279#if defined(BOTAN_HAS_PAKE_SPAKE2PLUS)
280 return ffi_guard_thunk(__func__, [=]() -> int {
281 *verifier = nullptr;
282 const auto& p = safe_get(params);
283 const auto rec = Botan::SPAKE2p::RegistrationRecord::deserialize(p, {record, record_len});
284 auto ctx = std::make_unique<Botan::SPAKE2p::VerifierContext>(p,
285 rec,
286 spake2p_opt_span(prover_id, prover_id_len),
287 spake2p_opt_span(verifier_id, verifier_id_len),
288 spake2p_opt_span(context, context_len));
289 return ffi_new_object(verifier, std::move(ctx));
290 });
291#else
292 BOTAN_UNUSED(verifier, params, record, record_len, prover_id, prover_id_len);
293 BOTAN_UNUSED(verifier_id, verifier_id_len, context, context_len);
295#endif
296}
static RegistrationRecord deserialize(const SystemParameters &params, std::span< const uint8_t > record)
Definition spake2p.cpp:262

References Botan_FFI::any_null_pointers(), BOTAN_FFI_ERROR_NOT_IMPLEMENTED, BOTAN_FFI_ERROR_NULL_POINTER, BOTAN_UNUSED, Botan::SPAKE2p::RegistrationRecord::deserialize(), Botan_FFI::ffi_guard_thunk(), Botan_FFI::ffi_new_object(), and Botan_FFI::safe_get().

◆ botan_spake2p_verifier_process_message()

int botan_spake2p_verifier_process_message ( botan_spake2p_verifier_t verifier,
botan_rng_t rng,
const uint8_t peer_message[],
size_t peer_message_len,
botan_view_ctx ctx,
botan_view_bin_fn view )

Consume the prover's key share (shareP) and produce the verifier's response (shareV followed by confirmV), which is sent to the prover.

This can be called only once per verifier object.

Parameters
verifierthe verifier object
Random Number Generatorsa random number generator
peer_messagethe prover's key share
peer_message_lenlength of peer_message in bytes
ctxa context pointer passed to the view callback
viewa view callback which is invoked with the verifier's response

Definition at line 302 of file ffi_spake2p.cpp.

307 {
308 if(any_null_pointers(peer_message)) {
310 }
311
312#if defined(BOTAN_HAS_PAKE_SPAKE2PLUS)
313 return BOTAN_FFI_VISIT(verifier, [=](auto& v) -> int {
314 return invoke_view_callback(view, ctx, v.process_message({peer_message, peer_message_len}, safe_get(rng)));
315 });
316#else
317 BOTAN_UNUSED(verifier, rng, peer_message, peer_message_len, ctx, view);
319#endif
320}

References Botan_FFI::any_null_pointers(), BOTAN_FFI_ERROR_NOT_IMPLEMENTED, BOTAN_FFI_ERROR_NULL_POINTER, BOTAN_FFI_VISIT, BOTAN_UNUSED, Botan_FFI::invoke_view_callback(), and Botan_FFI::safe_get().

◆ botan_spake2p_verifier_shared_secret()

int botan_spake2p_verifier_shared_secret ( botan_spake2p_verifier_t verifier,
botan_view_ctx ctx,
botan_view_bin_fn view )

Return the verifier's shared secret (K_shared)

This may be called only after botan_spake2p_verifier_verify_confirmation has succeeded, or after botan_spake2p_verifier_skip_confirmation.

Parameters
verifierthe verifier object
ctxa context pointer passed to the view callback
viewa view callback which is invoked with the shared secret

Definition at line 352 of file ffi_spake2p.cpp.

354 {
355#if defined(BOTAN_HAS_PAKE_SPAKE2PLUS)
356 return BOTAN_FFI_VISIT(verifier, [=](auto& v) -> int { return invoke_view_callback(view, ctx, v.shared_secret()); });
357#else
358 BOTAN_UNUSED(verifier, ctx, view);
360#endif
361}

References BOTAN_FFI_ERROR_NOT_IMPLEMENTED, BOTAN_FFI_VISIT, BOTAN_UNUSED, and Botan_FFI::invoke_view_callback().

◆ botan_spake2p_verifier_skip_confirmation()

int botan_spake2p_verifier_skip_confirmation ( botan_spake2p_verifier_t verifier)

Skip checking the prover's key confirmation (confirmP)

This can be called after botan_spake2p_verifier_process_message, in place of botan_spake2p_verifier_verify_confirmation, to allow extracting the shared secret without having checked the prover's key confirmation.

Warning: after calling this, nothing is known about the peer; only a prover which knows the password can compute the same shared secret, but no evidence of this has been received. It is intended solely for protocols which embed SPAKE2+ and perform the prover's key confirmation themselves, for example the proposed TLS PAKE extension, where the TLS handshake takes the place of confirmP. Anywhere else, use botan_spake2p_verifier_verify_confirmation.

Parameters
verifierthe verifier object

Definition at line 340 of file ffi_spake2p.cpp.

340 {
341#if defined(BOTAN_HAS_PAKE_SPAKE2PLUS)
342 return BOTAN_FFI_VISIT(verifier, [](auto& v) -> int {
343 v.skip_confirmation();
344 return BOTAN_FFI_SUCCESS;
345 });
346#else
347 BOTAN_UNUSED(verifier);
349#endif
350}

References BOTAN_FFI_ERROR_NOT_IMPLEMENTED, BOTAN_FFI_SUCCESS, BOTAN_FFI_VISIT, and BOTAN_UNUSED.

◆ botan_spake2p_verifier_verify_confirmation()

int botan_spake2p_verifier_verify_confirmation ( botan_spake2p_verifier_t verifier,
const uint8_t confirmation[],
size_t confirmation_len )

Check the prover's key confirmation (confirmP)

Returns BOTAN_FFI_ERROR_BAD_MAC if the confirmation is wrong, meaning the prover does not know the password.

Parameters
verifierthe verifier object
confirmationthe prover's key confirmation
confirmation_lenlength of confirmation in bytes

Definition at line 322 of file ffi_spake2p.cpp.

324 {
325 if(confirmation == nullptr) {
327 }
328
329#if defined(BOTAN_HAS_PAKE_SPAKE2PLUS)
330 return BOTAN_FFI_VISIT(verifier, [=](auto& v) -> int {
331 v.verify_confirmation({confirmation, confirmation_len});
332 return BOTAN_FFI_SUCCESS;
333 });
334#else
335 BOTAN_UNUSED(verifier, confirmation, confirmation_len);
337#endif
338}

References BOTAN_FFI_ERROR_NOT_IMPLEMENTED, BOTAN_FFI_ERROR_NULL_POINTER, BOTAN_FFI_SUCCESS, BOTAN_FFI_VISIT, and BOTAN_UNUSED.