15 releases (8 breaking)

0.9.0 Sep 11, 2023
0.8.0 Jun 6, 2023
0.7.1 May 31, 2023
0.6.1 Feb 15, 2023
0.3.0 Mar 27, 2020

#66 in Unix APIs

Download history 1137/week @ 2023-06-07 1034/week @ 2023-06-14 1420/week @ 2023-06-21 1484/week @ 2023-06-28 2357/week @ 2023-07-05 1576/week @ 2023-07-12 1566/week @ 2023-07-19 1690/week @ 2023-07-26 1613/week @ 2023-08-02 966/week @ 2023-08-09 997/week @ 2023-08-16 2051/week @ 2023-08-23 563/week @ 2023-08-30 928/week @ 2023-09-06 1194/week @ 2023-09-13 1868/week @ 2023-09-20

5,150 downloads per month
Used in 3 crates

MPL-2.0 license


Latest Version Documentation


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.


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


~88K SLoC