Skip to content

Commit

Permalink
Add CONTROL_WKC_V1 definitions and improve packetdump of tls-crypt-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
schwabe committed Nov 16, 2022
1 parent 067e31e commit 6bc1a7c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion openvpn/crypto/packet_id.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ namespace openvpn {
std::string str() const
{
std::ostringstream os;
os << "[" << time << "," << id << "]";
os << std::hex << "[0x" << time << ", 0x" << id << "]";
return os.str();
}
};
Expand Down
16 changes: 9 additions & 7 deletions openvpn/ssl/proto.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ namespace openvpn {
//CONTROL_HARD_RESET_SERVER_V1 = 2, // (obsolete) initial key from server, forget previous state
CONTROL_SOFT_RESET_V1 = 3, // new key, graceful transition from old to new key
CONTROL_V1 = 4, // control channel packet (usually TLS ciphertext)
CONTROL_WKC_V1 = 11, // control channel packet with wrapped client key appended
ACK_V1 = 5, // acknowledgement for packets received
DATA_V1 = 6, // data channel packet with 1-byte header
DATA_V2 = 9, // data channel packet with 4-byte header
Expand Down Expand Up @@ -1077,6 +1078,7 @@ namespace openvpn {
break;
}
case CONTROL_HARD_RESET_SERVER_V2:
case CONTROL_WKC_V1:
{
if (proto.is_server())
return;
Expand Down Expand Up @@ -1127,6 +1129,8 @@ namespace openvpn {
return "CONTROL_HARD_RESET_CLIENT_V3";
case CONTROL_HARD_RESET_SERVER_V2:
return "CONTROL_HARD_RESET_SERVER_V2";
case CONTROL_WKC_V1:
return "CONTROL_WKC_V1";
}
return nullptr;
}
Expand Down Expand Up @@ -1166,17 +1170,15 @@ namespace openvpn {
out << " SRC_PSID=" << src_psid.str();
}

if (tls_wrap_mode == TLS_CRYPT)
if (tls_wrap_mode == TLS_CRYPT || tls_wrap_mode == TLS_CRYPT_V2)
{
PacketID pid;
pid.read(b, PacketID::LONG_FORM);
out << " PID=" << pid.str();

const unsigned char *hmac = b.read_alloc(hmac_size);
out << " HMAC=" << render_hex(hmac, hmac_size);

// nothing else to print as the content is encrypted beyond this point
out << " TLS-CRYPT ENCRYPTED";
out << " TLS-CRYPT ENCRYPTED PAYLOAD=" << b.size() << " bytes";
}
else
{
Expand Down Expand Up @@ -1209,9 +1211,9 @@ namespace openvpn {

if (opcode != ACK_V1)
out << " MSG_ID=" << ReliableAck::read_id(b);
}
if (opcode != ACK_V1)
out << " SIZE=" << b.size() << '/' << orig_size;

out << " SIZE=" << b.size() << '/' << orig_size;
}
}
#ifdef OPENVPN_DEBUG_PROTO_DUMP
out << '\n' << string::trim_crlf_copy(dump_hex(buf));
Expand Down

0 comments on commit 6bc1a7c

Please sign in to comment.