Botan 3.9.0
Crypto and TLS for C&
Botan::TLS::Certificate_Verify_12 Class Referencefinal

#include <tls_messages.h>

Inheritance diagram for Botan::TLS::Certificate_Verify_12:
Botan::TLS::Certificate_Verify Botan::TLS::Handshake_Message

Public Member Functions

 Certificate_Verify ()=default
 Certificate_Verify (const std::vector< uint8_t > &buf)
 Certificate_Verify_12 (Handshake_IO &io, Handshake_State &state, const Policy &policy, RandomNumberGenerator &rng, const Private_Key *key)
std::vector< uint8_t > serialize () const override
Signature_Scheme signature_scheme () const
Handshake_Type type () const override
std::string type_string () const
bool verify (const X509_Certificate &cert, const Handshake_State &state, const Policy &policy) const
virtual Handshake_Type wire_type () const

Protected Attributes

Signature_Scheme m_scheme
std::vector< uint8_t > m_signature

Detailed Description

Certificate Verify Message

Definition at line 777 of file tls_messages.h.

Constructor & Destructor Documentation

◆ Certificate_Verify_12()

Botan::TLS::Certificate_Verify_12::Certificate_Verify_12 ( Handshake_IO & io,
Handshake_State & state,
const Policy & policy,
RandomNumberGenerator & rng,
const Private_Key * key )

Definition at line 28 of file msg_cert_verify.cpp.

32 {
33 BOTAN_ASSERT_NONNULL(priv_key);
34
35 std::pair<std::string, Signature_Format> format = state.choose_sig_format(*priv_key, m_scheme, true, policy);
36
38 state.callbacks().tls_sign_message(*priv_key, rng, format.first, format.second, state.hash().get_contents());
39
40 state.hash().update(io.send(*this));
41}
#define BOTAN_ASSERT_NONNULL(ptr)
Definition assert.h:114
std::vector< uint8_t > m_signature

References BOTAN_ASSERT_NONNULL, Botan::TLS::Handshake_State::callbacks(), Botan::TLS::Handshake_State::choose_sig_format(), Botan::TLS::Handshake_Hash::get_contents(), Botan::TLS::Handshake_State::hash(), Botan::TLS::Certificate_Verify::m_scheme, Botan::TLS::Certificate_Verify::m_signature, Botan::TLS::Handshake_IO::send(), Botan::TLS::Callbacks::tls_sign_message(), and Botan::TLS::Handshake_Hash::update().

Member Function Documentation

◆ Certificate_Verify() [1/2]

Botan::TLS::Certificate_Verify::Certificate_Verify ( )
default

◆ Certificate_Verify() [2/2]

Botan::TLS::Certificate_Verify::Certificate_Verify ( const std::vector< uint8_t > & buf)
explicit

Definition at line 764 of file msg_cert_verify.cpp.

46 {
47 TLS_Data_Reader reader("CertificateVerify", buf);
48
49 m_scheme = Signature_Scheme(reader.get_uint16_t());
50 m_signature = reader.get_range<uint8_t>(2, 0, 65535);
51 reader.assert_done();
52
53 if(!m_scheme.is_set()) {
54 throw Decoding_Error("Counterparty did not send hash/sig IDS");
55 }
56}

◆ serialize()

std::vector< uint8_t > Botan::TLS::Certificate_Verify::serialize ( ) const
overridevirtualinherited
Returns
DER representation of this message

Implements Botan::TLS::Handshake_Message.

Definition at line 61 of file msg_cert_verify.cpp.

61 {
63 std::vector<uint8_t> buf;
64 buf.reserve(2 + 2 + m_signature.size()); // work around GCC warning
65
66 const auto code = m_scheme.wire_code();
67 buf.push_back(get_byte<0>(code));
68 buf.push_back(get_byte<1>(code));
69
70 if(m_signature.size() > 0xFFFF) {
71 throw Encoding_Error("Certificate_Verify signature too long to encode");
72 }
73
74 const uint16_t sig_len = static_cast<uint16_t>(m_signature.size());
75 buf.push_back(get_byte<0>(sig_len));
76 buf.push_back(get_byte<1>(sig_len));
77 buf += m_signature;
78
79 return buf;
80}
#define BOTAN_ASSERT_NOMSG(expr)
Definition assert.h:75
constexpr uint8_t get_byte(T input)
Definition loadstor.h:79

References BOTAN_ASSERT_NOMSG, Botan::get_byte(), m_scheme, and m_signature.

Referenced by Certificate_Verify().

◆ signature_scheme()

Signature_Scheme Botan::TLS::Certificate_Verify::signature_scheme ( ) const
inlineinherited

Definition at line 762 of file tls_messages.h.

762{ return m_scheme; }

References m_scheme.

◆ type()

Handshake_Type Botan::TLS::Certificate_Verify::type ( ) const
inlineoverridevirtualinherited
Returns
the message type

Implements Botan::TLS::Handshake_Message.

Definition at line 760 of file tls_messages.h.

References Botan::TLS::CertificateVerify.

◆ type_string()

std::string Botan::TLS::Handshake_Message::type_string ( ) const
inherited
Returns
string representation of this message type

Definition at line 19 of file tls_handshake_state.cpp.

19 {
21}
virtual Handshake_Type type() const =0
const char * handshake_type_to_string(Handshake_Type type)

References Botan::TLS::handshake_type_to_string(), and type().

◆ verify()

bool Botan::TLS::Certificate_Verify_12::verify ( const X509_Certificate & cert,
const Handshake_State & state,
const Policy & policy ) const

Check the signature on a certificate verify message

Parameters
certthe purported certificate
statethe handshake state
policythe TLS policy

Definition at line 82 of file msg_cert_verify.cpp.

84 {
85 auto key = cert.subject_public_key();
86
87 policy.check_peer_key_acceptable(*key);
88
89 std::pair<std::string, Signature_Format> format =
90 state.parse_sig_format(*key, m_scheme, state.client_hello()->signature_schemes(), true, policy);
91
92 const bool signature_valid =
93 state.callbacks().tls_verify_message(*key, format.first, format.second, state.hash().get_contents(), m_signature);
94
95#if defined(BOTAN_UNSAFE_FUZZER_MODE)
96 BOTAN_UNUSED(signature_valid);
97 return true;
98
99#else
100 return signature_valid;
101
102#endif
103}
#define BOTAN_UNUSED
Definition assert.h:144

References BOTAN_UNUSED, Botan::TLS::Handshake_State::callbacks(), Botan::TLS::Policy::check_peer_key_acceptable(), Botan::TLS::Handshake_State::client_hello(), Botan::TLS::Handshake_Hash::get_contents(), Botan::TLS::Handshake_State::hash(), Botan::TLS::Certificate_Verify::m_scheme, Botan::TLS::Certificate_Verify::m_signature, Botan::TLS::Handshake_State::parse_sig_format(), Botan::X509_Certificate::subject_public_key(), and Botan::TLS::Callbacks::tls_verify_message().

◆ wire_type()

virtual Handshake_Type Botan::TLS::Handshake_Message::wire_type ( ) const
inlinevirtualinherited
Returns
the wire representation of the message's type

Reimplemented in Botan::TLS::Hello_Retry_Request.

Definition at line 39 of file tls_handshake_msg.h.

39 {
40 // Usually equal to the Handshake_Type enum value,
41 // with the exception of TLS 1.3 Hello Retry Request.
42 return type();
43 }

References type().

Referenced by Botan::TLS::Stream_Handshake_IO::send().

Member Data Documentation

◆ m_scheme

◆ m_signature


The documentation for this class was generated from the following files: