diff --git a/src/core/hw/aes/key.cpp b/src/core/hw/aes/key.cpp index 2148ab04c..e406aed71 100644 --- a/src/core/hw/aes/key.cpp +++ b/src/core/hw/aes/key.cpp @@ -223,7 +223,7 @@ void LoadNativeFirmKeysOld3DS() { return; } - auto rsa = RSA::GetSlot(0); + const auto rsa = RSA::GetSlot(0); if (!rsa) { LOG_ERROR(HW_AES, "RSA slot is missing"); return; diff --git a/src/core/hw/rsa/rsa.cpp b/src/core/hw/rsa/rsa.cpp index 8f2c93243..b4179fd69 100644 --- a/src/core/hw/rsa/rsa.cpp +++ b/src/core/hw/rsa/rsa.cpp @@ -31,7 +31,7 @@ std::vector HexToBytes(const std::string& hex) { constexpr std::size_t SlotSize = 4; std::array rsa_slots; -std::vector RsaSlot::GetSignature(const std::vector& message) { +std::vector RsaSlot::GetSignature(const std::vector& message) const { CryptoPP::Integer sig = CryptoPP::ModularExponentiation(CryptoPP::Integer(message.data(), message.size()), CryptoPP::Integer(exponent.data(), exponent.size()), @@ -74,7 +74,7 @@ void InitSlots() { std::vector exponent(256); file.ReadArray(exponent.data(), exponent.size()); - rsa_slots[0] = RsaSlot(exponent, modulus); + rsa_slots[0] = RsaSlot(std::move(exponent), std::move(modulus)); // TODO(B3N30): Initalize the other slots. But since they aren't used at all, we can skip them // for now } diff --git a/src/core/hw/rsa/rsa.h b/src/core/hw/rsa/rsa.h index 869d98d89..26dc84cb1 100644 --- a/src/core/hw/rsa/rsa.h +++ b/src/core/hw/rsa/rsa.h @@ -11,18 +11,18 @@ namespace HW::RSA { class RsaSlot { public: - RsaSlot() : init(false) {} - RsaSlot(const std::vector& exponent, const std::vector& modulus) - : init(true), exponent(exponent), modulus(modulus) {} - std::vector GetSignature(const std::vector& message); + RsaSlot() = default; + RsaSlot(std::vector exponent, std::vector modulus) + : init(true), exponent(std::move(exponent)), modulus(std::move(modulus)) {} + std::vector GetSignature(const std::vector& message) const; - operator bool() const { + explicit operator bool() const { // TODO(B3N30): Maybe check if exponent and modulus are vailid return init; } private: - bool init; + bool init = false; std::vector exponent; std::vector modulus; };