Botan 3.14.1
Crypto and TLS for C&
spake2p.cpp
Go to the documentation of this file.
1/*
2* (C) 2024,2025,2026 Jack Lloyd
3*
4* Botan is released under the Simplified BSD License (see license.txt)
5*/
6
7#include <botan/spake2p.h>
8
9#include <botan/exceptn.h>
10#include <botan/hash.h>
11#include <botan/hex.h>
12#include <botan/kdf.h>
13#include <botan/mac.h>
14#include <botan/mem_ops.h>
15#include <botan/pwdhash.h>
16#include <botan/internal/buffer_stuffer.h>
17#include <botan/internal/concat_util.h>
18#include <botan/internal/ct_utils.h>
19#include <botan/internal/fmt.h>
20#include <botan/internal/loadstor.h>
21#include <botan/internal/mem_utils.h>
22
23namespace Botan::SPAKE2p {
24
25namespace {
26
27std::array<uint8_t, 8> le64_length(std::span<const uint8_t> data) {
28 return store_le(static_cast<uint64_t>(data.size()));
29}
30
31std::pair<EC_Scalar, EC_Scalar> derive_w0_w1(const SystemParameters& params,
32 std::string_view password,
33 std::span<const uint8_t> prover_id,
34 std::span<const uint8_t> verifier_id,
35 std::span<const uint8_t> salt) {
36 /*
37 * RFC 9383 Section 3.2
38 *
39 * w0s || w1s = PBKDF(len(pw) || pw ||
40 * len(idProver) || idProver ||
41 * len(idVerifier) || idVerifier)
42 * w0 = w0s mod p
43 * w1 = w1s mod p
44 */
45 secure_vector<uint8_t> pbkdf_input(3 * 8 + password.size() + prover_id.size() + verifier_id.size());
46 BufferStuffer stuffer(pbkdf_input);
47
48 const auto append_with_le64_length = [&](std::span<const uint8_t> data) {
49 stuffer.append(le64_length(data));
50 stuffer.append(data);
51 };
52
53 append_with_le64_length(as_span_of_bytes(password));
54 append_with_le64_length(prover_id);
55 append_with_le64_length(verifier_id);
56 BOTAN_ASSERT_NOMSG(stuffer.full());
57
58 /*
59 * RFC 9106 Section 4
60 *
61 * If much less memory is available, a uniformly safe option is
62 * Argon2id with t=3 iterations, p=4 lanes, m=2^(16) (64 MiB of RAM)
63 */
64 auto pwhash = PasswordHashFamily::create_or_throw("Argon2id")->from_params(64 * 1024, 3, 4);
65
66 /*
67 * RFC 9383 Section 3.2
68 *
69 * To control bias, each half must be of length at least
70 * ceil(log2(p)) + k bits, with k >= 64
71 */
72 const size_t half_len = params.group().get_order_bytes() + 16;
73
74 secure_vector<uint8_t> w0s_w1s(2 * half_len);
75 const std::string_view pbkdf_input_sv(cast_uint8_ptr_to_char(pbkdf_input.data()), pbkdf_input.size());
76 pwhash->hash(w0s_w1s, pbkdf_input_sv, salt);
77
78 auto w0 = EC_Scalar::from_bytes_mod_order(params.group(), std::span{w0s_w1s}.first(half_len));
79 auto w1 = EC_Scalar::from_bytes_mod_order(params.group(), std::span{w0s_w1s}.last(half_len));
80
81 return {std::move(w0), std::move(w1)};
82}
83
84struct SessionKeys {
85 secure_vector<uint8_t> shared_key;
86 std::vector<uint8_t> confirm_p;
87 std::vector<uint8_t> confirm_v;
88};
89
90SessionKeys spake2p_key_schedule(const SystemParameters& params,
91 std::span<const uint8_t> context,
92 std::span<const uint8_t> prover_id,
93 std::span<const uint8_t> verifier_id,
94 std::span<const uint8_t> share_p,
95 std::span<const uint8_t> share_v,
96 const EC_AffinePoint& z,
97 const EC_AffinePoint& v,
98 const EC_Scalar& w0) {
99 auto hash = HashFunction::create_or_throw(params.hash_function());
100
101 const auto hash_with_le64_length = [&](std::span<const uint8_t> data) {
102 hash->update(le64_length(data));
103 hash->update(data);
104 };
105
106 /*
107 * RFC 9383 Section 3.3
108 *
109 * TT = len(Context) || Context
110 * || len(idProver) || idProver
111 * || len(idVerifier) || idVerifier
112 * || len(M) || M
113 * || len(N) || N
114 * || len(shareP) || shareP
115 * || len(shareV) || shareV
116 * || len(Z) || Z
117 * || len(V) || V
118 * || len(w0) || w0
119 */
120 hash_with_le64_length(context);
121 hash_with_le64_length(prover_id);
122 hash_with_le64_length(verifier_id);
123 hash_with_le64_length(params.spake2p_m().serialize_uncompressed());
124 hash_with_le64_length(params.spake2p_n().serialize_uncompressed());
125 hash_with_le64_length(share_p);
126 hash_with_le64_length(share_v);
127 hash_with_le64_length(z.serialize_uncompressed());
128 hash_with_le64_length(v.serialize_uncompressed());
129 hash_with_le64_length(w0.serialize());
130
131 const auto k_main = hash->final();
132
133 /*
134 * RFC 9383 Section 3.4
135 *
136 * K_main = Hash(TT)
137 * K_confirmP || K_confirmV = KDF(nil, K_main, "ConfirmationKeys")
138 * K_shared = KDF(nil, K_main, "SharedKey")
139 *
140 * confirmP = MAC(K_confirmP, shareV)
141 * confirmV = MAC(K_confirmV, shareP)
142 */
143 auto kdf = KDF::create_or_throw(fmt("HKDF({})", params.hash_function()));
144 auto mac = MessageAuthenticationCode::create_or_throw(fmt("HMAC({})", params.hash_function()));
145
146 const size_t mac_key_len = hash->output_length();
147 const auto confirm_keys = kdf->derive_key<secure_vector<uint8_t>>(2 * mac_key_len, k_main, "", "ConfirmationKeys");
148
149 SessionKeys keys;
150 keys.shared_key = kdf->derive_key<secure_vector<uint8_t>>(hash->output_length(), k_main, "", "SharedKey");
151
152 mac->set_key(std::span{confirm_keys}.first(mac_key_len));
153 mac->update(share_v);
154 keys.confirm_p = mac->final_stdvec();
155
156 mac->set_key(std::span{confirm_keys}.last(mac_key_len));
157 mac->update(share_p);
158 keys.confirm_v = mac->final_stdvec();
159
160 return keys;
161}
162
163std::tuple<EC_Group, EC_AffinePoint, EC_AffinePoint> spake2p_group_params(std::string_view group_name,
164 std::string_view m_hex,
165 std::string_view n_hex) {
166 auto group = EC_Group::from_name(group_name);
167 EC_AffinePoint m(group, hex_decode(m_hex));
168 EC_AffinePoint n(group, hex_decode(n_hex));
169 return {std::move(group), std::move(m), std::move(n)};
170}
171
172// The M/N constants from RFC 9383 Section 4
173
174constexpr std::string_view SPAKE2P_P256_M = "02886e2f97ace46e55ba9dd7242579f2993b64e16ef3dcab95afd497333d8fa12f";
175
176constexpr std::string_view SPAKE2P_P256_N = "03d8bbd6c639c62937b04d997f38c3770719c629d7014d49a24b4f98baa1292b49";
177
178constexpr std::string_view SPAKE2P_P384_M =
179 "030ff0895ae5ebf6187080a82d82b42e2765e3b2f8749c7e05eba366434b363d3dc36f15314739074d2eb8613fceec2853";
180
181constexpr std::string_view SPAKE2P_P384_N =
182 "02c72cf2e390853a1c1c4ad816a62fd15824f56078918f43f922ca21518f9c543bb252c5490214cf9aa3f0baab4b665c10";
183
184constexpr std::string_view SPAKE2P_P521_M =
185 "02003f06f38131b2ba2600791e82488e8d20ab889af753a41806c5db18d37d85608cfae06b82e4a72cd744c719193562a653ea1f119ee"
186 "f9356907edc9b56979962d7aa";
187
188constexpr std::string_view SPAKE2P_P521_N =
189 "0200c7924b9ec017f3094562894336a53c50167ba8c5963876880542bc669e494b2532d76c5b53dfb349fdf69154b9e0048c58a42e8ed"
190 "04cef052a3bc349d95575cd25";
191
192} // namespace
193
194SystemParameters::SystemParameters(EC_Group group, EC_AffinePoint m, EC_AffinePoint n, std::string_view hash_fn) :
195 m_group(std::move(group)), m_spake2p_m(std::move(m)), m_spake2p_n(std::move(n)), m_hash_fn(hash_fn) {}
196
198 auto [group, m, n] = spake2p_group_params("secp256r1", SPAKE2P_P256_M, SPAKE2P_P256_N);
199 return SystemParameters(std::move(group), std::move(m), std::move(n), "SHA-256");
200}
201
203 auto [group, m, n] = spake2p_group_params("secp256r1", SPAKE2P_P256_M, SPAKE2P_P256_N);
204 return SystemParameters(std::move(group), std::move(m), std::move(n), "SHA-512");
205}
206
208 auto [group, m, n] = spake2p_group_params("secp384r1", SPAKE2P_P384_M, SPAKE2P_P384_N);
209 return SystemParameters(std::move(group), std::move(m), std::move(n), "SHA-256");
210}
211
213 auto [group, m, n] = spake2p_group_params("secp384r1", SPAKE2P_P384_M, SPAKE2P_P384_N);
214 return SystemParameters(std::move(group), std::move(m), std::move(n), "SHA-512");
215}
216
218 auto [group, m, n] = spake2p_group_params("secp521r1", SPAKE2P_P521_M, SPAKE2P_P521_N);
219 return SystemParameters(std::move(group), std::move(m), std::move(n), "SHA-512");
220}
221
223 std::span<const uint8_t> seed,
224 std::string_view hash_fn) {
225 BOTAN_ARG_CHECK(group.has_cofactor() == false, "SPAKE2+ is not supported for groups with a cofactor");
226
227 if(!group.hash_to_curve_supported(hash_fn)) {
228 throw Not_Implemented("SPAKE2+ custom params require hash2curve support which is not available for this curve");
229 }
230
231 auto m = EC_AffinePoint::hash_to_curve_ro(group, hash_fn, seed, "SPAKE2+ M");
232 auto n = EC_AffinePoint::hash_to_curve_ro(group, hash_fn, seed, "SPAKE2+ N");
233
234 return SystemParameters(group, std::move(m), std::move(n), hash_fn);
235}
236
238 return 1 + 2 * m_group.get_p_bytes();
239}
240
242 if(m_hash_fn == "SHA-256") {
243 return 32;
244 } else if(m_hash_fn == "SHA-384") {
245 return 48;
246 } else if(m_hash_fn == "SHA-512") {
247 return 64;
248 } else {
249 return HashFunction::create_or_throw(m_hash_fn)->output_length();
250 }
251}
252
254 std::string_view password,
255 std::span<const uint8_t> prover_id,
256 std::span<const uint8_t> verifier_id,
257 std::span<const uint8_t> salt,
259 return ProverSecret::from_password(params, password, prover_id, verifier_id, salt).registration_record(rng);
260}
261
262RegistrationRecord RegistrationRecord::deserialize(const SystemParameters& params, std::span<const uint8_t> record) {
263 const size_t scalar_len = params.group().get_order_bytes();
264 const size_t point_len = params.share_size();
265
266 if(record.size() != scalar_len + point_len) {
267 throw Decoding_Error("Invalid length for SPAKE2+ registration record");
268 }
269
270 auto w0 = EC_Scalar::deserialize(params.group(), record.first(scalar_len));
271 auto l = EC_AffinePoint::deserialize_uncompressed(params.group(), record.last(point_len));
272
273 if(!w0 || !l) {
274 throw Decoding_Error("Invalid SPAKE2+ registration record");
275 }
276
277 return RegistrationRecord(std::move(*w0), std::move(*l));
278}
279
281 return concat<secure_vector<uint8_t>>(m_w0.serialize(), m_l.serialize_uncompressed());
282}
283
284ProverSecret::ProverSecret(EC_Scalar w0, EC_Scalar w1) : m_w0(std::move(w0)), m_w1(std::move(w1)) {
285 BOTAN_ARG_CHECK(m_w0.is_nonzero() && m_w1.is_nonzero(), "SPAKE2+ scalars w0 and w1 must be nonzero");
286}
287
289 std::string_view password,
290 std::span<const uint8_t> prover_id,
291 std::span<const uint8_t> verifier_id,
292 std::span<const uint8_t> salt) {
293 auto [w0, w1] = derive_w0_w1(params, password, prover_id, verifier_id, salt);
294 return ProverSecret(std::move(w0), std::move(w1));
295}
296
298 return ProverSecret(std::move(w0), std::move(w1));
299}
300
301ProverSecret ProverSecret::deserialize(const SystemParameters& params, std::span<const uint8_t> secret) {
302 if(auto w0_w1 = EC_Scalar::deserialize_pair(params.group(), secret)) {
303 return ProverSecret(std::move(w0_w1->first), std::move(w0_w1->second));
304 } else {
305 throw Decoding_Error("Invalid SPAKE2+ prover secret");
306 }
307}
308
312
314 const auto scope = CT::scoped_poison(m_w1);
315 // RFC 9383 Section 3.2: "the registration record L=w1*P"
317}
318
320 const ProverSecret& secret,
321 std::span<const uint8_t> prover_id,
322 std::span<const uint8_t> verifier_id,
323 std::span<const uint8_t> context) :
324 m_params(params),
325 m_secret(secret),
326 m_prover_id(prover_id.begin(), prover_id.end()),
327 m_verifier_id(verifier_id.begin(), verifier_id.end()),
328 m_context(context.begin(), context.end()) {}
329
331 BOTAN_STATE_CHECK(m_state == State::Initial);
332
333 const auto x = EC_Scalar::random(m_params.group(), rng);
334 const auto g = EC_AffinePoint::generator(m_params.group());
335
336 const auto scope = CT::scoped_poison(x, m_secret.m_w0);
337
338 // RFC 9383 Section 3.3: X = x*P + w0*M
339 if(auto share_p = EC_AffinePoint::mul_px_qy(g, x, m_params.spake2p_m(), m_secret.m_w0, rng)) {
340 CT::unpoison(*share_p);
341 m_our_message = std::make_pair(share_p->serialize_uncompressed(), x);
342 m_state = State::ShareGenerated;
343 return m_our_message->first;
344 } else {
345 throw Internal_Error("Computed the identity element during SPAKE2+ key exchange");
346 }
347}
348
349std::vector<uint8_t> ProverContext::process_message(std::span<const uint8_t> peer_message, RandomNumberGenerator& rng) {
350 BOTAN_STATE_CHECK(m_state == State::ShareGenerated && m_our_message.has_value());
351
352 // Any failure from here on is terminal, and destroys our ephemeral scalar x
353 m_state = State::Failed;
354 const auto our_message = std::exchange(m_our_message, std::nullopt);
355 const auto& share_p = our_message->first;
356 const auto& x = our_message->second;
357
358 const size_t share_size = m_params.share_size();
359 const size_t confirm_size = m_params.confirmation_size();
360
361 if(peer_message.size() != share_size + confirm_size) {
362 throw Decoding_Error("Invalid length for SPAKE2+ verifier message");
363 }
364
365 const auto share_v = peer_message.first(share_size);
366 const auto confirm_v = peer_message.last(confirm_size);
367
368 const auto y = EC_AffinePoint::deserialize_uncompressed(m_params.group(), share_v);
369 if(!y) {
370 throw Decoding_Error("Invalid SPAKE2+ key share");
371 }
372
373 const auto& w0 = m_secret.m_w0;
374 const auto& w1 = m_secret.m_w1;
375 const auto& n = m_params.spake2p_n();
376
377 const auto scope = CT::scoped_poison(x, w0, w1);
378
379 // RFC 9383 Section 3.3: Z = h*x*(Y - w0*N), V = h*w1*(Y - w0*N)
380 const auto z = EC_AffinePoint::mul_px_qy(*y, x, n, (x * w0).negate(), rng);
381 const auto v = EC_AffinePoint::mul_px_qy(*y, w1, n, (w1 * w0).negate(), rng);
382
383 if(!z || !v) {
384 throw Decoding_Error("Invalid SPAKE2+ key share");
385 }
386
387 auto keys = spake2p_key_schedule(m_params, m_context, m_prover_id, m_verifier_id, share_p, share_v, *z, *v, w0);
388 // Any further secret handling of the output is up to the caller
389 CT::unpoison_all(keys.shared_key, keys.confirm_p, keys.confirm_v);
390
391 if(!constant_time_compare(keys.confirm_v, confirm_v)) {
392 throw Invalid_Authentication_Tag("SPAKE2+ key confirmation failed");
393 }
394
395 m_shared_secret = std::move(keys.shared_key);
396 m_state = State::Complete;
397
398 return keys.confirm_p;
399}
400
402 BOTAN_STATE_CHECK(m_state == State::Complete);
403 return m_shared_secret;
404}
405
407 const RegistrationRecord& record,
408 std::span<const uint8_t> prover_id,
409 std::span<const uint8_t> verifier_id,
410 std::span<const uint8_t> context) :
411 m_params(params),
412 m_record(record),
413 m_prover_id(prover_id.begin(), prover_id.end()),
414 m_verifier_id(verifier_id.begin(), verifier_id.end()),
415 m_context(context.begin(), context.end()) {}
416
417std::vector<uint8_t> VerifierContext::process_message(std::span<const uint8_t> peer_message,
419 BOTAN_STATE_CHECK(m_state == State::Initial);
420
421 // Any failure from here on is terminal
422 m_state = State::Failed;
423
424 const auto x = EC_AffinePoint::deserialize_uncompressed(m_params.group(), peer_message);
425 if(!x) {
426 throw Decoding_Error("Invalid SPAKE2+ key share");
427 }
428
429 const auto& w0 = m_record.m_w0;
430
431 const auto y = EC_Scalar::random(m_params.group(), rng);
432 const auto g = EC_AffinePoint::generator(m_params.group());
433
434 const auto scope = CT::scoped_poison(y, w0);
435
436 // RFC 9383 Section 3.3: Y = y*P + w0*N
437 const auto share_v_pt = EC_AffinePoint::mul_px_qy(g, y, m_params.spake2p_n(), w0, rng);
438 CT::unpoison(share_v_pt);
439 if(!share_v_pt) {
440 throw Internal_Error("Computed the identity element during SPAKE2+ key exchange");
441 }
442 const auto share_v = share_v_pt->serialize_uncompressed();
443
444 // RFC 9383 Section 3.3: Z = h*y*(X - w0*M), V = h*y*L
445 const auto z = EC_AffinePoint::mul_px_qy(*x, y, m_params.spake2p_m(), (y * w0).negate(), rng);
446 if(!z) {
447 throw Decoding_Error("Invalid SPAKE2+ key share");
448 }
449 const auto v = m_record.m_l.mul(y, rng);
450
451 auto keys = spake2p_key_schedule(m_params, m_context, m_prover_id, m_verifier_id, peer_message, share_v, *z, v, w0);
452 // Any further secret handling of the output is up to the caller
453 CT::unpoison_all(keys.shared_key, keys.confirm_p, keys.confirm_v);
454
455 m_shared_secret = std::move(keys.shared_key);
456 m_expected_confirmation = std::move(keys.confirm_p);
457 m_state = State::Responded;
458
459 return concat<std::vector<uint8_t>>(share_v, keys.confirm_v);
460}
461
462void VerifierContext::verify_confirmation(std::span<const uint8_t> confirmation) {
463 BOTAN_STATE_CHECK(m_state == State::Responded);
464
465 if(!constant_time_compare(m_expected_confirmation, confirmation)) {
466 m_expected_confirmation.clear();
467 m_shared_secret.clear();
468 m_state = State::Failed;
469 throw Invalid_Authentication_Tag("SPAKE2+ key confirmation failed");
470 }
471
472 m_expected_confirmation.clear();
473 m_state = State::Complete;
474}
475
477 BOTAN_STATE_CHECK(m_state == State::Responded);
478
479 m_expected_confirmation.clear();
480 m_state = State::Complete;
481}
482
484 BOTAN_STATE_CHECK(m_state == State::Complete);
485 return m_shared_secret;
486}
487
488} // namespace Botan::SPAKE2p
#define BOTAN_ASSERT_NOMSG(expr)
Definition assert.h:82
#define BOTAN_STATE_CHECK(expr)
Definition assert.h:49
#define BOTAN_ARG_CHECK(expr, msg)
Definition assert.h:33
Helper class to ease in-place marshalling of concatenated fixed-length values.
constexpr void append(std::span< const uint8_t > buffer)
constexpr bool full() const
static EC_AffinePoint hash_to_curve_ro(const EC_Group &group, std::string_view hash_fn, std::span< const uint8_t > input, std::span< const uint8_t > domain_sep)
static std::optional< EC_AffinePoint > deserialize_uncompressed(const EC_Group &group, std::span< const uint8_t > bytes)
static std::optional< EC_AffinePoint > mul_px_qy(const EC_AffinePoint &p, const EC_Scalar &x, const EC_AffinePoint &q, const EC_Scalar &y, RandomNumberGenerator &rng)
static EC_AffinePoint g_mul(const EC_Scalar &scalar, RandomNumberGenerator &rng)
Multiply by the group generator returning a complete point.
T serialize_uncompressed() const
Definition ec_apoint.h:238
static EC_AffinePoint generator(const EC_Group &group)
Return the standard group generator.
Definition ec_apoint.cpp:84
static EC_Group from_name(std::string_view name)
Definition ec_group.cpp:529
size_t get_order_bytes() const
Definition ec_group.cpp:733
static std::optional< EC_Scalar > deserialize(const EC_Group &group, std::span< const uint8_t > bytes)
static T serialize_pair(const EC_Scalar &r, const EC_Scalar &s)
Definition ec_scalar.h:161
T serialize() const
Definition ec_scalar.h:144
static EC_Scalar from_bytes_mod_order(const EC_Group &group, std::span< const uint8_t > bytes)
Definition ec_scalar.cpp:68
bool is_nonzero() const
Definition ec_scalar.h:175
static EC_Scalar random(const EC_Group &group, RandomNumberGenerator &rng)
Definition ec_scalar.cpp:76
static std::optional< std::pair< EC_Scalar, EC_Scalar > > deserialize_pair(const EC_Group &group, std::span< const uint8_t > bytes)
static std::unique_ptr< HashFunction > create_or_throw(std::string_view algo_spec, std::string_view provider="")
Definition hash.cpp:311
static std::unique_ptr< KDF > create_or_throw(std::string_view algo_spec, std::string_view provider="")
Definition kdf.cpp:208
static std::unique_ptr< MessageAuthenticationCode > create_or_throw(std::string_view algo_spec, std::string_view provider="")
Definition mac.cpp:142
static std::unique_ptr< PasswordHashFamily > create_or_throw(std::string_view algo_spec, std::string_view provider="")
Definition pwdhash.cpp:125
std::vector< uint8_t > process_message(std::span< const uint8_t > peer_message, RandomNumberGenerator &rng)
Definition spake2p.cpp:349
std::vector< uint8_t > generate_message(RandomNumberGenerator &rng)
Definition spake2p.cpp:330
secure_vector< uint8_t > shared_secret() const
Definition spake2p.cpp:401
ProverContext(const SystemParameters &params, const ProverSecret &secret, std::span< const uint8_t > prover_id, std::span< const uint8_t > verifier_id, std::span< const uint8_t > context={})
Definition spake2p.cpp:319
static ProverSecret from_prehashed(EC_Scalar w0, EC_Scalar w1)
Definition spake2p.cpp:297
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
static ProverSecret deserialize(const SystemParameters &params, std::span< const uint8_t > secret)
Definition spake2p.cpp:301
RegistrationRecord registration_record(RandomNumberGenerator &rng) const
Definition spake2p.cpp:313
secure_vector< uint8_t > serialize() const
Definition spake2p.cpp:309
secure_vector< uint8_t > serialize() const
Definition spake2p.cpp:280
static RegistrationRecord deserialize(const SystemParameters &params, std::span< const uint8_t > record)
Definition spake2p.cpp:262
static RegistrationRecord 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, RandomNumberGenerator &rng)
Definition spake2p.cpp:253
const EC_Group & group() const
Definition spake2p.h:115
const EC_AffinePoint & spake2p_n() const
Definition spake2p.h:125
static SystemParameters rfc9383_p256_sha512()
Definition spake2p.cpp:202
static SystemParameters rfc9383_p521_sha512()
Definition spake2p.cpp:217
static SystemParameters rfc9383_p384_sha256()
Definition spake2p.cpp:207
const std::string & hash_function() const
Definition spake2p.h:130
static SystemParameters rfc9383_p256_sha256()
Definition spake2p.cpp:197
static SystemParameters rfc9383_p384_sha512()
Definition spake2p.cpp:212
const EC_AffinePoint & spake2p_m() const
Definition spake2p.h:120
static SystemParameters custom(const EC_Group &group, std::span< const uint8_t > seed, std::string_view hash_fn)
Definition spake2p.cpp:222
std::vector< uint8_t > process_message(std::span< const uint8_t > peer_message, RandomNumberGenerator &rng)
Definition spake2p.cpp:417
VerifierContext(const SystemParameters &params, const RegistrationRecord &record, std::span< const uint8_t > prover_id, std::span< const uint8_t > verifier_id, std::span< const uint8_t > context={})
Definition spake2p.cpp:406
secure_vector< uint8_t > shared_secret() const
Definition spake2p.cpp:483
void verify_confirmation(std::span< const uint8_t > confirmation)
Definition spake2p.cpp:462
constexpr decltype(auto) driveby_unpoison(T &&v)
Definition ct_utils.h:243
constexpr auto scoped_poison(const Ts &... xs)
Definition ct_utils.h:222
constexpr void unpoison_all(const Ts &... ts)
Definition ct_utils.h:207
constexpr void unpoison(const T *p, size_t n)
Definition ct_utils.h:67
std::span< const uint8_t > as_span_of_bytes(const char *s, size_t len)
Definition mem_utils.h:59
std::string fmt(std::string_view format, const T &... args)
Definition fmt.h:53
constexpr auto store_le(ParamTs &&... params)
Definition loadstor.h:736
constexpr auto concat(Rs &&... ranges)
Definition concat_util.h:95
size_t hex_decode(uint8_t output[], const char input[], size_t input_length, size_t &input_consumed, bool ignore_ws)
Definition hex.cpp:75
const char * cast_uint8_ptr_to_char(const uint8_t *b)
Definition mem_ops.h:323
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:128
bool constant_time_compare(std::span< const uint8_t > x, std::span< const uint8_t > y)
Definition mem_ops.cpp:17