security_framework/
lib.rs1#![cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos", target_os = "visionos"))]
2
3#![warn(missing_docs)]
5#![allow(non_upper_case_globals)]
6#![allow(clippy::manual_non_exhaustive)] #![allow(clippy::bad_bit_mask)] #![allow(clippy::struct_excessive_bools)]
9#![allow(clippy::unreadable_literal)]
10#![allow(clippy::ignore_without_reason)]
11
12use core_foundation_sys::base::OSStatus;
13use security_framework_sys::base::errSecSuccess;
14
15use crate::base::{Error, Result};
16
17#[cfg(test)]
18macro_rules! p {
19 ($e:expr) => {
20 match $e {
21 Ok(s) => s,
22 Err(e) => panic!("{:?}", e),
23 }
24 };
25}
26
27#[cfg(all(not(feature = "OSX_10_13"), any(feature = "alpn", feature = "session-tickets")))]
28#[macro_use]
29mod dlsym;
30
31pub mod access_control;
32#[cfg(target_os = "macos")]
33pub mod authorization;
34pub mod base;
35pub mod certificate;
36pub mod cipher_suite;
37#[cfg(target_os = "macos")]
38pub mod cms;
39pub mod identity;
40pub mod import_export;
41pub mod item;
42pub mod key;
43pub mod os;
44pub mod passwords;
45#[doc(hidden)]
46pub mod passwords_options;
47pub mod policy;
48pub mod random;
49pub mod secure_transport;
50pub mod trust;
51#[cfg(target_os = "macos")]
52pub mod trust_settings;
53
54#[inline(always)]
55fn cvt(err: OSStatus) -> Result<()> {
56 match err {
57 errSecSuccess => Ok(()),
58 err => Err(Error::from_code(err)),
59 }
60}
61
62#[cfg(test)]
63mod test {
64 use crate::certificate::SecCertificate;
65
66 pub fn certificate() -> SecCertificate {
67 let certificate = include_bytes!("../test/server.der");
68 p!(SecCertificate::from_der(certificate))
69 }
70}