Updated dependencies, bumped to 2021 edition

- Updated sha2 from a yanked version
- Updated sha-1
- Updated hmac
- Updated byteorder
- Updated base64
This commit is contained in:
Cléo Rebert 2022-01-13 15:55:04 +01:00
parent 43107283ac
commit 97695cf26d
3 changed files with 16 additions and 16 deletions

View File

@ -17,6 +17,6 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Build
run: cargo build --verbose --features qr
run: cargo build --verbose --all-features
- name: Run tests
run: cargo test --verbose --features qr
run: cargo test --verbose --all-features

View File

@ -1,8 +1,8 @@
[package]
name = "totp-rs"
version = "0.6.4"
version = "0.6.5"
authors = ["Cleo Rebert <cleo.rebert@gmail.com>"]
edition = "2018"
edition = "2021"
readme = "README.md"
license = "MIT"
description = "RFC-compliant TOTP implementation with ease of use as a goal and additionnal QoL features."
@ -21,11 +21,11 @@ serde_support = ["serde"]
[dependencies]
serde = { version = "1.0", features = ["derive"], optional = true }
sha2 = "0.9.5"
sha-1 = "0.9.7"
hmac = "0.8.0"
byteorder = ">= 1.3"
base32 = ">= 0.4"
qrcode = { version = ">= 0.12", optional = true }
image = { version = ">= 0.23", optional = true}
base64 = { version = ">= 0.12", optional = true }
sha2 = "~0.10.1"
sha-1 = "~0.10.0"
hmac = "~0.12.0"
byteorder = "~1.4.3"
base32 = "~0.4"
qrcode = { version = "~0.12", optional = true }
image = { version = "~0.23.14", optional = true}
base64 = { version = "~0.13", optional = true }

View File

@ -45,7 +45,7 @@ use std::io::Cursor;
#[cfg(feature = "qr")]
use {base64, image::Luma, qrcode::QrCode};
use hmac::{Hmac, Mac, NewMac};
use hmac::{Hmac, Mac};
use sha1::Sha1;
use sha2::{Sha256, Sha512};
@ -95,17 +95,17 @@ impl<T: AsRef<[u8]>> TOTP<T> {
let ctr = (time / self.step).to_be_bytes();
match self.algorithm {
Algorithm::SHA1 => {
let mut mac = HmacSha1::new_varkey(self.secret.as_ref()).expect("no key");
let mut mac = HmacSha1::new_from_slice(self.secret.as_ref()).expect("no key");
mac.update(&ctr);
mac.finalize().into_bytes().to_vec()
}
Algorithm::SHA256 => {
let mut mac = HmacSha256::new_varkey(self.secret.as_ref()).expect("no key");
let mut mac = HmacSha256::new_from_slice(self.secret.as_ref()).expect("no key");
mac.update(&ctr);
mac.finalize().into_bytes().to_vec()
}
Algorithm::SHA512 => {
let mut mac = HmacSha512::new_varkey(self.secret.as_ref()).expect("no key");
let mut mac = HmacSha512::new_from_slice(self.secret.as_ref()).expect("no key");
mac.update(&ctr);
mac.finalize().into_bytes().to_vec()
}