20 releases (10 breaking)

0.11.0 Oct 4, 2024
0.10.0 Jul 18, 2024
0.9.3 Mar 25, 2024
0.9.1 Oct 23, 2023
0.3.0 Mar 27, 2020

#82 in Unix APIs

Download history 1958/week @ 2024-07-21 1302/week @ 2024-07-28 1718/week @ 2024-08-04 2547/week @ 2024-08-11 1893/week @ 2024-08-18 2511/week @ 2024-08-25 1011/week @ 2024-09-01 1571/week @ 2024-09-08 1144/week @ 2024-09-15 1211/week @ 2024-09-22 895/week @ 2024-09-29 759/week @ 2024-10-06 2392/week @ 2024-10-13 412/week @ 2024-10-20 3035/week @ 2024-10-27 1795/week @ 2024-11-03

7,697 downloads per month
Used in 3 crates

MPL-2.0 license

185KB
4K SLoC

Latest Version Documentation

libcryptsetup-rs

This crate provides Rust bindings for libcryptsetup.

Note on thread-safety

libcryptsetup is not thread-safe and also depends on libraries that are not thread-safe. Any use of libcryptsetup by default in a multithreaded environment will result in undefined behavior.

As a workaround, this library provides a feature (mutex) to cause all calls to libcryptsetup to acquire a crate-level mutex. This will enforce single threaded access to all invocations of the libcryptsetup API.

Rust's decision to make pointers !Send should be respected. Any data structure that contains a pointer is not safe to send across threads. Providing an unsafe impl Send {} for any data structure provided by libcryptsetup-rs that is not Send may result in undefined behavior.

Building

The libcryptsetup bindings require some dependencies outside of cargo to build properly:

  1. cryptsetup (provided by cryptsetup on Fedora)
  2. cryptsetup development headers (provided by cryptsetup-devel on Fedora)
  3. libclang (provided by clang on Fedora)

Sanity testing bindings

There is one test that actually invokes libcryptsetup and can be used for basic sanity testing of the bindings as it will only succeed if low level bindings are correctly generated, the high level bindings build, and libcryptsetup successfully encrypts a loopback device.

This can be invoked as follows:

make test-loopback

Dependencies

~1–4.5MB
~85K SLoC