From 1d82c2b01788455bbde060b665b3f5c05f3f033d Mon Sep 17 00:00:00 2001 From: Dennis Schwerdel Date: Sun, 29 Nov 2015 21:53:08 +0100 Subject: [PATCH] Forgot to call sodium_init (re #1) --- .gitignore | 1 + src/crypto/dummy.rs | 4 ++++ src/crypto/sodium.rs | 5 +++++ src/main.rs | 1 + 4 files changed, 11 insertions(+) diff --git a/.gitignore b/.gitignore index 08a7486..7cc2878 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ target vpncloud-oldnodes ._* vpncloud.1* +*sodium diff --git a/src/crypto/dummy.rs b/src/crypto/dummy.rs index 7022b49..9f232c1 100644 --- a/src/crypto/dummy.rs +++ b/src/crypto/dummy.rs @@ -5,6 +5,10 @@ pub enum Crypto { } impl Crypto { + pub fn init() { + + } + pub fn method(&self) -> u8 { 0 } diff --git a/src/crypto/sodium.rs b/src/crypto/sodium.rs index da24c4d..1f15558 100644 --- a/src/crypto/sodium.rs +++ b/src/crypto/sodium.rs @@ -18,6 +18,10 @@ fn inc_nonce(nonce: [u8; 8]) -> [u8; 8] { } impl Crypto { + pub fn init() { + unsafe { sodium_init() }; + } + pub fn method(&self) -> u8 { match self { &Crypto::None => 0, @@ -40,6 +44,7 @@ impl Crypto { } pub fn from_shared_key(password: &str) -> Self { + let salt = "vpncloudVPNCLOUDvpncl0udVpnCloud".as_bytes(); assert_eq!(salt.len(), crypto_pwhash_scryptsalsa208sha256_SALTBYTES); let mut key = [0; crypto_pwhash_scryptsalsa208sha256_STRBYTES]; diff --git a/src/main.rs b/src/main.rs index a15c141..faba535 100644 --- a/src/main.rs +++ b/src/main.rs @@ -111,6 +111,7 @@ fn run (args: Args) { name.hash(&mut s); s.finish() }); + Crypto::init(); let crypto = match args.flag_shared_key { Some(key) => Crypto::from_shared_key(&key), None => Crypto::None