Botan  2.6.0
Crypto and TLS for C++11
Public Member Functions | List of all members
Botan::TLS::Certificate_Verify Class Referencefinal

#include <tls_messages.h>

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

Public Member Functions

 Certificate_Verify (Handshake_IO &io, Handshake_State &state, const Policy &policy, RandomNumberGenerator &rng, const Private_Key *key)
 
 Certificate_Verify (const std::vector< uint8_t > &buf, Protocol_Version version)
 
Handshake_Type type () const override
 
std::string type_string () const
 
bool verify (const X509_Certificate &cert, const Handshake_State &state, const Policy &policy) const
 

Detailed Description

Certificate Verify Message

Definition at line 441 of file tls_messages.h.

Constructor & Destructor Documentation

◆ Certificate_Verify() [1/2]

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

Definition at line 22 of file msg_cert_verify.cpp.

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::Handshake_IO::send(), Botan::TLS::Callbacks::tls_sign_message(), and Botan::TLS::Handshake_Hash::update().

27  {
28  BOTAN_ASSERT_NONNULL(priv_key);
29 
30  std::pair<std::string, Signature_Format> format =
31  state.choose_sig_format(*priv_key, m_scheme, true, policy);
32 
33  m_signature =
34  state.callbacks().tls_sign_message(*priv_key, rng, format.first, format.second,
35  state.hash().get_contents());
36 
37  state.hash().update(io.send(*this));
38  }
#define BOTAN_ASSERT_NONNULL(ptr)
Definition: assert.h:82

◆ Certificate_Verify() [2/2]

Botan::TLS::Certificate_Verify::Certificate_Verify ( const std::vector< uint8_t > &  buf,
Protocol_Version  version 
)

Definition at line 43 of file msg_cert_verify.cpp.

References Botan::TLS::TLS_Data_Reader::get_range(), Botan::TLS::TLS_Data_Reader::get_uint16_t(), and Botan::TLS::Protocol_Version::supports_negotiable_signature_algorithms().

45  {
46  TLS_Data_Reader reader("CertificateVerify", buf);
47 
48  if(version.supports_negotiable_signature_algorithms())
49  {
50  m_scheme = static_cast<Signature_Scheme>(reader.get_uint16_t());
51  }
52 
53  m_signature = reader.get_range<uint8_t>(2, 0, 65535);
54  }
Signature_Scheme
Definition: tls_algos.h:84

Member Function Documentation

◆ type()

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

Implements Botan::TLS::Handshake_Message.

Definition at line 444 of file tls_messages.h.

References Botan::TLS::CERTIFICATE_VERIFY.

◆ 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.

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

20  {
22  }
virtual Handshake_Type type() const =0
const char * handshake_type_to_string(Handshake_Type type)

◆ verify()

bool Botan::TLS::Certificate_Verify::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 81 of file msg_cert_verify.cpp.

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

84  {
85  std::unique_ptr<Public_Key> 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.get(), m_scheme, true, policy);
91 
92  const bool signature_valid =
93  state.callbacks().tls_verify_message(*key, format.first, format.second,
94  state.hash().get_contents(), m_signature);
95 
96 #if defined(BOTAN_UNSAFE_FUZZER_MODE)
97  return true;
98 #else
99  return signature_valid;
100 #endif
101  }

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