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#[cfg(feature = "full")]
32mod encoding;
33mod value;
34pub use value::Value;
35/// Safe wrappers for `SecCertificateRef` and public-key APIs in Security.framework.
36pub mod certificate;
37/// Safe wrappers for CMS encoder and decoder APIs in Security.framework.
38#[cfg(feature = "full")]
39pub mod cms;
40/// Safe wrappers for code-signing APIs such as `SecCodeRef` and `SecTaskRef`.
41#[cfg(feature = "full")]
42pub mod code;
43/// Re-exports code-signing wrappers built on Security.framework.
44#[cfg(feature = "full")]
45pub mod code_signing;
46/// Error types used by the Security.framework wrappers.
47pub mod error;
48#[cfg(feature = "raw-ffi")]
49#[cfg_attr(docsrs, doc(cfg(feature = "raw-ffi")))]
50pub mod ffi;
51/// Safe wrappers for `SecIdentityRef`.
52#[cfg(feature = "full")]
53pub mod identity;
54/// Safe wrappers for `SecKeyRef` algorithms and private-key APIs.
55pub mod key;
56/// Safe wrappers for `SecKeyRef` key-agreement APIs.
57#[cfg(feature = "full")]
58pub mod key_agreement;
59/// Safe wrappers for password-based key-derivation APIs in Security.framework.
60#[cfg(feature = "full")]
61pub mod key_derivation;
62/// Safe wrappers for keychain and access-control APIs in Security.framework.
63#[cfg(feature = "full")]
64pub mod keychain;
65/// Safe wrappers for `SecPolicyRef` and policy configuration APIs.
66#[cfg(feature = "full")]
67pub mod policy;
68/// Re-exports secure-random wrappers built on `SecRandomCopyBytes`.
69#[cfg(feature = "full")]
70pub mod random;
71/// Safe wrappers for `SecRandomCopyBytes`.
72#[cfg(feature = "full")]
73pub mod random_bytes;
74#[cfg(feature = "full")]
75pub mod secret;
76/// Safe wrappers for Secure Transport session APIs in Security.framework.
77#[cfg(feature = "full")]
78pub mod secure_transport;
79/// Safe wrappers for Security Transforms APIs.
80#[cfg(feature = "full")]
81pub mod transform;
82/// Safe wrappers for `SecTrustRef` and trust-evaluation APIs.
83#[cfg(feature = "full")]
84pub mod trust;
85
86#[cfg(feature = "full")]
87pub use authorization::{Authorization, AuthorizationOptions};
88pub use certificate::{Certificate, PublicKey};
89#[cfg(feature = "full")]
90pub use cms::{
91    Cms, CmsCertificateChainMode, CmsCertificateVerification, CmsDecoder, CmsDigestAlgorithm,
92    CmsEncoder, CmsSignedAttributes, CmsSignerStatus, CmsSignerStatusReport,
93};
94#[cfg(feature = "full")]
95pub use code::{
96    AuditToken, Code, CodeSigningFlags, CodeStatus, Requirement, SigningInformation, SigningValue,
97    StaticCode, Task,
98};
99pub use error::{OsStatus, Result, SecurityError, StatusError};
100#[cfg(feature = "full")]
101pub use identity::Identity;
102pub use key::{
103    EncryptionAlgorithm, ExternalFormat, ExternalItemType, KeyType, PrivateKey, SignatureAlgorithm,
104};
105#[cfg(feature = "full")]
106pub use key_agreement::{AgreementPrivateKey, AgreementPublicKey};
107#[cfg(feature = "full")]
108pub use key_derivation::{DerivedKey, KeyDerivation};
109#[cfg(feature = "full")]
110pub use keychain::{
111    AccessControl, AccessControlFlags, AccessControlProtection, InternetCredential,
112    InternetPassword, Keychain, KeychainEntry, KeychainOptions,
113};
114#[cfg(feature = "full")]
115pub use policy::{Policy, PolicyIdentifier, PolicyName, PolicyProperties, RevocationFlags};
116#[cfg(feature = "full")]
117pub use random_bytes::SecureRandom;
118#[cfg(feature = "full")]
119pub use secret::SecretBytes;
120#[cfg(feature = "full")]
121pub use secure_transport::{ProtocolVersion, SecureTransportContext, SecureTransportState};
122#[cfg(feature = "full")]
123pub use transform::Transform;
124#[cfg(feature = "full")]
125pub use trust::{Trust, TrustOptions, TrustResultType};
126
127/// Common imports for users of this crate.
128#[cfg(feature = "full")]
129pub mod prelude {
130    pub use crate::authorization::{Authorization, AuthorizationOptions};
131    pub use crate::certificate::{Certificate, PublicKey};
132    pub use crate::cms::{
133        Cms, CmsCertificateChainMode, CmsCertificateVerification, CmsDecoder, CmsDigestAlgorithm,
134        CmsEncoder, CmsSignedAttributes, CmsSignerStatus, CmsSignerStatusReport,
135    };
136    pub use crate::code::{
137        AuditToken, Code, CodeSigningFlags, CodeStatus, Requirement, SigningInformation,
138        SigningValue, StaticCode, Task,
139    };
140    pub use crate::error::{OsStatus, Result, SecurityError, StatusError};
141    pub use crate::identity::Identity;
142    pub use crate::key::{
143        EncryptionAlgorithm, ExternalFormat, ExternalItemType, KeyType, PrivateKey,
144        SignatureAlgorithm,
145    };
146    pub use crate::key_agreement::{AgreementPrivateKey, AgreementPublicKey};
147    pub use crate::key_derivation::{DerivedKey, KeyDerivation};
148    pub use crate::keychain::{
149        AccessControl, AccessControlFlags, AccessControlProtection, InternetCredential,
150        InternetPassword, Keychain, KeychainEntry, KeychainOptions,
151    };
152    pub use crate::policy::{
153        Policy, PolicyIdentifier, PolicyName, PolicyProperties, RevocationFlags,
154    };
155    pub use crate::random_bytes::SecureRandom;
156    pub use crate::secret::SecretBytes;
157    pub use crate::secure_transport::{
158        ProtocolVersion, SecureTransportContext, SecureTransportState,
159    };
160    pub use crate::transform::Transform;
161    pub use crate::trust::{Trust, TrustOptions, TrustResultType};
162}