public static TssSdk.AntiDecryptResult TssSdkDecrypt(byte[] src, uint src_len, ref byte[] tar, ref uint tar_len) { TssSdk.AntiDecryptResult result = TssSdk.AntiDecryptResult.ANTI_DECRYPT_FAIL; GCHandle gCHandle = GCHandle.Alloc(src, 3); GCHandle gCHandle2 = GCHandle.Alloc(tar, 3); if (gCHandle.get_IsAllocated() && gCHandle2.get_IsAllocated()) { TssSdk.DecryptPkgInfo decryptPkgInfo = new TssSdk.DecryptPkgInfo(); decryptPkgInfo.encrypt_data_ = gCHandle.AddrOfPinnedObject(); decryptPkgInfo.encrypt_data_len = src_len; decryptPkgInfo.game_pkg_ = gCHandle2.AddrOfPinnedObject(); decryptPkgInfo.game_pkg_len_ = tar_len; result = TssSdk.tss_sdk_decryptpacket(decryptPkgInfo); tar_len = decryptPkgInfo.game_pkg_len_; } if (gCHandle.get_IsAllocated()) { gCHandle.Free(); } if (gCHandle2.get_IsAllocated()) { gCHandle2.Free(); } return(result); }
public static TssSdk.AntiEncryptResult TssSdkEncrypt(int cmd_id, byte[] src, uint src_len, ref byte[] tar, ref uint tar_len) { TssSdk.AntiEncryptResult result = TssSdk.AntiEncryptResult.ANTI_NOT_NEED_ENCRYPT; GCHandle gCHandle = GCHandle.Alloc(src, 3); GCHandle gCHandle2 = GCHandle.Alloc(tar, 3); if (gCHandle.get_IsAllocated() && gCHandle2.get_IsAllocated()) { TssSdk.EncryptPkgInfo encryptPkgInfo = new TssSdk.EncryptPkgInfo(); encryptPkgInfo.cmd_id_ = cmd_id; encryptPkgInfo.game_pkg_ = gCHandle.AddrOfPinnedObject(); encryptPkgInfo.game_pkg_len_ = src_len; encryptPkgInfo.encrpty_data_ = gCHandle2.AddrOfPinnedObject(); encryptPkgInfo.encrypt_data_len_ = tar_len; result = TssSdk.tss_sdk_encryptpacket(encryptPkgInfo); tar_len = encryptPkgInfo.encrypt_data_len_; } if (gCHandle.get_IsAllocated()) { gCHandle.Free(); } if (gCHandle2.get_IsAllocated()) { gCHandle2.Free(); } return(result); }