11 unstable releases (5 breaking)

Uses new Rust 2021

0.6.0 Aug 25, 2022
0.5.1 Jul 27, 2022
0.5.0 Feb 11, 2022
0.4.4 Apr 23, 2021
0.3.0 Mar 27, 2020

#143 in Cryptography

Download history 562/week @ 2022-06-05 814/week @ 2022-06-12 532/week @ 2022-06-19 854/week @ 2022-06-26 1453/week @ 2022-07-03 1000/week @ 2022-07-10 610/week @ 2022-07-17 917/week @ 2022-07-24 1278/week @ 2022-07-31 683/week @ 2022-08-07 1015/week @ 2022-08-14 1271/week @ 2022-08-21 624/week @ 2022-08-28 905/week @ 2022-09-04 438/week @ 2022-09-11 836/week @ 2022-09-18

2,846 downloads per month
Used in 3 crates

MPL-2.0 license

170KB
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:

sudo cargo test -- --test-threads=1 --ignored

Dependencies

~0.6–2.5MB
~51K SLoC