Botan 1.10.17
Botan::Certificate_Verify Class Reference

#include <tls_messages.h>

Inheritance diagram for Botan::Certificate_Verify:
Botan::HandshakeMessage

Public Member Functions

 Certificate_Verify (const MemoryRegion< byte > &buf)
 Certificate_Verify (RandomNumberGenerator &rng, Record_Writer &, HandshakeHash &, const Private_Key *)
void send (Record_Writer &, HandshakeHash &) const
Handshake_Type type () const
bool verify (const X509_Certificate &, HandshakeHash &)

Detailed Description

Certificate Verify Message

Definition at line 163 of file tls_messages.h.

Constructor & Destructor Documentation

◆ Certificate_Verify() [1/2]

Botan::Certificate_Verify::Certificate_Verify ( RandomNumberGenerator & rng,
Record_Writer & writer,
HandshakeHash & hash,
const Private_Key * priv_key )

Create a new Certificate Verify message

Definition at line 21 of file cert_ver.cpp.

25 {
26 std::string padding = "";
28
29 if(priv_key->algo_name() == "RSA")
30 padding = "EMSA3(TLS.Digest.0)";
31 else if(priv_key->algo_name() == "DSA")
32 {
33 padding = "EMSA1(SHA-1)";
34 format = DER_SEQUENCE;
35 }
36 else
37 throw Invalid_Argument(priv_key->algo_name() +
38 " is invalid/unknown for TLS signatures");
39
40 PK_Signer signer(*priv_key, padding, format);
41
42 signature = signer.sign_message(hash.final(), rng);
43 send(writer, hash);
44 }
void send(Record_Writer &, HandshakeHash &) const
Definition hello.cpp:16
std::invalid_argument Invalid_Argument
Definition exceptn.h:20
Signature_Format
Definition pubkey.h:24
@ DER_SEQUENCE
Definition pubkey.h:24
@ IEEE_1363
Definition pubkey.h:24

References Botan::Public_Key::algo_name(), Botan::DER_SEQUENCE, Botan::HandshakeHash::final(), Botan::IEEE_1363, Botan::HandshakeMessage::send(), and Botan::PK_Signer::sign_message().

◆ Certificate_Verify() [2/2]

Botan::Certificate_Verify::Certificate_Verify ( const MemoryRegion< byte > & buf)
inline

Definition at line 174 of file tls_messages.h.

174{ deserialize(buf); }

Member Function Documentation

◆ send()

void Botan::HandshakeMessage::send ( Record_Writer & writer,
HandshakeHash & hash ) const
inherited

Definition at line 16 of file hello.cpp.

17 {
18 SecureVector<byte> buf = serialize();
19 SecureVector<byte> send_buf(4);
20
21 const size_t buf_size = buf.size();
22
23 send_buf[0] = type();
24
25 for(size_t i = 1; i != 4; ++i)
26 send_buf[i] = get_byte<u32bit>(i, buf_size);
27
28 send_buf += buf;
29
30 hash.update(send_buf);
31
32 writer.send(HANDSHAKE, &send_buf[0], send_buf.size());
33 writer.flush();
34 }
virtual Handshake_Type type() const =0
byte get_byte(size_t byte_num, T input)
Definition get_byte.h:21
@ HANDSHAKE
Definition tls_magic.h:36

References Botan::Record_Writer::flush(), Botan::get_byte(), Botan::HANDSHAKE, Botan::Record_Writer::send(), Botan::MemoryRegion< T >::size(), type(), and Botan::HandshakeHash::update().

Referenced by Botan::Certificate::Certificate(), Botan::Certificate_Req::Certificate_Req(), Botan::Certificate_Verify::Certificate_Verify(), Botan::Client_Hello::Client_Hello(), Botan::Client_Key_Exchange::Client_Key_Exchange(), Botan::Finished::Finished(), Botan::Hello_Request::Hello_Request(), Botan::Server_Hello::Server_Hello(), Botan::Server_Hello_Done::Server_Hello_Done(), and Botan::Server_Key_Exchange::Server_Key_Exchange().

◆ type()

Handshake_Type Botan::Certificate_Verify::type ( ) const
inlinevirtual

Implements Botan::HandshakeMessage.

Definition at line 166 of file tls_messages.h.

166{ return CERTIFICATE_VERIFY; }
@ CERTIFICATE_VERIFY
Definition tls_magic.h:49

References Botan::CERTIFICATE_VERIFY.

◆ verify()

bool Botan::Certificate_Verify::verify ( const X509_Certificate & cert,
HandshakeHash & hash )

Verify a Certificate Verify message

Definition at line 73 of file cert_ver.cpp.

75 {
76 // FIXME: duplicate of Server_Key_Exchange::verify
77
78 std::auto_ptr<Public_Key> key(cert.subject_public_key());
79
80 std::string padding = "";
82
83 if(key->algo_name() == "RSA")
84 padding = "EMSA3(TLS.Digest.0)";
85 else if(key->algo_name() == "DSA")
86 {
87 padding = "EMSA1(SHA-1)";
88 format = DER_SEQUENCE;
89 }
90 else
91 throw Invalid_Argument(key->algo_name() +
92 " is invalid/unknown for TLS signatures");
93
94 PK_Verifier verifier(*key, padding, format);
95 return verifier.verify_message(hash.final(), signature);
96 }

References Botan::DER_SEQUENCE, Botan::HandshakeHash::final(), Botan::IEEE_1363, Botan::X509_Certificate::subject_public_key(), and Botan::PK_Verifier::verify_message().


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