diff --git a/Cargo.toml b/Cargo.toml index 31d66aa..fcd67da 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,12 +7,13 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -heapless = { version = "0.5.5" } +delog = "0.1.0-alpha.3" +heapless = "0.5.6" +heapless-bytes = "0.1.1" # Components iso7816 = { path = "../iso7816" } -delog = "0.1.0-alpha.3" -interchange = {path = "../interchange"} +interchange = "0.1.0" # Testing serial_test = { version = "*", optional = true } @@ -27,6 +28,3 @@ log-info = [] log-debug = [] log-warn = [] log-error = [] - -[patch.crates-io] -heapless = { git = "https://github.com/nicolas-solokeys/heapless", branch = "bytebuf" } diff --git a/src/dispatch.rs b/src/dispatch.rs index d33199b..dd9774e 100644 --- a/src/dispatch.rs +++ b/src/dispatch.rs @@ -87,7 +87,7 @@ impl ApduDispatch { fn apdu_type(apdu: &Command) -> RequestType { if apdu.instruction() == Instruction::Select && (apdu.p1 & 0x04) != 0 { - RequestType::Select(Aid::from_slice(apdu.data()).unwrap()) + RequestType::Select(Aid::try_from_slice(apdu.data()).unwrap()) } else if apdu.instruction() == Instruction::GetResponse { RequestType::GetResponse } else { @@ -289,7 +289,7 @@ impl ApduDispatch let to_send = &res[..boundary]; let remaining = &res[boundary..]; - let mut message = response::Data::from_slice(to_send).unwrap(); + let mut message = response::Data::try_from_slice(to_send).unwrap(); let return_code = if remaining.len() > 255 { // XX = 00 indicates more than 255 bytes of data 0x6100u16 @@ -308,7 +308,7 @@ impl ApduDispatch } else { info!("Still {} bytes in response buffer", remaining.len()); ( - RawApduBuffer::Response(response::Data::from_slice(remaining).unwrap()), + RawApduBuffer::Response(response::Data::try_from_slice(remaining).unwrap()), message ) } diff --git a/src/lib.rs b/src/lib.rs index fcbed39..80645eb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,3 +9,4 @@ pub mod dispatch; pub mod types; pub use iso7816; pub use heapless; +pub use heapless_bytes; diff --git a/tests/dispatch.rs b/tests/dispatch.rs index e616859..755a1ab 100644 --- a/tests/dispatch.rs +++ b/tests/dispatch.rs @@ -15,7 +15,7 @@ use iso7816::{ }; use interchange::Interchange; -use heapless::ByteBuf; +use heapless_bytes::Bytes; #[macro_use] extern crate serial_test; @@ -60,7 +60,7 @@ impl Applet for TestApp1 { println!("TestApp1::call"); match apdu.instruction().into() { 0x10 => { - let mut buf = ByteBuf::new(); + let mut buf = Bytes::new(); // Just echo 5x 0's for the request apdu header buf.push(0).unwrap(); buf.push(0).unwrap(); @@ -72,7 +72,7 @@ impl Applet for TestApp1 { } // For measuring the stack burden of dispatch 0x15 => { - let mut buf = ByteBuf::new(); + let mut buf = Bytes::new(); let addr = (&buf as *const iso7816::response::Data ) as u32; buf.extend_from_slice(&addr.to_be_bytes()).unwrap(); Ok(AppletResponse::Respond(buf)) @@ -113,7 +113,7 @@ impl Applet for TestApp2 { println!("TestApp2::call"); match apdu.instruction().into() { 0x20 => { - let mut buf = ByteBuf::new(); + let mut buf = Bytes::new(); buf.push(0).unwrap(); buf.push(0).unwrap(); buf.push(0).unwrap();