pegase 0.2.0

Cli to generate secret config files from yaml recipe
Documentation
use yescrypt::{Mode, Params, PasswordHasher, Yescrypt};

use crate::internal::secrets::InternalError;

// https://github.com/openwall/yescrypt/blob/main/PARAMETERS
// TODO use const defined in yescrypt crate once they are available

pub const DEFAULT_N: u64 = 4096;
pub const MIN_N: u64 = u64::MIN;
pub const MAX_N: u64 = u64::MAX;

pub const DEFAULT_R: u32 = 32;
pub const MIN_R: u32 = u32::MIN;
pub const MAX_R: u32 = u32::MAX;

pub const DEFAULT_P: u32 = 1;
pub const MIN_P: u32 = u32::MIN;
pub const MAX_P: u32 = u32::MAX;

pub fn generate_yescrypt(password: &[u8], n: u64, r: u32, p: u32) -> Result<String, InternalError> {
    let yescrypt: Yescrypt = Params::new(Mode::default(), n, r, p)?.into();

    Ok(yescrypt.hash_password(password)?.to_string())
}