Botan  1.10.9
Public Member Functions | List of all members
Botan::Certificate_Verify Class Reference

#include <tls_messages.h>

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

Public Member Functions

 Certificate_Verify (RandomNumberGenerator &rng, Record_Writer &, HandshakeHash &, const Private_Key *)
 
 Certificate_Verify (const MemoryRegion< byte > &buf)
 
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

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.

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

25  {
26  std::string padding = "";
27  Signature_Format format = IEEE_1363;
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
Signature_Format
Definition: pubkey.h:24
std::invalid_argument Invalid_Argument
Definition: exceptn.h:20
RandomNumberGenerator * rng
Definition: global_rng.cpp:165
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

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

Definition at line 16 of file hello.cpp.

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

Referenced by Botan::Certificate::Certificate(), Botan::Certificate_Req::Certificate_Req(), 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().

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
Handshake_Type Botan::Certificate_Verify::type ( ) const
inlinevirtual

Implements Botan::HandshakeMessage.

Definition at line 166 of file tls_messages.h.

References Botan::CERTIFICATE_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.

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

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 = "";
81  Signature_Format format = IEEE_1363;
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  }
Signature_Format
Definition: pubkey.h:24
std::invalid_argument Invalid_Argument
Definition: exceptn.h:20

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