Skip to content

Commit

Permalink
Signing: hash shall be always confirmed by user before signing
Browse files Browse the repository at this point in the history
  • Loading branch information
yogh333 committed May 17, 2024
1 parent f612787 commit 56d54cc
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,6 @@ fn handle_apdu(comm: &mut io::Comm, ins: Ins, ctx: &mut Ctx) -> Result<(), Reply
}
Ins::SignHash => {
let p1 = apdu_header.p1;
let p2 = apdu_header.p2;

let mut data = comm.get_data()?;

match p1 {
Expand All @@ -187,17 +185,13 @@ fn handle_apdu(comm: &mut io::Comm, ins: Ins, ctx: &mut Ctx) -> Result<(), Reply
}
_ => {
ctx.hash_info.m_hash = data.into();
if p2 > 0 {
match display::sign_ui(data) {
true => {
sign_hash(ctx).unwrap();
}
false => {
return Err(io::StatusWords::UserCancelled.into());
}
match display::sign_ui(data) {
true => {
sign_hash(ctx).unwrap();
}
false => {
return Err(io::StatusWords::UserCancelled.into());
}
} else {
sign_hash(ctx).unwrap();
}
comm.append([0x41].as_slice());
comm.append(ctx.hash_info.r.as_ref());
Expand Down

0 comments on commit 56d54cc

Please sign in to comment.