What changed, and why it matters
This commit is purely a code cleanup: it runs the Rust formatter (fmt) and applies Clippy lint suggestions. The changes are cosmetic—reformatting lines, reordering imports, removing unused imports, and adding 'unsafe' markers to functions that already contained unsafe operations. There is no functional change to how the firmware handles keys, transactions, or user data, and no security vulnerability is introduced or fixed.
No security action required. Treat as normal maintenance; standard CI/build verification is sufficient.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff shows automated formatting and Clippy-driven refactorings across 24 Rust files. Notable patterns: (1) import reordering/removal (e.g., dropping unused ‘alloc::slice’ in psbt.rs, reordering imports in address.rs and iota/mod.rs); (2) string formatting collapsed to single lines; (3) function signatures reformatted across multiple lines; (4) several ‘extern C’ functions in rust_c/src/bitcoin/psbt.rs and elsewhere marked ‘unsafe’ at the function level instead of wrapping unsafe blocks internally; (5) replacement of ‘core::slice::from_raw_parts’ with the ‘extract_array!’ macro in many places, which is a stylistic/safety-helper refactor but does not change the underlying pointer+deref behavior; (6) feature-gate changes from ‘bitcoin’ to ‘multi-coins’ for CryptoPSBTExtend in ur.rs and ur_ext.rs. No logic, bounds checks, cryptographic operations, or control flow are altered.
Changed components
rust/apps/aptos/src/aptos_type/parser.rsrust/apps/arweave/src/ao_transaction.rsrust/apps/bitcoin/src/multi_sig/address.rsrust/apps/cosmos/src/proto_wrapper/msg/common.rsrust/apps/cosmos/src/proto_wrapper/msg/msg.rsrust/rust_c/src/arweave/mod.rsrust/rust_c/src/avalanche/mod.rsrust/rust_c/src/bitcoin/legacy.rsrust/rust_c/src/bitcoin/psbt.rsrust/rust_c/src/common/ur.rsrust/rust_c/src/common/ur_ext.rsrust/rust_c/src/common/web_auth.rsrust/rust_c/src/cosmos/structs.rsrust/rust_c/src/iota/mod.rsrust/rust_c/src/iota/structs.rsrust/rust_c/src/monero/mod.rsrust/rust_c/src/near/mod.rsrust/rust_c/src/near/structs.rsrust/rust_c/src/stellar/mod.rsrust/rust_c/src/sui/mod.rsrust/rust_c/src/ton/mod.rsrust/rust_c/src/wallet/cypherpunk_wallet/cake.rsrust/rust_c/src/xrp/mod.rsrust/rust_c/src/zcash/mod.rsInspect captured patch +188 / −188
diff --git a/rust/apps/aptos/src/aptos_type/parser.rs b/rust/apps/aptos/src/aptos_type/parser.rs
index c27da5c..048d3ba 100644
--- a/rust/apps/aptos/src/aptos_type/parser.rs
+++ b/rust/apps/aptos/src/aptos_type/parser.rs
@@ -417,8 +417,6 @@ pub fn parse_struct_tag(s: &str) -> crate::errors::Result<StructTag> {
if let TypeTag::Struct(struct_tag) = type_tag {
Ok(*struct_tag)
} else {
- Err(AptosError::ParseTxError(format!(
- "invalid struct tag: {s}"
- )))
+ Err(AptosError::ParseTxError(format!("invalid struct tag: {s}")))
}
}
diff --git a/rust/apps/arweave/src/ao_transaction.rs b/rust/apps/arweave/src/ao_transaction.rs
index 3472811..2eeced6 100644
--- a/rust/apps/arweave/src/ao_transaction.rs
+++ b/rust/apps/arweave/src/ao_transaction.rs
@@ -42,7 +42,7 @@ impl TryFrom<DataItem> for AOTransferTransaction {
let to = recipient.get_value();
let quantity = quantity.get_value();
let mut tags = vec![];
-
+
while let Some(tag) = rest_tags.next() {
tags.push(tag.clone());
}
diff --git a/rust/apps/bitcoin/src/multi_sig/address.rs b/rust/apps/bitcoin/src/multi_sig/address.rs
index e6ddedf..76cadea 100644
--- a/rust/apps/bitcoin/src/multi_sig/address.rs
+++ b/rust/apps/bitcoin/src/multi_sig/address.rs
@@ -118,8 +118,8 @@ mod tests {
use crate::multi_sig::wallet::parse_wallet_config;
use crate::multi_sig::MultiSigFormat;
use crate::network::Network;
- use bitcoin::PublicKey;
use alloc::vec::Vec;
+ use bitcoin::PublicKey;
#[test]
fn test_create_multi_sig_address_for_wallet() {
diff --git a/rust/apps/cosmos/src/proto_wrapper/msg/common.rs b/rust/apps/cosmos/src/proto_wrapper/msg/common.rs
index f067b72..038cc1a 100644
--- a/rust/apps/cosmos/src/proto_wrapper/msg/common.rs
+++ b/rust/apps/cosmos/src/proto_wrapper/msg/common.rs
@@ -49,9 +49,7 @@ pub fn map_messages(messages: &[Any]) -> Result<Vec<Box<dyn Msg>>, CosmosError>
))
})?;
let msg_undelegate = MsgUnDelegateWrapper::try_from(&unpacked).map_err(|e| {
- CosmosError::ParseTxError(format!(
- "proto MsgUndelegate deserialize failed {e}"
- ))
+ CosmosError::ParseTxError(format!("proto MsgUndelegate deserialize failed {e}"))
})?;
message_vec.push(Box::new(msg_undelegate));
}
@@ -115,9 +113,7 @@ pub fn map_messages(messages: &[Any]) -> Result<Vec<Box<dyn Msg>>, CosmosError>
))
})?;
let msg_multi_send = MsgMultiSendWrapper::try_from(&unpacked).map_err(|e| {
- CosmosError::ParseTxError(format!(
- "proto MsgMultiSend deserialize failed {e}"
- ))
+ CosmosError::ParseTxError(format!("proto MsgMultiSend deserialize failed {e}"))
})?;
message_vec.push(Box::new(msg_multi_send));
}
@@ -147,9 +143,7 @@ pub fn map_messages(messages: &[Any]) -> Result<Vec<Box<dyn Msg>>, CosmosError>
},
)?;
let msg_exec = MsgExecWrapper::try_from(&unpacked).map_err(|e| {
- CosmosError::ParseTxError(format!(
- "proto MsgMultiSend deserialize failed {e}"
- ))
+ CosmosError::ParseTxError(format!("proto MsgMultiSend deserialize failed {e}"))
})?;
message_vec.push(Box::new(msg_exec));
}
diff --git a/rust/apps/cosmos/src/proto_wrapper/msg/msg.rs b/rust/apps/cosmos/src/proto_wrapper/msg/msg.rs
index c4db0a1..a938e0a 100644
--- a/rust/apps/cosmos/src/proto_wrapper/msg/msg.rs
+++ b/rust/apps/cosmos/src/proto_wrapper/msg/msg.rs
@@ -63,9 +63,8 @@ impl TryFrom<&proto::cosmos::bank::v1beta1::MsgSend> for MsgSend {
impl SerializeJson for MsgSend {
fn to_json(&self) -> Result<Value, CosmosError> {
- let value = serde_json::to_value(self).map_err(|err| {
- CosmosError::ParseTxError(format!("MsgSend serialize failed {err}"))
- })?;
+ let value = serde_json::to_value(self)
+ .map_err(|err| CosmosError::ParseTxError(format!("MsgSend serialize failed {err}")))?;
let msg = json!({
"type": Value::String(Self::TYPE_URL.to_string()),
"value": value,
@@ -232,9 +231,8 @@ impl TryFrom<&proto::cosmos::gov::v1beta1::MsgVote> for MsgVote {
impl SerializeJson for MsgVote {
fn to_json(&self) -> Result<Value, CosmosError> {
- let value = serde_json::to_value(self).map_err(|err| {
- CosmosError::ParseTxError(format!("MsgVote serialize failed {err}"))
- })?;
+ let value = serde_json::to_value(self)
+ .map_err(|err| CosmosError::ParseTxError(format!("MsgVote serialize failed {err}")))?;
let msg = json!({
"type": Value::String(Self::TYPE_URL.to_string()),
"value": value,
@@ -354,9 +352,7 @@ impl TryFrom<&proto::cosmos::distribution::v1beta1::MsgWithdrawDelegatorReward>
impl SerializeJson for MsgWithdrawDelegatorReward {
fn to_json(&self) -> Result<Value, CosmosError> {
let value = serde_json::to_value(self).map_err(|err| {
- CosmosError::ParseTxError(format!(
- "MsgWithdrawDelegatorReward serialize failed {err}"
- ))
+ CosmosError::ParseTxError(format!("MsgWithdrawDelegatorReward serialize failed {err}"))
})?;
let msg = json!({
"type": Value::String(Self::TYPE_URL.to_string()),
@@ -479,9 +475,8 @@ impl TryFrom<&proto::cosmos::authz::v1beta1::MsgExec> for MsgExec {
impl SerializeJson for MsgExec {
fn to_json(&self) -> Result<Value, CosmosError> {
- let value = serde_json::to_value(self).map_err(|err| {
- CosmosError::ParseTxError(format!("MsgExec serialize failed {err}"))
- })?;
+ let value = serde_json::to_value(self)
+ .map_err(|err| CosmosError::ParseTxError(format!("MsgExec serialize failed {err}")))?;
let msg = json!({
"type": Value::String(Self::TYPE_URL.to_string()),
"value": value,
diff --git a/rust/rust_c/src/arweave/mod.rs b/rust/rust_c/src/arweave/mod.rs
index fee926b..686ed75 100644
--- a/rust/rust_c/src/arweave/mod.rs
+++ b/rust/rust_c/src/arweave/mod.rs
@@ -237,7 +237,11 @@ unsafe fn parse_sign_data(ptr: PtrUR) -> Result<Vec<u8>, ArweaveError> {
}
}
-unsafe fn build_sign_result(ptr: PtrUR, p: &[u8], q: &[u8]) -> Result<ArweaveSignature, ArweaveError> {
+unsafe fn build_sign_result(
+ ptr: PtrUR,
+ p: &[u8],
+ q: &[u8],
+) -> Result<ArweaveSignature, ArweaveError> {
let sign_request = extract_ptr_with_type!(ptr, ArweaveSignRequest);
let salt_len = match sign_request.get_salt_len() {
SaltLen::Zero => 0,
diff --git a/rust/rust_c/src/avalanche/mod.rs b/rust/rust_c/src/avalanche/mod.rs
index e7b1b02..3b4d6ea 100644
--- a/rust/rust_c/src/avalanche/mod.rs
+++ b/rust/rust_c/src/avalanche/mod.rs
@@ -223,7 +223,11 @@ unsafe fn build_sign_result(ptr: PtrUR, seed: &[u8]) -> Result<AvaxSignature, Av
}
#[no_mangle]
-pub unsafe extern "C" fn avax_sign(ptr: PtrUR, seed: PtrBytes, seed_len: u32) -> PtrT<UREncodeResult> {
+pub unsafe extern "C" fn avax_sign(
+ ptr: PtrUR,
+ seed: PtrBytes,
+ seed_len: u32,
+) -> PtrT<UREncodeResult> {
avax_sign_dynamic(ptr, seed, seed_len, FRAGMENT_MAX_LENGTH_DEFAULT)
}
diff --git a/rust/rust_c/src/bitcoin/legacy.rs b/rust/rust_c/src/bitcoin/legacy.rs
index 919ece7..9e56acc 100644
--- a/rust/rust_c/src/bitcoin/legacy.rs
+++ b/rust/rust_c/src/bitcoin/legacy.rs
@@ -5,8 +5,8 @@ use crate::common::keystone::{build_parse_context, build_payload};
use crate::common::structs::{TransactionCheckResult, TransactionParseResult};
use crate::common::types::{PtrBytes, PtrString, PtrT, PtrUR};
use crate::common::ur::{QRCodeType, UREncodeResult};
-use alloc::boxed::Box;
use crate::extract_array;
+use alloc::boxed::Box;
#[no_mangle]
pub unsafe extern "C" fn utxo_parse_keystone(
diff --git a/rust/rust_c/src/bitcoin/psbt.rs b/rust/rust_c/src/bitcoin/psbt.rs
index 3848ad5..e1f0b8c 100644
--- a/rust/rust_c/src/bitcoin/psbt.rs
+++ b/rust/rust_c/src/bitcoin/psbt.rs
@@ -1,6 +1,5 @@
use alloc::boxed::Box;
use alloc::collections::BTreeMap;
-use alloc::slice;
use alloc::string::{String, ToString};
use alloc::vec::Vec;
use app_bitcoin::multi_sig::wallet::parse_wallet_config;
@@ -16,6 +15,7 @@ use crate::common::structs::{
use crate::common::types::{Ptr, PtrBytes, PtrString, PtrT, PtrUR};
use crate::common::ur::{UREncodeResult, FRAGMENT_MAX_LENGTH_DEFAULT, FRAGMENT_UNLIMITED_LENGTH};
use crate::common::utils::{convert_c_char, recover_c_array, recover_c_char};
+use crate::extract_array;
use crate::extract_ptr_with_type;
use app_bitcoin::parsed_tx::ParseContext;
use app_bitcoin::{self, parse_psbt_hex_sign_status, parse_psbt_sign_status};
@@ -29,7 +29,7 @@ use super::structs::DisplayTx;
use ur_registry::crypto_psbt_extend::SupportedPsbtCoin;
#[no_mangle]
-pub extern "C" fn btc_parse_psbt(
+pub unsafe extern "C" fn btc_parse_psbt(
ptr: PtrUR,
master_fingerprint: PtrBytes,
length: u32,
@@ -42,20 +42,18 @@ pub extern "C" fn btc_parse_psbt(
let crypto_psbt = extract_ptr_with_type!(ptr, CryptoPSBT);
let psbt = crypto_psbt.get_psbt();
- unsafe {
- let multisig_wallet_config = if multisig_wallet_config.is_null() {
- None
- } else {
- Some(recover_c_char(multisig_wallet_config))
- };
- let mfp = core::slice::from_raw_parts(master_fingerprint, 4);
- let public_keys = recover_c_array(public_keys);
- parse_psbt(mfp, public_keys, psbt, multisig_wallet_config)
- }
+ let multisig_wallet_config = if multisig_wallet_config.is_null() {
+ None
+ } else {
+ Some(recover_c_char(multisig_wallet_config))
+ };
+ let mfp = extract_array!(master_fingerprint, u8, 4);
+ let public_keys = recover_c_array(public_keys);
+ parse_psbt(mfp, public_keys, psbt, multisig_wallet_config)
}
#[no_mangle]
-pub extern "C" fn utxo_parse_extend_psbt(
+pub unsafe extern "C" fn utxo_parse_extend_psbt(
ptr: PtrUR,
public_keys: PtrT<CSliceFFI<ExtendedPublicKey>>,
master_fingerprint: PtrBytes,
@@ -66,15 +64,14 @@ pub extern "C" fn utxo_parse_extend_psbt(
}
let crypto_psbt = extract_ptr_with_type!(ptr, CryptoPSBTExtend);
let psbt = crypto_psbt.get_psbt();
- unsafe {
- let mfp = core::slice::from_raw_parts(master_fingerprint, 4);
- let public_keys = recover_c_array(public_keys);
- parse_psbt(mfp, public_keys, psbt, None)
- }
+
+ let mfp = extract_array!(master_fingerprint, u8, 4);
+ let public_keys = recover_c_array(public_keys);
+ parse_psbt(mfp, public_keys, psbt, None)
}
#[no_mangle]
-fn btc_sign_psbt_dynamic(
+unsafe fn btc_sign_psbt_dynamic(
psbt: Vec<u8>,
seed: PtrBytes,
seed_len: u32,
@@ -85,7 +82,7 @@ fn btc_sign_psbt_dynamic(
if master_fingerprint_len != 4 {
return UREncodeResult::from(RustCError::InvalidMasterFingerprint).c_ptr();
}
- let master_fingerprint = unsafe { core::slice::from_raw_parts(master_fingerprint, 4) };
+ let master_fingerprint = extract_array!(master_fingerprint, u8, 4);
let master_fingerprint =
match bitcoin::bip32::Fingerprint::from_str(hex::encode(master_fingerprint).as_str())
.map_err(|_e| RustCError::InvalidMasterFingerprint)
@@ -96,7 +93,7 @@ fn btc_sign_psbt_dynamic(
}
};
- let seed = unsafe { slice::from_raw_parts(seed, seed_len as usize) };
+ let seed = extract_array!(seed, u8, seed_len as usize);
let result = app_bitcoin::sign_psbt(psbt, seed, master_fingerprint);
match result.map(|v| CryptoPSBT::new(v).try_into()) {
@@ -114,7 +111,7 @@ fn btc_sign_psbt_dynamic(
}
#[no_mangle]
-pub extern "C" fn utxo_sign_psbt_extend(
+pub unsafe extern "C" fn utxo_sign_psbt_extend(
ptr: PtrUR,
seed: PtrBytes,
seed_len: u32,
@@ -142,7 +139,7 @@ pub extern "C" fn utxo_sign_psbt_extend(
}
#[no_mangle]
-pub extern "C" fn btc_sign_psbt(
+pub unsafe extern "C" fn btc_sign_psbt(
ptr: PtrUR,
seed: PtrBytes,
seed_len: u32,
@@ -162,7 +159,7 @@ pub extern "C" fn btc_sign_psbt(
}
#[no_mangle]
-pub extern "C" fn btc_sign_psbt_unlimited(
+pub unsafe extern "C" fn btc_sign_psbt_unlimited(
ptr: PtrUR,
seed: PtrBytes,
seed_len: u32,
@@ -182,7 +179,7 @@ pub extern "C" fn btc_sign_psbt_unlimited(
}
#[no_mangle]
-pub extern "C" fn btc_sign_multisig_psbt(
+pub unsafe extern "C" fn btc_sign_multisig_psbt(
ptr: PtrUR,
seed: PtrBytes,
seed_len: u32,
@@ -199,7 +196,7 @@ pub extern "C" fn btc_sign_multisig_psbt(
}
.c_ptr();
}
- let master_fingerprint = unsafe { core::slice::from_raw_parts(master_fingerprint, 4) };
+ let master_fingerprint = extract_array!(master_fingerprint, u8, 4);
let master_fingerprint =
match bitcoin::bip32::Fingerprint::from_str(hex::encode(master_fingerprint).as_str())
.map_err(|_e| RustCError::InvalidMasterFingerprint)
@@ -220,7 +217,7 @@ pub extern "C" fn btc_sign_multisig_psbt(
let crypto_psbt = extract_ptr_with_type!(ptr, CryptoPSBT);
let psbt = crypto_psbt.get_psbt();
- let seed = unsafe { slice::from_raw_parts(seed, seed_len as usize) };
+ let seed = extract_array!(seed, u8, seed_len as usize);
let result = app_bitcoin::sign_psbt_no_serialize(psbt, seed, master_fingerprint);
match result.map(|v| {
@@ -268,7 +265,7 @@ pub extern "C" fn btc_sign_multisig_psbt(
}
#[no_mangle]
-pub extern "C" fn btc_export_multisig_psbt(ptr: PtrUR) -> *mut MultisigSignResult {
+pub unsafe extern "C" fn btc_export_multisig_psbt(ptr: PtrUR) -> *mut MultisigSignResult {
let crypto_psbt = extract_ptr_with_type!(ptr, CryptoPSBT);
let psbt = crypto_psbt.get_psbt();
let sign_state = parse_psbt_hex_sign_status(&psbt);
@@ -301,44 +298,42 @@ pub extern "C" fn btc_export_multisig_psbt(ptr: PtrUR) -> *mut MultisigSignResul
}
#[no_mangle]
-pub extern "C" fn btc_export_multisig_psbt_bytes(
+pub unsafe extern "C" fn btc_export_multisig_psbt_bytes(
psbt_bytes: PtrBytes,
psbt_bytes_length: u32,
) -> *mut MultisigSignResult {
- unsafe {
- let psbt = core::slice::from_raw_parts(psbt_bytes, psbt_bytes_length as usize);
- let psbt = psbt.to_vec();
- let sign_state = parse_psbt_hex_sign_status(&psbt);
- match sign_state {
- Ok(state) => {
- let (ptr, size, _cap) = psbt.clone().into_raw_parts();
- MultisigSignResult {
- ur_result: UREncodeResult::encode(
- psbt,
- CryptoPSBT::get_registry_type().get_type(),
- FRAGMENT_MAX_LENGTH_DEFAULT,
- )
- .c_ptr(),
- sign_status: convert_c_char(state.sign_status.unwrap_or("".to_string())),
- is_completed: state.is_completed,
- psbt_hex: ptr,
- psbt_len: size as u32,
- }
- .c_ptr()
- }
- Err(e) => MultisigSignResult {
- ur_result: UREncodeResult::from(e).c_ptr(),
- sign_status: null_mut(),
- is_completed: false,
- psbt_hex: null_mut(),
- psbt_len: 0,
+ let psbt = extract_array!(psbt_bytes, u8, psbt_bytes_length as usize);
+ let psbt = psbt.to_vec();
+ let sign_state = parse_psbt_hex_sign_status(&psbt);
+ match sign_state {
+ Ok(state) => {
+ let (ptr, size, _cap) = psbt.clone().into_raw_parts();
+ MultisigSignResult {
+ ur_result: UREncodeResult::encode(
+ psbt,
+ CryptoPSBT::get_registry_type().get_type(),
+ FRAGMENT_MAX_LENGTH_DEFAULT,
+ )
+ .c_ptr(),
+ sign_status: convert_c_char(state.sign_status.unwrap_or("".to_string())),
+ is_completed: state.is_completed,
+ psbt_hex: ptr,
+ psbt_len: size as u32,
}
- .c_ptr(),
+ .c_ptr()
}
+ Err(e) => MultisigSignResult {
+ ur_result: UREncodeResult::from(e).c_ptr(),
+ sign_status: null_mut(),
+ is_completed: false,
+ psbt_hex: null_mut(),
+ psbt_len: 0,
+ }
+ .c_ptr(),
}
}
-fn btc_check_psbt_common(
+unsafe fn btc_check_psbt_common(
psbt: Vec<u8>,
master_fingerprint: PtrBytes,
length: u32,
@@ -346,24 +341,22 @@ fn btc_check_psbt_common(
verify_code: PtrString,
multisig_wallet_config: PtrString,
) -> PtrT<TransactionCheckResult> {
- unsafe {
- let verify_code = if verify_code.is_null() {
- None
- } else {
- Some(recover_c_char(verify_code))
- };
- let multisig_wallet_config = if multisig_wallet_config.is_null() {
- None
- } else {
- Some(recover_c_char(multisig_wallet_config))
- };
- let mfp = core::slice::from_raw_parts(master_fingerprint, 4);
- let public_keys = recover_c_array(public_keys);
- check_psbt(mfp, public_keys, psbt, verify_code, multisig_wallet_config)
- }
+ let verify_code = if verify_code.is_null() {
+ None
+ } else {
+ Some(recover_c_char(verify_code))
+ };
+ let multisig_wallet_config = if multisig_wallet_config.is_null() {
+ None
+ } else {
+ Some(recover_c_char(multisig_wallet_config))
+ };
+ let mfp = extract_array!(master_fingerprint, u8, 4);
+ let public_keys = recover_c_array(public_keys);
+ check_psbt(mfp, public_keys, psbt, verify_code, multisig_wallet_config)
}
#[no_mangle]
-pub extern "C" fn btc_check_psbt(
+pub unsafe extern "C" fn btc_check_psbt(
ptr: PtrUR,
master_fingerprint: PtrBytes,
length: u32,
@@ -388,7 +381,7 @@ pub extern "C" fn btc_check_psbt(
}
#[no_mangle]
-pub extern "C" fn utxo_check_psbt_extend(
+pub unsafe extern "C" fn utxo_check_psbt_extend(
ptr: PtrUR,
master_fingerprint: PtrBytes,
length: u32,
@@ -413,7 +406,7 @@ pub extern "C" fn utxo_check_psbt_extend(
}
#[no_mangle]
-pub extern "C" fn btc_check_psbt_bytes(
+pub unsafe extern "C" fn btc_check_psbt_bytes(
ptr: PtrUR,
master_fingerprint: PtrBytes,
length: u32,
@@ -438,7 +431,7 @@ pub extern "C" fn btc_check_psbt_bytes(
}
#[no_mangle]
-pub extern "C" fn btc_parse_psbt_bytes(
+pub unsafe extern "C" fn btc_parse_psbt_bytes(
psbt_bytes: PtrBytes,
psbt_bytes_length: u32,
master_fingerprint: PtrBytes,
@@ -449,25 +442,23 @@ pub extern "C" fn btc_parse_psbt_bytes(
if length != 4 {
return TransactionParseResult::from(RustCError::InvalidMasterFingerprint).c_ptr();
}
- unsafe {
- let psbt = core::slice::from_raw_parts(psbt_bytes, psbt_bytes_length as usize);
- let psbt = match get_psbt_bytes(psbt) {
- Ok(psbt) => psbt,
- Err(e) => return TransactionParseResult::from(e).c_ptr(),
- };
- let multisig_wallet_config = if multisig_wallet_config.is_null() {
- None
- } else {
- Some(recover_c_char(multisig_wallet_config))
- };
- let mfp = core::slice::from_raw_parts(master_fingerprint, 4);
- let public_keys = recover_c_array(public_keys);
- parse_psbt(mfp, public_keys, psbt, multisig_wallet_config)
- }
+ let psbt = extract_array!(psbt_bytes, u8, psbt_bytes_length as usize);
+ let psbt = match get_psbt_bytes(psbt) {
+ Ok(psbt) => psbt,
+ Err(e) => return TransactionParseResult::from(e).c_ptr(),
+ };
+ let multisig_wallet_config = if multisig_wallet_config.is_null() {
+ None
+ } else {
+ Some(recover_c_char(multisig_wallet_config))
+ };
+ let mfp = extract_array!(master_fingerprint, u8, 4);
+ let public_keys = recover_c_array(public_keys);
+ parse_psbt(mfp, public_keys, psbt, multisig_wallet_config)
}
#[no_mangle]
-pub extern "C" fn btc_sign_multisig_psbt_bytes(
+pub unsafe extern "C" fn btc_sign_multisig_psbt_bytes(
psbt_bytes: PtrBytes,
psbt_bytes_length: u32,
seed: PtrBytes,
@@ -485,7 +476,7 @@ pub extern "C" fn btc_sign_multisig_psbt_bytes(
}
.c_ptr();
}
- let master_fingerprint = unsafe { core::slice::from_raw_parts(master_fingerprint, 4) };
+ let master_fingerprint = extract_array!(master_fingerprint, u8, 4);
let master_fingerprint =
match bitcoin::bip32::Fingerprint::from_str(hex::encode(master_fingerprint).as_str())
.map_err(|_e| RustCError::InvalidMasterFingerprint)
@@ -503,8 +494,8 @@ pub extern "C" fn btc_sign_multisig_psbt_bytes(
}
};
- let psbt = unsafe {
- let psbt = core::slice::from_raw_parts(psbt_bytes, psbt_bytes_length as usize);
+ let psbt = {
+ let psbt = extract_array!(psbt_bytes, u8, psbt_bytes_length as usize);
match get_psbt_bytes(psbt) {
Ok(psbt) => psbt,
@@ -521,7 +512,7 @@ pub extern "C" fn btc_sign_multisig_psbt_bytes(
}
};
- let seed = unsafe { slice::from_raw_parts(seed, seed_len as usize) };
+ let seed = extract_array!(seed, u8, seed_len as usize);
let result = app_bitcoin::sign_psbt_no_serialize(psbt, seed, master_fingerprint);
match result.map(|v| {
@@ -568,7 +559,7 @@ pub extern "C" fn btc_sign_multisig_psbt_bytes(
}
}
-fn parse_psbt(
+unsafe fn parse_psbt(
mfp: &[u8],
public_keys: &[ExtendedPublicKey],
psbt: Vec<u8>,
@@ -616,7 +607,7 @@ fn parse_psbt(
}
}
-fn check_psbt(
+unsafe fn check_psbt(
mfp: &[u8],
public_keys: &[ExtendedPublicKey],
psbt: Vec<u8>,
@@ -676,7 +667,7 @@ fn get_psbt_bytes(psbt_bytes: &[u8]) -> Result<Vec<u8>, RustCError> {
}
#[no_mangle]
-pub extern "C" fn utxo_sign_psbt_extend_dynamic(
+pub unsafe extern "C" fn utxo_sign_psbt_extend_dynamic(
psbt: Vec<u8>,
seed: PtrBytes,
seed_len: u32,
@@ -689,7 +680,7 @@ pub extern "C" fn utxo_sign_psbt_extend_dynamic(
return UREncodeResult::from(RustCError::InvalidMasterFingerprint).c_ptr();
}
- let master_fingerprint = unsafe { core::slice::from_raw_parts(master_fingerprint, 4) };
+ let master_fingerprint = extract_array!(master_fingerprint, u8, 4);
let master_fingerprint =
match bitcoin::bip32::Fingerprint::from_str(hex::encode(master_fingerprint).as_str())
.map_err(|_e| RustCError::InvalidMasterFingerprint)
@@ -698,7 +689,7 @@ pub extern "C" fn utxo_sign_psbt_extend_dynamic(
Err(e) => return UREncodeResult::from(e).c_ptr(),
};
- let seed = unsafe { slice::from_raw_parts(seed, seed_len as usize) };
+ let seed = extract_array!(seed, u8, seed_len as usize);
let result = app_bitcoin::sign_psbt(psbt, seed, master_fingerprint);
match result {
diff --git a/rust/rust_c/src/common/ur.rs b/rust/rust_c/src/common/ur.rs
index d582fcc..4108fed 100644
--- a/rust/rust_c/src/common/ur.rs
+++ b/rust/rust_c/src/common/ur.rs
@@ -298,7 +298,7 @@ pub enum ViewType {
pub enum QRCodeType {
#[cfg(feature = "bitcoin")]
CryptoPSBT,
- #[cfg(feature = "bitcoin")]
+ #[cfg(feature = "multi-coins")]
CryptoPSBTExtend,
CryptoMultiAccounts,
#[cfg(feature = "bitcoin")]
@@ -368,7 +368,7 @@ impl QRCodeType {
match value {
#[cfg(feature = "bitcoin")]
InnerURType::CryptoPsbt(_) => Ok(QRCodeType::CryptoPSBT),
- #[cfg(feature = "bitcoin")]
+ #[cfg(feature = "multi-coins")]
InnerURType::CryptoPsbtExtend(_) => Ok(QRCodeType::CryptoPSBTExtend),
InnerURType::CryptoMultiAccounts(_) => Ok(QRCodeType::CryptoMultiAccounts),
#[cfg(feature = "bitcoin")]
@@ -723,7 +723,7 @@ pub fn decode_ur(ur: String) -> URParseResult {
match ur_type {
#[cfg(feature = "bitcoin")]
QRCodeType::CryptoPSBT => _decode_ur::<CryptoPSBT>(ur, ur_type),
- #[cfg(feature = "bitcoin")]
+ #[cfg(feature = "multi-coins")]
QRCodeType::CryptoPSBTExtend => _decode_ur::<CryptoPSBTExtend>(ur, ur_type),
#[cfg(feature = "bitcoin")]
QRCodeType::CryptoAccount => _decode_ur::<CryptoAccount>(ur, ur_type),
@@ -827,7 +827,7 @@ fn receive_ur(ur: String, decoder: &mut KeystoneURDecoder) -> URParseMultiResult
match ur_type {
#[cfg(feature = "bitcoin")]
QRCodeType::CryptoPSBT => _receive_ur::<CryptoPSBT>(ur, ur_type, decoder),
- #[cfg(feature = "bitcoin")]
+ #[cfg(feature = "multi-coins")]
QRCodeType::CryptoPSBTExtend => _receive_ur::<CryptoPSBTExtend>(ur, ur_type, decoder),
#[cfg(feature = "bitcoin")]
QRCodeType::CryptoAccount => _receive_ur::<CryptoAccount>(ur, ur_type, decoder),
diff --git a/rust/rust_c/src/common/ur_ext.rs b/rust/rust_c/src/common/ur_ext.rs
index b52e393..75d5af4 100644
--- a/rust/rust_c/src/common/ur_ext.rs
+++ b/rust/rust_c/src/common/ur_ext.rs
@@ -80,7 +80,7 @@ impl InferViewType for CryptoPSBT {
}
}
-#[cfg(feature = "bitcoin")]
+#[cfg(feature = "multi-coins")]
impl InferViewType for CryptoPSBTExtend {
fn infer(&self) -> Result<ViewType, URError> {
match self.get_coin_id() {
diff --git a/rust/rust_c/src/common/web_auth.rs b/rust/rust_c/src/common/web_auth.rs
index eb3e6e5..5a849d4 100644
--- a/rust/rust_c/src/common/web_auth.rs
+++ b/rust/rust_c/src/common/web_auth.rs
@@ -37,10 +37,8 @@ pub unsafe extern "C" fn calculate_auth_code(
match from_value::<String>(_data.clone()) {
Ok(_hex) => match base64::decode(&_hex) {
Ok(_value) => unsafe {
- let rsa_key_n =
- extract_array!(rsa_key_n, u8, rsa_key_n_len as usize);
- let rsa_key_d =
- extract_array!(rsa_key_d, u8, rsa_key_d_len as usize);
+ let rsa_key_n = extract_array!(rsa_key_n, u8, rsa_key_n_len as usize);
+ let rsa_key_d = extract_array!(rsa_key_d, u8, rsa_key_d_len as usize);
match _calculate_auth_code(&_value, rsa_key_n, rsa_key_d) {
Ok(_result) => Ok(_result),
Err(_err) => Err(RustCError::WebAuthFailed(format!("{_err}"))),
diff --git a/rust/rust_c/src/cosmos/structs.rs b/rust/rust_c/src/cosmos/structs.rs
index 415a580..290961c 100644
--- a/rust/rust_c/src/cosmos/structs.rs
+++ b/rust/rust_c/src/cosmos/structs.rs
@@ -8,7 +8,7 @@ use crate::common::free::Free;
use crate::common::structs::TransactionParseResult;
use crate::common::types::{PtrString, PtrT};
use crate::common::utils::convert_c_char;
-use crate::{check_and_free_ptr, impl_c_ptr, make_free_method, free_str_ptr};
+use crate::{check_and_free_ptr, free_str_ptr, impl_c_ptr, make_free_method};
#[repr(C)]
pub struct DisplayCosmosTx {
diff --git a/rust/rust_c/src/iota/mod.rs b/rust/rust_c/src/iota/mod.rs
index e6fe7d3..acf8e8d 100644
--- a/rust/rust_c/src/iota/mod.rs
+++ b/rust/rust_c/src/iota/mod.rs
@@ -6,8 +6,8 @@ use crate::common::utils::{convert_c_char, recover_c_char};
use crate::extract_array;
use crate::extract_ptr_with_type;
use crate::sui::get_public_key;
+use alloc::format;
use alloc::vec::Vec;
-use alloc::{format};
use alloc::{
string::{String, ToString},
vec,
diff --git a/rust/rust_c/src/iota/structs.rs b/rust/rust_c/src/iota/structs.rs
index 7a3ef10..761b1f5 100644
--- a/rust/rust_c/src/iota/structs.rs
+++ b/rust/rust_c/src/iota/structs.rs
@@ -15,9 +15,7 @@ use crate::common::free::{free_ptr_string, Free};
use crate::common::structs::TransactionParseResult;
use crate::common::types::{Ptr, PtrString, PtrT};
use crate::common::utils::convert_c_char;
-use crate::{
- free_str_ptr, free_vec, impl_c_ptr, impl_c_ptrs, make_free_method,
-};
+use crate::{free_str_ptr, free_vec, impl_c_ptr, impl_c_ptrs, make_free_method};
use app_ethereum::address::checksum_address;
use app_sui::Intent;
use sui_types::{
diff --git a/rust/rust_c/src/monero/mod.rs b/rust/rust_c/src/monero/mod.rs
index 00bc1b7..9eba270 100644
--- a/rust/rust_c/src/monero/mod.rs
+++ b/rust/rust_c/src/monero/mod.rs
@@ -110,9 +110,7 @@ pub unsafe extern "C" fn monero_unsigned_request_check(
UNSIGNED_TX_PREFIX,
) {
Ok(_) => TransactionCheckResult::new().c_ptr(),
- Err(_) => {
- TransactionCheckResult::from(RustCError::InvalidMasterFingerprint).c_ptr()
- }
+ Err(_) => TransactionCheckResult::from(RustCError::InvalidMasterFingerprint).c_ptr(),
}
}
diff --git a/rust/rust_c/src/near/mod.rs b/rust/rust_c/src/near/mod.rs
index dfba42c..6aede75 100644
--- a/rust/rust_c/src/near/mod.rs
+++ b/rust/rust_c/src/near/mod.rs
@@ -83,7 +83,11 @@ pub unsafe extern "C" fn near_parse_tx(ptr: PtrUR) -> PtrT<TransactionParseResul
}
#[no_mangle]
-pub unsafe extern "C" fn near_sign_tx(ptr: PtrUR, seed: PtrBytes, seed_len: u32) -> PtrT<UREncodeResult> {
+pub unsafe extern "C" fn near_sign_tx(
+ ptr: PtrUR,
+ seed: PtrBytes,
+ seed_len: u32,
+) -> PtrT<UREncodeResult> {
let seed = extract_array!(seed, u8, seed_len as usize);
build_sign_result(ptr, seed)
.map(|v| v.try_into())
diff --git a/rust/rust_c/src/near/structs.rs b/rust/rust_c/src/near/structs.rs
index 6d0a859..07c5c4f 100644
--- a/rust/rust_c/src/near/structs.rs
+++ b/rust/rust_c/src/near/structs.rs
@@ -74,11 +74,11 @@ impl Free for DisplayNearTxOverview {
free_str_ptr!(self.transfer_value);
free_str_ptr!(self.transfer_from);
free_str_ptr!(self.transfer_to);
- if !self.action_list.is_null() {
- let x = Box::from_raw(self.action_list);
- let ve = Vec::from_raw_parts(x.data, x.size, x.cap);
- ve.iter().for_each(|v| {
- v.free();
+ if !self.action_list.is_null() {
+ let x = Box::from_raw(self.action_list);
+ let ve = Vec::from_raw_parts(x.data, x.size, x.cap);
+ ve.iter().for_each(|v| {
+ v.free();
});
}
}
diff --git a/rust/rust_c/src/stellar/mod.rs b/rust/rust_c/src/stellar/mod.rs
index 3499256..451aaac 100644
--- a/rust/rust_c/src/stellar/mod.rs
+++ b/rust/rust_c/src/stellar/mod.rs
@@ -32,7 +32,9 @@ pub unsafe extern "C" fn stellar_get_address(pubkey: PtrString) -> *mut SimpleRe
}
#[no_mangle]
-pub unsafe extern "C" fn stellar_parse(ptr: PtrUR) -> PtrT<TransactionParseResult<DisplayStellarTx>> {
+pub unsafe extern "C" fn stellar_parse(
+ ptr: PtrUR,
+) -> PtrT<TransactionParseResult<DisplayStellarTx>> {
let sign_request = extract_ptr_with_type!(ptr, StellarSignRequest);
let raw_message = match sign_request.get_sign_type() {
SignType::Transaction => base_to_xdr(&sign_request.get_sign_data()),
@@ -93,7 +95,11 @@ fn build_signature_data(
}
#[no_mangle]
-pub unsafe extern "C" fn stellar_sign(ptr: PtrUR, seed: PtrBytes, seed_len: u32) -> PtrT<UREncodeResult> {
+pub unsafe extern "C" fn stellar_sign(
+ ptr: PtrUR,
+ seed: PtrBytes,
+ seed_len: u32,
+) -> PtrT<UREncodeResult> {
let seed = extract_array!(seed, u8, seed_len as usize);
let sign_request = extract_ptr_with_type!(ptr, StellarSignRequest);
let sign_data = sign_request.get_sign_data();
diff --git a/rust/rust_c/src/sui/mod.rs b/rust/rust_c/src/sui/mod.rs
index edfffb7..06f42e5 100644
--- a/rust/rust_c/src/sui/mod.rs
+++ b/rust/rust_c/src/sui/mod.rs
@@ -133,7 +133,11 @@ pub unsafe extern "C" fn sui_parse_sign_message_hash(
}
#[no_mangle]
-pub unsafe extern "C" fn sui_sign_hash(ptr: PtrUR, seed: PtrBytes, seed_len: u32) -> PtrT<UREncodeResult> {
+pub unsafe extern "C" fn sui_sign_hash(
+ ptr: PtrUR,
+ seed: PtrBytes,
+ seed_len: u32,
+) -> PtrT<UREncodeResult> {
let seed = extract_array!(seed, u8, seed_len as usize);
let sign_request = extract_ptr_with_type!(ptr, SuiSignHashRequest);
let hash = sign_request.get_message_hash();
diff --git a/rust/rust_c/src/ton/mod.rs b/rust/rust_c/src/ton/mod.rs
index 352d4a4..cb54361 100644
--- a/rust/rust_c/src/ton/mod.rs
+++ b/rust/rust_c/src/ton/mod.rs
@@ -1,12 +1,15 @@
pub mod structs;
-use crate::{common::{
- errors::RustCError,
- ffi::VecFFI,
- structs::{SimpleResponse, TransactionCheckResult, TransactionParseResult},
- types::{Ptr, PtrBytes, PtrString, PtrT, PtrUR},
- ur::{FRAGMENT_MAX_LENGTH_DEFAULT, UREncodeResult},
- utils::recover_c_char,
-}, extract_array};
+use crate::{
+ common::{
+ errors::RustCError,
+ ffi::VecFFI,
+ structs::{SimpleResponse, TransactionCheckResult, TransactionParseResult},
+ types::{Ptr, PtrBytes, PtrString, PtrT, PtrUR},
+ ur::{UREncodeResult, FRAGMENT_MAX_LENGTH_DEFAULT},
+ utils::recover_c_char,
+ },
+ extract_array,
+};
use alloc::{
boxed::Box,
format, slice,
@@ -53,7 +56,9 @@ pub unsafe extern "C" fn ton_parse_transaction(
}
#[no_mangle]
-pub unsafe extern "C" fn ton_parse_proof(ptr: PtrUR) -> PtrT<TransactionParseResult<DisplayTonProof>> {
+pub unsafe extern "C" fn ton_parse_proof(
+ ptr: PtrUR,
+) -> PtrT<TransactionParseResult<DisplayTonProof>> {
let ton_tx = extract_ptr_with_type!(ptr, TonSignRequest);
let serial = ton_tx.get_sign_data();
diff --git a/rust/rust_c/src/wallet/cypherpunk_wallet/cake.rs b/rust/rust_c/src/wallet/cypherpunk_wallet/cake.rs
index ee8173d..bdd65c8 100644
--- a/rust/rust_c/src/wallet/cypherpunk_wallet/cake.rs
+++ b/rust/rust_c/src/wallet/cypherpunk_wallet/cake.rs
@@ -64,12 +64,7 @@ pub unsafe extern "C" fn get_connect_cake_wallet_ur(
PrivateKey::from_bytes(&pvk).get_public_key(),
);
- generate_wallet_result(
- primary_address.to_string(),
- hex::encode(&pvk),
- false,
- )
- .c_ptr()
+ generate_wallet_result(primary_address.to_string(), hex::encode(&pvk), false).c_ptr()
}
#[no_mangle]
diff --git a/rust/rust_c/src/xrp/mod.rs b/rust/rust_c/src/xrp/mod.rs
index d6338ac..caec43f 100644
--- a/rust/rust_c/src/xrp/mod.rs
+++ b/rust/rust_c/src/xrp/mod.rs
@@ -52,7 +52,11 @@ pub unsafe extern "C" fn xrp_get_address(
}
}
-unsafe fn build_sign_result(ptr: PtrUR, hd_path: PtrString, seed: &[u8]) -> Result<Vec<u8>, XRPError> {
+unsafe fn build_sign_result(
+ ptr: PtrUR,
+ hd_path: PtrString,
+ seed: &[u8],
+) -> Result<Vec<u8>, XRPError> {
let crypto_bytes = extract_ptr_with_type!(ptr, Bytes);
let hd_path = recover_c_char(hd_path);
app_xrp::sign_tx(crypto_bytes.get_bytes().as_slice(), &hd_path, seed)
@@ -251,7 +255,9 @@ pub unsafe extern "C" fn xrp_check_tx_bytes(
}
#[no_mangle]
-pub unsafe extern "C" fn xrp_parse_bytes_tx(ptr: PtrUR) -> PtrT<TransactionParseResult<DisplayXrpTx>> {
+pub unsafe extern "C" fn xrp_parse_bytes_tx(
+ ptr: PtrUR,
+) -> PtrT<TransactionParseResult<DisplayXrpTx>> {
let payload = build_payload(ptr, QRCodeType::Bytes).unwrap();
let content = payload.content.unwrap();
let sign_tx = match content {
diff --git a/rust/rust_c/src/zcash/mod.rs b/rust/rust_c/src/zcash/mod.rs
index f53bee0..86adf3d 100644
--- a/rust/rust_c/src/zcash/mod.rs
+++ b/rust/rust_c/src/zcash/mod.rs
@@ -30,7 +30,7 @@ pub unsafe extern "C" fn derive_zcash_ufvk(
account_path: PtrString,
) -> *mut SimpleResponse<c_char> {
let seed = extract_array!(seed, u8, seed_len as usize);
- let account_path = recover_c_char(account_path);
+ let account_path = unsafe { recover_c_char(account_path) };
let ufvk_text = derive_ufvk(&MainNetwork, seed, &account_path);
match ufvk_text {
Ok(text) => SimpleResponse::success(convert_c_char(text)).simple_c_ptr(),
@@ -57,7 +57,7 @@ pub unsafe extern "C" fn calculate_zcash_seed_fingerprint(
pub unsafe extern "C" fn generate_zcash_default_address(
ufvk_text: PtrString,
) -> *mut SimpleResponse<c_char> {
- let ufvk_text = recover_c_char(ufvk_text);
+ let ufvk_text = unsafe { recover_c_char(ufvk_text) };
let address = get_address(&MainNetwork, &ufvk_text);
match address {
Ok(text) => SimpleResponse::success(convert_c_char(text)).simple_c_ptr(),
@@ -80,7 +80,7 @@ pub unsafe extern "C" fn check_zcash_tx(
.c_ptr();
}
let pczt = extract_ptr_with_type!(tx, ZcashPczt);
- let ufvk_text = recover_c_char(ufvk);
+ let ufvk_text = unsafe { recover_c_char(ufvk) };
let seed_fingerprint = extract_array!(seed_fingerprint, u8, 32);
let seed_fingerprint = seed_fingerprint.try_into().unwrap();
match app_zcash::check_pczt(
@@ -102,7 +102,7 @@ pub unsafe extern "C" fn parse_zcash_tx(
seed_fingerprint: PtrBytes,
) -> Ptr<TransactionParseResult<DisplayPczt>> {
let pczt = extract_ptr_with_type!(tx, ZcashPczt);
- let ufvk_text = recover_c_char(ufvk);
+ let ufvk_text = unsafe { recover_c_char(ufvk) };
let seed_fingerprint = extract_array!(seed_fingerprint, u8, 32);
let seed_fingerprint = seed_fingerprint.try_into().unwrap();
match app_zcash::parse_pczt(&MainNetwork, &pczt.get_data(), &ufvk_text, seed_fingerprint) {
@@ -149,9 +149,9 @@ pub unsafe extern "C" fn rust_aes256_cbc_encrypt(
iv: PtrBytes,
iv_len: u32,
) -> *mut SimpleResponse<c_char> {
- let data = recover_c_char(data);
+ let data = unsafe { recover_c_char(data) };
let data = data.as_bytes();
- let password = recover_c_char(password);
+ let password = unsafe { recover_c_char(password) };
let iv = extract_array!(iv, u8, iv_len as usize);
let key = sha256(password.as_bytes());
let iv = GenericArray::from_slice(iv);
@@ -167,9 +167,9 @@ pub unsafe extern "C" fn rust_aes256_cbc_decrypt(
iv: PtrBytes,
iv_len: u32,
) -> *mut SimpleResponse<c_char> {
- let hex_data = recover_c_char(hex_data);
+ let hex_data = unsafe { recover_c_char(hex_data) };
let data = hex::decode(hex_data).unwrap();
- let password = recover_c_char(password);
+ let password = unsafe { recover_c_char(password) };
let iv = extract_array!(iv, u8, iv_len as usize);
let key = sha256(password.as_bytes());
let iv = GenericArray::from_slice(iv);
@@ -208,12 +208,12 @@ mod tests {
let mut data = convert_c_char("hello world".to_string());
let mut password = convert_c_char("password".to_string());
let mut seed = hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap();
- let iv = rust_derive_iv_from_seed(seed.as_mut_ptr(), 64);
+ let iv = unsafe { rust_derive_iv_from_seed(seed.as_mut_ptr(), 64) };
let mut iv = unsafe { slice::from_raw_parts_mut((*iv).data, 16) };
let iv_len = 16;
- let ct = rust_aes256_cbc_encrypt(data, password, iv.as_mut_ptr(), iv_len as u32);
+ let ct = unsafe { rust_aes256_cbc_encrypt(data, password, iv.as_mut_ptr(), iv_len as u32) };
let ct_vec = unsafe { (*ct).data };
- let value = recover_c_char(ct_vec);
+ let value = unsafe { recover_c_char(ct_vec) };
assert_eq!(value, "639194f4bf964e15d8ea9c9bd9d96918");
}
@@ -225,13 +225,13 @@ mod tests {
let data = convert_c_char("639194f4bf964e15d8ea9c9bd9d96918".to_string());
let password = convert_c_char("password".to_string());
let mut seed = hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap();
- let iv = rust_derive_iv_from_seed(seed.as_mut_ptr(), 64);
+ let iv = unsafe { rust_derive_iv_from_seed(seed.as_mut_ptr(), 64) };
let iv = unsafe { slice::from_raw_parts_mut((*iv).data, 16) };
let iv_len = 16;
- let pt = rust_aes256_cbc_decrypt(data, password, iv.as_mut_ptr(), iv_len as u32);
+ let pt = unsafe { rust_aes256_cbc_decrypt(data, password, iv.as_mut_ptr(), iv_len as u32) };
assert!(!pt.is_null());
let ct_vec = unsafe { (*pt).data };
- let value = recover_c_char(ct_vec);
+ let value = unsafe { recover_c_char(ct_vec) };
assert_eq!(value, "hello world");
}
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.