Skip to content

Commit

Permalink
fix: modify apdu Lc max length
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoguang1010 committed Oct 8, 2023
1 parent 207a2fb commit 4a30c4b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions imkey-core/ikc-common/src/apdu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ impl BtcApdu {

pub fn btc_sign(index: u8, hash_type: u8, path: &str) -> String {
let path_bytes = path.as_bytes();
if path_bytes.len() as u32 > LC_MAX {
panic!("data to long");
}
let mut apdu =
ApduHeader::new(0x80, 0x42, index, hash_type, path_bytes.len() as u8).to_array();
apdu.extend(path_bytes.iter());
Expand Down Expand Up @@ -364,6 +367,9 @@ impl BtcForkApdu {

pub fn btc_fork_sign(ins: u8, index: u8, hash_type: u8, path: &str) -> String {
let path_bytes = path.as_bytes();
if path_bytes.len() as u32 > LC_MAX {
panic!("data to long");
}
let mut apdu =
ApduHeader::new(0x80, ins, index, hash_type, path_bytes.len() as u8).to_array();
apdu.extend(path_bytes.iter());
Expand Down
2 changes: 1 addition & 1 deletion imkey-core/ikc-common/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub const TSM_ACTION_COS_UPGRADE: &str = "/seCosUpdate";
pub const TSM_ACTION_COS_CHECK_UPDATE: &str = "/cosCheckUpdate";

//apud related constant
pub const LC_MAX: u32 = 245;
pub const LC_MAX: u32 = 239;

pub const ETH_AID: &str = "695F657468";
pub const EOS_AID: &str = "695F656F73";
Expand Down

0 comments on commit 4a30c4b

Please sign in to comment.