diff --git a/crates/scheduler/CHANGELOG.md b/crates/scheduler/CHANGELOG.md index b174ff54..28882e17 100644 --- a/crates/scheduler/CHANGELOG.md +++ b/crates/scheduler/CHANGELOG.md @@ -26,6 +26,7 @@ ### Patch +- Fix board API feature gates for AES-128-CCM and AES-256-GCM - Remove unreachable `multivalue` feature gates - Correctly gate events of nested APIs - Rename `debug` internal feature to `internal-debug` diff --git a/crates/scheduler/src/call/crypto/ccm.rs b/crates/scheduler/src/call/crypto/ccm.rs index 8fd96dec..648b8879 100644 --- a/crates/scheduler/src/call/crypto/ccm.rs +++ b/crates/scheduler/src/call/crypto/ccm.rs @@ -13,36 +13,36 @@ // limitations under the License. use wasefire_applet_api::crypto::ccm::{self as api, Api}; -#[cfg(feature = "board-api-aes128-ccm")] +#[cfg(feature = "board-api-crypto-aes128-ccm")] use wasefire_board_api::crypto::aead::{Api as _, Array}; use wasefire_board_api::Api as Board; -#[cfg(feature = "board-api-aes128-ccm")] +#[cfg(feature = "board-api-crypto-aes128-ccm")] use wasefire_board_api::{self as board, Support}; -#[cfg(feature = "board-api-aes128-ccm")] +#[cfg(feature = "board-api-crypto-aes128-ccm")] use crate::applet::store::MemoryApi; -#[cfg(feature = "board-api-aes128-ccm")] +#[cfg(feature = "board-api-crypto-aes128-ccm")] use crate::Trap; use crate::{DispatchSchedulerCall, SchedulerCall}; pub fn process(call: Api>) { match call { Api::IsSupported(call) => is_supported(call), - Api::Encrypt(call) => or_trap!("board-api-aes128-ccm", encrypt(call)), - Api::Decrypt(call) => or_trap!("board-api-aes128-ccm", decrypt(call)), + Api::Encrypt(call) => or_trap!("board-api-crypto-aes128-ccm", encrypt(call)), + Api::Decrypt(call) => or_trap!("board-api-crypto-aes128-ccm", decrypt(call)), } } fn is_supported(call: SchedulerCall) { let api::is_supported::Params {} = call.read(); - #[cfg(feature = "board-api-aes128-ccm")] + #[cfg(feature = "board-api-crypto-aes128-ccm")] let supported = bool::from(board::crypto::Aes128Ccm::::SUPPORT) as u32; - #[cfg(not(feature = "board-api-aes128-ccm"))] + #[cfg(not(feature = "board-api-crypto-aes128-ccm"))] let supported = 0; call.reply(Ok(api::is_supported::Results { supported: supported.into() })) } -#[cfg(feature = "board-api-aes128-ccm")] +#[cfg(feature = "board-api-crypto-aes128-ccm")] fn encrypt(mut call: SchedulerCall) { let api::encrypt::Params { key, iv, len, clear, cipher } = call.read(); let scheduler = call.scheduler(); @@ -61,7 +61,7 @@ fn encrypt(mut call: SchedulerCall) { call.reply(results); } -#[cfg(feature = "board-api-aes128-ccm")] +#[cfg(feature = "board-api-crypto-aes128-ccm")] fn decrypt(mut call: SchedulerCall) { let api::decrypt::Params { key, iv, len, cipher, clear } = call.read(); let scheduler = call.scheduler(); @@ -81,12 +81,12 @@ fn decrypt(mut call: SchedulerCall) { call.reply(results); } -#[cfg(feature = "board-api-aes128-ccm")] +#[cfg(feature = "board-api-crypto-aes128-ccm")] fn expand_iv(iv: &[u8]) -> Array { core::array::from_fn(|i| i.checked_sub(5).map(|i| iv[i]).unwrap_or(0)).into() } -#[cfg(feature = "board-api-aes128-ccm")] +#[cfg(feature = "board-api-crypto-aes128-ccm")] fn ensure_support() -> Result<(), Trap> { match bool::from(board::crypto::Aes128Ccm::::SUPPORT) { true => Ok(()), diff --git a/crates/scheduler/src/call/crypto/gcm.rs b/crates/scheduler/src/call/crypto/gcm.rs index 75454417..deb7ce68 100644 --- a/crates/scheduler/src/call/crypto/gcm.rs +++ b/crates/scheduler/src/call/crypto/gcm.rs @@ -13,49 +13,49 @@ // limitations under the License. use wasefire_applet_api::crypto::gcm::{self as api, Api}; -#[cfg(feature = "board-api-aes256-gcm")] +#[cfg(feature = "board-api-crypto-aes256-gcm")] use wasefire_board_api::crypto::aead::Api as _; use wasefire_board_api::Api as Board; -#[cfg(feature = "board-api-aes256-gcm")] +#[cfg(feature = "board-api-crypto-aes256-gcm")] use wasefire_board_api::{self as board, Support as _}; -#[cfg(feature = "board-api-aes256-gcm")] +#[cfg(feature = "board-api-crypto-aes256-gcm")] use crate::applet::store::MemoryApi; -#[cfg(feature = "board-api-aes256-gcm")] +#[cfg(feature = "board-api-crypto-aes256-gcm")] use crate::Trap; use crate::{DispatchSchedulerCall, SchedulerCall}; pub fn process(call: Api>) { match call { Api::Support(call) => support(call), - Api::TagLength(call) => or_trap!("board-api-aes256-gcm", tag_length(call)), - Api::Encrypt(call) => or_trap!("board-api-aes256-gcm", encrypt(call)), - Api::Decrypt(call) => or_trap!("board-api-aes256-gcm", decrypt(call)), + Api::TagLength(call) => or_trap!("board-api-crypto-aes256-gcm", tag_length(call)), + Api::Encrypt(call) => or_trap!("board-api-crypto-aes256-gcm", encrypt(call)), + Api::Decrypt(call) => or_trap!("board-api-crypto-aes256-gcm", decrypt(call)), } } fn support(call: SchedulerCall) { let api::support::Params {} = call.read(); - #[cfg(feature = "board-api-aes256-gcm")] + #[cfg(feature = "board-api-crypto-aes256-gcm")] let support = { use wasefire_applet_api::crypto::gcm::Support; let support = board::crypto::Aes256Gcm::::SUPPORT; (support.no_copy as u32) << Support::NoCopy as u32 | (support.in_place_no_copy as u32) << Support::InPlaceNoCopy as u32 }; - #[cfg(not(feature = "board-api-aes256-gcm"))] + #[cfg(not(feature = "board-api-crypto-aes256-gcm"))] let support = 0; call.reply(Ok(api::support::Results { support: support.into() })) } -#[cfg(feature = "board-api-aes256-gcm")] +#[cfg(feature = "board-api-crypto-aes256-gcm")] fn tag_length(call: SchedulerCall) { let api::tag_length::Params {} = call.read(); let len = (tag_len::() as u32).into(); call.reply(Ok(api::tag_length::Results { len })) } -#[cfg(feature = "board-api-aes256-gcm")] +#[cfg(feature = "board-api-crypto-aes256-gcm")] fn encrypt(mut call: SchedulerCall) { let api::encrypt::Params { key, iv, aad, aad_len, length, clear, cipher, tag } = call.read(); let scheduler = call.scheduler(); @@ -75,7 +75,7 @@ fn encrypt(mut call: SchedulerCall) { call.reply(results); } -#[cfg(feature = "board-api-aes256-gcm")] +#[cfg(feature = "board-api-crypto-aes256-gcm")] fn decrypt(mut call: SchedulerCall) { let api::decrypt::Params { key, iv, aad, aad_len, tag, length, cipher, clear } = call.read(); let scheduler = call.scheduler(); @@ -95,13 +95,13 @@ fn decrypt(mut call: SchedulerCall) { call.reply(results); } -#[cfg(feature = "board-api-aes256-gcm")] +#[cfg(feature = "board-api-crypto-aes256-gcm")] const fn tag_len() -> usize { use typenum::Unsigned; as board::crypto::aead::Api<_, _>>::Tag::USIZE } -#[cfg(feature = "board-api-aes256-gcm")] +#[cfg(feature = "board-api-crypto-aes256-gcm")] fn ensure_support() -> Result<(), Trap> { match bool::from(board::crypto::Aes256Gcm::::SUPPORT) { true => Ok(()),