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) {
27secure_vector<uint8_t> ber_decode_sk(std::span<const uint8_t> key_bits) {
28 secure_vector<uint8_t> decoded_bits;
49 return std::make_unique<X448_PrivateKey>(rng);
65 m_private = {secret_key.begin(), secret_key.end()};
66 x448_basepoint_from_data(
m_public, std::span(m_private).first<X448_LEN>());
72 x448_basepoint_from_data(
m_public, std::span(m_private).first<X448_LEN>());
84 std::array<uint8_t, X448_LEN> public_point;
86 x448_basepoint_from_data(public_point, std::span(m_private).first<X448_LEN>());
97 X448_KA_Operation(std::span<const uint8_t> sk, std::string_view kdf) :
98 PK_Ops::Key_Agreement_with_KDF(kdf), m_sk(sk.begin(), sk.end()) {
102 size_t agreed_value_size()
const override {
return X448_LEN; }
104 secure_vector<uint8_t> raw_agree(
const uint8_t w_data[],
size_t w_len)
override {
105 std::span<const uint8_t> w(w_data, w_len);
115 secure_vector<uint8_t> m_sk;
121 std::string_view params,
122 std::string_view provider)
const {
123 if(provider ==
"base" || provider.empty()) {
124 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)
void randomize(std::span< uint8_t > output)
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 > 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 CT::Mask< T > is_equal(const T x[], const T y[], 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)