fix hosted mode

This commit is contained in:
bunnie 2025-11-27 22:10:43 +08:00
parent 1ae786b7d2
commit b88f6cad91
3 changed files with 19 additions and 3 deletions

View file

@ -72,8 +72,14 @@ board-baosec = [
"blitstr2/board-baosec",
"usb-bao1x/board-baosec",
"persistent_store/board-baosec",
"ctap-crypto/board-baosec",
]
hosted-baosec = [
"bao1x-emu",
"ux-api/hosted-baosec",
"usb-bao1x/hosted-baosec",
"ctap-crypto/hosted-baosec",
]
hosted-baosec = ["bao1x-emu", "ux-api/hosted-baosec", "usb-bao1x/hosted-baosec"]
with_ctap1 = ["ctap-crypto/with_ctap1"]
vendor_hid = []

View file

@ -13,7 +13,8 @@ edition = "2018"
cbor = { path = "../cbor", package = "cbor-vault2" }
arrayref = "0.3.6"
subtle = { version = "2.2.3", default-features = false }
bao1x-hal-service = { path = "../../../../services/bao1x-hal-service" }
bao1x-hal-service = { path = "../../../../services/bao1x-hal-service", optional = true }
bao1x-emu = { path = "../../../../services/bao1x-emu", optional = true }
xous-names = { package = "xous-api-names", version = "0.9.67" }
rand_core = "0.6.3"
p256 = { version = "0.11.1", default-features = false, features = [
@ -41,5 +42,7 @@ byteorder = { version = "1", default-features = false }
rfc6979 = "0.2.0"
[features]
board-baosec = ["bao1x-hal-service"]
hosted-baosec = ["bao1x-emu"]
with_ctap1 = []
derive_debug = []

View file

@ -38,12 +38,19 @@ fn bytes_to_u32(bytes: [u8; 32]) -> [u32; 8] {
}
pub struct XousRng256 {
#[cfg(feature = "board-baosec")]
trng: bao1x_hal_service::trng::Trng,
#[cfg(feature = "hosted-baosec")]
trng: bao1x_emu::trng::Trng,
}
impl XousRng256 {
pub fn new(xns: &xous_names::XousNames) -> Self {
XousRng256 { trng: bao1x_hal_service::trng::Trng::new(xns).unwrap() }
#[cfg(feature = "board-baosec")]
let ret = XousRng256 { trng: bao1x_hal_service::trng::Trng::new(xns).unwrap() };
#[cfg(feature = "hosted-baosec")]
let ret = XousRng256 { trng: bao1x_emu::trng::Trng::new(xns).unwrap() };
ret
}
}
impl Rng256 for XousRng256 {