Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | List of all members
Botan::TLS::Certificate Class Referencefinal

`#include <tls_messages.h>`

Inheritance diagram for Botan::TLS::Certificate:

## 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 431 of file tls_messages.h.

## Constructor & Destructor Documentation

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 24 of file msg_certificate.cpp.

References Botan::TLS::Handshake_IO::send(), and Botan::TLS::Handshake_Hash::update().

26 :
27 m_certs(cert_list)
28 {
29 hash.update(io.send(*this));
30 }
hash
MechanismType hash
Definition: p11_mechanism.cpp:63

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

Deserialize a Certificate message

Definition at line 35 of file msg_certificate.cpp.

References Botan::make_uint32().

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

## Member Function Documentation

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

Definition at line 435 of file tls_messages.h.

435 { return m_certs; }

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

Definition at line 437 of file tls_messages.h.

437 { return m_certs.size(); }

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

Definition at line 438 of file tls_messages.h.

438 { return m_certs.empty(); }

Handshake_Type Botan::TLS::Certificate::type | ( |  | ) | const
| inline override virtual

Returns
  the message type

Implements Botan::TLS::Handshake_Message.

Definition at line 434 of file tls_messages.h.

References Botan::TLS::CERTIFICATE.

434 { return CERTIFICATE; }
Botan::TLS::CERTIFICATE
Definition: tls_magic.h:44

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 {
19 return handshake_type_to_string(type());
20 }
Botan::TLS::Handshake_Message::type
virtual Handshake_Type type() const =0
Botan::TLS::handshake_type_to_string
const char * handshake_type_to_string(Handshake_Type type)
Definition: tls_handshake_state.cpp:22

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

- src/lib/tls/tls_messages.h
- src/lib/tls/msg_certificate.cpp