Clear ipad and opad in pbkdf2_hmac
@@ -159,10 +159,15 @@ impl Hmac {
pub fn pbkdf2_hmac(mut ipad: Vec<u8>, mut opad: Vec<u8>, data: &[u8],
hmac: ShaVariantOption) -> Vec<u8> {
+ let mut mac: Vec<u8> = Vec::new();
+ mac.extend_from_slice(&opad);
ipad.extend_from_slice(data);
- opad.extend_from_slice(&hmac.hash(&ipad));
+ mac.extend_from_slice(&hmac.hash(&ipad));
- hmac.hash(&opad)
+ Clear::clear(&mut ipad);
+ Clear::clear(&mut opad);
+
+ hmac.hash(&mac)
}
