mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-07-04 23:31:19 +01:00
service: nfp: Allow amiibos without keys
This commit is contained in:
parent
82fdfb33ac
commit
3e0aaeba98
3 changed files with 18 additions and 1 deletions
|
@ -9,6 +9,7 @@
|
||||||
#include <mbedtls/hmac_drbg.h>
|
#include <mbedtls/hmac_drbg.h>
|
||||||
|
|
||||||
#include "common/fs/file.h"
|
#include "common/fs/file.h"
|
||||||
|
#include "common/fs/fs.h"
|
||||||
#include "common/fs/path_util.h"
|
#include "common/fs/path_util.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "core/hle/service/mii/mii_manager.h"
|
#include "core/hle/service/mii/mii_manager.h"
|
||||||
|
@ -279,7 +280,7 @@ bool LoadKeys(InternalKey& locked_secret, InternalKey& unfixed_info) {
|
||||||
Common::FS::FileType::BinaryFile};
|
Common::FS::FileType::BinaryFile};
|
||||||
|
|
||||||
if (!keys_file.IsOpen()) {
|
if (!keys_file.IsOpen()) {
|
||||||
LOG_ERROR(Service_NFP, "No keys detected");
|
LOG_ERROR(Service_NFP, "Failed to open key file");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -295,6 +296,11 @@ bool LoadKeys(InternalKey& locked_secret, InternalKey& unfixed_info) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsKeyAvailable() {
|
||||||
|
const auto yuzu_keys_dir = Common::FS::GetYuzuPath(Common::FS::YuzuPath::KeysDir);
|
||||||
|
return Common::FS::Exists(yuzu_keys_dir / "key_retail.bin");
|
||||||
|
}
|
||||||
|
|
||||||
bool DecodeAmiibo(const EncryptedNTAG215File& encrypted_tag_data, NTAG215File& tag_data) {
|
bool DecodeAmiibo(const EncryptedNTAG215File& encrypted_tag_data, NTAG215File& tag_data) {
|
||||||
InternalKey locked_secret{};
|
InternalKey locked_secret{};
|
||||||
InternalKey unfixed_info{};
|
InternalKey unfixed_info{};
|
||||||
|
|
|
@ -91,6 +91,9 @@ void Cipher(const DerivedKeys& keys, const NTAG215File& in_data, NTAG215File& ou
|
||||||
/// Loads both amiibo keys from key_retail.bin
|
/// Loads both amiibo keys from key_retail.bin
|
||||||
bool LoadKeys(InternalKey& locked_secret, InternalKey& unfixed_info);
|
bool LoadKeys(InternalKey& locked_secret, InternalKey& unfixed_info);
|
||||||
|
|
||||||
|
/// Returns true if key_retail.bin exist
|
||||||
|
bool IsKeyAvailable();
|
||||||
|
|
||||||
/// Decodes encripted amiibo data returns true if output is valid
|
/// Decodes encripted amiibo data returns true if output is valid
|
||||||
bool DecodeAmiibo(const EncryptedNTAG215File& encrypted_tag_data, NTAG215File& tag_data);
|
bool DecodeAmiibo(const EncryptedNTAG215File& encrypted_tag_data, NTAG215File& tag_data);
|
||||||
|
|
||||||
|
|
|
@ -234,6 +234,14 @@ Result NfpDevice::Mount(MountTarget mount_target_) {
|
||||||
return NotAnAmiibo;
|
return NotAnAmiibo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Mark amiibos as read only when keys are missing
|
||||||
|
if (!AmiiboCrypto::IsKeyAvailable()) {
|
||||||
|
LOG_ERROR(Service_NFP, "No keys detected");
|
||||||
|
device_state = DeviceState::TagMounted;
|
||||||
|
mount_target = MountTarget::Rom;
|
||||||
|
return ResultSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
if (!AmiiboCrypto::DecodeAmiibo(encrypted_tag_data, tag_data)) {
|
if (!AmiiboCrypto::DecodeAmiibo(encrypted_tag_data, tag_data)) {
|
||||||
LOG_ERROR(Service_NFP, "Can't decode amiibo {}", device_state);
|
LOG_ERROR(Service_NFP, "Can't decode amiibo {}", device_state);
|
||||||
return CorruptedData;
|
return CorruptedData;
|
||||||
|
|
Loading…
Reference in a new issue