Skip to content
Merged
Changes from 1 commit
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 @@ -134,6 +134,11 @@ 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> {
let mut current_key_material = master_node.to_vec();

if current_key_material.len() < 64 {
return MmError::err(KeyDerivationError::InvalidKeyLength);
}

Comment thread
borngraced marked this conversation as resolved.
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