Botan  2.1.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 508 of file tls_messages.h.

Constructor & Destructor Documentation

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

Definition at line 21 of file msg_cert_verify.cpp.

References BOTAN_ASSERT_NONNULL, Botan::TLS::Handshake_State::choose_sig_format(), Botan::TLS::Handshake_Hash::get_contents(), Botan::TLS::Handshake_State::hash(), Botan::TLS::Handshake_IO::send(), Botan::PK_Signer::sign_message(), and Botan::TLS::Handshake_Hash::update().

26  {
27  BOTAN_ASSERT_NONNULL(priv_key);
28 
29  std::pair<std::string, Signature_Format> format =
30  state.choose_sig_format(*priv_key, m_hash_algo, m_sig_algo, true, policy);
31 
32  PK_Signer signer(*priv_key, rng, format.first, format.second);
33 
34  m_signature = signer.sign_message(state.hash().get_contents(), rng);
35 
36  state.hash().update(io.send(*this));
37  }
#define BOTAN_ASSERT_NONNULL(ptr)
Definition: assert.h:79
Botan::TLS::Certificate_Verify::Certificate_Verify ( const std::vector< uint8_t > &  buf,
Protocol_Version  version 
)

Definition at line 42 of file msg_cert_verify.cpp.

References Botan::TLS::TLS_Data_Reader::get_byte(), Botan::TLS::TLS_Data_Reader::get_range(), Botan::TLS::Signature_Algorithms::hash_algo_name(), Botan::TLS::Signature_Algorithms::sig_algo_name(), and Botan::TLS::Protocol_Version::supports_negotiable_signature_algorithms().

44  {
45  TLS_Data_Reader reader("CertificateVerify", buf);
46 
47  if(version.supports_negotiable_signature_algorithms())
48  {
49  m_hash_algo = Signature_Algorithms::hash_algo_name(reader.get_byte());
50  m_sig_algo = Signature_Algorithms::sig_algo_name(reader.get_byte());
51  }
52 
53  m_signature = reader.get_range<uint8_t>(2, 0, 65535);
54  }
static std::string sig_algo_name(uint8_t code)
static std::string hash_algo_name(uint8_t code)

Member Function Documentation

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

Implements Botan::TLS::Handshake_Message.

Definition at line 511 of file tls_messages.h.

References Botan::TLS::CERTIFICATE_VERIFY.

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

Definition at line 17 of file tls_handshake_state.cpp.

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

18  {
20  }
virtual Handshake_Type type() const =0
const char * handshake_type_to_string(Handshake_Type type)
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 80 of file msg_cert_verify.cpp.

References 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::PK_Verifier::verify_message().

83  {
84  std::unique_ptr<Public_Key> key(cert.subject_public_key());
85 
86  policy.check_peer_key_acceptable(*key);
87 
88  std::pair<std::string, Signature_Format> format =
89  state.parse_sig_format(*key.get(), m_hash_algo, m_sig_algo,
90  true, policy);
91 
92  PK_Verifier verifier(*key, format.first, format.second);
93 
94  const bool signature_valid =
95  verifier.verify_message(state.hash().get_contents(), m_signature);
96 
97 #if defined(BOTAN_UNSAFE_FUZZER_MODE)
98  return true;
99 #else
100  return signature_valid;
101 #endif
102  }

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