Skip to content

Commit

Permalink
Remove session specification for TLS handshake protocol
Browse files Browse the repository at this point in the history
Ref. #292
  • Loading branch information
treiher committed Jul 27, 2021
1 parent de4fcc7 commit f85752f
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 2,457 deletions.
193 changes: 1 addition & 192 deletions tests/integration/session/greentls.rflx
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
with TLS_Alert;
with TLS_Handshake;

package GreenTLS is

type KM_Length is range 0 .. 16320 with Size => 16;

type Content is
message
null
Expand Down Expand Up @@ -49,7 +46,7 @@ package GreenTLS is
type Heartbeat_Control_Message is
message
Local : Heartbeat_Mode;
Remote : TLS_Handshake::Heartbeat_Mode;
Remote : Heartbeat_Mode;
end message;

for Control_Message use (Data => Heartbeat_Control_Message)
Expand Down Expand Up @@ -89,14 +86,6 @@ package GreenTLS is
for Application_Control_Message use (Data => Alert_Message)
if Tag = Application_Alert;

type Application_Protocol_Message is
message
Protocol : TLS_Handshake::Protocol_Name;
end message;

for Application_Control_Message use (Data => Application_Protocol_Message)
if Tag = Application_Protocol;

type Application_No_Early_Data_Message is null message;

for Application_Control_Message use (Data => Application_No_Early_Data_Message)
Expand All @@ -112,186 +101,6 @@ package GreenTLS is
Data : Opaque;
end message;

type Padding is range 0 .. 0 with Size => 2;

type Configuration is
message
PSK_Key_Exchange_Modes : TLS_Handshake::PSK_Key_Exchange_Modes; -- FIXME: must only contain PSK_KE and/or PSK_DHE_KE
Cipher_Suites_Length : TLS_Handshake::Cipher_Suites_Length
then Cipher_Suites
with Size => Cipher_Suites_Length * 8;
Cipher_Suites : TLS_Handshake::Cipher_Suites;
Supported_Groups : TLS_Handshake::Supported_Groups;
Signature_Algorithms : TLS_Handshake::Signature_Algorithms;
Signature_Algorithms_Cert_Enabled : Boolean
then Signature_Algorithms_Cert
if Signature_Algorithms_Cert_Enabled = True
then Key_Shares
if Signature_Algorithms_Cert_Enabled = False;
Signature_Algorithms_Cert : TLS_Handshake::Signature_Algorithms_Cert;
Key_Shares : TLS_Handshake::Key_Share_CH;
Protocols : TLS_Handshake::Protocol_Name_List;
Server_Authentication_Enabled : Boolean;
Post_Handshake_Auth_Enabled : Boolean;
Early_Data_Enabled : Boolean;
Server_Name_Enabled : Boolean;
Max_Fragment_Length_Enabled : Boolean;
Max_Fragment_Length : TLS_Handshake::Max_Fragment_Length_Value;
Heartbeat_Mode : Heartbeat_Mode;
Padding : Padding;
end message;

type Name_Length is range 1 .. 253 with Size => 8;
type Port is range 1 .. 65535 with Size => 16;

type Connection is
message
Name_Length : Name_Length
then Name
with Size => Name_Length * 8;
Name : Opaque;
Port : Port;
end message;

type Keystore_Message_Type is (Keystore_Request, Keystore_Response) with Size => 8;
type Keystore_Request_Type is
(Keystore_Request_Server_Preferred_Groups,
Keystore_Request_PSKs,
Keystore_Request_Certificates,
Keystore_Request_Signature,
Keystore_Request_New_Session_Ticket)
with Size => 8;
type Keystore_Payload_Length is range 0 .. 2**16 - 1 with Size => 16;

type Keystore_Message is
message
Tag : Keystore_Message_Type;
Request : Keystore_Request_Type;
Length : Keystore_Payload_Length
then Payload
with Size => Length * 8;
Payload : Opaque;
end message;

for Keystore_Message use (Payload => Connection)
if Tag = Keystore_Request and (Request = Keystore_Request_Server_Preferred_Groups or Request = Keystore_Request_PSKs);

for Keystore_Message use (Payload => TLS_Handshake::Supported_Groups)
if Tag = Keystore_Response and Request = Keystore_Request_Server_Preferred_Groups;

type Key_Type is (External, Resumption) with Size => 8;

type PSK is
message
Identity : TLS_Handshake::PSK_Identity;
Cipher_Suite : TLS_Handshake::Cipher_Suite;
Key_Type : Key_Type;
Key_Length : Key_Length
then Key
with Size => Key_Length * 8;
Key : Opaque;
end message;

type PSKs is sequence of PSK;

type PSK_Message is
message
null
then PSKs
with Size => Message'Size;
PSKs : PSKs;
end message;

for Keystore_Message use (Payload => PSK_Message)
if Tag = Keystore_Response and Request = Keystore_Request_PSKs;

type Certificate_Query is
message
Certificate_Authorities : TLS_Handshake::Certificate_Authorities;
OID_Filters : TLS_Handshake::OID_Filters;
Signature_Algorithms : TLS_Handshake::Signature_Algorithms;
Signature_Algorithms_Cert : TLS_Handshake::Signature_Algorithms_Cert;
end message;

for Keystore_Message use (Payload => Certificate_Query)
if Tag = Keystore_Request and Request = Keystore_Request_Certificates;

type Certificate_ID is mod 2**16;

type Certificate is
message
ID : Certificate_ID;
Length : TLS_Handshake::Certificate_List_Length
then Certificate_List
with Size => Length * 8;
Certificate_List : TLS_Handshake::Certificate_Entries;
end message;

for Keystore_Message use (Payload => Certificate)
if Tag = Keystore_Response and Request = Keystore_Request_Certificates;

type Signature_Query is
message
ID : Certificate_ID;
Length : KM_Length
then Data
with Size => Length * 8;
Data : Opaque;
end message;

for Keystore_Message use (Payload => Signature_Query)
if Tag = Keystore_Request and Request = Keystore_Request_Signature;

for Keystore_Message use (Payload => TLS_Handshake::Certificate_Verify)
if Tag = Keystore_Response and Request = Keystore_Request_Signature;

type New_Session_Ticket is
message
Connection : Connection;
Session : TLS_Handshake::New_Session_Ticket;
PSK_Length : KM_Length
then PSK
with Size => PSK_Length * 8;
PSK : Opaque;
end message;

for Keystore_Message use (Payload => New_Session_Ticket)
if Tag = Keystore_Request and Request = Keystore_Request_New_Session_Ticket;

type Done is null message;

for Keystore_Message use (Payload => Done)
if Tag = Keystore_Response and Request = Keystore_Request_New_Session_Ticket;

type Certificate_Validation_Result is
(Valid_Certificate,
Bad_Certificate,
Unsupported_Certificate,
Certificate_Revoked,
Certificate_Expired,
Certificate_Unknown)
with Size => 8;

type Signature_Validation_Result is
(Valid_Signature,
Illegal_Parameter,
Decrypt_Error)
with Size => 8;

type RNG_Message_Type is (RNG_Request, RNG_Response) with Size => 8;

type RNG_Message is
message
Tag : RNG_Message_Type;
Length : KM_Length
then Data
with Size => Length * 8
if Tag = RNG_Response
then null
if Tag = RNG_Request;
Data : Opaque;
end message;

type Sequence_Number is mod 2**16;

end GreenTLS;
2 changes: 1 addition & 1 deletion tests/integration/session/session_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
TESTDIR = "tests/integration/session"


@pytest.mark.parametrize("spec", ["tls_handshake_session", "tls_record_session"])
@pytest.mark.parametrize("spec", ["tls_record_session"])
def test_session(spec: str, tmp_path: Path) -> None:
p = Parser()
p.parse(Path(f"{TESTDIR}/{spec}.rflx"))
Expand Down
Loading

0 comments on commit f85752f

Please sign in to comment.