xref: /webrtc/dtls/src/lib.rs (revision 04f0bd9e)
1 #![warn(rust_2018_idioms)]
2 #![allow(dead_code)]
3 
4 #[macro_use]
5 extern crate serde_derive;
6 
7 pub mod alert;
8 pub mod application_data;
9 pub mod change_cipher_spec;
10 pub mod cipher_suite;
11 pub mod client_certificate_type;
12 pub mod compression_methods;
13 pub mod config;
14 pub mod conn;
15 pub mod content;
16 pub mod crypto;
17 pub mod curve;
18 mod error;
19 pub mod extension;
20 pub mod flight;
21 pub mod fragment_buffer;
22 pub mod handshake;
23 pub mod handshaker;
24 pub mod listener;
25 pub mod prf;
26 pub mod record_layer;
27 pub mod signature_hash_algorithm;
28 pub mod state;
29 
30 pub use error::Error;
31 
32 use cipher_suite::*;
33 use extension::extension_use_srtp::SrtpProtectionProfile;
34 
35 pub(crate) fn find_matching_srtp_profile(
36     a: &[SrtpProtectionProfile],
37     b: &[SrtpProtectionProfile],
38 ) -> Result<SrtpProtectionProfile, ()> {
39     for a_profile in a {
40         for b_profile in b {
41             if a_profile == b_profile {
42                 return Ok(*a_profile);
43             }
44         }
45     }
46     Err(())
47 }
48 
49 pub(crate) fn find_matching_cipher_suite(
50     a: &[CipherSuiteId],
51     b: &[CipherSuiteId],
52 ) -> Result<CipherSuiteId, ()> {
53     for a_suite in a {
54         for b_suite in b {
55             if a_suite == b_suite {
56                 return Ok(*a_suite);
57             }
58         }
59     }
60     Err(())
61 }
62