diff --git a/src/crypto.rs b/src/crypto.rs index feb88db..f9c4620 100644 --- a/src/crypto.rs +++ b/src/crypto.rs @@ -8,7 +8,7 @@ use sodiumoxide::crypto::{ sign, }; -use crate::utils::{SALT_LENGTH, SYMMETRIC_KEY_SIZE}; +use crate::utils::{SALT_SIZE, SYMMETRIC_KEY_SIZE}; use super::error::{Error, Result}; @@ -34,7 +34,7 @@ pub fn init() -> Result<()> { to_enc_error!(sodiumoxide::init(), "Failed initialising libsodium") } -pub fn derive_key(salt: &[u8; SALT_LENGTH], password: &str) -> Result<[u8; SYMMETRIC_KEY_SIZE]> { +pub fn derive_key(salt: &[u8; SALT_SIZE], password: &str) -> Result<[u8; SYMMETRIC_KEY_SIZE]> { let mut key = [0; SYMMETRIC_KEY_SIZE]; let password = password.as_bytes(); diff --git a/src/service.rs b/src/service.rs index d959e5e..66ddf0d 100644 --- a/src/service.rs +++ b/src/service.rs @@ -7,7 +7,7 @@ use std::convert::TryInto; use std::iter; use std::sync::Arc; -use crate::utils::{PRIVATE_KEY_SIZE, SALT_LENGTH}; +use crate::utils::{PRIVATE_KEY_SIZE, SALT_SIZE}; use serde::{Deserialize, Serialize}; use super::{ @@ -196,7 +196,7 @@ impl Account { // generation. let salt = login_challenge .salt - .get(..SALT_LENGTH) + .get(..SALT_SIZE) .ok_or(Error::Encryption( "Salt obtained from login challenge too short: expected at least 16 bytes", ))? @@ -352,7 +352,7 @@ impl Account { let salt = login_challenge .salt - .get(..SALT_LENGTH) + .get(..SALT_SIZE) .ok_or(Error::Encryption( "Salt obtained from login challenge too short: expected at least 16 bytes", ))? diff --git a/src/utils.rs b/src/utils.rs index 7e6a89f..a1a79de 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -14,7 +14,7 @@ pub type StrBase64 = str; pub type StringBase64 = String; /// The size of the salt added to the password to derive the symmetric encryption key -pub const SALT_LENGTH: usize = 16; // sodium.crypto_pwhash_argon2id_SALTBYTES +pub const SALT_SIZE: usize = 16; // sodium.crypto_pwhash_argon2id_SALTBYTES /// The size of the private encryption key pub const PRIVATE_KEY_SIZE: usize = 32; // sodium.crypto_box_curve25519xsalsa20poly1305_SECRETKEYBYTES; /// The size of a symmetric encryption key