Forgot to call sodium_init (re #1)

pull/9/head
Dennis Schwerdel 2015-11-29 21:53:08 +01:00
parent f6d5c7bbee
commit 1d82c2b017
4 changed files with 11 additions and 0 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@ target
vpncloud-oldnodes
._*
vpncloud.1*
*sodium

View File

@ -5,6 +5,10 @@ pub enum Crypto {
}
impl Crypto {
pub fn init() {
}
pub fn method(&self) -> u8 {
0
}

View File

@ -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];

View File

@ -111,6 +111,7 @@ fn run<T: Protocol> (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