Skip to content

Commit

Permalink
hmac
Browse files Browse the repository at this point in the history
  • Loading branch information
sergey-shandar committed Jul 17, 2024
1 parent 7bf2da0 commit dd6d60f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions blockset-lib/src/hmac.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ const fn sha256(data: U512) -> U256 {
state.end(u512x::ZERO, 0)
}

const fn op(key: U256, pad: U256, data: U256) -> U256 {
sha256([u256x::bitor(&key, &pad), data])
}

pub const fn hmac(key: U256, msg: U256) -> U256 {
let hash = sha256([u256x::bitor(&key, &I_PAD), msg]);
sha256([u256x::bitor(&key, &O_PAD), hash])
let hash = op(key, I_PAD, msg);
op(key, O_PAD, hash)
}

0 comments on commit dd6d60f

Please sign in to comment.