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

#include <tls_messages.h>

Inheritance diagram for Botan::TLS::Certificate:
Botan::TLS::Handshake_Message

Public Member Functions

const std::vector< X509_Certificate > & cert_chain () const
 
 Certificate (Handshake_IO &io, Handshake_Hash &hash, const std::vector< X509_Certificate > &certs)
 
 Certificate (const std::vector< uint8_t > &buf, const Policy &policy)
 
size_t count () const
 
bool empty () const
 
Handshake_Type type () const override
 
std::string type_string () const
 

Detailed Description

Certificate Message

Definition at line 362 of file tls_messages.h.

Constructor & Destructor Documentation

◆ Certificate() [1/2]

Botan::TLS::Certificate::Certificate ( Handshake_IO io,
Handshake_Hash hash,
const std::vector< X509_Certificate > &  cert_list 
)

Create a new Certificate message

Definition at line 23 of file msg_certificate.cpp.

References hash, and Botan::TLS::Handshake_IO::send().

25  :
26  m_certs(cert_list)
27  {
28  hash.update(io.send(*this));
29  }
MechanismType hash

◆ Certificate() [2/2]

Botan::TLS::Certificate::Certificate ( const std::vector< uint8_t > &  buf,
const Policy policy 
)
explicit

Deserialize a Certificate message

Definition at line 34 of file msg_certificate.cpp.

References Botan::make_uint32().

35  {
36  if(buf.size() < 3)
37  throw Decoding_Error("Certificate: Message malformed");
38 
39  const size_t total_size = make_uint32(0, buf[0], buf[1], buf[2]);
40 
41  if(total_size != buf.size() - 3)
42  throw Decoding_Error("Certificate: Message malformed");
43 
44  const uint8_t* certs = buf.data() + 3;
45 
46  while(size_t remaining_bytes = buf.data() + buf.size() - certs)
47  {
48  if(remaining_bytes < 3)
49  throw Decoding_Error("Certificate: Message malformed");
50 
51  const size_t cert_size = make_uint32(0, certs[0], certs[1], certs[2]);
52 
53  if(remaining_bytes < (3 + cert_size))
54  throw Decoding_Error("Certificate: Message malformed");
55 
56  DataSource_Memory cert_buf(&certs[3], cert_size);
57  m_certs.push_back(X509_Certificate(cert_buf));
58 
59  certs += cert_size + 3;
60  }
61  }
uint32_t make_uint32(uint8_t i0, uint8_t i1, uint8_t i2, uint8_t i3)
Definition: loadstor.h:65

Member Function Documentation

◆ cert_chain()

const std::vector<X509_Certificate>& Botan::TLS::Certificate::cert_chain ( ) const
inline

Definition at line 366 of file tls_messages.h.

366 { return m_certs; }

◆ count()

size_t Botan::TLS::Certificate::count ( ) const
inline

Definition at line 368 of file tls_messages.h.

368 { return m_certs.size(); }

◆ empty()

bool Botan::TLS::Certificate::empty ( ) const
inline

Definition at line 369 of file tls_messages.h.

369 { return m_certs.empty(); }

◆ type()

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

Implements Botan::TLS::Handshake_Message.

Definition at line 365 of file tls_messages.h.

References Botan::TLS::CERTIFICATE.

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

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