Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions mm2src/crypto/src/key_derivation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,12 @@ pub(crate) fn derive_keys_for_mnemonic(

/// Splits a path into its components and derives a key for each component.
fn derive_key_from_path(master_node: &[u8], path: &str) -> MmResult<[u8; 32], KeyDerivationError> {
if master_node.len() < 64 {
return MmError::err(KeyDerivationError::InvalidKeyLength);
}

let mut current_key_material = master_node.to_vec();

for segment in path.split('/').filter(|s| !s.is_empty()) {
let mut mac = HmacSha512::new_from_slice(&current_key_material[..32])
.map_err(|_| KeyDerivationError::HmacInitialization)?;
Expand Down