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
125
126
127
128
129
130
131
132
133
134
135
//! DTLS 1.2 for the Sans-I/O WebRTC stack.
//!
//! An implementation of Datagram Transport Layer Security ([RFC 6347]) with the extensions
//! WebRTC requires: DTLS-SRTP key export ([RFC 5764]), extended master secret
//! ([RFC 7627]), and elliptic-curve cipher suites ([RFC 4492], [RFC 5289]). It secures the
//! media and data-channel path: SRTP keying material comes out of the DTLS handshake, and
//! SCTP data channels run over the DTLS association itself.
//!
//! # Structure
//!
//! * [`endpoint`] — the Sans-I/O entry point: feed it datagrams, poll it for the datagrams
//! it wants to send and the events it produces. No sockets, no timers of its own.
//! * [`config`] — certificates, cipher-suite and curve preferences, the client/server role,
//! and the SRTP protection profiles to negotiate.
//! * [`handshake`], [`flight`], [`state`] — the handshake message types and the flight state
//! machine that drives them, including retransmission.
//! * [`cipher_suite`], [`crypto`], [`curve`], [`signature_hash_algorithm`] — the
//! cryptographic primitives and the negotiated-suite abstraction.
//! * [`extension`] — the ClientHello/ServerHello extensions, including `use_srtp` and SNI.
//! * [`alert`], [`content`], [`record_layer`] — the record layer and its content types.
//!
//! # Example
//!
//! A WebRTC handshake is configured with a self-signed certificate and the SRTP profiles to
//! negotiate through `use_srtp`; the keys for those profiles are then exported from the
//! completed handshake rather than signalled:
//!
//! ```
//! use rtc_dtls::config::{ConfigBuilder, ExtendedMasterSecretType};
//! use rtc_dtls::extension::extension_use_srtp::SrtpProtectionProfile;
//!
//! let builder = ConfigBuilder::default()
//! .with_srtp_protection_profiles(vec![
//! SrtpProtectionProfile::Srtp_Aead_Aes_128_Gcm,
//! SrtpProtectionProfile::Srtp_Aes128_Cm_Hmac_Sha1_80,
//! ])
//! .with_extended_master_secret(ExtendedMasterSecretType::Require);
//! # let _ = builder;
//! ```
//!
//! Most applications do not depend on this crate directly — the
//! [`rtc`](https://docs.rs/rtc) crate drives it as one layer of the peer-connection
//! pipeline.
//!
//! [RFC 6347]: https://datatracker.ietf.org/doc/html/rfc6347
//! [RFC 5764]: https://datatracker.ietf.org/doc/html/rfc5764
//! [RFC 7627]: https://datatracker.ietf.org/doc/html/rfc7627
//! [RFC 4492]: https://datatracker.ietf.org/doc/html/rfc4492
//! [RFC 5289]: https://datatracker.ietf.org/doc/html/rfc5289
/// Alert records: fatal errors and the orderly `close_notify`.
/// Application data records — the payload DTLS carries once the handshake completes.
/// The ChangeCipherSpec record, which switches a side over to the negotiated keys.
/// The negotiable cipher suites and the [`CipherSuite`] trait they
/// implement.
/// Certificate types a server may request from a client.
/// The compression-methods field. DTLS in WebRTC always negotiates null compression.
/// Handshake configuration: certificates, roles, cipher-suite and SRTP profile preferences.
/// Connection state shared across the handshake and record layers.
/// Record content types: handshake, alert, change-cipher-spec and application data.
/// Cryptographic primitives: the AEAD and CBC ciphers, certificates and signatures.
/// Elliptic curves and the key-exchange values exchanged over them.
/// The Sans-I/O entry point: feed it datagrams, poll it for output and events.
/// ClientHello and ServerHello extensions, including `use_srtp` and SNI.
/// The flight state machine, which drives the handshake and its retransmissions.
/// Reassembly of handshake messages fragmented across datagrams.
/// The handshake message types and the cache that hashes them for `Finished`.
/// Handshake orchestration: state, roles and the verification callbacks.
/// The pseudo-random function that expands the master secret into keys.
/// The record layer: framing, sequence numbers and epochs.
/// Signature and hash algorithm pairs, as negotiated for certificate verification.
/// The negotiated connection state: keys, sequence numbers and peer identity.
use *;
use SrtpProtectionProfile;
compile_error!;
compile_error!;
extern crate aws_lc_rs as ring;
pub
pub