11#include <botan/tls_messages.h>
13#include <botan/credentials_manager.h>
14#include <botan/pk_keys.h>
15#include <botan/tls_algos.h>
16#include <botan/tls_extensions.h>
17#include <botan/internal/stl_util.h>
18#include <botan/internal/tls_handshake_io.h>
19#include <botan/internal/tls_handshake_state.h>
20#include <botan/internal/tls_reader.h>
62 std::vector<uint8_t> buf;
70 throw Encoding_Error(
"Certificate_Verify signature too long to encode");
73 const uint16_t sig_len =
static_cast<uint16_t
>(
m_signature.size());
83 const Policy& policy)
const {
88 std::pair<std::string, Signature_Format> format =
91 const bool signature_valid =
94#if defined(BOTAN_UNSAFE_FUZZER_MODE)
99 return signature_valid;
104#if defined(BOTAN_HAS_TLS_13)
109 std::vector<uint8_t> msg(64, 0x20);
110 msg.reserve(64 + 33 + 1 + hash.size());
113 :
"TLS 1.3, client CertificateVerify";
115 msg.insert(msg.end(), context_string.cbegin(), context_string.cend());
118 msg.insert(msg.end(), hash.cbegin(), hash.cend());
122Signature_Scheme choose_signature_scheme(
const Private_Key& key,
123 const std::vector<Signature_Scheme>& allowed_schemes,
124 const std::vector<Signature_Scheme>& peer_allowed_schemes) {
125 for(Signature_Scheme scheme : allowed_schemes) {
126 if(scheme.is_available() && scheme.is_suitable_for(key) &&
value_exists(peer_allowed_schemes, scheme)) {
131 throw TLS_Exception(Alert::HandshakeFailure,
"Failed to agree on a signature algorithm");
140 const std::vector<Signature_Scheme>& peer_allowed_schemes,
141 std::string_view hostname,
152 const auto context = std::string(hostname);
158 throw TLS_Exception(Alert::InternalError,
"Application did not provide a private key for its credential");
172 throw TLS_Exception(Alert::IllegalParameter,
"Peer sent unknown signature scheme");
176 throw TLS_Exception(Alert::IllegalParameter,
"Peer sent signature algorithm that is not suitable for TLS 1.3");
192 throw TLS_Exception(Alert::IllegalParameter,
"Signature algorithm does not match certificate's public key");
198 #if defined(BOTAN_UNSAFE_FUZZER_MODE)
202 return signature_valid;
#define BOTAN_ASSERT_NOMSG(expr)
#define BOTAN_ASSERT_NONNULL(ptr)
virtual std::shared_ptr< Private_Key > private_key_for(const X509_Certificate &cert, const std::string &type, const std::string &context)
virtual AlgorithmIdentifier algorithm_identifier() const =0
virtual std::vector< uint8_t > tls_sign_message(const Private_Key &key, RandomNumberGenerator &rng, std::string_view padding, Signature_Format format, const std::vector< uint8_t > &msg)
virtual bool tls_verify_message(const Public_Key &key, std::string_view padding, Signature_Format format, const std::vector< uint8_t > &msg, const std::vector< uint8_t > &sig)
const X509_Certificate & leaf() const
std::shared_ptr< const Public_Key > public_key() const
bool has_certificate_chain() const
bool verify(const X509_Certificate &cert, const Handshake_State &state, const Policy &policy) const
Certificate_Verify_12(Handshake_IO &io, Handshake_State &state, const Policy &policy, RandomNumberGenerator &rng, const Private_Key *key)
bool verify(const Public_Key &public_key, Callbacks &callbacks, const Transcript_Hash &transcript_hash) const
Certificate_Verify_13(const std::vector< uint8_t > &buf, Connection_Side side)
Signature_Scheme m_scheme
Certificate_Verify()=default
std::vector< uint8_t > serialize() const override
std::vector< uint8_t > m_signature
const std::vector< uint8_t > & get_contents() const
void update(const uint8_t in[], size_t length)
virtual std::vector< uint8_t > send(const Handshake_Message &msg)=0
std::pair< std::string, Signature_Format > parse_sig_format(const Public_Key &key, Signature_Scheme scheme, const std::vector< Signature_Scheme > &offered_schemes, bool for_client_auth, const Policy &policy) const
Callbacks & callbacks() const
void client_hello(Client_Hello_12 *client_hello)
std::pair< std::string, Signature_Format > choose_sig_format(const Private_Key &key, Signature_Scheme &scheme, bool for_client_auth, const Policy &policy) const
virtual void check_peer_key_acceptable(const Public_Key &public_key) const
virtual std::vector< Signature_Scheme > allowed_signature_schemes() const
bool is_compatible_with(const Protocol_Version &protocol_version) const noexcept
AlgorithmIdentifier key_algorithm_identifier() const noexcept
Signature_Scheme::Code wire_code() const noexcept
std::optional< Signature_Format > format() const noexcept
bool is_set() const noexcept
std::string padding_string() const noexcept
bool is_available() const noexcept
std::vector< T > get_range(size_t len_bytes, size_t min_elems, size_t max_elems)
std::unique_ptr< Public_Key > subject_public_key() const
std::vector< uint8_t > Transcript_Hash
constexpr uint8_t get_byte(T input)
bool value_exists(const std::vector< T > &vec, const OT &val)