diff --git a/lib/TLS/include/Method.h b/lib/TLS/include/Method.h index 2d7122d..25ffa1b 100644 --- a/lib/TLS/include/Method.h +++ b/lib/TLS/include/Method.h @@ -279,33 +279,35 @@ namespace eap eap::sanitizing_blob make_finished() const; /// - /// Makes a TLS handshake + /// Makes a TLS message /// /// \sa [The Transport Layer Security (TLS) Protocol Version 1.2 (Chapter A.1. Record Layer)](https://tools.ietf.org/html/rfc5246#appendix-A.1) /// - /// \param[in] msg Handshake data contents + /// \param[in] type Message type + /// \param[in] msg Message data contents /// - /// \returns TLS handshake message + /// \returns TLS message message /// - static eap::sanitizing_blob make_handshake(_In_ const sanitizing_blob &msg); + static eap::sanitizing_blob make_message(_In_ tls_message_type_t type, _In_ const sanitizing_blob &msg); /// - /// Makes a TLS handshake + /// Makes a TLS message /// - /// \param[in] msg Handshake data contents + /// \param[in] type Message type + /// \param[in] msg Message data contents /// \param[in] encrypt Should the message be encrypted? /// - /// \returns TLS handshake message + /// \returns TLS message message /// - inline eap::sanitizing_blob make_handshake(_In_ const sanitizing_blob &msg, _In_ bool encrypted) + inline eap::sanitizing_blob make_message(_In_ tls_message_type_t type, _In_ const sanitizing_blob &msg, _In_ bool encrypted) { if (encrypted) { // Make unencrypted handshake, encrypt it, then make a new handshake message. - sanitizing_blob msg_enc(std::move(make_handshake(msg))); + sanitizing_blob msg_enc(make_message(type, msg)); encrypt_message(msg_enc); - return make_handshake(msg_enc); + return make_message(type, msg_enc); } else - return make_handshake(msg); + return make_message(type, msg); } /// diff --git a/lib/TLS/src/Method.cpp b/lib/TLS/src/Method.cpp index 337f80b..e8d02a0 100644 --- a/lib/TLS/src/Method.cpp +++ b/lib/TLS/src/Method.cpp @@ -373,7 +373,7 @@ void eap::method_tls::process_request_packet( m_packet_res.m_id = m_packet_req.m_id; m_packet_res.m_flags = 0; sanitizing_blob hello(make_client_hello()); - sanitizing_blob handshake(make_handshake(hello, m_cipher_spec)); + sanitizing_blob handshake(make_message(tls_message_type_handshake, hello, m_cipher_spec)); m_packet_res.m_data.assign(handshake.begin(), handshake.end()); CryptHashData(m_hash_handshake_msgs_md5 , hello.data(), (DWORD)hello.size(), 0); CryptHashData(m_hash_handshake_msgs_sha1, hello.data(), (DWORD)hello.size(), 0); @@ -416,7 +416,7 @@ void eap::method_tls::process_request_packet( if (m_send_client_cert) { // Client certificate requested. sanitizing_blob client_cert(make_client_cert()); - sanitizing_blob handshake(make_handshake(client_cert, m_cipher_spec)); + sanitizing_blob handshake(make_message(tls_message_type_handshake, client_cert, m_cipher_spec)); m_packet_res.m_data.insert(m_packet_res.m_data.end(), handshake.begin(), handshake.end()); CryptHashData(m_hash_handshake_msgs_md5 , client_cert.data(), (DWORD)client_cert.size(), 0); CryptHashData(m_hash_handshake_msgs_sha1, client_cert.data(), (DWORD)client_cert.size(), 0); @@ -434,7 +434,7 @@ void eap::method_tls::process_request_packet( // Create client key exchange message, and append to packet. sanitizing_blob client_key_exchange(make_client_key_exchange(pms)); - sanitizing_blob handshake(make_handshake(client_key_exchange, m_cipher_spec)); + sanitizing_blob handshake(make_message(tls_message_type_handshake, client_key_exchange, m_cipher_spec)); m_packet_res.m_data.insert(m_packet_res.m_data.end(), handshake.begin(), handshake.end()); CryptHashData(m_hash_handshake_msgs_md5 , client_key_exchange.data(), (DWORD)client_key_exchange.size(), 0); CryptHashData(m_hash_handshake_msgs_sha1, client_key_exchange.data(), (DWORD)client_key_exchange.size(), 0); @@ -458,7 +458,7 @@ void eap::method_tls::process_request_packet( // Create finished message, and append to packet. sanitizing_blob finished(make_finished()); - sanitizing_blob handshake(make_handshake(finished, m_cipher_spec)); + sanitizing_blob handshake(make_message(tls_message_type_handshake, finished, m_cipher_spec)); m_packet_res.m_data.insert(m_packet_res.m_data.end(), handshake.begin(), handshake.end()); CryptHashData(m_hash_handshake_msgs_md5 , finished.data(), (DWORD)finished.size(), 0); CryptHashData(m_hash_handshake_msgs_sha1, finished.data(), (DWORD)finished.size(), 0);