Skip to main content

security/
lib.rs

1#![doc = include_str!("../README.md")]
2#![cfg(target_os = "macos")]
3//!
4//! ---
5//!
6//! # API documentation
7//!
8//! Safe Rust bindings for Apple's `Security.framework` on macOS.
9
10#![cfg_attr(docsrs, feature(doc_cfg))]
11#![allow(
12    clippy::missing_const_for_fn,
13    clippy::missing_errors_doc,
14    clippy::missing_panics_doc,
15    clippy::module_name_repetitions,
16    clippy::must_use_candidate,
17    clippy::needless_pass_by_value,
18    clippy::option_if_let_else,
19    clippy::redundant_pub_crate,
20    clippy::unnecessary_lazy_evaluations
21)]
22
23#[cfg(feature = "async")]
24#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
25pub mod async_api;
26/// Safe wrappers for Authorization Services APIs in Security.framework.
27#[cfg(feature = "full")]
28pub mod authorization;
29#[cfg_attr(not(feature = "full"), allow(dead_code))]
30mod bridge;
31/// Safe wrappers for `SecCertificateRef` and public-key APIs in Security.framework.
32pub mod certificate;
33/// Safe wrappers for CMS encoder and decoder APIs in Security.framework.
34#[cfg(feature = "full")]
35pub mod cms;
36/// Safe wrappers for code-signing APIs such as `SecCodeRef` and `SecTaskRef`.
37#[cfg(feature = "full")]
38pub mod code;
39/// Re-exports code-signing wrappers built on Security.framework.
40#[cfg(feature = "full")]
41pub mod code_signing;
42/// Error types used by the Security.framework wrappers.
43pub mod error;
44#[cfg(feature = "raw-ffi")]
45#[cfg_attr(docsrs, doc(cfg(feature = "raw-ffi")))]
46pub mod ffi;
47/// Safe wrappers for `SecIdentityRef`.
48#[cfg(feature = "full")]
49pub mod identity;
50/// Safe wrappers for `SecKeyRef` algorithms and private-key APIs.
51pub mod key;
52/// Safe wrappers for `SecKeyRef` key-agreement APIs.
53#[cfg(feature = "full")]
54pub mod key_agreement;
55/// Safe wrappers for password-based key-derivation APIs in Security.framework.
56#[cfg(feature = "full")]
57pub mod key_derivation;
58/// Safe wrappers for keychain and access-control APIs in Security.framework.
59#[cfg(feature = "full")]
60pub mod keychain;
61/// Safe wrappers for `SecPolicyRef` and policy configuration APIs.
62#[cfg(feature = "full")]
63pub mod policy;
64/// Re-exports secure-random wrappers built on `SecRandomCopyBytes`.
65#[cfg(feature = "full")]
66pub mod random;
67/// Safe wrappers for `SecRandomCopyBytes`.
68#[cfg(feature = "full")]
69pub mod random_bytes;
70#[cfg(feature = "full")]
71pub mod secret;
72/// Safe wrappers for Secure Transport session APIs in Security.framework.
73#[cfg(feature = "full")]
74pub mod secure_transport;
75/// Safe wrappers for Security Transforms APIs.
76#[cfg(feature = "full")]
77pub mod transform;
78/// Safe wrappers for `SecTrustRef` and trust-evaluation APIs.
79#[cfg(feature = "full")]
80pub mod trust;
81
82#[cfg(feature = "full")]
83pub use authorization::{Authorization, AuthorizationOptions};
84pub use certificate::{Certificate, PublicKey};
85#[cfg(feature = "full")]
86pub use cms::{
87    Cms, CmsCertificateChainMode, CmsCertificateVerification, CmsDecoder, CmsDigestAlgorithm,
88    CmsEncoder, CmsSignedAttributes, CmsSignerStatus, CmsSignerStatusReport,
89};
90#[cfg(feature = "full")]
91pub use code::{
92    AuditToken, Code, CodeSigningFlags, CodeStatus, Requirement, SigningInformation, SigningValue,
93    StaticCode, Task,
94};
95pub use error::{OsStatus, Result, SecurityError, StatusError};
96#[cfg(feature = "full")]
97pub use identity::Identity;
98pub use key::{
99    EncryptionAlgorithm, ExternalFormat, ExternalItemType, KeyType, PrivateKey, SignatureAlgorithm,
100};
101#[cfg(feature = "full")]
102pub use key_agreement::{AgreementPrivateKey, AgreementPublicKey};
103#[cfg(feature = "full")]
104pub use key_derivation::{DerivedKey, KeyDerivation};
105#[cfg(feature = "full")]
106pub use keychain::{
107    AccessControl, AccessControlFlags, AccessControlProtection, InternetCredential,
108    InternetPassword, Keychain, KeychainEntry, KeychainOptions,
109};
110#[cfg(feature = "full")]
111pub use policy::{Policy, PolicyIdentifier, PolicyName, PolicyProperties, RevocationFlags};
112#[cfg(feature = "full")]
113pub use random_bytes::SecureRandom;
114#[cfg(feature = "full")]
115pub use secret::SecretBytes;
116#[cfg(feature = "full")]
117pub use secure_transport::{ProtocolVersion, SecureTransportContext, SecureTransportState};
118#[cfg(feature = "full")]
119pub use transform::Transform;
120#[cfg(feature = "full")]
121pub use trust::{Trust, TrustOptions, TrustResultType};
122
123/// Common imports for users of this crate.
124#[cfg(feature = "full")]
125pub mod prelude {
126    pub use crate::authorization::{Authorization, AuthorizationOptions};
127    pub use crate::certificate::{Certificate, PublicKey};
128    pub use crate::cms::{
129        Cms, CmsCertificateChainMode, CmsCertificateVerification, CmsDecoder, CmsDigestAlgorithm,
130        CmsEncoder, CmsSignedAttributes, CmsSignerStatus, CmsSignerStatusReport,
131    };
132    pub use crate::code::{
133        AuditToken, Code, CodeSigningFlags, CodeStatus, Requirement, SigningInformation,
134        SigningValue, StaticCode, Task,
135    };
136    pub use crate::error::{OsStatus, Result, SecurityError, StatusError};
137    pub use crate::identity::Identity;
138    pub use crate::key::{
139        EncryptionAlgorithm, ExternalFormat, ExternalItemType, KeyType, PrivateKey,
140        SignatureAlgorithm,
141    };
142    pub use crate::key_agreement::{AgreementPrivateKey, AgreementPublicKey};
143    pub use crate::key_derivation::{DerivedKey, KeyDerivation};
144    pub use crate::keychain::{
145        AccessControl, AccessControlFlags, AccessControlProtection, InternetCredential,
146        InternetPassword, Keychain, KeychainEntry, KeychainOptions,
147    };
148    pub use crate::policy::{
149        Policy, PolicyIdentifier, PolicyName, PolicyProperties, RevocationFlags,
150    };
151    pub use crate::random_bytes::SecureRandom;
152    pub use crate::secret::SecretBytes;
153    pub use crate::secure_transport::{
154        ProtocolVersion, SecureTransportContext, SecureTransportState,
155    };
156    pub use crate::transform::Transform;
157    pub use crate::trust::{Trust, TrustOptions, TrustResultType};
158}