aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/tls/info.txt1
-rw-r--r--src/tls/msg_cert_req.cpp66
-rw-r--r--src/tls/msg_certificate.cpp88
-rw-r--r--src/tls/tls_extensions.h2
4 files changed, 89 insertions, 68 deletions
diff --git a/src/tls/info.txt b/src/tls/info.txt
index 40a4cc9a5..5294d3026 100644
--- a/src/tls/info.txt
+++ b/src/tls/info.txt
@@ -36,6 +36,7 @@ tls_session_key.h
<source>
msg_cert_req.cpp
msg_cert_verify.cpp
+msg_certificate.cpp
msg_client_hello.cpp
msg_client_kex.cpp
msg_finished.cpp
diff --git a/src/tls/msg_cert_req.cpp b/src/tls/msg_cert_req.cpp
index 63d830b9e..4104025cf 100644
--- a/src/tls/msg_cert_req.cpp
+++ b/src/tls/msg_cert_req.cpp
@@ -163,72 +163,6 @@ std::vector<byte> Certificate_Req::serialize() const
return buf;
}
-/**
-* Create a new Certificate message
-*/
-Certificate::Certificate(Handshake_IO& io,
- Handshake_Hash& hash,
- const std::vector<X509_Certificate>& cert_list) :
- m_certs(cert_list)
- {
- hash.update(io.send(*this));
- }
-
-/**
-* Deserialize a Certificate message
-*/
-Certificate::Certificate(const std::vector<byte>& buf)
- {
- if(buf.size() < 3)
- throw Decoding_Error("Certificate: Message malformed");
-
- const size_t total_size = make_u32bit(0, buf[0], buf[1], buf[2]);
-
- if(total_size != buf.size() - 3)
- throw Decoding_Error("Certificate: Message malformed");
-
- const byte* certs = &buf[3];
-
- while(size_t remaining_bytes = &buf[buf.size()] - certs)
- {
- if(remaining_bytes < 3)
- throw Decoding_Error("Certificate: Message malformed");
-
- const size_t cert_size = make_u32bit(0, certs[0], certs[1], certs[2]);
-
- if(remaining_bytes < (3 + cert_size))
- throw Decoding_Error("Certificate: Message malformed");
-
- DataSource_Memory cert_buf(&certs[3], cert_size);
- m_certs.push_back(X509_Certificate(cert_buf));
-
- certs += cert_size + 3;
- }
- }
-
-/**
-* Serialize a Certificate message
-*/
-std::vector<byte> Certificate::serialize() const
- {
- std::vector<byte> buf(3);
-
- for(size_t i = 0; i != m_certs.size(); ++i)
- {
- std::vector<byte> raw_cert = m_certs[i].BER_encode();
- const size_t cert_size = raw_cert.size();
- for(size_t i = 0; i != 3; ++i)
- buf.push_back(get_byte<u32bit>(i+1, cert_size));
- buf += raw_cert;
- }
-
- const size_t buf_size = buf.size() - 3;
- for(size_t i = 0; i != 3; ++i)
- buf[i] = get_byte<u32bit>(i+1, buf_size);
-
- return buf;
- }
-
}
}
diff --git a/src/tls/msg_certificate.cpp b/src/tls/msg_certificate.cpp
new file mode 100644
index 000000000..417ad34ce
--- /dev/null
+++ b/src/tls/msg_certificate.cpp
@@ -0,0 +1,88 @@
+/*
+* Certificate Message
+* (C) 2004-2006,2012 Jack Lloyd
+*
+* Released under the terms of the Botan license
+*/
+
+#include <botan/internal/tls_messages.h>
+#include <botan/internal/tls_reader.h>
+#include <botan/internal/tls_extensions.h>
+#include <botan/internal/tls_handshake_io.h>
+#include <botan/der_enc.h>
+#include <botan/ber_dec.h>
+#include <botan/loadstor.h>
+
+namespace Botan {
+
+namespace TLS {
+
+/**
+* Create a new Certificate message
+*/
+Certificate::Certificate(Handshake_IO& io,
+ Handshake_Hash& hash,
+ const std::vector<X509_Certificate>& cert_list) :
+ m_certs(cert_list)
+ {
+ hash.update(io.send(*this));
+ }
+
+/**
+* Deserialize a Certificate message
+*/
+Certificate::Certificate(const std::vector<byte>& buf)
+ {
+ if(buf.size() < 3)
+ throw Decoding_Error("Certificate: Message malformed");
+
+ const size_t total_size = make_u32bit(0, buf[0], buf[1], buf[2]);
+
+ if(total_size != buf.size() - 3)
+ throw Decoding_Error("Certificate: Message malformed");
+
+ const byte* certs = &buf[3];
+
+ while(size_t remaining_bytes = &buf[buf.size()] - certs)
+ {
+ if(remaining_bytes < 3)
+ throw Decoding_Error("Certificate: Message malformed");
+
+ const size_t cert_size = make_u32bit(0, certs[0], certs[1], certs[2]);
+
+ if(remaining_bytes < (3 + cert_size))
+ throw Decoding_Error("Certificate: Message malformed");
+
+ DataSource_Memory cert_buf(&certs[3], cert_size);
+ m_certs.push_back(X509_Certificate(cert_buf));
+
+ certs += cert_size + 3;
+ }
+ }
+
+/**
+* Serialize a Certificate message
+*/
+std::vector<byte> Certificate::serialize() const
+ {
+ std::vector<byte> buf(3);
+
+ for(size_t i = 0; i != m_certs.size(); ++i)
+ {
+ std::vector<byte> raw_cert = m_certs[i].BER_encode();
+ const size_t cert_size = raw_cert.size();
+ for(size_t i = 0; i != 3; ++i)
+ buf.push_back(get_byte<u32bit>(i+1, cert_size));
+ buf += raw_cert;
+ }
+
+ const size_t buf_size = buf.size() - 3;
+ for(size_t i = 0; i != 3; ++i)
+ buf[i] = get_byte<u32bit>(i+1, buf_size);
+
+ return buf;
+ }
+
+}
+
+}
diff --git a/src/tls/tls_extensions.h b/src/tls/tls_extensions.h
index 23f13db83..6b1652deb 100644
--- a/src/tls/tls_extensions.h
+++ b/src/tls/tls_extensions.h
@@ -379,8 +379,6 @@ class Extensions
Extensions() {}
Extensions(TLS_Data_Reader& reader); // deserialize
-
- ~Extensions();
private:
Extensions(const Extensions&) {}
Extensions& operator=(const Extensions&) { return (*this); }