#sodium #crypto

unmaintained rust_sodium

Fast cryptographic library for Rust (bindings to libsodium)

14 releases (9 breaking)

0.10.2 Jan 28, 2019
0.10.1 Oct 24, 2018
0.10.0 Aug 24, 2018
0.9.0 May 7, 2018
0.1.2 Sep 27, 2016

#14 in #sodium

Download history 172/week @ 2024-07-21 404/week @ 2024-07-28 402/week @ 2024-08-04 106/week @ 2024-08-11 481/week @ 2024-08-18 56/week @ 2024-08-25 67/week @ 2024-09-01 80/week @ 2024-09-08 59/week @ 2024-09-15 149/week @ 2024-09-22 361/week @ 2024-09-29 106/week @ 2024-10-06 205/week @ 2024-10-13 197/week @ 2024-10-20 182/week @ 2024-10-27 123/week @ 2024-11-03

728 downloads per month
Used in 15 crates (11 directly)

MIT/Apache

2MB
9K SLoC

rust_sodium

Rust bindings to libsodium.

This project is largely based on sodiumoxide. Some main differences are:

  • this project builds or downloads libsodium by default, favouring a statically-built, fixed version of the native library
  • offers the ability to initialise libsodium with a psuedorandom number generator, allowing for reproducible data to be generated, which can be useful in the context of tests
  • implements a test to ensure the FFI bindings match the native library's interface
  • runs CI tests on Windows (AppVeyor), OS X and Linux (Travis)
Crate Documentation Linux/OS X Windows Issues
Documentation Build Status Build status Stories in Ready
MaidSafe website SAFE Dev Forum SAFE Network Forum

Note for building on Linux

Certain situations may require building libsodium configured with --disable-pie. To enable this, set an environment variable RUST_SODIUM_DISABLE_PIE while building, e.g.

RUST_SODIUM_DISABLE_PIE=1 cargo build

To use your own copy of libsodium

If you already have a copy of libsodium, you can choose to link this rather than having rust_sodium download and build libsodium for you. You should ensure that it is the same version as is specified in VERSION of [our build.rs] (https://github.com/maidsafe/rust_sodium/blob/master/rust_sodium-sys/build.rs) file.

Set an environment variable RUST_SODIUM_LIB_DIR to the folder where libsodium exists. A static version of libsodium will be preferred unless you also set RUST_SODIUM_SHARED to any value.

Alternatively, you can use pkgconfig if appropriate to locate libsodium by setting RUST_SODIUM_USE_PKG_CONFIG to any value. In this case, RUST_SODIUM_SHARED has no effect, and generally a shared version of libsodium will be used.

Cross-Compiling

Cross-Compiling for ARM

  1. Install dependencies and toolchain:

    sudo apt update
    sudo apt install build-essential gcc-arm-linux-gnueabihf libc6-armhf-cross libc6-dev-armhf-cross -y
    rustup target add armv7-unknown-linux-gnueabihf
    
  2. Add the following to a .cargo/config file:

    [target.armv7-unknown-linux-gnueabihf]
    linker = "arm-linux-gnueabihf-gcc"
    
  3. Build by running:

    cargo build --release --target armv7-unknown-linux-gnueabihf
    

Cross-Compiling for 32-bit Linux

  1. Install dependencies and toolchain:

    sudo apt update
    sudo apt install build-essential gcc-multilib -y
    rustup target add i686-unknown-linux-gnu
    
  2. Build by running:

    cargo build --release --target i686-unknown-linux-gnu
    

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies