1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
//! TODO: Write intro: <https://github.com/tlspuffin/tlspuffin/issues/94>
//!
//! ### Used protocol and cryptographic libraries
//!
//! In order to easily implement concrete functions, we use several libraries which provide us with predefined encoders for TLS packets, cryptographic primitives, as well as higher level cryptographic operations specific for TLS.
//!
//! We forked the [rustls](https://github.com/ctz/rustls) library for cryptographic operations like deriving secrets. We also use it to encode and decode TLS messages.
//!
//! The cryptographic library [ring](https://github.com/briansmith/ring) allows us to use the derived secrets to encrypt and decrypt TLS messages.
//! # Example
//!
//! ```rust
//! use puffin::agent::{AgentName, AgentDescriptor, TLSVersion::*};
//! use puffin::trace::{Step, Source, TraceContext, Trace, Action, InputAction, OutputAction, Query};
//! use puffin::algebra::{Term, signature::Signature};
//! use tlspuffin::tls::fn_impl::fn_client_hello;
//! use tlspuffin::tls::rustls::msgs::handshake::{SessionID, Random, ClientExtension};
//! use tlspuffin::tls::rustls::msgs::enums::{ProtocolVersion, CipherSuite, Compression, HandshakeType};
//! use tlspuffin::query::TlsQueryMatcher;
//!
//!
//! let client: AgentName = AgentName::first();
//! let server: AgentName = client.next();
//!
//! let trace = Trace {
//!     prior_traces: vec![],
//!     descriptors: vec![
//!         AgentDescriptor::new_client(client, V1_3),
//!         AgentDescriptor::new_server(server, V1_3),
//!     ],
//!     steps: vec![
//!             OutputAction::new_step(client),
//!             // Client: Hello Client -> Server
//!             Step {
//!                 agent: server,
//!                 action: Action::Input(InputAction {
//!                     recipe: Term::Application(
//!                         Signature::new_function(&fn_client_hello),
//!                         vec![
//!                             Term::Variable(Signature::new_var_with_type::<ProtocolVersion, _>(
//!                                     Some(Source::Agent(client)),  
//!                                     Some(TlsQueryMatcher::Handshake(Some(HandshakeType::ClientHello))),
//!                                     0
//!                             )),
//!                             Term::Variable(Signature::new_var_with_type::<Random, _>(
//!                                     Some(Source::Agent(client)),  
//!                                     Some(TlsQueryMatcher::Handshake(Some(HandshakeType::ClientHello))),
//!                                     0
//!                             )),
//!                             Term::Variable(Signature::new_var_with_type::<SessionID, _>(
//!                                     Some(Source::Agent(client)),
//!                                     Some(TlsQueryMatcher::Handshake(Some(HandshakeType::ClientHello))),
//!                                     0
//!                             )),
//!                             Term::Variable(Signature::new_var_with_type::<Vec<CipherSuite>, _>(
//!                                     Some(Source::Agent(client)),
//!                                     Some(TlsQueryMatcher::Handshake(Some(HandshakeType::ClientHello))),
//!                                     0
//!                             )),
//!                             Term::Variable(Signature::new_var_with_type::<Vec<Compression>, _>(
//!                                     Some(Source::Agent(client)),
//!                                     Some(TlsQueryMatcher::Handshake(Some(HandshakeType::ClientHello))),
//!                                     0
//!                             )),
//!                             Term::Variable(Signature::new_var_with_type::<Vec<ClientExtension>, _>(
//!                                     Some(Source::Agent(client)),
//!                                     Some(TlsQueryMatcher::Handshake(Some(HandshakeType::ClientHello))),
//!                                     0
//!                             )),
//!                         ],
//!                     ),
//!                 }),
//!             },
//!     // further steps here
//!     ]
//! };
//! ```
//!
//! # Example with `term!` macro
//!
//! ```rust
//! use puffin::agent::AgentName;
//! use puffin::term;
//! use tlspuffin::tls::fn_impl::fn_client_hello;
//! use tlspuffin::tls::rustls::msgs::handshake::{SessionID, Random, ClientExtension};
//! use tlspuffin::tls::rustls::msgs::enums::{Compression, HandshakeType, ProtocolVersion, CipherSuite};
//! use puffin::algebra::Term;
//! use tlspuffin::query::TlsQueryMatcher;
//! use puffin::trace::Source;
//!
//! let client = AgentName::first();
//! let term: Term<TlsQueryMatcher> = term! {
//!     fn_client_hello(
//!         ((client, 0)/ProtocolVersion),
//!         ((client, 0)/Random),
//!         ((client, 0)/SessionID),
//!         ((client, 0)/Vec<CipherSuite>),
//!         ((client, 0)/Vec<Compression>),
//!         ((client, 0)/Vec<ClientExtension>)
//!     )
//! };
//! ```
//!

#[cfg(feature = "boringssl-binding")]
pub mod boringssl;
pub mod claims;
pub mod debug;
#[cfg(feature = "openssl-binding")]
pub mod openssl;
mod protocol;
pub mod put;
pub mod put_registry;
pub mod query;
pub mod static_certs;
pub mod tcp;
pub mod tls;
#[cfg(feature = "wolfssl-binding")]
pub mod wolfssl;

#[cfg(test)]
mod integration_tests;
#[cfg(test)]
mod test_utils;