Skip to content

Commit 7ee4356

Browse files
committed
Bump to v1.6.4, add missing sodium_init() call
1 parent ff58d06 commit 7ee4356

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "shadowsocks-rust"
3-
version = "1.6.3"
3+
version = "1.6.4"
44
authors = ["Y. T. CHUNG <zonyitoo@gmail.com>"]
55
description = "shadowsocks is a fast tunnel proxy that helps you bypass firewalls."
66
repository = "https://github.com/zonyitoo/shadowsocks-rust"

src/crypto/sodium.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
//! Cipher defined with libsodium
22
3+
use std::sync::{ONCE_INIT, Once};
4+
35
use bytes::{BufMut, BytesMut};
46

57
use crypto::{CipherResult, CipherType, StreamCipher};
68

79
use libc::c_ulonglong;
810
use libsodium_ffi::{crypto_stream_aes128ctr_xor, crypto_stream_chacha20_ietf_xor_ic, crypto_stream_chacha20_xor_ic,
9-
crypto_stream_salsa20_xor_ic, crypto_stream_xsalsa20_xor_ic};
11+
crypto_stream_salsa20_xor_ic, crypto_stream_xsalsa20_xor_ic, sodium_init};
1012

1113
use crypto::cipher::Error;
1214

15+
static SODIUM_INIT_FLAG: Once = ONCE_INIT;
16+
1317
/// Cipher provided by Rust-Crypto
1418
pub struct SodiumCipher {
1519
cipher_type: CipherType,
@@ -32,6 +36,10 @@ impl SodiumCipher {
3236
_ => panic!("sodium cipher does not support {:?} cipher", t),
3337
}
3438

39+
SODIUM_INIT_FLAG.call_once(|| unsafe {
40+
assert_eq!(sodium_init(), 0);
41+
});
42+
3543
SodiumCipher {
3644
cipher_type: t,
3745
key: key.to_owned(),

0 commit comments

Comments
 (0)