aboutsummaryrefslogtreecommitdiffstats
path: root/src/tls/cert_req.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tls/cert_req.cpp')
-rw-r--r--src/tls/cert_req.cpp90
1 files changed, 45 insertions, 45 deletions
diff --git a/src/tls/cert_req.cpp b/src/tls/cert_req.cpp
index 0168e4b7d..bdb25057c 100644
--- a/src/tls/cert_req.cpp
+++ b/src/tls/cert_req.cpp
@@ -37,29 +37,9 @@ Certificate_Req::Certificate_Req(Record_Writer& writer,
}
/**
-* Serialize a Certificate Request message
-*/
-MemoryVector<byte> Certificate_Req::serialize() const
- {
- MemoryVector<byte> buf;
-
- append_tls_length_value(buf, types, 1);
-
- for(size_t i = 0; i != names.size(); ++i)
- {
- DER_Encoder encoder;
- encoder.encode(names[i]);
-
- append_tls_length_value(buf, encoder.get_contents(), 2);
- }
-
- return buf;
- }
-
-/**
* Deserialize a Certificate Request message
*/
-void Certificate_Req::deserialize(const MemoryRegion<byte>& buf)
+Certificate_Req::Certificate_Req(const MemoryRegion<byte>& buf)
{
if(buf.size() < 4)
throw Decoding_Error("Certificate_Req: Bad certificate request");
@@ -96,43 +76,40 @@ void Certificate_Req::deserialize(const MemoryRegion<byte>& buf)
}
/**
-* Create a new Certificate message
+* Serialize a Certificate Request message
*/
-Certificate::Certificate(Record_Writer& writer,
- TLS_Handshake_Hash& hash,
- const std::vector<X509_Certificate>& cert_list)
+MemoryVector<byte> Certificate_Req::serialize() const
{
- certs = cert_list;
- send(writer, hash);
- }
+ MemoryVector<byte> buf;
-/**
-* Serialize a Certificate message
-*/
-MemoryVector<byte> Certificate::serialize() const
- {
- MemoryVector<byte> buf(3);
+ append_tls_length_value(buf, types, 1);
- for(size_t i = 0; i != certs.size(); ++i)
+ for(size_t i = 0; i != names.size(); ++i)
{
- MemoryVector<byte> raw_cert = 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;
- }
+ DER_Encoder encoder;
+ encoder.encode(names[i]);
- 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);
+ append_tls_length_value(buf, encoder.get_contents(), 2);
+ }
return buf;
}
/**
+* Create a new Certificate message
+*/
+Certificate::Certificate(Record_Writer& writer,
+ TLS_Handshake_Hash& hash,
+ const std::vector<X509_Certificate>& cert_list)
+ {
+ certs = cert_list;
+ send(writer, hash);
+ }
+
+/**
* Deserialize a Certificate message
*/
-void Certificate::deserialize(const MemoryRegion<byte>& buf)
+Certificate::Certificate(const MemoryRegion<byte>& buf)
{
if(buf.size() < 3)
throw Decoding_Error("Certificate: Message malformed");
@@ -163,4 +140,27 @@ void Certificate::deserialize(const MemoryRegion<byte>& buf)
}
}
+/**
+* Serialize a Certificate message
+*/
+MemoryVector<byte> Certificate::serialize() const
+ {
+ MemoryVector<byte> buf(3);
+
+ for(size_t i = 0; i != certs.size(); ++i)
+ {
+ MemoryVector<byte> raw_cert = 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;
+ }
+
}