diff --git a/imkey-core/ikc-common/src/apdu.rs b/imkey-core/ikc-common/src/apdu.rs index 259f433d..6c916d97 100644 --- a/imkey-core/ikc-common/src/apdu.rs +++ b/imkey-core/ikc-common/src/apdu.rs @@ -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()); @@ -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()); diff --git a/imkey-core/ikc-common/src/constants.rs b/imkey-core/ikc-common/src/constants.rs index 436f9c8c..a5e08030 100644 --- a/imkey-core/ikc-common/src/constants.rs +++ b/imkey-core/ikc-common/src/constants.rs @@ -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";