mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-18 13:28:33 +00:00
Add validation to kdf parameters (#1930)
## Issue Addressed Closes #1906 Closes #1907 ## Proposed Changes - Emits warnings when the KDF parameters are two low. - Returns errors when the KDF parameters are high enough to pose a potential DoS threat. - Validates AES IV length is 128 bits, errors if empty, warnings otherwise. ## Additional Info NIST advice used for PBKDF2 ranges https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf. Scrypt ranges are based on the maximum value of the `u32` (i.e 4GB of memory) The minimum range has been set to anything below the default fields.
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
//! data structures. Specifically, there should not be any actual crypto logic in this file.
|
||||
|
||||
use super::hex_bytes::HexBytes;
|
||||
use crate::DKLEN;
|
||||
use hmac::{Hmac, Mac, NewMac};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sha2::Sha256;
|
||||
@@ -128,3 +129,15 @@ pub struct Scrypt {
|
||||
pub p: u32,
|
||||
pub salt: HexBytes,
|
||||
}
|
||||
|
||||
impl Scrypt {
|
||||
pub fn default_scrypt(salt: Vec<u8>) -> Self {
|
||||
Self {
|
||||
dklen: DKLEN,
|
||||
n: 262144,
|
||||
p: 1,
|
||||
r: 8,
|
||||
salt: salt.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user