|
Botan 3.13.0
Crypto and TLS for C&
|
#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) |
| 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 ) |
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.
| params | the SPAKE2+ system parameters |
| password | the (null terminated) password |
| prover_id | the identity of the prover |
| prover_id_len | length of prover_id in bytes |
| verifier_id | the identity of the verifier |
| verifier_id_len | length of verifier_id in bytes |
| salt | a salt value, ideally random and stored with the registration record |
| salt_len | length of salt in bytes |
| ctx | a context pointer passed to the view callback |
| view | a view callback which is invoked with the serialized prover secret |
Definition at line 137 of file ffi_spake2p.cpp.
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().
| 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)
| params | the SPAKE2+ system parameters |
| confirmation_size | output parameter for the key confirmation size |
Definition at line 121 of file ffi_spake2p.cpp.
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.
| 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.
References BOTAN_FFI_CHECKED_DELETE.
| 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.
| params | output parameter for the created system parameters |
| ciphersuite | the SPAKE2+ ciphersuite name |
Definition at line 68 of file ffi_spake2p.cpp.
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().
| 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.
| params | output parameter for the created system parameters |
| group | the elliptic curve group to use |
| SEED | the seed bytes used to derive the M/N group elements |
| seed_len | length of seed in bytes |
| hash_fn | the hash function to use (eg "SHA-256") |
Definition at line 84 of file ffi_spake2p.cpp.
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().
| 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)
| params | the SPAKE2+ system parameters |
| share_size | output parameter for the key share size |
Definition at line 106 of file ffi_spake2p.cpp.
References BOTAN_FFI_ERROR_NOT_IMPLEMENTED, BOTAN_FFI_ERROR_NULL_POINTER, BOTAN_FFI_SUCCESS, BOTAN_FFI_VISIT, and BOTAN_UNUSED.
| 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.
References BOTAN_FFI_CHECKED_DELETE.
| 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.
| prover | the prover object |
| Random Number Generators | a random number generator |
| ctx | a context pointer passed to the view callback |
| view | a view callback which is invoked with the key share |
Definition at line 225 of file ffi_spake2p.cpp.
References BOTAN_FFI_ERROR_NOT_IMPLEMENTED, BOTAN_FFI_VISIT, BOTAN_UNUSED, Botan_FFI::invoke_view_callback(), and Botan_FFI::safe_get().
| 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.
| prover | output parameter for the created prover object |
| params | the SPAKE2+ system parameters |
| secret | the serialized prover secret |
| secret_len | length of secret in bytes |
| prover_id | the identity of the prover |
| prover_id_len | length of prover_id in bytes |
| verifier_id | the identity of the verifier |
| verifier_id_len | length of verifier_id in bytes |
| context | an application specific context string |
| context_len | length of context in bytes |
Definition at line 188 of file ffi_spake2p.cpp.
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().
| 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.
| prover | the prover object |
| Random Number Generators | a random number generator |
| peer_message | the verifier's response |
| peer_message_len | length of peer_message in bytes |
| ctx | a context pointer passed to the view callback |
| view | a view callback which is invoked with the prover's key confirmation |
Definition at line 238 of file ffi_spake2p.cpp.
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().
| 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.
| prover | the prover object |
| ctx | a context pointer passed to the view callback |
| view | a view callback which is invoked with the shared secret |
Definition at line 257 of file ffi_spake2p.cpp.
References BOTAN_FFI_ERROR_NOT_IMPLEMENTED, BOTAN_FFI_VISIT, BOTAN_UNUSED, and Botan_FFI::invoke_view_callback().
| 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.
| params | the SPAKE2+ system parameters |
| Random Number Generators | a random number generator |
| secret | the serialized prover secret |
| secret_len | length of secret in bytes |
| ctx | a context pointer passed to the view callback |
| view | a view callback which is invoked with the serialized registration record |
Definition at line 167 of file ffi_spake2p.cpp.
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().
| 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.
References BOTAN_FFI_CHECKED_DELETE.
| 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.
| verifier | output parameter for the created verifier object |
| params | the SPAKE2+ system parameters |
| record | the serialized registration record |
| record_len | length of record in bytes |
| prover_id | the identity of the prover |
| prover_id_len | length of prover_id in bytes |
| verifier_id | the identity of the verifier |
| verifier_id_len | length of verifier_id in bytes |
| context | an application specific context string |
| context_len | length of context in bytes |
Definition at line 266 of file ffi_spake2p.cpp.
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().
| 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.
| verifier | the verifier object |
| Random Number Generators | a random number generator |
| peer_message | the prover's key share |
| peer_message_len | length of peer_message in bytes |
| ctx | a context pointer passed to the view callback |
| view | a view callback which is invoked with the verifier's response |
Definition at line 303 of file ffi_spake2p.cpp.
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().
| 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.
| verifier | the verifier object |
| ctx | a context pointer passed to the view callback |
| view | a view callback which is invoked with the shared secret |
Definition at line 353 of file ffi_spake2p.cpp.
References BOTAN_FFI_ERROR_NOT_IMPLEMENTED, BOTAN_FFI_VISIT, BOTAN_UNUSED, and Botan_FFI::invoke_view_callback().
| 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.
| verifier | the verifier object |
Definition at line 341 of file ffi_spake2p.cpp.
References BOTAN_FFI_ERROR_NOT_IMPLEMENTED, BOTAN_FFI_SUCCESS, BOTAN_FFI_VISIT, and BOTAN_UNUSED.
| 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.
| verifier | the verifier object |
| confirmation | the prover's key confirmation |
| confirmation_len | length of confirmation in bytes |
Definition at line 323 of file ffi_spake2p.cpp.
References BOTAN_FFI_ERROR_NOT_IMPLEMENTED, BOTAN_FFI_ERROR_NULL_POINTER, BOTAN_FFI_SUCCESS, BOTAN_FFI_VISIT, and BOTAN_UNUSED.