mirror of
https://github.com/trussed-dev/apdu-dispatch.git
synced 2026-06-20 04:16:15 -07:00
Further cleanup; give up on heapless PR, external interchange/trussed
This commit is contained in:
committed by
Nicolas Stalder
parent
4d2d5b25ae
commit
5a502a77b6
+4
-6
@@ -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" }
|
||||
|
||||
+3
-3
@@ -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
|
||||
)
|
||||
}
|
||||
|
||||
@@ -9,3 +9,4 @@ pub mod dispatch;
|
||||
pub mod types;
|
||||
pub use iso7816;
|
||||
pub use heapless;
|
||||
pub use heapless_bytes;
|
||||
|
||||
+4
-4
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user