mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-06-15 19:51:42 +00:00
This introduces the ability to read and write game data and model information from an Amiibo dump file (BIN format). Note that this functionality requires the presence of a key_retail.bin file. For the option to appear and function in the UI, ensure that the key_retail.bin file is located in the <RyujinxData>/system folder.
44 lines
1.3 KiB
C#
44 lines
1.3 KiB
C#
using System.IO;
|
|
|
|
namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption
|
|
{
|
|
public class AmiiboDecrypter
|
|
{
|
|
public AmiiboMasterKey DataKey { get; private set; }
|
|
public AmiiboMasterKey TagKey { get; private set; }
|
|
|
|
public AmiiboDecrypter(string keyRetailBinPath)
|
|
{
|
|
var combinedKeys = File.ReadAllBytes(keyRetailBinPath);
|
|
var keys = AmiiboMasterKey.FromCombinedBin(combinedKeys);
|
|
DataKey = keys.DataKey;
|
|
TagKey = keys.TagKey;
|
|
}
|
|
|
|
public AmiiboDump DecryptAmiiboDump(byte[] encryptedDumpData)
|
|
{
|
|
// Initialize AmiiboDump with encrypted data
|
|
AmiiboDump amiiboDump = new AmiiboDump(encryptedDumpData, DataKey, TagKey, isLocked: true);
|
|
|
|
// Unlock (decrypt) the dump
|
|
amiiboDump.Unlock();
|
|
|
|
// Optional: Verify HMACs
|
|
amiiboDump.VerifyHMACs();
|
|
|
|
return amiiboDump;
|
|
}
|
|
|
|
public AmiiboDump EncryptAmiiboDump(byte[] decryptedDumpData)
|
|
{
|
|
// Initialize AmiiboDump with decrypted data
|
|
AmiiboDump amiiboDump = new AmiiboDump(decryptedDumpData, DataKey, TagKey, isLocked: false);
|
|
|
|
// Lock (encrypt) the dump
|
|
amiiboDump.Lock();
|
|
|
|
return amiiboDump;
|
|
}
|
|
}
|
|
}
|