Skip to content

Commit

Permalink
Add pending review screen + check APDU CLA == 0x5A (as set by starkne…
Browse files Browse the repository at this point in the history
…t-js client)
  • Loading branch information
yogh333 committed Mar 5, 2024
1 parent 45832e2 commit 94736b1
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 20 deletions.
7 changes: 6 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,18 @@ use crypto::{get_pubkey, set_derivation_path, sign_hash};
use context::{Ctx, RequestType};

use ledger_device_sdk::io;
use ledger_device_sdk::ui::gadgets::display_pending_review;

ledger_device_sdk::set_panic!(ledger_device_sdk::exiting_panic);

#[no_mangle]
extern "C" fn sample_main() {
let mut comm = io::Comm::new();

// Developer mode / pending review popup
// must be cleared with user interaction
display_pending_review(&mut comm);

let mut ctx: Ctx = Ctx::new();

loop {
Expand Down Expand Up @@ -60,7 +65,7 @@ fn handle_apdu(comm: &mut io::Comm, ins: Ins, ctx: &mut Ctx) -> Result<(), Reply
}

let apdu_header = comm.get_apdu_metadata();
if apdu_header.cla != 0x80 {
if apdu_header.cla != 0x5A {
return Err(io::StatusWords::BadCla.into());
}

Expand Down
2 changes: 1 addition & 1 deletion test/publickey_confirm.apdu
Original file line number Diff line number Diff line change
@@ -1 +1 @@
=> 800101001880000a55c741e9c9c47a6028800000008000000000000000
=> 5A0101001880000a55c741e9c9c47a6028800000008000000000000000
2 changes: 1 addition & 1 deletion test/publickey_noconfirm.apdu
Original file line number Diff line number Diff line change
@@ -1 +1 @@
=> 800100001880000a55c741e9c9c47a6028800000008000000000000000
=> 5A0100001880000a55c741e9c9c47a6028800000008000000000000000
4 changes: 2 additions & 2 deletions test/sign_confirm.apdu
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
=> 800200011880000a55c741e9c9c47a6028800000008000000000000000
=> 800201012055b8f28706a5008d3103bcb2bfa6356e56b95c34fed265c955846670a6bb4ef0
=> 5A0200011880000a55c741e9c9c47a6028800000008000000000000000
=> 5A0201012055b8f28706a5008d3103bcb2bfa6356e56b95c34fed265c955846670a6bb4ef0
14 changes: 7 additions & 7 deletions test/sign_multicall_tx.apdu
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
=> 800300001880000a55c741e9c9c47a6028800000008000000000000000
=> 80030100a007e00d496e324876bbc8531f2d9a82bf154d1a04a50218ee74cdd372f75a551a00000000000000000000000000000000000000000000000000038d7ea4c680000000000000000000000000000000000000000000000000534e5f474f45524c4900000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001
=> 800302004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004
=> 80030300650507446de5cfcb833d4e786f3a0510deb2429ae753741a836a7efa80c9c747cb046d696e7400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002
=> 80030301680507446de5cfcb833d4e786f3a0510deb2429ae753741a836a7efa80c9c747cb07617070726f766500000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002
=> 800304004007e00d496e324876bbc8531f2d9a82bf154d1a04a50218ee74cdd372f75a551a00000000000000000000000000000000000000000000000000000000000003e8
=> 800304014007e00d496e324876bbc8531f2d9a82bf154d1a04a50218ee74cdd372f75a551a0000000000000000000000000000000000000000000000000000000000002710
=> 5A0300001880000a55c741e9c9c47a6028800000008000000000000000
=> 5A030100a007e00d496e324876bbc8531f2d9a82bf154d1a04a50218ee74cdd372f75a551a00000000000000000000000000000000000000000000000000038d7ea4c680000000000000000000000000000000000000000000000000534e5f474f45524c4900000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001
=> 5A0302004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004
=> 5A030300650507446de5cfcb833d4e786f3a0510deb2429ae753741a836a7efa80c9c747cb046d696e7400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002
=> 5A030301680507446de5cfcb833d4e786f3a0510deb2429ae753741a836a7efa80c9c747cb07617070726f766500000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002
=> 5A0304004007e00d496e324876bbc8531f2d9a82bf154d1a04a50218ee74cdd372f75a551a00000000000000000000000000000000000000000000000000000000000003e8
=> 5A0304014007e00d496e324876bbc8531f2d9a82bf154d1a04a50218ee74cdd372f75a551a0000000000000000000000000000000000000000000000000000000000002710
4 changes: 2 additions & 2 deletions test/sign_noconfirm.apdu
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
=> 800200011880000a55c741e9c9c47a6028800000008000000000000000
=> 800201002055b8f28706a5008d3103bcb2bfa6356e56b95c34fed265c955846670a6bb4ef0
=> 5A0200011880000a55c741e9c9c47a6028800000008000000000000000
=> 5A0201002055b8f28706a5008d3103bcb2bfa6356e56b95c34fed265c955846670a6bb4ef0
10 changes: 5 additions & 5 deletions test/sign_singlecall_tx.apdu
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
=> 800300001880000a55c741e9c9c47a6028800000008000000000000000
=> 80030100A007e00d496e324876bbc8531f2d9a82bf154d1a04a50218ee74cdd372f75a551a00000000000000000000000000000000000000000000000000038d7ea4c680000000000000000000000000000000000000000000000000534e5f474f45524c4900000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001
=> 800302004000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002
=> 80030300650507446de5cfcb833d4e786f3a0510deb2429ae753741a836a7efa80c9c747cb046d696e7400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002
=> 800304004007e00d496e324876bbc8531f2d9a82bf154d1a04a50218ee74cdd372f75a551a00000000000000000000000000000000000000000000000000000000000003e8
=> 5A0300001880000a55c741e9c9c47a6028800000008000000000000000
=> 5A030100A007e00d496e324876bbc8531f2d9a82bf154d1a04a50218ee74cdd372f75a551a00000000000000000000000000000000000000000000000000038d7ea4c680000000000000000000000000000000000000000000000000534e5f474f45524c4900000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001
=> 5A0302004000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002
=> 5A030300650507446de5cfcb833d4e786f3a0510deb2429ae753741a836a7efa80c9c747cb046d696e7400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002
=> 5A0304004007e00d496e324876bbc8531f2d9a82bf154d1a04a50218ee74cdd372f75a551a00000000000000000000000000000000000000000000000000000000000003e8
2 changes: 1 addition & 1 deletion test/version.apdu
Original file line number Diff line number Diff line change
@@ -1 +1 @@
=> 8000000000
=> 5A00000000

0 comments on commit 94736b1

Please sign in to comment.