diff --git a/src/hmac.rs b/src/hmac.rs index 17977e3..ebf46cd 100644 --- a/src/hmac.rs +++ b/src/hmac.rs @@ -29,6 +29,15 @@ use {Error, Hash, HashEngine}; #[derive(Copy, Clone, PartialEq, Eq, Default, PartialOrd, Ord, Hash)] pub struct Hmac(T); +/// Pair of underlying hash midstates which represent the current state +/// of an `HmacEngine` +pub struct HmacMidState { + /// Midstate of the inner hash engine + pub inner: ::MidState, + /// Midstate of the outer hash engine + pub outer: ::MidState, +} + /// Pair of underyling hash engines, used for the inner and outer hash of HMAC #[derive(Clone)] pub struct HmacEngine { @@ -73,10 +82,13 @@ impl HmacEngine { } impl HashEngine for HmacEngine { - type MidState = <::Engine as HashEngine>::MidState; + type MidState = HmacMidState; fn midstate(&self) -> Self::MidState { - self.iengine.midstate() + HmacMidState { + inner: self.iengine.midstate(), + outer: self.oengine.midstate(), + } } const BLOCK_SIZE: usize = T::Engine::BLOCK_SIZE;