mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
add standard features to the config & fixup code paths that broke
This commit is contained in:
parent
d995912a97
commit
5812cef8f3
9 changed files with 31 additions and 19 deletions
|
|
@ -35,4 +35,6 @@ enum-iterator = "0.6.0"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
tts = []
|
tts = []
|
||||||
default = []
|
with_ctap1 = ["ctap-crypto/with_ctap1"]
|
||||||
|
with_ctap2_1 = []
|
||||||
|
default = ["with_ctap1", "with_ctap2_1"]
|
||||||
|
|
|
||||||
|
|
@ -32,4 +32,7 @@ serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = { version = "1.0" }
|
serde_json = { version = "1.0" }
|
||||||
ring = { version = "0.16.11" }
|
ring = { version = "0.16.11" }
|
||||||
byteorder = { version = "1", default-features = false }
|
byteorder = { version = "1", default-features = false }
|
||||||
rfc6979 = "0.2.0"
|
rfc6979 = "0.2.0"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
with_ctap1 = []
|
||||||
|
|
@ -44,7 +44,8 @@ pub struct SecKey {
|
||||||
a: EphemeralSecret,
|
a: EphemeralSecret,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(not(target_os = "xous"), derive(Clone, PartialEq, Debug))]
|
//#[cfg_attr(test, derive(Clone, PartialEq, Debug))]
|
||||||
|
#[derive(Clone, PartialEq, Debug)]
|
||||||
pub struct PubKey {
|
pub struct PubKey {
|
||||||
// pub p: EncodedPoint,
|
// pub p: EncodedPoint,
|
||||||
pub p: PublicKey,
|
pub p: PublicKey,
|
||||||
|
|
|
||||||
|
|
@ -208,7 +208,8 @@ impl PubKey {
|
||||||
_ => None
|
_ => None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//#[cfg(test)]
|
//#[cfg(test)] - commented out because for some reason we can't get the test configs to work right
|
||||||
|
#[allow(dead_code)]
|
||||||
fn to_bytes_uncompressed(&self, bytes: &mut [u8; 65]) {
|
fn to_bytes_uncompressed(&self, bytes: &mut [u8; 65]) {
|
||||||
// not sure if this is correct -- we'll find out when we run the tests
|
// not sure if this is correct -- we'll find out when we run the tests
|
||||||
// this generates a SEC1 EncodedPoint, but I'm not sure if that's the same thing as
|
// this generates a SEC1 EncodedPoint, but I'm not sure if that's the same thing as
|
||||||
|
|
@ -222,12 +223,13 @@ impl PubKey {
|
||||||
|
|
||||||
#[cfg(feature = "with_ctap1")]
|
#[cfg(feature = "with_ctap1")]
|
||||||
pub fn to_uncompressed(&self) -> [u8; PubKey::UNCOMPRESSED_LENGTH] {
|
pub fn to_uncompressed(&self) -> [u8; PubKey::UNCOMPRESSED_LENGTH] {
|
||||||
|
use arrayref::mut_array_refs;
|
||||||
// Formatting according to:
|
// Formatting according to:
|
||||||
// https://tools.ietf.org/id/draft-jivsov-ecc-compact-05.html#overview
|
// https://tools.ietf.org/id/draft-jivsov-ecc-compact-05.html#overview
|
||||||
const B0_BYTE_MARKER: u8 = 0x04;
|
const B0_BYTE_MARKER: u8 = 0x04;
|
||||||
let mut representation = [0; PubKey::UNCOMPRESSED_LENGTH];
|
let mut representation = [0; PubKey::UNCOMPRESSED_LENGTH];
|
||||||
let (marker, x, y) =
|
let (marker, x, y) =
|
||||||
mut_array_refs![&mut representation, 1, int256::NBYTES, int256::NBYTES];
|
mut_array_refs![&mut representation, 1, INT256_NBYTES, INT256_NBYTES];
|
||||||
marker[0] = B0_BYTE_MARKER;
|
marker[0] = B0_BYTE_MARKER;
|
||||||
x.copy_from_slice(
|
x.copy_from_slice(
|
||||||
self.p
|
self.p
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,8 @@ impl From<PublicKeyCredentialUserEntity> for cbor::Value {
|
||||||
|
|
||||||
// https://www.w3.org/TR/webauthn/#enumdef-publickeycredentialtype
|
// https://www.w3.org/TR/webauthn/#enumdef-publickeycredentialtype
|
||||||
#[derive(Clone, PartialEq)]
|
#[derive(Clone, PartialEq)]
|
||||||
#[cfg_attr(any(test, feature = "debug_ctap"), derive(Debug))]
|
//#[cfg_attr(any(test, feature = "debug_ctap"), derive(Debug))]
|
||||||
|
#[derive(Debug)]
|
||||||
pub enum PublicKeyCredentialType {
|
pub enum PublicKeyCredentialType {
|
||||||
PublicKey,
|
PublicKey,
|
||||||
// This is the default for all strings not covered above.
|
// This is the default for all strings not covered above.
|
||||||
|
|
@ -456,7 +457,8 @@ impl TryFrom<cbor::Value> for SignatureAlgorithm {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq, PartialOrd)]
|
#[derive(Clone, Copy, PartialEq, PartialOrd)]
|
||||||
#[cfg_attr(any(test, feature = "debug_ctap"), derive(Debug))]
|
//#[cfg_attr(any(test, feature = "debug_ctap"), derive(Debug))]
|
||||||
|
#[derive(Debug)]
|
||||||
#[cfg_attr(test, derive(IntoEnumIterator))]
|
#[cfg_attr(test, derive(IntoEnumIterator))]
|
||||||
pub enum CredentialProtectionPolicy {
|
pub enum CredentialProtectionPolicy {
|
||||||
UserVerificationOptional = 0x01,
|
UserVerificationOptional = 0x01,
|
||||||
|
|
@ -503,7 +505,7 @@ pub struct PublicKeyCredentialSource {
|
||||||
pub user_name: Option<String>,
|
pub user_name: Option<String>,
|
||||||
pub user_icon: Option<String>,
|
pub user_icon: Option<String>,
|
||||||
}
|
}
|
||||||
#[cfg(not(any(target_os = "none", target_os = "xous")))]
|
|
||||||
impl std::fmt::Debug for PublicKeyCredentialSource {
|
impl std::fmt::Debug for PublicKeyCredentialSource {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
f.debug_struct("PublicKeyCredentialSource")
|
f.debug_struct("PublicKeyCredentialSource")
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ const AT_FLAG: u8 = 0x40;
|
||||||
// Set this bit when an extension is used.
|
// Set this bit when an extension is used.
|
||||||
const ED_FLAG: u8 = 0x80;
|
const ED_FLAG: u8 = 0x80;
|
||||||
|
|
||||||
pub const TOUCH_TIMEOUT_MS: isize = 30000;
|
pub const TOUCH_TIMEOUT_MS: i64 = 30000;
|
||||||
#[cfg(feature = "with_ctap1")]
|
#[cfg(feature = "with_ctap1")]
|
||||||
const U2F_UP_PROMPT_TIMEOUT: Duration<i64> = Duration::from_ms(10000);
|
const U2F_UP_PROMPT_TIMEOUT: Duration<i64> = Duration::from_ms(10000);
|
||||||
const RESET_TIMEOUT_DURATION: Duration<i64> = Duration::from_ms(10000);
|
const RESET_TIMEOUT_DURATION: Duration<i64> = Duration::from_ms(10000);
|
||||||
|
|
@ -1273,7 +1273,7 @@ mod test {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test] // this exhibits compilation errors in some configs
|
||||||
fn test_process_make_credential_credential_with_cred_protect() {
|
fn test_process_make_credential_credential_with_cred_protect() {
|
||||||
let mut rng = ThreadRng256 {};
|
let mut rng = ThreadRng256 {};
|
||||||
let user_immediately_present = |_| Ok(());
|
let user_immediately_present = |_| Ok(());
|
||||||
|
|
@ -1929,7 +1929,7 @@ mod test {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test] // this exhibits compilation errors in some configs
|
||||||
fn test_process_get_next_assertion_not_allowed() {
|
fn test_process_get_next_assertion_not_allowed() {
|
||||||
let mut rng = ThreadRng256 {};
|
let mut rng = ThreadRng256 {};
|
||||||
let user_immediately_present = |_| Ok(());
|
let user_immediately_present = |_| Ok(());
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,7 @@ const CRED_INITAL_SIZE: usize = 512;
|
||||||
//
|
//
|
||||||
// With P=20 and K=150, we have I=2M which is enough for 500 increments per day for 10 years.
|
// With P=20 and K=150, we have I=2M which is enough for 500 increments per day for 10 years.
|
||||||
const NUM_PAGES: usize = 20;
|
const NUM_PAGES: usize = 20;
|
||||||
|
#[allow(dead_code)] // OpenSK legacy
|
||||||
const MAX_SUPPORTED_RESIDENTIAL_KEYS: usize = 150;
|
const MAX_SUPPORTED_RESIDENTIAL_KEYS: usize = 150;
|
||||||
|
|
||||||
const MAX_PIN_RETRIES: u8 = 8;
|
const MAX_PIN_RETRIES: u8 = 8;
|
||||||
|
|
@ -559,10 +560,9 @@ impl PersistentStore {
|
||||||
Some(1), None::<fn()>
|
Some(1), None::<fn()>
|
||||||
) {
|
) {
|
||||||
Ok(mut pl) => {
|
Ok(mut pl) => {
|
||||||
if pl.write(min_pin_length) == Ok(1) {
|
match pl.write(&[min_pin_length]) {
|
||||||
Ok(())
|
Ok(1) => Ok(()),
|
||||||
} else {
|
_ => Err(Ctap2StatusCode::CTAP2_ERR_VENDOR_INTERNAL_ERROR),
|
||||||
Err(Ctap2StatusCode::CTAP2_ERR_VENDOR_INTERNAL_ERROR)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => Err(Ctap2StatusCode::CTAP2_ERR_VENDOR_INTERNAL_ERROR),
|
_ => Err(Ctap2StatusCode::CTAP2_ERR_VENDOR_INTERNAL_ERROR),
|
||||||
|
|
@ -613,8 +613,8 @@ impl PersistentStore {
|
||||||
Some(_MAX_RP_IDS_LENGTH), None::<fn()>
|
Some(_MAX_RP_IDS_LENGTH), None::<fn()>
|
||||||
) {
|
) {
|
||||||
Ok(mut mrpli) => {
|
Ok(mut mrpli) => {
|
||||||
mprli.write(&_serialize_min_pin_length_rp_ids(min_pin_length_rp_ids)?)
|
mrpli.write(&_serialize_min_pin_length_rp_ids(min_pin_length_rp_ids)?)
|
||||||
.or(Err(Ctap2StatusCode::CTAP2_ERR_VENDOR_INTERNAL_ERROR))
|
.or(Err(Ctap2StatusCode::CTAP2_ERR_VENDOR_INTERNAL_ERROR)).map(|_|())
|
||||||
}
|
}
|
||||||
_ => Err(Ctap2StatusCode::CTAP2_ERR_VENDOR_INTERNAL_ERROR)
|
_ => Err(Ctap2StatusCode::CTAP2_ERR_VENDOR_INTERNAL_ERROR)
|
||||||
}
|
}
|
||||||
|
|
@ -733,6 +733,7 @@ impl PersistentStore {
|
||||||
/// Sets the AAGUID.
|
/// Sets the AAGUID.
|
||||||
///
|
///
|
||||||
/// If it is already defined, it is overwritten.
|
/// If it is already defined, it is overwritten.
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn set_aaguid(
|
pub fn set_aaguid(
|
||||||
&mut self,
|
&mut self,
|
||||||
aaguid: &[u8; key_material::AAGUID_LENGTH],
|
aaguid: &[u8; key_material::AAGUID_LENGTH],
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@
|
||||||
use std::stringify;
|
use std::stringify;
|
||||||
|
|
||||||
/// Number of keys that persist the CTAP reset command.
|
/// Number of keys that persist the CTAP reset command.
|
||||||
|
#[allow(dead_code)] // OpenSK legacy
|
||||||
pub const NUM_PERSISTENT_KEYS: usize = 20;
|
pub const NUM_PERSISTENT_KEYS: usize = 20;
|
||||||
|
|
||||||
/// Helper to define keys as a partial partition of a range.
|
/// Helper to define keys as a partial partition of a range.
|
||||||
|
|
@ -62,7 +63,7 @@ define_names! {
|
||||||
///
|
///
|
||||||
/// Depending on `MAX_SUPPORTED_RESIDENTIAL_KEYS`, only a prefix of those keys is used. Each
|
/// Depending on `MAX_SUPPORTED_RESIDENTIAL_KEYS`, only a prefix of those keys is used. Each
|
||||||
/// board may configure `MAX_SUPPORTED_RESIDENTIAL_KEYS` depending on the storage size.
|
/// board may configure `MAX_SUPPORTED_RESIDENTIAL_KEYS` depending on the storage size.
|
||||||
CREDENTIALS = 1700..2000;
|
// CREDENTIALS = 1700..2000;
|
||||||
|
|
||||||
/// The secret of the CredRandom feature.
|
/// The secret of the CredRandom feature.
|
||||||
CRED_RANDOM_SECRET = 2041;
|
CRED_RANDOM_SECRET = 2041;
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ fn main() -> ! {
|
||||||
// this call will block until the PDDB is mounted.
|
// this call will block until the PDDB is mounted.
|
||||||
let boot_time = ClockValue::new(tt.elapsed_ms() as i64, 1000);
|
let boot_time = ClockValue::new(tt.elapsed_ms() as i64, 1000);
|
||||||
let mut ctap_state = CtapState::new(&mut rng, check_user_presence, boot_time);
|
let mut ctap_state = CtapState::new(&mut rng, check_user_presence, boot_time);
|
||||||
//let mut ctap_hid = CtapHid::new();
|
let mut ctap_hid = CtapHid::new();
|
||||||
|
|
||||||
let mut repl = Repl::new(&xns, sid);
|
let mut repl = Repl::new(&xns, sid);
|
||||||
let mut update_repl = true;
|
let mut update_repl = true;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue