mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
add other hash support; notch back the hmac dependencies
our engine is a version older in API rev, so notch back the dependencies so we're all at the same rev
This commit is contained in:
parent
5d8b85c0bf
commit
7765f3dec3
5 changed files with 34 additions and 16 deletions
13
Cargo.lock
generated
13
Cargo.lock
generated
|
|
@ -3103,13 +3103,15 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "sha-1"
|
name = "sha-1"
|
||||||
version = "0.10.0"
|
version = "0.9.8"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "028f48d513f9678cda28f6e4064755b3fbb2af6acd672f2c209b62323f7aea0f"
|
checksum = "99cd6713db3cf16b6c84e06321e049a9b9f699826e16096d23bbcc44d15d51a6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"block-buffer 0.9.0",
|
||||||
"cfg-if 1.0.0",
|
"cfg-if 1.0.0",
|
||||||
"cpufeatures",
|
"cpufeatures",
|
||||||
"digest 0.10.3",
|
"digest 0.9.0",
|
||||||
|
"opaque-debug",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -3912,14 +3914,14 @@ dependencies = [
|
||||||
"cbor",
|
"cbor",
|
||||||
"chrono",
|
"chrono",
|
||||||
"content-plugin-api",
|
"content-plugin-api",
|
||||||
"crypto-common",
|
"crypto-mac",
|
||||||
"ctap-crypto",
|
"ctap-crypto",
|
||||||
"digest 0.9.0",
|
"digest 0.9.0",
|
||||||
"enum-iterator",
|
"enum-iterator",
|
||||||
"gam",
|
"gam",
|
||||||
"graphics-server",
|
"graphics-server",
|
||||||
"hex 0.4.3",
|
"hex 0.4.3",
|
||||||
"hmac 0.12.1",
|
"hmac 0.11.0",
|
||||||
"ime-plugin-api",
|
"ime-plugin-api",
|
||||||
"locales",
|
"locales",
|
||||||
"log",
|
"log",
|
||||||
|
|
@ -3933,6 +3935,7 @@ dependencies = [
|
||||||
"random-pick",
|
"random-pick",
|
||||||
"rkyv",
|
"rkyv",
|
||||||
"sha-1",
|
"sha-1",
|
||||||
|
"sha2",
|
||||||
"subtle",
|
"subtle",
|
||||||
"ticktimer-server",
|
"ticktimer-server",
|
||||||
"trng",
|
"trng",
|
||||||
|
|
|
||||||
|
|
@ -171,7 +171,7 @@ perform the Xous firmware upgrade. This requires running manual update commands,
|
||||||
- Autobacklight feature: selectable feature to automatically raise the backlight when keys are pressed. Thanks to gsora for the feature!
|
- Autobacklight feature: selectable feature to automatically raise the backlight when keys are pressed. Thanks to gsora for the feature!
|
||||||
- More importantly, this adds `crossbeam` into the kernel. This is a somewhat heavyweight item and is not recommended for use in core
|
- More importantly, this adds `crossbeam` into the kernel. This is a somewhat heavyweight item and is not recommended for use in core
|
||||||
services, but by including it to drive the auto-backlight feature, we get regular code coverage of the condvar pathway.
|
services, but by including it to drive the auto-backlight feature, we get regular code coverage of the condvar pathway.
|
||||||
|
- TOTP integration thanks to blakesmith's PoC TOTP code!
|
||||||
|
|
||||||
## Roadmap to 1.0
|
## Roadmap to 1.0
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,11 +40,12 @@ chrono = {version = "0.4.19", default-features = false, features = ["std"]}
|
||||||
passwords = "3.1.9"
|
passwords = "3.1.9"
|
||||||
|
|
||||||
# totp
|
# totp
|
||||||
crypto-common = "0.1.3"
|
crypto-mac = "0.11.1"
|
||||||
sha-1 = "0.10.0"
|
sha-1 = "0.9.8"
|
||||||
hmac = "0.12.1"
|
hmac = "0.11.0"
|
||||||
digest = "0.9.0"
|
digest = "0.9.0"
|
||||||
base32 = "0.4.0"
|
base32 = "0.4.0"
|
||||||
|
sha2 = {path="../../services/engine-sha512"}
|
||||||
|
|
||||||
# testing
|
# testing
|
||||||
random-pick = {version = "1.2.15", optional = true}
|
random-pick = {version = "1.2.15", optional = true}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crypto_common::InvalidLength;
|
use crypto_mac::InvalidKeyLength;
|
||||||
use sha1::Sha1;
|
use sha1::Sha1;
|
||||||
use hmac::{Hmac, Mac};
|
use hmac::{Hmac, Mac, NewMac};
|
||||||
use std::{
|
use std::{
|
||||||
convert::TryFrom,
|
convert::TryFrom,
|
||||||
time::{SystemTime, SystemTimeError},
|
time::{SystemTime, SystemTimeError},
|
||||||
|
|
@ -55,7 +55,7 @@ pub(crate) struct TotpEntry {
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub(crate) enum Error {
|
pub(crate) enum Error {
|
||||||
Io(std::io::Error),
|
Io(std::io::Error),
|
||||||
DigestLength(InvalidLength),
|
DigestLength(InvalidKeyLength),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<std::io::Error> for Error {
|
impl From<std::io::Error> for Error {
|
||||||
|
|
@ -64,8 +64,8 @@ impl From<std::io::Error> for Error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<InvalidLength> for Error {
|
impl From<InvalidKeyLength> for Error {
|
||||||
fn from(err: InvalidLength) -> Self {
|
fn from(err: InvalidKeyLength) -> Self {
|
||||||
Error::DigestLength(err)
|
Error::DigestLength(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -94,7 +94,19 @@ fn generate_hmac_bytes(unix_timestamp: u64, totp_entry: &TotpEntry) -> Result<Ve
|
||||||
let hash: &[u8] = &mac.finalize().into_bytes();
|
let hash: &[u8] = &mac.finalize().into_bytes();
|
||||||
computed_hmac.extend_from_slice(hash);
|
computed_hmac.extend_from_slice(hash);
|
||||||
}
|
}
|
||||||
_ => todo!(),
|
// note: sha256/sha512 implementations not yet tested, as we have yet to find a site that uses this to test against.
|
||||||
|
TotpAlgorithm::HmacSha256 => {
|
||||||
|
let mut mac: Hmac<sha2::Sha256> = Hmac::new_from_slice(&totp_entry.shared_secret)?;
|
||||||
|
mac.update(&unpack_u64(unix_timestamp / totp_entry.step_seconds as u64));
|
||||||
|
let hash: &[u8] = &mac.finalize().into_bytes();
|
||||||
|
computed_hmac.extend_from_slice(hash);
|
||||||
|
}
|
||||||
|
TotpAlgorithm::HmacSha512 => {
|
||||||
|
let mut mac: Hmac<sha2::Sha512> = Hmac::new_from_slice(&totp_entry.shared_secret)?;
|
||||||
|
mac.update(&unpack_u64(unix_timestamp / totp_entry.step_seconds as u64));
|
||||||
|
let hash: &[u8] = &mac.finalize().into_bytes();
|
||||||
|
computed_hmac.extend_from_slice(hash);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(computed_hmac)
|
Ok(computed_hmac)
|
||||||
|
|
|
||||||
|
|
@ -556,7 +556,9 @@ impl VaultUx {
|
||||||
totp::get_current_unix_time().unwrap_or(0),
|
totp::get_current_unix_time().unwrap_or(0),
|
||||||
&totp
|
&totp
|
||||||
).unwrap_or(t!("vault.error.record_error", xous::LANG).to_string());
|
).unwrap_or(t!("vault.error.record_error", xous::LANG).to_string());
|
||||||
write!(box_text, "{}\n{}", item.name, code).ok();
|
// why code on top? because the item.name can be very long, and it can wrap which would cause
|
||||||
|
// the code to become hidden.
|
||||||
|
write!(box_text, "{}\n{}", code, item.name).ok();
|
||||||
} else {
|
} else {
|
||||||
write!(box_text, "{}", t!("vault.error.record_error", xous::LANG)).ok();
|
write!(box_text, "{}", t!("vault.error.record_error", xous::LANG)).ok();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue