Skip to content

Commit

Permalink
libsodium-sys is already good enough to depend
Browse files Browse the repository at this point in the history
  • Loading branch information
zonyitoo committed Dec 22, 2019
1 parent d69450f commit c3d117e
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 37 deletions.
12 changes: 0 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,5 @@ install:
export OPENSSL_DIR=/c/OpenSSL/bin;
fi

# Install libsodium on Windows
- if [ "#{TRAVIS_OS_NAME}" = "windows" ]; then
curl -O "https://download.libsodium.org/libsodium/releases/libsodium-1.0.18-stable-mingw.tar.gz";
mkdir -p "/c/libsodium";
tar -xf libsodium-1.0.18-stable-mingw.tar.gz -C "/c/libsodium";
export SODIUM_INCLUDE_DIR=/c/libsodium/libsodium-win64/include;
export SODIUM_LIB_DIR=/c/libsodium/libsodium-win64/lib;
export SODIUM_STATIC=yes;
else
export SODIUM_BUILD_STATIC=yes;
fi

script:
- cargo test --no-fail-fast --features miscreant
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ lto = true

[features]
default = ["sodium", "rc4", "aes-cfb", "aes-ctr", "trust-dns"]
sodium = ["libsodium-ffi"]
sodium = ["libsodium-sys"]
rc4 = ["openssl"]
aes-cfb = ["openssl"]
aes-ctr = ["openssl"]
Expand Down Expand Up @@ -64,7 +64,7 @@ serde_urlencoded = "0.6"
serde = { version = "1.0", features = ["derive"] }
url = "2.1"
byte_string = "1.0"
libsodium-ffi = { version = "0.2", optional = true }
libsodium-sys = { version = "0.2", optional = true }
miscreant = { version = "0.4", optional = true }
trust-dns-resolver = { version = "0.18.0-alpha", features = ["dns-over-rustls", "dns-over-https-rustls"], optional = true }
hkdf = "0.8"
Expand Down
33 changes: 16 additions & 17 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
environment:
SSL_CERT_FILE: "C:\\OpenSSL\\cacert.pem"
SSL_CERT_FILE: "C:\\OpenSSL\\cacert.pem"

matrix:
- TARGET: x86_64-pc-windows-msvc
BITS: 64
MSYS2: 1
OPENSSL_DIR: C:\OpenSSL-Win64
SODIUM_BUILD_STATIC: yes
RUST_BACKTRACE: 1
# - TARGET: i686-pc-windows-gnu
# BITS: 32
# OPENSSL_DIR: C:\OpenSSL-Win32
# MSYS2: 1
# SODIUM_BUILD_STATIC: yes
# RUST_BACKTRACE: 1
matrix:
- TARGET: x86_64-pc-windows-msvc
BITS: 64
MSYS2: 1
OPENSSL_DIR: C:\OpenSSL-Win64
RUST_BACKTRACE: 1
# - TARGET: i686-pc-windows-gnu
# BITS: 32
# OPENSSL_DIR: C:\OpenSSL-Win32
# MSYS2: 1
# SODIUM_BUILD_STATIC: yes
# RUST_BACKTRACE: 1
install:
# Install Rust
- appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe
Expand All @@ -28,8 +27,8 @@ install:
build: false

test_script:
- cargo test --no-fail-fast
- cargo test --no-fail-fast

cache:
- target
- C:\Users\appveyor\.cargo\registry
- target
- C:\Users\appveyor\.cargo\registry
2 changes: 0 additions & 2 deletions build/Dockerfile.x86_64-pc-windows-gnu
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ ENV OPENSSL_DIR=/usr/x86_64-w64-mingw32 \
OPENSSL_LIB_DIR=/usr/x86_64-w64-mingw32/lib \
OPENSSL_STATIC=1 \
OPENSSL_LIBS=ssl:crypto \
SODIUM_BUILD_INCLUDE_DIR=/usr/x86_64-w64-mingw32/include \
SODIUM_STATIC=1 \
PKG_CONFIG_ALLOW_CROSS=true \
PKG_CONFIG_ALL_STATIC=true \
PKG_CONFIG_PATH=/usr/x86_64-w64-mingw32/lib/pkgconfig \
Expand Down
2 changes: 0 additions & 2 deletions build/Dockerfile.x86_64-unknown-linux-musl
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ ENV OPENSSL_DIR=/usr/local/musl \
OPENSSL_INCLUDE_DIR=/usr/local/musl/include \
OPENSSL_LIB_DIR=/usr/local/musl/lib \
OPENSSL_STATIC=1 \
SODIUM_BUILD_INCLUDE_DIR=/usr/local/x86_64-linux-musl/include \
SODIUM_STATIC=1 \
PKG_CONFIG_ALLOW_CROSS=true \
PKG_CONFIG_ALL_STATIC=true \
PKG_CONFIG_PATH=/usr/local/musl/lib/pkgconfig \
Expand Down
2 changes: 1 addition & 1 deletion src/crypto/aead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ pub fn make_skey(t: CipherType, key: &[u8], salt: &[u8]) -> Bytes {
/// AEAD ciphers requires to increase nonce after encrypt/decrypt every chunk
#[cfg(feature = "sodium")]
pub fn increase_nonce(nonce: &mut [u8]) {
use libsodium_ffi::sodium_increment;
use libsodium_sys::sodium_increment;

unsafe {
sodium_increment(nonce.as_mut_ptr(), nonce.len());
Expand Down
2 changes: 1 addition & 1 deletion src/crypto/sodium.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::{ptr, sync::Once};
use bytes::{BufMut, Bytes, BytesMut};

use libc::c_ulonglong;
use libsodium_ffi::{
use libsodium_sys::{
crypto_aead_xchacha20poly1305_ietf_decrypt,
crypto_aead_xchacha20poly1305_ietf_encrypt,
crypto_stream_chacha20_ietf_xor_ic,
Expand Down

0 comments on commit c3d117e

Please sign in to comment.