keyfork/vendor/nettle-sys-2.3.0
Ryan Heywood ec8a5c893f
prepare for stagex bindgen
2024-03-06 19:34:53 -05:00
..
docker/arm-linux-androidabi crates/keyfork: add link-static and link-dynamic 2024-03-05 19:07:19 -05:00
docs crates/keyfork: add link-static and link-dynamic 2024-03-05 19:07:19 -05:00
src crates/keyfork: add link-static and link-dynamic 2024-03-05 19:07:19 -05:00
.cargo_vcs_info.json crates/keyfork: add link-static and link-dynamic 2024-03-05 19:07:19 -05:00
.gitignore crates/keyfork: add link-static and link-dynamic 2024-03-05 19:07:19 -05:00
.gitlab-ci.yml crates/keyfork: add link-static and link-dynamic 2024-03-05 19:07:19 -05:00
Cargo.toml prepare for stagex bindgen 2024-03-06 19:34:53 -05:00
Cargo.toml.orig crates/keyfork: add link-static and link-dynamic 2024-03-05 19:07:19 -05:00
Cross.toml crates/keyfork: add link-static and link-dynamic 2024-03-05 19:07:19 -05:00
LICENSE-GPL2 crates/keyfork: add link-static and link-dynamic 2024-03-05 19:07:19 -05:00
LICENSE-GPL3 crates/keyfork: add link-static and link-dynamic 2024-03-05 19:07:19 -05:00
LICENSE-LGPL3 crates/keyfork: add link-static and link-dynamic 2024-03-05 19:07:19 -05:00
README.md crates/keyfork: add link-static and link-dynamic 2024-03-05 19:07:19 -05:00
bindgen-wrapper.h crates/keyfork: add link-static and link-dynamic 2024-03-05 19:07:19 -05:00
build.rs vendor: use bindgen-cli instead of bindgen library 2024-03-05 22:23:47 -05:00
cv448-stubs.rs crates/keyfork: add link-static and link-dynamic 2024-03-05 19:07:19 -05:00
ocb-stubs.rs crates/keyfork: add link-static and link-dynamic 2024-03-05 19:07:19 -05:00

README.md

nettle-sys

Low-level Rust bindings for the Nettle cryptographic library.

The documentation can be found here.

Building

To build the Nettle bindings, you need a few libraries and support packages. Notably, you need the Nettle cryptographic library version 3.4.1 or up. Some cryptographic algorithms are only available if build against newer versions of Nettle, see optional features.

Please see below for OS-specific commands to install the needed libraries.

Debian

$ sudo apt install clang llvm pkg-config nettle-dev

Arch Linux

$ sudo pacman -S clang pkg-config nettle --needed

Fedora

$ sudo dnf install clang pkg-config nettle-devel

macOS (Mojave), using MacPorts

$ sudo port install nettle pkgconfig

Windows

MSYS2

You can install the needed libraries with the following command:

$ pacman -S mingw-w64-x86_64-{clang,pkg-config,nettle} libnettle-devel

Optional features

Some cryptographic algorithms are only available if build against newer versions of Nettle. Support for each feature is detected at build time.

In case the automatic detection does not work for some reason, the optional algorithms can be enabled or disabled by setting the given environment variable.

Setting such a variable to 1, y, yes, enable, or true enables a feature. Any other value disables it.

Algorithm Required Nettle version Environment variable
cv448, ed448 >= 3.6 NETTLE_HAVE_CV448
OCB >= 3.9 NETTLE_HAVE_OCB

Cross compilation

nettle-sys can be cross compiled using cross and a custom Docker container. First, build the container and install cross:

cargo install cross
docker -t nettle-sys/<toolchain>:1 docker/<toolchain>

Then, you can cross compile the project:

cross --target <toolchain> -v

The build artifacts will be placed in target/debug/<toolchain>.

Static linking

By default, nettle-sys is dynamically linked to its dependencies.

By defining the NETTLE_STATIC environment variable during the build, it can also be statically link to its dependencies:

env NETTLE_STATIC=yes cargo build

This is particularly useful to produce standalone binaries that can be easily distributed.

Pregenerate bindings.rs

By default, nettle-sys invokes bindgen to generate bindings for Nettle. In some build environments, this might not work due to bindgen depending on libllvm. In this case, the bindings.rs may be pregenerated, and used by setting:

env NETTLE_PREGENERATED_BINDINGS=/path/to/bindings.rs cargo build

Note: bindings.rs is specific to target architecture, operating system, and Nettle version.

License

This project is licensed under either of

at your option.