diff options
Diffstat (limited to 'src/ssl')
-rw-r--r-- | src/ssl/c_kex.cpp | 6 | ||||
-rw-r--r-- | src/ssl/cert_req.cpp | 14 | ||||
-rw-r--r-- | src/ssl/cert_ver.cpp | 6 | ||||
-rw-r--r-- | src/ssl/finished.cpp | 6 | ||||
-rw-r--r-- | src/ssl/handshake_hash.cpp | 8 | ||||
-rw-r--r-- | src/ssl/handshake_hash.h | 6 | ||||
-rw-r--r-- | src/ssl/hello.cpp | 42 | ||||
-rw-r--r-- | src/ssl/s_kex.cpp | 12 | ||||
-rw-r--r-- | src/ssl/tls_session_key.cpp | 20 |
9 files changed, 61 insertions, 59 deletions
diff --git a/src/ssl/c_kex.cpp b/src/ssl/c_kex.cpp index fafb67d3d..2a5dea7b3 100644 --- a/src/ssl/c_kex.cpp +++ b/src/ssl/c_kex.cpp @@ -82,10 +82,10 @@ SecureVector<byte> Client_Key_Exchange::serialize() const if(include_length) { u16bit key_size = key_material.size(); - buf.append(get_byte(0, key_size)); - buf.append(get_byte(1, key_size)); + buf.push_back(get_byte(0, key_size)); + buf.push_back(get_byte(1, key_size)); } - buf.append(key_material); + buf += key_material; return buf; } diff --git a/src/ssl/cert_req.cpp b/src/ssl/cert_req.cpp index 7a32af03b..9cd6bd5c1 100644 --- a/src/ssl/cert_req.cpp +++ b/src/ssl/cert_req.cpp @@ -37,9 +37,9 @@ SecureVector<byte> Certificate_Req::serialize() const { SecureVector<byte> buf; - buf.append(types.size()); + buf.push_back(types.size()); for(u32bit i = 0; i != types.size(); i++) - buf.append(types[i]); + buf.push_back(types[i]); DER_Encoder encoder; for(u32bit i = 0; i != names.size(); i++) @@ -48,9 +48,9 @@ SecureVector<byte> Certificate_Req::serialize() const SecureVector<byte> der_names = encoder.get_contents(); u16bit names_size = der_names.size(); - buf.append(get_byte(0, names_size)); - buf.append(get_byte(1, names_size)); - buf.append(der_names); + buf.push_back(get_byte(0, names_size)); + buf.push_back(get_byte(1, names_size)); + buf += der_names; return buf; } @@ -109,8 +109,8 @@ SecureVector<byte> Certificate::serialize() const SecureVector<byte> raw_cert = certs[i].BER_encode(); u32bit cert_size = raw_cert.size(); for(u32bit j = 0; j != 3; j++) - buf.append(get_byte(j+1, cert_size)); - buf.append(raw_cert); + buf.push_back(get_byte(j+1, cert_size)); + buf += raw_cert; } u32bit buf_size = buf.size() - 3; diff --git a/src/ssl/cert_ver.cpp b/src/ssl/cert_ver.cpp index d1d39f74e..7c6725572 100644 --- a/src/ssl/cert_ver.cpp +++ b/src/ssl/cert_ver.cpp @@ -51,9 +51,9 @@ SecureVector<byte> Certificate_Verify::serialize() const SecureVector<byte> buf; u16bit sig_len = signature.size(); - buf.append(get_byte(0, sig_len)); - buf.append(get_byte(1, sig_len)); - buf.append(signature); + buf.push_back(get_byte(0, sig_len)); + buf.push_back(get_byte(1, sig_len)); + buf += signature; return buf; } diff --git a/src/ssl/finished.cpp b/src/ssl/finished.cpp index 6648a2c3e..86eee7fe3 100644 --- a/src/ssl/finished.cpp +++ b/src/ssl/finished.cpp @@ -86,10 +86,10 @@ SecureVector<byte> Finished::compute_verify(const MemoryRegion<byte>& secret, SecureVector<byte> input; if(side == CLIENT) - input.append(TLS_CLIENT_LABEL, sizeof(TLS_CLIENT_LABEL)); + input += std::make_pair(TLS_CLIENT_LABEL, sizeof(TLS_CLIENT_LABEL)); else - input.append(TLS_SERVER_LABEL, sizeof(TLS_SERVER_LABEL)); - input.append(hash.final()); + input += std::make_pair(TLS_SERVER_LABEL, sizeof(TLS_SERVER_LABEL)); + input += hash.final(); return prf.derive_key(12, secret, input); } diff --git a/src/ssl/handshake_hash.cpp b/src/ssl/handshake_hash.cpp index fb9f5f9f4..a9e1d8e13 100644 --- a/src/ssl/handshake_hash.cpp +++ b/src/ssl/handshake_hash.cpp @@ -24,8 +24,8 @@ SecureVector<byte> HandshakeHash::final() sha1.update(data); SecureVector<byte> output; - output.append(md5.final()); - output.append(sha1.final()); + output += md5.final(); + output += sha1.final(); return output; } @@ -58,8 +58,8 @@ SecureVector<byte> HandshakeHash::final_ssl3(const MemoryRegion<byte>& secret) sha1.update(inner_sha1); SecureVector<byte> output; - output.append(md5.final()); - output.append(sha1.final()); + output += md5.final(); + output += sha1.final(); return output; } diff --git a/src/ssl/handshake_hash.h b/src/ssl/handshake_hash.h index df50e4dfe..4c145c6c6 100644 --- a/src/ssl/handshake_hash.h +++ b/src/ssl/handshake_hash.h @@ -21,13 +21,13 @@ class BOTAN_DLL HandshakeHash { public: void update(const byte in[], u32bit length) - { data.append(in, length); } + { data += std::make_pair(in, length); } void update(const MemoryRegion<byte>& in) - { update(&in[0], in.size()); } + { data += in; } void update(byte in) - { update(&in, 1); } + { data.push_back(in); } SecureVector<byte> final(); SecureVector<byte> final_ssl3(const MemoryRegion<byte>&); diff --git a/src/ssl/hello.cpp b/src/ssl/hello.cpp index 9ee3f87b9..887d13f1f 100644 --- a/src/ssl/hello.cpp +++ b/src/ssl/hello.cpp @@ -25,7 +25,7 @@ void HandshakeMessage::send(Record_Writer& writer, HandshakeHash& hash) const send_buf[2] = get_byte(2, buf_size); send_buf[3] = get_byte(3, buf_size); - send_buf.append(buf); + send_buf += buf; hash.update(send_buf); @@ -82,25 +82,26 @@ SecureVector<byte> Client_Hello::serialize() const { SecureVector<byte> buf; - buf.append(static_cast<byte>(c_version >> 8)); - buf.append(static_cast<byte>(c_version )); - buf.append(c_random); - buf.append(static_cast<byte>(sess_id.size())); - buf.append(sess_id); + buf.push_back(static_cast<byte>(c_version >> 8)); + buf.push_back(static_cast<byte>(c_version )); + buf += c_random; + + buf.push_back(static_cast<byte>(sess_id.size())); + buf += sess_id; u16bit suites_size = 2*suites.size(); - buf.append(get_byte(0, suites_size)); - buf.append(get_byte(1, suites_size)); + buf.push_back(get_byte(0, suites_size)); + buf.push_back(get_byte(1, suites_size)); for(u32bit i = 0; i != suites.size(); i++) { - buf.append(get_byte(0, suites[i])); - buf.append(get_byte(1, suites[i])); + buf.push_back(get_byte(0, suites[i])); + buf.push_back(get_byte(1, suites[i])); } - buf.append(static_cast<byte>(comp_algos.size())); + buf.push_back(static_cast<byte>(comp_algos.size())); for(u32bit i = 0; i != comp_algos.size(); i++) - buf.append(comp_algos[i]); + buf.push_back(comp_algos[i]); return buf; } @@ -260,16 +261,17 @@ SecureVector<byte> Server_Hello::serialize() const { SecureVector<byte> buf; - buf.append(static_cast<byte>(s_version >> 8)); - buf.append(static_cast<byte>(s_version )); - buf.append(s_random); - buf.append(static_cast<byte>(sess_id.size())); - buf.append(sess_id); + buf.push_back(static_cast<byte>(s_version >> 8)); + buf.push_back(static_cast<byte>(s_version )); + buf += s_random; + + buf.push_back(static_cast<byte>(sess_id.size())); + buf += sess_id; - buf.append(get_byte(0, suite)); - buf.append(get_byte(1, suite)); + buf.push_back(get_byte(0, suite)); + buf.push_back(get_byte(1, suite)); - buf.append(comp_algo); + buf.push_back(comp_algo); return buf; } diff --git a/src/ssl/s_kex.cpp b/src/ssl/s_kex.cpp index 220ef2e0b..6e4749491 100644 --- a/src/ssl/s_kex.cpp +++ b/src/ssl/s_kex.cpp @@ -75,9 +75,9 @@ SecureVector<byte> Server_Key_Exchange::serialize() const { SecureVector<byte> buf = serialize_params(); u16bit sig_len = signature.size(); - buf.append(get_byte(0, sig_len)); - buf.append(get_byte(1, sig_len)); - buf.append(signature); + buf.push_back(get_byte(0, sig_len)); + buf.push_back(get_byte(1, sig_len)); + buf += signature; return buf; } @@ -92,9 +92,9 @@ SecureVector<byte> Server_Key_Exchange::serialize_params() const SecureVector<byte> param = BigInt::encode(params[j]); u16bit param_size = param.size(); - buf.append(get_byte(0, param_size)); - buf.append(get_byte(1, param_size)); - buf.append(param); + buf.push_back(get_byte(0, param_size)); + buf.push_back(get_byte(1, param_size)); + buf += param; } return buf; } diff --git a/src/ssl/tls_session_key.cpp b/src/ssl/tls_session_key.cpp index 138d0a77c..341ce7bb0 100644 --- a/src/ssl/tls_session_key.cpp +++ b/src/ssl/tls_session_key.cpp @@ -79,14 +79,14 @@ SymmetricKey SessionKeys::ssl3_keygen(u32bit prf_gen, SSL3_PRF prf; SecureVector<byte> salt; - salt.append(client_random); - salt.append(server_random); + salt += client_random; + salt += server_random; master_sec = prf.derive_key(48, pre_master, salt); salt.clear(); - salt.append(server_random); - salt.append(client_random); + salt += server_random; + salt += client_random; return prf.derive_key(prf_gen, master_sec, salt); } @@ -109,16 +109,16 @@ SymmetricKey SessionKeys::tls1_keygen(u32bit prf_gen, TLS_PRF prf; SecureVector<byte> salt; - salt.append(MASTER_SECRET_MAGIC, sizeof(MASTER_SECRET_MAGIC)); - salt.append(client_random); - salt.append(server_random); + salt += std::make_pair(MASTER_SECRET_MAGIC, sizeof(MASTER_SECRET_MAGIC)); + salt += client_random; + salt += server_random; master_sec = prf.derive_key(48, pre_master, salt); salt.clear(); - salt.append(KEY_GEN_MAGIC, sizeof(KEY_GEN_MAGIC)); - salt.append(server_random); - salt.append(client_random); + salt += std::make_pair(KEY_GEN_MAGIC, sizeof(KEY_GEN_MAGIC)); + salt += server_random; + salt += client_random; return prf.derive_key(prf_gen, master_sec, salt); } |