1pub use either::Either;
16
17#[macro_use]
18mod macros;
19
20mod activate;
21mod backup;
22pub mod consts;
23mod context;
24mod debug;
25mod device;
26mod err;
27mod format;
28mod key;
29mod keyfile;
30mod keyslot;
31mod log;
32mod luks2;
33mod mem;
34mod runtime;
35mod settings;
36mod status;
37#[cfg(test)]
38mod tests;
39mod wipe;
40
41#[cfg(cryptsetup23supported)]
42pub use crate::mem::{SafeBorrowedMemZero, SafeMemzero, SafeOwnedMemZero};
43pub use crate::{
44 activate::CryptActivationHandle,
45 backup::CryptBackupHandle,
46 context::CryptContextHandle,
47 debug::set_debug_level,
48 device::{CryptDevice, CryptInit},
49 err::LibcryptErr,
50 format::{
51 CryptFormatHandle, CryptParamsIntegrity, CryptParamsIntegrityRef, CryptParamsLoopaes,
52 CryptParamsLoopaesRef, CryptParamsLuks1, CryptParamsLuks1Ref, CryptParamsLuks2,
53 CryptParamsLuks2Ref, CryptParamsPlain, CryptParamsPlainRef, CryptParamsTcrypt,
54 CryptParamsTcryptRef, CryptParamsVerity, CryptParamsVerityRef,
55 },
56 key::CryptVolumeKeyHandle,
57 keyfile::{CryptKeyfileContents, CryptKeyfileHandle},
58 keyslot::CryptKeyslotHandle,
59 log::{log, set_log_callback},
60 luks2::{
61 flags::CryptLuks2FlagsHandle,
62 reencrypt::{CryptLuks2ReencryptHandle, CryptParamsReencrypt, CryptParamsReencryptRef},
63 token::{register, CryptLuks2TokenHandle, CryptTokenInfo, TokenInput},
64 },
65 mem::SafeMemHandle,
66 runtime::{ActiveDevice, CryptRuntimeHandle},
67 settings::{CryptPbkdfType, CryptPbkdfTypeRef, CryptSettingsHandle},
68 status::{get_sector_size, status, CryptDeviceStatusHandle},
69 wipe::CryptWipeHandle,
70};
71
72pub use libc::{c_int, c_uint, size_t};
74
75pub type Result<T> = std::result::Result<T, LibcryptErr>;
77
78#[cfg(feature = "mutex")]
79static MUTEX: std::sync::LazyLock<per_thread_mutex::PerThreadMutex> =
80 std::sync::LazyLock::new(per_thread_mutex::PerThreadMutex::default);
81
82#[cfg(not(feature = "mutex"))]
83static THREAD_ID: std::sync::LazyLock<std::thread::ThreadId> =
84 std::sync::LazyLock::new(|| std::thread::current().id());
85
86#[cfg(test)]
87mod test {
88 use crate::tests;
89
90 #[ignore]
91 #[test]
92 fn test_encrypt_by_password() {
93 tests::encrypt::test_encrypt_by_password();
94 }
95
96 #[ignore]
97 #[test]
98 #[cfg(cryptsetup24supported)]
99 fn test_reencrypt_by_password() {
100 tests::reencrypt::test_reencrypt_by_password();
101 }
102
103 #[ignore]
104 #[test]
105 fn test_encrypt_by_keyfile() {
106 tests::encrypt::test_encrypt_by_keyfile();
107 }
108
109 #[ignore]
110 #[test]
111 fn test_encrypt_by_password_without_explicit_format() {
112 tests::encrypt::test_encrypt_by_password_without_explicit_format();
113 }
114
115 #[ignore]
116 #[test]
117 fn test_unencrypted() {
118 tests::encrypt::test_unencrypted();
119 }
120
121 #[ignore]
122 #[test]
123 fn test_crypt_setup_free_exists() {
124 tests::keyfile::test_keyfile_cleanup();
125 }
126}