diff --git a/services/llio/Cargo.toml b/services/llio/Cargo.toml index ce9dffe48..1f4f7d045 100644 --- a/services/llio/Cargo.toml +++ b/services/llio/Cargo.toml @@ -21,8 +21,9 @@ locales = { path = "../../locales" } num-derive = { version = "0.3.3", default-features = false } num-traits = { version = "0.2.14", default-features = false } -rkyv = { version = "0.4.3", default-features = false, features = [ - "const_generics", +rkyv = { version = "0.8.8", default-features = false, features = [ + "std", + "alloc", ] } xous-semver = "0.1.2" diff --git a/services/llio/src/api.rs b/services/llio/src/api.rs index fd5e08f39..c007bda50 100644 --- a/services/llio/src/api.rs +++ b/services/llio/src/api.rs @@ -63,13 +63,13 @@ pub(crate) enum Opcode { GpioIntAsFalling, //(u32), GpioIntPending, GpioIntEna, //(u32), - GpioIntSubscribe, //(String<64>), // + GpioIntSubscribe, //(String), // GpioIntHappened, /// set UART mux UartMux, //(UartType), - // InfoLitexId, //(String<64>), // TODO: returns the ASCII string baked into the FPGA that describes the + // InfoLitexId, //(String), // TODO: returns the ASCII string baked into the FPGA that describes the // FPGA build, inside Registration InfoDna, InfoGit, @@ -106,9 +106,9 @@ pub(crate) enum Opcode { AdcGpio2, /// events - EventComSubscribe, //(String<64>), - //EventRtcSubscribe, //(String<64>), - EventUsbAttachSubscribe, //(String<64>), + EventComSubscribe, //(String), + //EventRtcSubscribe, //(String), + EventUsbAttachSubscribe, //(String), EventComEnable, //(bool), //EventRtcEnable, //(bool), EventUsbAttachEnable, //(bool), diff --git a/services/pddb/Cargo.toml b/services/pddb/Cargo.toml index 63f28eba6..68c8267ce 100644 --- a/services/pddb/Cargo.toml +++ b/services/pddb/Cargo.toml @@ -17,7 +17,10 @@ susres = { package = "xous-api-susres", version = "0.9.59" } log = "0.4.14" num-derive = { version = "0.3.3", default-features = false } num-traits = { version = "0.2.14", default-features = false } -rkyv = { version = "0.4.3", features = ["const_generics"] } +rkyv = { version = "0.8.8", default-features = false, features = [ + "std", + "alloc", +] } trng = { path = "../trng" } spinor = { path = "../spinor" } aes = { path = "../aes" } diff --git a/services/pddb/src/api.rs b/services/pddb/src/api.rs index d04ebcd36..f16260d44 100644 --- a/services/pddb/src/api.rs +++ b/services/pddb/src/api.rs @@ -264,7 +264,7 @@ pub type ApiToken = [u32; 3]; pub struct PddbBasisList { /// the first 63 that fit in the list -- generally we anticipate not more than a few being open at a /// time, so this should be enough. - pub list: [xous_ipc::String; 63], + pub list: [String; 63], /// total number of basis open. Should be <= 63, but we allow it to be larger to indicate cases where /// this structure wasn't big enough. pub num: u32, @@ -298,16 +298,16 @@ impl BasisRetentionPolicy { } #[derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)] pub struct PddbBasisRequest { - pub name: xous_ipc::String, + pub name: String, pub code: PddbRequestCode, pub policy: Option, } #[derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)] pub struct PddbDictRequest { pub basis_specified: bool, - pub basis: xous_ipc::String, - pub dict: xous_ipc::String, - pub key: xous_ipc::String, + pub basis: String, + pub dict: String, + pub key: String, pub index: u32, pub token: [u32; 4], pub code: PddbRequestCode, @@ -323,9 +323,9 @@ pub struct PddbDictRequest { #[derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)] pub struct PddbKeyRequest { pub basis_specified: bool, - pub basis: xous_ipc::String, - pub dict: xous_ipc::String, - pub key: xous_ipc::String, + pub basis: String, + pub dict: String, + pub key: String, pub token: Option, pub create_dict: bool, pub create_key: bool, @@ -350,8 +350,8 @@ pub(crate) const MAX_PDDB_DELETE_LEN: usize = 3800; // approximate limit, might #[derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)] pub(crate) struct PddbDeleteList { pub basis_specified: bool, - pub basis: xous_ipc::String, - pub dict: xous_ipc::String, + pub basis: String, + pub dict: String, pub data: [u8; MAX_PDDB_DELETE_LEN], pub retcode: PddbRetcode, } @@ -524,8 +524,8 @@ pub struct PddbKeyAttrIpc { pub len: u64, pub reserved: u64, pub age: u64, - pub dict: xous_ipc::String, - pub basis: xous_ipc::String, + pub dict: String, + pub basis: String, pub flags: u32, pub index: u32, pub token: ApiToken, @@ -537,8 +537,8 @@ impl PddbKeyAttrIpc { len: 0, reserved: 0, age: 0, - dict: xous_ipc::String::::new(), - basis: xous_ipc::String::::new(), + dict: String::::new(), + basis: String::::new(), flags: 0, index: 0, token, @@ -552,8 +552,8 @@ impl PddbKeyAttrIpc { len: self.len as usize, reserved: self.reserved as usize, age: self.age as usize, - dict: String::from(self.dict.as_str().unwrap()), - basis: String::from(self.basis.as_str().unwrap()), + dict: String::from(self.dict.as_str()), + basis: String::from(self.basis.as_str()), flags: KeyFlags(self.flags), index: NonZeroU32::new(self.index).unwrap(), } @@ -564,8 +564,8 @@ impl PddbKeyAttrIpc { len: attr.len as u64, reserved: attr.reserved as u64, age: attr.age as u64, - dict: xous_ipc::String::::from_str(&attr.dict), - basis: xous_ipc::String::::from_str(&attr.basis), + dict: String::::from_str(&attr.dict), + basis: String::::from_str(&attr.basis), flags: attr.flags.0, index: attr.index.get(), token, @@ -579,7 +579,7 @@ impl PddbKeyAttrIpc { #[derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)] pub struct PddbDangerousDebug { pub request: DebugRequest, - pub dump_name: xous_ipc::String<128>, + pub dump_name: String, } #[cfg(not(target_os = "xous"))] #[derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)] diff --git a/services/pddb/src/api/rkyv_enum.rs b/services/pddb/src/api/rkyv_enum.rs index edd15e92b..baff14138 100644 --- a/services/pddb/src/api/rkyv_enum.rs +++ b/services/pddb/src/api/rkyv_enum.rs @@ -48,7 +48,7 @@ pub enum PddbRekeyOp { /// system basis keys are encrypted directly by the rootkeys enclave, so changing /// its password requires calling a routine in root_keys (that does not exist /// at this current time). - ChangePass(xous_ipc::String), + ChangePass(String), */ /// Return codes Success, diff --git a/services/pddb/src/backend/hw.rs b/services/pddb/src/backend/hw.rs index 8f8954d34..4a228f5ed 100644 --- a/services/pddb/src/backend/hw.rs +++ b/services/pddb/src/backend/hw.rs @@ -2777,7 +2777,7 @@ impl PddbOs { Ok(bname) => { let name = bname.first().as_str().to_string(); let request = BasisRequestPassword { - db_name: xous_ipc::String::from_str(name.to_string()), + db_name: String::from(name.to_string()), plaintext_pw: None, }; let mut buf = Buffer::into_buf(request).unwrap(); @@ -2785,7 +2785,7 @@ impl PddbOs { let retpass = buf.to_original::().unwrap(); // 2. validate the name/password combo let basis_key = - self.basis_derive_key(&name, retpass.plaintext_pw.unwrap().as_str().unwrap()); + self.basis_derive_key(&name, retpass.plaintext_pw.unwrap().as_str()); // validate the password by finding the root block of the basis. We rely entirely // upon the AEAD with key commit to ensure the password is correct. let maybe_entry = if let Some(basis_map) = @@ -3446,7 +3446,7 @@ impl PddbOs { { Ok(bname) => { let request = BasisRequestPassword { - db_name: xous_ipc::String::from_str(bname.first().as_str()), + db_name: String::from(bname.first().as_str()), plaintext_pw: None, }; let mut buf = Buffer::into_buf(request).unwrap(); diff --git a/services/pddb/src/lib.rs b/services/pddb/src/lib.rs index 0f1a93d63..286e1e307 100644 --- a/services/pddb/src/lib.rs +++ b/services/pddb/src/lib.rs @@ -280,7 +280,7 @@ impl Pddb { /// return a list of all open bases pub fn list_basis(&self) -> Vec { - let list_alloc = PddbBasisList { list: [xous_ipc::String::::default(); 63], num: 0 }; + let list_alloc = PddbBasisList { list: [String::::default(); 63], num: 0 }; let mut buf = Buffer::into_buf(list_alloc).expect("Couldn't convert to memory structure"); buf.lend_mut(self.conn, Opcode::ListBasis.to_u32().unwrap()) .expect("Couldn't execute ListBasis opcode"); @@ -293,14 +293,14 @@ impl Pddb { if index as u32 == list.num { break; } - ret.push(name.as_str().expect("name is not valid utf-8").to_string()); + ret.push(name.as_str().to_string()); } ret } /// The caller of this function will block and return only if the order of Bases has changed. pub fn monitor_basis(&self) -> Vec { - let list_alloc = PddbBasisList { list: [xous_ipc::String::::default(); 63], num: 0 }; + let list_alloc = PddbBasisList { list: [String::::default(); 63], num: 0 }; let mut buf = Buffer::into_buf(list_alloc).expect("Couldn't convert to memory structure"); buf.lend_mut(self.conn, Opcode::BasisMonitor.to_u32().unwrap()) .expect("Couldn't execute ListBasis opcode"); @@ -313,7 +313,7 @@ impl Pddb { if index as u32 == list.num { break; } - ret.push(name.as_str().expect("name is not valid utf-8").to_string()); + ret.push(name.as_str().to_string()); } ret } @@ -322,7 +322,7 @@ impl Pddb { /// if the PDDB is not mounted, returns None pub fn latest_basis(&self) -> Option { let mgmt = PddbBasisRequest { - name: xous_ipc::String::::new(), + name: String::::new(), code: PddbRequestCode::Uninit, policy: None, }; @@ -331,7 +331,7 @@ impl Pddb { .expect("Couldn't execute ListBasis opcode"); let ret = buf.to_original::().expect("couldn't restore list structure"); match ret.code { - PddbRequestCode::NoErr => Some(ret.name.as_str().expect("name wasn't valid utf-8").to_string()), + PddbRequestCode::NoErr => Some(ret.name.as_str().to_string()), PddbRequestCode::NotMounted => None, _ => { log::error!("Invalid return from latest basis call"); @@ -345,7 +345,7 @@ impl Pddb { return Err(Error::new(ErrorKind::InvalidInput, "basis name too long")); } let mgmt = PddbBasisRequest { - name: xous_ipc::String::::from_str(basis_name), + name: String::::from_str(basis_name), code: PddbRequestCode::Create, policy: None, }; @@ -376,7 +376,7 @@ impl Pddb { return Err(Error::new(ErrorKind::InvalidInput, "basis name too long")); } let mgmt = PddbBasisRequest { - name: xous_ipc::String::::from_str(basis_name), + name: String::::from_str(basis_name), code: PddbRequestCode::Open, policy, }; @@ -404,7 +404,7 @@ impl Pddb { return Err(Error::new(ErrorKind::InvalidInput, "basis name too long")); } let mgmt = PddbBasisRequest { - name: xous_ipc::String::::from_str(basis_name), + name: String::::from_str(basis_name), code: PddbRequestCode::Close, policy: None, }; @@ -430,7 +430,7 @@ impl Pddb { return Err(Error::new(ErrorKind::InvalidInput, "basis name too long")); } let mgmt = PddbBasisRequest { - name: xous_ipc::String::::from_str(basis_name), + name: String::::from_str(basis_name), code: PddbRequestCode::Delete, policy: None, }; @@ -477,9 +477,9 @@ impl Pddb { if bname.len() > BASIS_NAME_LEN - 1 { return Err(Error::new(ErrorKind::InvalidInput, "basis name too long")); } - xous_ipc::String::::from_str(bname) + String::::from_str(bname) } else { - xous_ipc::String::::new() + String::::new() }; if key_changed_cb.is_some() { @@ -492,9 +492,9 @@ impl Pddb { let request = PddbKeyRequest { basis_specified: basis_name.is_some(), - basis: xous_ipc::String::::from_str(&bname), - dict: xous_ipc::String::::from_str(dict_name), - key: xous_ipc::String::::from_str(key_name), + basis: String::::from_str(&bname), + dict: String::::from_str(dict_name), + key: String::::from_str(key_name), create_dict, create_key, token: None, @@ -524,7 +524,7 @@ impl Pddb { // i think these fields are redundant, let's save the storage and remove them for // now... dict: String::from(dict_name), //key: String::from(key_name), - //basis: if basis_name.is_some() {Some(String::from(bname.as_str().unwrap()))} else + //basis: if basis_name.is_some() {Some(String::from(bname.as_str()))} else // {None}, pos: 0, token, @@ -560,9 +560,9 @@ impl Pddb { if bname.len() > BASIS_NAME_LEN - 1 { return Err(Error::new(ErrorKind::InvalidInput, "basis name too long")); } - xous_ipc::String::::from_str(bname) + String::::from_str(bname) } else { - xous_ipc::String::::new() + String::::new() }; let maybe_cb = self.cb.take(); @@ -571,9 +571,9 @@ impl Pddb { let request = PddbKeyRequest { basis_specified: basis_name.is_some(), - basis: xous_ipc::String::::from_str(&bname), - dict: xous_ipc::String::::from_str(dict_name), - key: xous_ipc::String::::from_str(key_name), + basis: String::::from_str(&bname), + dict: String::::from_str(dict_name), + key: String::::from_str(key_name), create_dict: false, create_key: false, token: None, @@ -614,14 +614,14 @@ impl Pddb { if bname.len() > BASIS_NAME_LEN - 1 { return Err(Error::new(ErrorKind::InvalidInput, "basis name too long")); } - xous_ipc::String::::from_str(bname) + String::::from_str(bname) } else { - xous_ipc::String::::new() + String::::new() }; let mut request = PddbDeleteList { basis_specified: basis_name.is_some(), - basis: xous_ipc::String::::from_str(&bname), - dict: xous_ipc::String::::from_str(dict_name), + basis: String::::from_str(&bname), + dict: String::::from_str(dict_name), retcode: PddbRetcode::Uninit, data: [0u8; MAX_PDDB_DELETE_LEN], }; @@ -670,9 +670,9 @@ impl Pddb { if bname.len() > BASIS_NAME_LEN - 1 { return Err(Error::new(ErrorKind::InvalidInput, "basis name too long")); } - xous_ipc::String::::from_str(bname) + String::::from_str(bname) } else { - xous_ipc::String::::new() + String::::new() }; let maybe_cb = self.cb.take(); @@ -681,9 +681,9 @@ impl Pddb { let request = PddbKeyRequest { basis_specified: basis_name.is_some(), - basis: xous_ipc::String::::from_str(&bname), - dict: xous_ipc::String::::from_str(dict_name), - key: xous_ipc::String::::new(), + basis: String::::from_str(&bname), + dict: String::::from_str(dict_name), + key: String::::new(), create_dict: false, create_key: false, token: None, @@ -764,9 +764,9 @@ impl Pddb { if bname.len() > BASIS_NAME_LEN - 1 { return Err(Error::new(ErrorKind::InvalidInput, "basis name too long")); } - xous_ipc::String::::from_str(bname) + String::::from_str(bname) } else { - xous_ipc::String::::new() + String::::new() }; // this is a two-phase query, because it's quite likely that the number of keys can be very large in a // dict. @@ -778,9 +778,9 @@ impl Pddb { ]; let request = PddbDictRequest { basis_specified: basis_name.is_some(), - basis: xous_ipc::String::::from_str(&bname), - dict: xous_ipc::String::::from_str(dict_name), - key: xous_ipc::String::::new(), + basis: String::::from_str(&bname), + dict: String::::from_str(dict_name), + key: String::::new(), index: 0, code: PddbRequestCode::Uninit, token, @@ -877,9 +877,9 @@ impl Pddb { if bname.len() > BASIS_NAME_LEN - 1 { return Err(Error::new(ErrorKind::InvalidInput, "basis name too long")); } - xous_ipc::String::::from_str(bname) + String::::from_str(bname) } else { - xous_ipc::String::::new() + String::::new() }; // this is a two-phase query, because it's quite likely that the number of keys can be very large in a // dict. @@ -891,9 +891,9 @@ impl Pddb { ]; let request = PddbDictRequest { basis_specified: basis_name.is_some(), - basis: xous_ipc::String::::from_str(&bname), - dict: xous_ipc::String::::new(), - key: xous_ipc::String::::new(), + basis: String::::from_str(&bname), + dict: String::::new(), + key: String::::new(), index: 0, code: PddbRequestCode::Uninit, token, @@ -918,9 +918,9 @@ impl Pddb { for index in 0..count { let request = PddbDictRequest { basis_specified: basis_name.is_some(), - basis: xous_ipc::String::::from_str(&bname), - dict: xous_ipc::String::::new(), - key: xous_ipc::String::::new(), + basis: String::::from_str(&bname), + dict: String::::new(), + key: String::::new(), index, code: PddbRequestCode::Uninit, token, @@ -935,7 +935,7 @@ impl Pddb { let response = buf.to_original::().unwrap(); match response.code { PddbRequestCode::NoErr => dict_list - .push(String::from(response.dict.as_str().expect("utf-8 parse error in key name"))), + .push(String::from(response.dict.as_str())), _ => return Err(Error::new(ErrorKind::Other, "Internal error")), } } @@ -1107,9 +1107,9 @@ impl Pddb { // setup the request arguments let mut request = PddbDictRequest { basis_specified: basis.is_some(), - basis: xous_ipc::String::::from_str(basis.unwrap_or("")), - dict: xous_ipc::String::::from_str(dict), - key: xous_ipc::String::::new(), + basis: String::::from_str(basis.unwrap_or("")), + dict: String::::from_str(dict), + key: String::::new(), index: 0, token: [0u32; 4], code: PddbRequestCode::BulkRead, @@ -1247,7 +1247,7 @@ impl Pddb { #[cfg(not(target_os = "xous"))] pub fn dbg_dump(&self, name: &str) -> Result<()> { let ipc = - PddbDangerousDebug { request: DebugRequest::Dump, dump_name: xous_ipc::String::from_str(name) }; + PddbDangerousDebug { request: DebugRequest::Dump, dump_name: String::from(name) }; let buf = Buffer::into_buf(ipc).or(Err(Error::new(ErrorKind::Other, "Xous internal error")))?; buf.lend(self.conn, Opcode::DangerousDebug.to_u32().unwrap()) .or(Err(Error::new(ErrorKind::Other, "Xous internal error"))) @@ -1258,7 +1258,7 @@ impl Pddb { /// It's a cheesy way to test a power cycle, without having to power cycle. #[cfg(not(target_os = "xous"))] pub fn dbg_remount(&self) -> Result<()> { - let ipc = PddbDangerousDebug { request: DebugRequest::Remount, dump_name: xous_ipc::String::new() }; + let ipc = PddbDangerousDebug { request: DebugRequest::Remount, dump_name: String::new() }; let buf = Buffer::into_buf(ipc).or(Err(Error::new(ErrorKind::Other, "Xous internal error")))?; buf.lend(self.conn, Opcode::DangerousDebug.to_u32().unwrap()) .or(Err(Error::new(ErrorKind::Other, "Xous internal error"))) @@ -1268,7 +1268,7 @@ impl Pddb { /// Forces a basis pruning, for testing the pruning and prune recovery code. #[cfg(not(target_os = "xous"))] pub fn dbg_prune(&self) -> Result<()> { - let ipc = PddbDangerousDebug { request: DebugRequest::Prune, dump_name: xous_ipc::String::new() }; + let ipc = PddbDangerousDebug { request: DebugRequest::Prune, dump_name: String::new() }; let buf = Buffer::into_buf(ipc).or(Err(Error::new(ErrorKind::Other, "Xous internal error")))?; buf.lend(self.conn, Opcode::DangerousDebug.to_u32().unwrap()) .or(Err(Error::new(ErrorKind::Other, "Xous internal error"))) @@ -1278,7 +1278,7 @@ impl Pddb { /// Turns on debug spew #[cfg(not(target_os = "xous"))] pub fn dbg_set_debug(&self) -> Result<()> { - let ipc = PddbDangerousDebug { request: DebugRequest::SetDebug, dump_name: xous_ipc::String::new() }; + let ipc = PddbDangerousDebug { request: DebugRequest::SetDebug, dump_name: String::new() }; let buf = Buffer::into_buf(ipc).or(Err(Error::new(ErrorKind::Other, "Xous internal error")))?; buf.lend(self.conn, Opcode::DangerousDebug.to_u32().unwrap()) .or(Err(Error::new(ErrorKind::Other, "Xous internal error"))) diff --git a/services/pddb/src/main.rs b/services/pddb/src/main.rs index 467d27200..ce8fd1572 100644 --- a/services/pddb/src/main.rs +++ b/services/pddb/src/main.rs @@ -413,8 +413,8 @@ const FILE_ID_SERVICES_PDDB_SRC_DICTIONARY: u32 = 1; #[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)] pub(crate) struct BasisRequestPassword { - db_name: xous_ipc::String<{ crate::api::BASIS_NAME_LEN }>, - plaintext_pw: Option>, + db_name: String<{ crate::api::BASIS_NAME_LEN }>, + plaintext_pw: Option>, } #[derive(Debug, PartialEq, Eq)] pub(crate) enum PasswordState { @@ -896,14 +896,14 @@ fn wrapped_main() -> ! { if let Some(pw) = ret.plaintext_pw { match basis_cache.basis_create( &mut pddb_os, - mgmt.name.as_str().expect("name is not valid utf-8"), - pw.as_str().expect("password was not valid utf-8"), + mgmt.name.as_str(), + pw.as_str(), ) { Ok(_) => { log::info!( "{}PDDB.CREATEOK,{},{}", xous::BOOKEND_START, - mgmt.name.as_str().unwrap(), + mgmt.name.as_str(), xous::BOOKEND_END ); mgmt.code = PddbRequestCode::NoErr @@ -940,8 +940,8 @@ fn wrapped_main() -> ! { if let Some(pw) = ret.plaintext_pw { if let Some(basis) = basis_cache.basis_unlock( &mut pddb_os, - mgmt.name.as_str().expect("name is not valid utf-8"), - pw.as_str().expect("password was not valid utf-8"), + mgmt.name.as_str(), + pw.as_str(), mgmt.policy.unwrap_or(BasisRetentionPolicy::Persist), ) { if basis_cache.basis_contains(&basis.name) { @@ -960,7 +960,7 @@ fn wrapped_main() -> ! { log::info!( "{}PDDB.UNLOCKOK,{},{}", xous::BOOKEND_START, - mgmt.name.as_str().unwrap(), + mgmt.name.as_str(), xous::BOOKEND_END ); if basis_monitor_notifications.len() > 0 { @@ -974,7 +974,7 @@ fn wrapped_main() -> ! { log::info!( "{}PDDB.BADPASS,{},{}", xous::BOOKEND_START, - mgmt.name.as_str().unwrap(), + mgmt.name.as_str(), xous::BOOKEND_END ); modals @@ -1019,7 +1019,7 @@ fn wrapped_main() -> ! { match mgmt.code { PddbRequestCode::Close => { match basis_cache - .basis_unmount(&mut pddb_os, mgmt.name.as_str().expect("name is not valid utf-8")) + .basis_unmount(&mut pddb_os, mgmt.name.as_str()) { Ok(_) => { mgmt.code = PddbRequestCode::NoErr; @@ -1050,7 +1050,7 @@ fn wrapped_main() -> ! { match mgmt.code { PddbRequestCode::Delete => { match basis_cache - .basis_delete(&mut pddb_os, mgmt.name.as_str().expect("name is not valid utf-8")) + .basis_delete(&mut pddb_os, mgmt.name.as_str()) { Ok(_) => mgmt.code = PddbRequestCode::NoErr, Err(e) => match e.kind() { @@ -1078,12 +1078,12 @@ fn wrapped_main() -> ! { unsafe { Buffer::from_memory_message_mut(msg.body.memory_message_mut().unwrap()) }; let mut req: PddbKeyRequest = buffer.to_original::().unwrap(); let bname = if req.basis_specified { - Some(req.basis.as_str().unwrap()) + Some(req.basis.as_str()) } else { Some(basis.as_str()) }; - let dict = req.dict.as_str().expect("dict utf-8 decode error"); - let key = req.key.as_str().expect("key utf-8 decode error"); + let dict = req.dict.as_str(); + let key = req.key.as_str(); log::debug!("get: {:?} {}", bname, key); #[cfg(feature = "perfcounter")] pddb_os.perf_entry( @@ -1272,9 +1272,9 @@ fn wrapped_main() -> ! { let mut buffer = unsafe { Buffer::from_memory_message_mut(msg.body.memory_message_mut().unwrap()) }; let mut req: PddbKeyRequest = buffer.to_original::().unwrap(); - let bname = if req.basis_specified { Some(req.basis.as_str().unwrap()) } else { None }; - let dict = req.dict.as_str().expect("dict utf-8 decode error"); - let key = req.key.as_str().expect("key utf-8 decode error"); + let bname = if req.basis_specified { Some(req.basis.as_str()) } else { None }; + let dict = req.dict.as_str(); + let key = req.key.as_str(); match basis_cache.key_remove(&mut pddb_os, dict, key, bname, false) { Ok(_) => { let mut evict_list = Vec::::new(); @@ -1342,8 +1342,8 @@ fn wrapped_main() -> ! { } log::info!("Deleting key list: {:?}", key_list); let start = tt.elapsed_ms(); - let bname = if req.basis_specified { Some(req.basis.as_str().unwrap()) } else { None }; - let dict = req.dict.as_str().expect("dict utf-8 decode error"); + let bname = if req.basis_specified { Some(req.basis.as_str()) } else { None }; + let dict = req.dict.as_str(); match basis_cache.key_list_remove(&mut pddb_os, dict, key_list, bname) { Ok(_) => req.retcode = PddbRetcode::Ok, Err(e) => match e.kind() { @@ -1367,8 +1367,8 @@ fn wrapped_main() -> ! { let mut buffer = unsafe { Buffer::from_memory_message_mut(msg.body.memory_message_mut().unwrap()) }; let mut req: PddbKeyRequest = buffer.to_original::().unwrap(); - let bname = if req.basis_specified { Some(req.basis.as_str().unwrap()) } else { None }; - let dict = req.dict.as_str().expect("dict utf-8 decode error"); + let bname = if req.basis_specified { Some(req.basis.as_str()) } else { None }; + let dict = req.dict.as_str(); log::debug!("attempting to remove dict {} basis {:?}", dict, bname); match basis_cache.dict_remove(&mut pddb_os, dict, bname, false) { Ok(_) => { @@ -1464,8 +1464,8 @@ fn wrapped_main() -> ! { continue; } key_token = Some(req.token); - let bname = if req.basis_specified { Some(req.basis.as_str().unwrap()) } else { None }; - let dict = req.dict.as_str().expect("dict utf-8 decode error"); + let bname = if req.basis_specified { Some(req.basis.as_str()) } else { None }; + let dict = req.dict.as_str(); log::debug!("counting keys in dict {} basis {:?}", dict, bname); #[cfg(feature = "perfcounter")] pddb_os.perf_entry(FILE_ID_SERVICES_PDDB_SRC_MAIN, perflib::PERFMETA_NONE, 0, std::line!()); @@ -1574,7 +1574,7 @@ fn wrapped_main() -> ! { } dict_token = Some(req.token); dict_list.clear(); - let bname = if req.basis_specified { Some(req.basis.as_str().unwrap()) } else { None }; + let bname = if req.basis_specified { Some(req.basis.as_str()) } else { None }; let list = basis_cache.dict_list(&mut pddb_os, bname); if list.len() > 0 { req.index = list.len() as u32; @@ -1601,7 +1601,7 @@ fn wrapped_main() -> ! { req.code = PddbRequestCode::InternalError; } else { req.dict = - xous_ipc::String::::from_str(&dict_list[req.index as usize]); + String::::from_str(&dict_list[req.index as usize]); req.code = PddbRequestCode::NoErr; // the last index requested must be the highest one! if req.index == dict_list.len() as u32 - 1 { @@ -1734,9 +1734,9 @@ fn wrapped_main() -> ! { // confirm data exists; setup the tracking state let key_list: Vec = match basis_cache.key_list( &mut pddb_os, - bulk_descriptor.dict.as_str().unwrap(), + bulk_descriptor.dict.as_str(), if bulk_descriptor.basis_specified { - Some(bulk_descriptor.basis.as_str().unwrap()) + Some(bulk_descriptor.basis.as_str()) } else { None }, @@ -2184,14 +2184,14 @@ fn wrapped_main() -> ! { let dbg = buffer.to_original::().unwrap(); match dbg.request { DebugRequest::Dump => { - log::info!("dumping pddb to {}", dbg.dump_name.as_str().unwrap()); + log::info!("dumping pddb to {}", dbg.dump_name.as_str()); #[cfg(not(feature = "autobasis"))] - pddb_os.dbg_dump(Some(dbg.dump_name.as_str().unwrap().to_string()), None); + pddb_os.dbg_dump(Some(dbg.dump_name.as_str().to_string()), None); #[cfg(feature = "autobasis")] { let export_extra = pddb_os.dbg_extra(); pddb_os.dbg_dump( - Some(dbg.dump_name.as_str().unwrap().to_string()), + Some(dbg.dump_name.as_str().to_string()), Some(&export_extra), ); } diff --git a/services/pddb/src/menu.rs b/services/pddb/src/menu.rs index 49289ed9a..6a6348547 100644 --- a/services/pddb/src/menu.rs +++ b/services/pddb/src/menu.rs @@ -1,7 +1,7 @@ use gam::*; use locales::t; use num_traits::*; -use xous_ipc::String; +use String; use crate::api::*; @@ -9,21 +9,21 @@ pub(crate) fn pddb_menu(conn: xous::CID) { let mut menu_items = Vec::::new(); menu_items.push(MenuItem { - name: String::from_str(t!("pddb.menu.listbasis", locales::LANG)), + name: String::from(t!("pddb.menu.listbasis", locales::LANG)), action_conn: Some(conn), action_opcode: Opcode::MenuListBasis.to_u32().unwrap(), action_payload: MenuPayload::Scalar([0, 0, 0, 0]), close_on_select: true, }); menu_items.push(MenuItem { - name: String::from_str(t!("pddb.menu.change_unlock_pin", locales::LANG)), + name: String::from(t!("pddb.menu.change_unlock_pin", locales::LANG)), action_conn: Some(conn), action_opcode: Opcode::MenuChangePin.to_u32().unwrap(), action_payload: MenuPayload::Scalar([0, 0, 0, 0]), close_on_select: true, }); menu_items.push(MenuItem { - name: String::from_str(t!("mainmenu.closemenu", locales::LANG)), + name: String::from(t!("mainmenu.closemenu", locales::LANG)), action_conn: None, action_opcode: 0, action_payload: MenuPayload::Scalar([0, 0, 0, 0]), diff --git a/services/pddb/src/ux.rs b/services/pddb/src/ux.rs index 786feca89..4572358e3 100644 --- a/services/pddb/src/ux.rs +++ b/services/pddb/src/ux.rs @@ -105,7 +105,7 @@ pub(crate) fn password_ux_manager( Some(t!("pddb.password", locales::LANG)), false, Some( - format!("{}'{}'", t!("pddb.password_for", locales::LANG), db_name.as_str().unwrap()) + format!("{}'{}'", t!("pddb.password_for", locales::LANG), db_name.as_str()) .as_str(), ), false, @@ -114,7 +114,7 @@ pub(crate) fn password_ux_manager( log::info!( "{}PDDB.REQPW,{},{}", xous::BOOKEND_START, - db_name.as_str().unwrap(), + db_name.as_str(), xous::BOOKEND_END ); pddb_modal.activate(); @@ -129,7 +129,7 @@ pub(crate) fn password_ux_manager( Buffer::from_memory_message_mut(response.body.memory_message_mut().unwrap()) }; let mut request = buffer.to_original::().unwrap(); - request.plaintext_pw = Some(xous_ipc::String::from_str(pw.first().as_str())); + request.plaintext_pw = Some(String::from(pw.first().as_str())); // return the password to the caller buffer.replace(request).unwrap(); // response goes out of scope here and calls Drop which returns the message diff --git a/services/root-keys/Cargo.toml b/services/root-keys/Cargo.toml index 35e4b5f5e..dcdd32de3 100644 --- a/services/root-keys/Cargo.toml +++ b/services/root-keys/Cargo.toml @@ -23,8 +23,9 @@ utralib = { version = "0.1.24", optional = true, default-features = false } xous-ipc = "0.9.63" num-derive = { version = "0.4.1", default-features = false } num-traits = { version = "0.2.14", default-features = false } -rkyv = { version = "0.4.3", default-features = false, features = [ - "const_generics", +rkyv = { version = "0.8.8", default-features = false, features = [ + "std", + "alloc", ] } zeroize = { version = "1.7.0", features = ["zeroize_derive"] } rand_core = "0.6.4" diff --git a/services/root-keys/src/implementation.rs b/services/root-keys/src/implementation.rs index e10b6c3e6..e3b8d38c3 100644 --- a/services/root-keys/src/implementation.rs +++ b/services/root-keys/src/implementation.rs @@ -2632,7 +2632,7 @@ impl<'a> RootKeys { #[cfg(feature = "hazardous-debug")] fn debug_print_key(&self, offset: usize, num_bits: usize, name: &str) { use core::fmt::Write; - let mut debugstr = xous_ipc::String::<4096>::new(); + let mut debugstr = String::new(); write!(debugstr, "{}", name).unwrap(); for word in self.sensitive_data.borrow_mut().as_slice::() [offset..offset as usize + num_bits / (size_of::() * 8)] diff --git a/services/root-keys/src/main.rs b/services/root-keys/src/main.rs index 933b48378..ce1c0e0cb 100644 --- a/services/root-keys/src/main.rs +++ b/services/root-keys/src/main.rs @@ -21,7 +21,7 @@ use tts_frontend::*; use xous::{msg_blocking_scalar_unpack, msg_scalar_unpack, send_message}; use xous_ipc::Buffer; #[cfg(feature = "policy-menu")] -use xous_ipc::String; +use String; #[cfg(any(feature = "precursor", feature = "renode"))] mod implementation; @@ -612,7 +612,7 @@ fn main() -> ! { { let mut menu_items = Vec::::new(); menu_items.push(MenuItem { - name: String::from_str(t!("rootkeys.policy_keep", locales::LANG)), + name: String::from(t!("rootkeys.policy_keep", locales::LANG)), action_conn: Some(main_cid), action_opcode: Opcode::UxPolicyReturn.to_u32().unwrap(), action_payload: MenuPayload::Scalar([ @@ -624,7 +624,7 @@ fn main() -> ! { close_on_select: true, }); menu_items.push(MenuItem { - name: String::from_str(t!("rootkeys.policy_suspend", locales::LANG)), + name: String::from(t!("rootkeys.policy_suspend", locales::LANG)), action_conn: Some(main_cid), action_opcode: Opcode::UxPolicyReturn.to_u32().unwrap(), action_payload: MenuPayload::Scalar([ @@ -636,7 +636,7 @@ fn main() -> ! { close_on_select: true, }); menu_items.push(MenuItem { - name: String::from_str(t!("rootkeys.policy_clear", locales::LANG)), + name: String::from(t!("rootkeys.policy_clear", locales::LANG)), action_conn: Some(main_cid), action_opcode: Opcode::UxPolicyReturn.to_u32().unwrap(), action_payload: MenuPayload::Scalar([