tlspuffin/tls/
mod.rs

1//! The *tls* module provides concrete implementations for the functions used in the term.
2//!
3//! The module offers a variety of
4//! [`DynamicFunction`](puffin::algebra::dynamic_function::DynamicFunction)s which can be used in
5//! the fuzzing.
6
7use fn_impl::*;
8use puffin::algebra::dynamic_function::FunctionAttributes;
9use puffin::algebra::error::FnError;
10use puffin::define_signature;
11use puffin::error::Error;
12
13use crate::protocol::TLSProtocolTypes;
14
15mod key_exchange;
16mod key_schedule;
17mod sign;
18
19pub mod differential_rfc_violations;
20pub mod rustls;
21pub mod seeds;
22pub mod violation;
23pub mod vulnerabilities;
24
25/// This module contains all the concrete implementations of function symbols.
26#[path = "."]
27pub mod fn_impl {
28    pub mod fn_cert;
29    pub mod fn_constants;
30    pub mod fn_extensions;
31    pub mod fn_fields;
32    pub mod fn_messages;
33    pub mod fn_transcript;
34    pub mod fn_utils;
35
36    pub use fn_cert::*;
37    pub use fn_constants::*;
38    pub use fn_extensions::*;
39    pub use fn_fields::*;
40    pub use fn_messages::*;
41    pub use fn_transcript::*;
42    pub use fn_utils::*;
43}
44
45impl From<rustls::error::Error> for Error {
46    fn from(error: rustls::error::Error) -> Self {
47        Error::Stream(error.to_string())
48    }
49}
50
51/// Function symbol which can be used for debugging
52#[allow(dead_code)]
53fn fn_debug(
54    message: &crate::tls::rustls::msgs::message::Message,
55) -> Result<crate::tls::rustls::msgs::message::Message, FnError> {
56    dbg!(message);
57    Ok(message.clone())
58}
59
60#[macro_export]
61macro_rules! nyi_fn {
62    ($(#[$attr:meta])*) => {};
63}
64
65define_signature!(
66    TLS_SIGNATURE<TLSProtocolTypes>,
67    // constants
68    fn_true
69    fn_false
70    fn_seq_0
71    fn_seq_1
72    fn_seq_2
73    fn_seq_3
74    fn_seq_4
75    fn_seq_5
76    fn_seq_6
77    fn_seq_7
78    fn_seq_8
79    fn_seq_9
80    fn_seq_10
81    fn_seq_11
82    fn_seq_12
83    fn_seq_13
84    fn_seq_14
85    fn_seq_15
86    fn_seq_16
87    fn_large_length
88    fn_empty_bytes_vec
89    fn_large_bytes_vec [no_bit] // exclude MakeMessage and thus bit-level mutations
90    // messages
91    fn_alert_close_notify
92    fn_application_data
93    fn_certificate
94    fn_certificate13
95    fn_certificate_request
96    fn_certificate_request13
97    fn_certificate_status
98    fn_certificate_verify
99    fn_change_cipher_spec
100    fn_client_hello
101    fn_client_key_exchange
102    fn_empty_handshake_message
103    fn_encrypted_extensions // Just a wrapper, not encrypting per se
104    fn_finished
105    fn_heartbeat
106    // fn_heartbeat_fake_length // Now subsumed by bit-level mutations
107    fn_hello_request
108    fn_hello_retry_request [get] // because some compressions get lost
109    fn_hello_retry_request_random
110    fn_key_update
111    fn_key_update_not_requested
112    fn_message_hash
113    fn_new_session_ticket
114    fn_new_session_ticket13
115    fn_server_hello
116    fn_server_hello_done
117    fn_server_key_exchange
118    // extensions
119    fn_client_extensions_new [list]
120    fn_client_extensions_append [list]
121    fn_client_extensions_make
122    fn_server_extensions_new [list]
123    fn_server_extensions_make
124    fn_server_extensions_append [list]
125    fn_hello_retry_extensions_make
126    fn_hello_retry_extensions_new [list]
127    fn_hello_retry_extensions_append [list]
128    fn_cert_req_extensions_new [list]
129    fn_cert_req_extensions_append [list]
130    fn_cert_extensions_make
131    fn_cert_extensions_new [list]
132    fn_cert_extensions_append [list]
133    fn_new_session_ticket_extensions_new
134    fn_new_session_ticket_extensions_append
135    fn_server_name_extension
136    fn_server_name_server_extension
137    fn_status_request_extension
138    fn_status_request_server_extension
139    fn_status_request_certificate_extension
140    fn_ec_point_formats_extension
141    fn_ec_point_formats_server_extension
142    fn_supported_signature_schemes_extension_new
143    fn_supported_signature_schemes_extension_append [list]
144    fn_sig_scheme_rsa_pkcs1_sha256
145    fn_sig_scheme_rsa_pss_sha256
146    fn_signature_algorithm_extension
147    fn_signature_algorithm_cert_req_extension
148    fn_empty_vec_of_vec
149    fn_append_vec [list]
150    fn_al_protocol_negotiation
151    fn_al_protocol_server_negotiation
152    fn_signed_certificate_timestamp_extension
153    fn_signed_certificate_timestamp_server_extension
154    fn_signed_certificate_timestamp_certificate_extension
155    fn_extended_master_secret_extension
156    fn_extended_master_secret_server_extension
157    fn_session_ticket_request_extension
158    fn_session_ticket_offer_extension
159    fn_session_ticket_server_extension
160    fn_new_preshared_key_identity
161    fn_empty_preshared_keys_identity_vec
162    fn_append_preshared_keys_identity [list]
163    fn_preshared_keys_extension_empty_binder [opaque]
164    fn_preshared_keys_server_extension
165    fn_early_data_extension
166    fn_early_data_new_session_ticket_extension
167    fn_early_data_server_extension
168    fn_supported_versions12_extension
169    fn_supported_versions13_extension
170    fn_supported_versions_both_extension
171    fn_supported_versions12_hello_retry_extension
172    fn_supported_versions13_hello_retry_extension
173    fn_supported_versions12_server_extension
174    fn_supported_versions13_server_extension
175    fn_cookie_extension
176    fn_cookie_hello_retry_extension
177    fn_psk_exchange_mode_dhe_ke_extension
178    fn_psk_exchange_mode_ke_extension
179    fn_certificate_authorities_extension
180    fn_signature_algorithm_cert_extension
181    fn_key_share_deterministic
182    fn_key_share_extension_make
183    fn_key_share_extension_new [list]
184    fn_key_share_extension_append [list]
185    fn_key_share_extension
186    fn_key_share_server_extension
187    fn_key_share_hello_retry_extension
188    fn_transport_parameters_extension
189    fn_transport_parameters_server_extension
190    fn_renegotiation_info_extension
191    fn_renegotiation_info_server_extension
192    fn_transport_parameters_draft_extension
193    fn_transport_parameters_draft_server_extension
194    fn_unknown_client_extension
195    fn_unknown_server_extension
196    fn_unknown_hello_retry_extension
197    fn_unknown_cert_request_extension
198    fn_new_session_ticket_extensions [list]
199    fn_unknown_new_session_ticket_extension
200    fn_unknown_certificate_extension
201    // fields
202    fn_protocol_version13
203    fn_protocol_version12
204    fn_new_session_id
205    fn_empty_session_id
206    fn_new_random
207    // TODO: once fn_compression_append is added, we should then also add fn_compression_make
208    fn_compressions
209    fn_compression
210    fn_no_key_share
211    fn_get_server_key_share [get]
212    fn_get_client_key_share [get]
213    fn_get_any_client_curve [get]
214    fn_verify_data [opaque]
215    fn_verify_data_server [opaque]
216    fn_client_sign_transcript [opaque]
217    fn_server_sign_transcript [opaque]
218    fn_cipher_suites_make
219    fn_new_cipher_suites
220    fn_append_cipher_suite [list]
221    fn_cipher_suite12
222    fn_cipher_suite13_aes_128_gcm_sha256
223    fn_cipher_suite13_aes_256_gcm_sha384
224    fn_cipher_suite13_aes_128_ccm_sha256
225    fn_weak_export_cipher_suite
226    fn_excluded_cipher_suite
227    fn_secure_rsa_cipher_suite12
228    fn_support_group_extension_new [list]
229    fn_support_group_extension_make
230    fn_support_group_extension_append [list]
231    // utils
232    fn_new_flight
233    fn_append_flight [list]
234    fn_new_opaque_flight [list]
235    fn_coalesced_flight
236    fn_append_opaque_flight [list]
237    fn_new_transcript
238    fn_new_hrr_transcript [opaque]
239    fn_append_transcript [opaque] // this one is opaque and not list since it returns the hash of all elements added to the list so far
240    fn_decrypt_handshake_flight [opaque]
241    fn_decrypt_multiple_handshake_messages [opaque] [no_gen]
242    fn_decrypt_application_flight [opaque]
243    fn_find_server_certificate [get]
244    fn_find_server_certificate_request [get]
245    fn_find_server_ticket [get]
246    fn_find_server_certificate_verify [get]
247    fn_find_encrypted_extensions [get]
248    fn_find_server_finished [get]
249    fn_no_psk
250    fn_psk
251    fn_decrypt_application [opaque] [no_gen]
252    fn_encrypt_handshake [opaque]
253    fn_encrypt_handshake_opaque [opaque]
254    fn_encrypt_application [opaque]
255    fn_derive_psk [opaque]
256    fn_derive_binder [opaque]
257    fn_fill_binder [opaque]
258    fn_get_ticket [get]
259    fn_get_ticket_age_add [get]
260    fn_get_ticket_nonce [get]
261    fn_new_transcript12
262    fn_decode_server_ecdh_pubkey [opaque]
263    fn_decode_client_ecdh_pubkey [opaque]
264    fn_sign_rsa_ecdhe_server_key_exchange12 [opaque]
265    fn_encode_ec_pubkey12
266    fn_new_pubkey12 [opaque]
267    fn_encrypt12 [opaque]
268    fn_decrypt12 [no_gen]
269    fn_new_certificate
270    fn_new_certificates [list]
271    fn_append_certificate [list]
272    fn_named_group_secp256r1
273    fn_named_group_secp384r1
274    fn_named_group_x25519
275    fn_u64_to_u32 [get]
276    fn_u32_to_u16 [get]
277    fn_payload_u8
278    fn_payload_u16
279    fn_payload_u24
280    fn_make_payload_u16_vec_u16
281    fn_empty_payload_u16_vec
282    fn_append_payload_u16_vec [list]
283    fn_make_payload_u8_vec_u16
284    fn_empty_payload_u8_vec
285    fn_append_payload_u8_vec [list]
286    // transcript functions
287    fn_server_hello_transcript [opaque] [no_gen]
288    fn_client_finished_transcript [opaque] [no_gen]
289    fn_server_finished_transcript [opaque] [no_gen]
290    fn_certificate_transcript [opaque] [no_gen]
291    // certificate functions
292    fn_bob_cert
293    fn_bob_key
294    fn_alice_cert
295    fn_alice_key
296    fn_eve_cert
297    fn_random_ec_cert
298    fn_random_ec_key
299    fn_certificate_from_vec_u8
300    fn_certificate_entry_extensions
301    fn_empty_certificate_chain
302    fn_new_certificate_entries
303    fn_append_certificate_entries [list]
304    fn_certificate_entries_make
305    fn_chain_append_certificate_entry [list]
306    fn_get_context [get]
307    fn_eve_pkcs1_signature
308    fn_rsa_sign_client [opaque]
309    fn_rsa_sign_server [opaque]
310    fn_ecdsa_sign_client [opaque] [no_det] // fn_ecdsa_sign_client has built-in randomness
311    // TODO: replace this with explicit term
312    fn_ecdsa_sign_server [opaque]
313    fn_rsa_pss_signature_algorithm
314    fn_rsa_pkcs1_signature_algorithm
315    fn_invalid_signature_algorithm
316    fn_ecdsa_signature_algorithm
317);