mirror of
https://github.com/PabloMK7/citra.git
synced 2025-09-12 13:50:03 +00:00
nfc: Use existing secrets infrastructure for amiibo encryption. (#6652)
This commit is contained in:
parent
4383f6d80a
commit
c00768d6d0
5 changed files with 68 additions and 80 deletions
|
@ -593,8 +593,18 @@ void SelectDlpNfcKeyYIndex(u8 index) {
|
|||
key_slots[KeySlotID::DLPNFCDataKey].SetKeyY(dlp_nfc_key_y_slots.at(index));
|
||||
}
|
||||
|
||||
const NfcSecret& GetNfcSecret(u8 index) {
|
||||
return nfc_secrets[index];
|
||||
bool NfcSecretsAvailable() {
|
||||
auto missing_secret =
|
||||
std::find_if(nfc_secrets.begin(), nfc_secrets.end(), [](auto& nfc_secret) {
|
||||
return nfc_secret.phrase.empty() || nfc_secret.seed.empty() ||
|
||||
nfc_secret.hmac_key.empty();
|
||||
});
|
||||
SelectDlpNfcKeyYIndex(DlpNfcKeyY::Nfc);
|
||||
return IsNormalKeyAvailable(KeySlotID::DLPNFCDataKey) && missing_secret == nfc_secrets.end();
|
||||
}
|
||||
|
||||
const NfcSecret& GetNfcSecret(NfcSecretId secret_id) {
|
||||
return nfc_secrets[secret_id];
|
||||
}
|
||||
|
||||
const AESIV& GetNfcIv() {
|
||||
|
|
|
@ -60,6 +60,11 @@ struct NfcSecret {
|
|||
std::vector<u8> hmac_key;
|
||||
};
|
||||
|
||||
enum NfcSecretId : std::size_t {
|
||||
UnfixedInfo = 0,
|
||||
LockedSecret = 1,
|
||||
};
|
||||
|
||||
constexpr std::size_t MaxCommonKeySlot = 6;
|
||||
constexpr std::size_t NumDlpNfcKeyYs = 2;
|
||||
constexpr std::size_t NumNfcSecrets = 2;
|
||||
|
@ -83,7 +88,8 @@ AESKey GetNormalKey(std::size_t slot_id);
|
|||
void SelectCommonKeyIndex(u8 index);
|
||||
void SelectDlpNfcKeyYIndex(u8 index);
|
||||
|
||||
const NfcSecret& GetNfcSecret(u8 index);
|
||||
bool NfcSecretsAvailable();
|
||||
const NfcSecret& GetNfcSecret(NfcSecretId secret_id);
|
||||
const AESIV& GetNfcIv();
|
||||
|
||||
} // namespace HW::AES
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue