11#include <botan/ber_dec.h>
12#include <botan/der_enc.h>
14#include <botan/internal/ct_utils.h>
15#include <botan/internal/pk_ops_impl.h>
16#include <botan/internal/x448_internal.h>
21void x448_basepoint_from_data(std::span<uint8_t, X448_LEN> mypublic, std::span<const uint8_t, X448_LEN> secret) {
53 return std::make_unique<X448_PrivateKey>(rng);
69 m_private.assign(secret_key.begin(), secret_key.end());
71 x448_basepoint_from_data(
m_public, std::span(m_private).first<X448_LEN>());
86 std::array<uint8_t, X448_LEN> public_point;
89 x448_basepoint_from_data(public_point, std::span(m_private).first<X448_LEN>());
100 X448_KA_Operation(std::span<const uint8_t> sk, std::string_view kdf) :
101 PK_Ops::Key_Agreement_with_KDF(kdf), m_sk(sk.begin(), sk.end()) {
105 size_t agreed_value_size()
const override {
return X448_LEN; }
110 std::span<const uint8_t> w(w_data, w_len);
129 if(
CT::all_zeros(shared_secret.data(), shared_secret.size()).as_bool()) {
130 throw Invalid_Argument(
"X448 public point appears to be of low order");
133 return shared_secret;
143 std::string_view params,
144 std::string_view provider)
const {
145 if(provider ==
"base" || provider.empty()) {
146 return std::make_unique<X448_KA_Operation>(m_private, params);
#define BOTAN_ASSERT_NOMSG(expr)
#define BOTAN_ARG_CHECK(expr, msg)
virtual OID object_identifier() const
secure_vector< uint8_t > get_contents()
DER_Encoder & encode(bool b)
A private key for the X448 key agreement scheme according to RFC 7748.
std::unique_ptr< Public_Key > public_key() const override
secure_vector< uint8_t > private_key_bits() const override
X448_PrivateKey(const AlgorithmIdentifier &alg_id, std::span< const uint8_t > key_bits)
std::vector< uint8_t > public_value() const override
std::unique_ptr< PK_Ops::Key_Agreement > create_key_agreement_op(RandomNumberGenerator &rng, std::string_view params, std::string_view provider) const override
bool check_key(RandomNumberGenerator &rng, bool strong) const override
A public key for the X448 key agreement scheme according to RFC 7748.
AlgorithmIdentifier algorithm_identifier() const override
std::unique_ptr< Private_Key > generate_another(RandomNumberGenerator &rng) const final
std::vector< uint8_t > raw_public_key_bits() const override
std::vector< uint8_t > public_value() const
std::array< uint8_t, 56 > m_public
bool check_key(RandomNumberGenerator &rng, bool strong) const override
std::vector< uint8_t > public_key_bits() const override
std::string algo_name() const override
int(* final)(unsigned char *, CTX *)
constexpr auto scoped_poison(const Ts &... xs)
constexpr CT::Mask< T > is_equal(const T x[], const T y[], size_t len)
constexpr void unpoison(const T *p, size_t n)
constexpr CT::Mask< T > all_zeros(const T elem[], size_t len)
secure_vector< uint8_t > encode_point(const Point448 &p)
Encode a point to a 56 byte vector. RFC 7748 Section 5 (encodeUCoordinate)
Point448 x448_basepoint(const ScalarX448 &k)
Multiply a scalar with the base group element (5)
constexpr size_t X448_LEN
std::vector< T, secure_allocator< T > > secure_vector
Point448 x448(const ScalarX448 &k, const Point448 &u)
Multiply a scalar k with a point u.
constexpr void copy_mem(T *out, const T *in, size_t n)
Point448 decode_point(std::span< const uint8_t > p_bytes)
Decode a point from a byte array. RFC 7748 Section 5 (decodeUCoordinate)
ScalarX448 decode_scalar(std::span< const uint8_t > scalar_bytes)
Decode a scalar from a byte array. RFC 7748 Section 5 (decodeScalar448)