Botan 3.13.0
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 137 of file ffi_spake2p.cpp.

146 {
147 if(any_null_pointers(params, password)) {
149 }
150
151#if defined(BOTAN_HAS_PAKE_SPAKE2PLUS)
152 return ffi_guard_thunk(__func__, [=]() -> int {
154 password,
155 spake2p_opt_span(prover_id, prover_id_len),
156 spake2p_opt_span(verifier_id, verifier_id_len),
157 spake2p_opt_span(salt, salt_len));
158 return invoke_view_callback(view, ctx, sec.serialize());
159 });
160#else
161 BOTAN_UNUSED(params, password, prover_id, prover_id_len, verifier_id, verifier_id_len);
162 BOTAN_UNUSED(salt, salt_len, ctx, view);
164#endif
165}
#define BOTAN_UNUSED
Definition assert.h:144
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:283
@ 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:190
T & safe_get(botan_struct< T, M > *p)
Definition ffi_util.h:79
int ffi_guard_thunk(const char *func_name, T thunk)
Definition ffi_util.h:95
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 121 of file ffi_spake2p.cpp.

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

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 102 of file ffi_spake2p.cpp.

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

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 68 of file ffi_spake2p.cpp.

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

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 84 of file ffi_spake2p.cpp.

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

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 106 of file ffi_spake2p.cpp.

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

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 221 of file ffi_spake2p.cpp.

221 {
222 return BOTAN_FFI_CHECKED_DELETE(prover);
223}

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 225 of file ffi_spake2p.cpp.

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

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 188 of file ffi_spake2p.cpp.

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

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 238 of file ffi_spake2p.cpp.

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

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 257 of file ffi_spake2p.cpp.

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

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 167 of file ffi_spake2p.cpp.

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

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 299 of file ffi_spake2p.cpp.

299 {
300 return BOTAN_FFI_CHECKED_DELETE(verifier);
301}

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 266 of file ffi_spake2p.cpp.

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

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 303 of file ffi_spake2p.cpp.

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

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 353 of file ffi_spake2p.cpp.

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

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 341 of file ffi_spake2p.cpp.

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

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 323 of file ffi_spake2p.cpp.

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

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