Bump to v1.6.4, add missing sodium_init() call

This commit is contained in:
Y. T. Chung
2017-08-31 22:10:05 +08:00
parent ff58d06e99
commit 7ee4356948
3 changed files with 11 additions and 3 deletions
Generated
+1 -1
View File
@@ -1,6 +1,6 @@
[root]
name = "shadowsocks-rust"
version = "1.6.3"
version = "1.6.4"
dependencies = [
"base64 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"byte_string 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "shadowsocks-rust"
version = "1.6.3"
version = "1.6.4"
authors = ["Y. T. CHUNG <zonyitoo@gmail.com>"]
description = "shadowsocks is a fast tunnel proxy that helps you bypass firewalls."
repository = "https://github.com/zonyitoo/shadowsocks-rust"
+9 -1
View File
@@ -1,15 +1,19 @@
//! Cipher defined with libsodium
use std::sync::{ONCE_INIT, Once};
use bytes::{BufMut, BytesMut};
use crypto::{CipherResult, CipherType, StreamCipher};
use libc::c_ulonglong;
use libsodium_ffi::{crypto_stream_aes128ctr_xor, crypto_stream_chacha20_ietf_xor_ic, crypto_stream_chacha20_xor_ic,
crypto_stream_salsa20_xor_ic, crypto_stream_xsalsa20_xor_ic};
crypto_stream_salsa20_xor_ic, crypto_stream_xsalsa20_xor_ic, sodium_init};
use crypto::cipher::Error;
static SODIUM_INIT_FLAG: Once = ONCE_INIT;
/// Cipher provided by Rust-Crypto
pub struct SodiumCipher {
cipher_type: CipherType,
@@ -32,6 +36,10 @@ impl SodiumCipher {
_ => panic!("sodium cipher does not support {:?} cipher", t),
}
SODIUM_INIT_FLAG.call_once(|| unsafe {
assert_eq!(sodium_init(), 0);
});
SodiumCipher {
cipher_type: t,
key: key.to_owned(),