/* * X448 * (C) 2024 Jack Lloyd * 2024 Fabian Albert - Rohde & Schwarz Cybersecurity * * Botan is released under the Simplified BSD License (see license.txt) */ #ifndef BOTAN_X448_H_ #define BOTAN_X448_H_ #include #include namespace Botan { /** * @brief A public key for the X448 key agreement scheme according to RFC 7748. */ class BOTAN_PUBLIC_API(3, 4) X448_PublicKey : public virtual Public_Key { public: /** * Create a X448 Public Key. * @param alg_id the X.509 algorithm identifier * @param key_bits DER encoded public key bits */ X448_PublicKey(const AlgorithmIdentifier& alg_id, std::span key_bits); /** * Create a X448 Public Key. * @param pub 56-byte raw public key */ explicit X448_PublicKey(std::span pub); std::string algo_name() const override { return "X448"; } size_t estimated_strength() const override { return 224; } size_t key_length() const override { return 448; } bool check_key(RandomNumberGenerator& rng, bool strong) const override; AlgorithmIdentifier algorithm_identifier() const override; BOTAN_DEPRECATED("Use raw_public_key_bits") std::vector public_value() const { return raw_public_key_bits(); } std::vector raw_public_key_bits() const override; std::vector public_key_bits() const override; bool supports_operation(PublicKeyOperation op) const override { return (op == PublicKeyOperation::KeyAgreement); } std::unique_ptr generate_another(RandomNumberGenerator& rng) const final; protected: X448_PublicKey() = default; std::array m_public{}; // NOLINT(*non-private-member-variable*) }; BOTAN_DIAGNOSTIC_PUSH BOTAN_DIAGNOSTIC_IGNORE_INHERITED_VIA_DOMINANCE /** * @brief A private key for the X448 key agreement scheme according to RFC 7748. */ class BOTAN_PUBLIC_API(3, 4) X448_PrivateKey final : public X448_PublicKey, public virtual Private_Key, public virtual PK_Key_Agreement_Key { public: /** * Construct a private key from the specified parameters. * @param alg_id the X.509 algorithm identifier * @param key_bits PKCS #8 structure */ X448_PrivateKey(const AlgorithmIdentifier& alg_id, std::span key_bits); /** * Generate a private key. * @param rng the RNG to use */ explicit X448_PrivateKey(RandomNumberGenerator& rng); /** * Construct a private key from the specified parameters. * @param secret_key the private key */ explicit X448_PrivateKey(std::span secret_key); std::vector public_value() const override { return raw_public_key_bits(); } secure_vector raw_private_key_bits() const override { return {m_private.begin(), m_private.end()}; } secure_vector private_key_bits() const override; std::unique_ptr public_key() const override; bool check_key(RandomNumberGenerator& rng, bool strong) const override; std::unique_ptr create_key_agreement_op(RandomNumberGenerator& rng, std::string_view params, std::string_view provider) const override; private: secure_vector m_private; }; BOTAN_DIAGNOSTIC_POP } // namespace Botan #endif