nfc: Use existing secrets infrastructure for amiibo encryption. (#6652)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user