Skip to content

Commit

Permalink
Merge pull request #20 from tkhr0/bump
Browse files Browse the repository at this point in the history
bump crypto crates
  • Loading branch information
tkhr0 committed Dec 2, 2023
2 parents ca743d1 + cfb3345 commit ec2df7c
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 75 deletions.
116 changes: 49 additions & 67 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ name = "mfa-cli"
path = "src/main.rs"

[dependencies]
generic-array = "0.14.1"
hmac = "0.7.1"
sha-1 = "0.8.2"
digest = "0.8.1"
hmac = "0.12"
sha-1 = "0.10"
digest = "0.10"
byteorder = "1"
base32 = "0.4.0"
clap = "2.33"
Expand Down
7 changes: 3 additions & 4 deletions src/hmac_sha1.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
extern crate digest;
extern crate generic_array;
extern crate hmac;
extern crate sha1;

Expand All @@ -13,14 +12,14 @@ type HmacSha1 = Hmac<Sha1>;

// HMAC-SHA-1 を計算する
pub fn gen_hmac_sha1(key: &[u8], input: &[u8]) -> Result<GenericArray<u8, OutputSize>, String> {
let mut mac = match HmacSha1::new_varkey(key) {
let mut mac = match HmacSha1::new_from_slice(key) {
Ok(mac) => mac,
Err(err) => return Err(format!("{}", err)),
};

mac.input(input);
mac.update(input);

Ok(mac.result().code())
Ok(mac.finalize().into_bytes())
}

#[cfg(test)]
Expand Down

0 comments on commit ec2df7c

Please sign in to comment.