// Copyright 2020 Citra Emulator Project // Licensed under GPLv2 or any later version // Refer to the license.txt file included. #pragma once #include #include #include "common/common_types.h" namespace HW::RSA { class RsaSlot { public: RsaSlot() = default; RsaSlot(std::vector exponent, std::vector modulus) : init(true), exponent(std::move(exponent)), modulus(std::move(modulus)) {} std::vector ModularExponentiation(std::span message, int out_size_bytes = -1) const; std::vector Sign(std::span message) const; bool Verify(std::span message, std::span signature) const; explicit operator bool() const { // TODO(B3N30): Maybe check if exponent and modulus are vailid return init; } void SetExponent(const std::vector& e) { exponent = e; } const std::vector& GetExponent() const { return exponent; } void SetModulus(const std::vector& m) { modulus = m; } const std::vector& GetModulus() const { return modulus; } void SetPrivateD(const std::vector& d) { private_d = d; } const std::vector& GetPrivateD() const { return private_d; } private: bool init = false; std::vector exponent; std::vector modulus; std::vector private_d; }; void InitSlots(); const RsaSlot& GetSlot(std::size_t slot_id); const RsaSlot& GetTicketWrapSlot(); const RsaSlot& GetSecureInfoSlot(); const RsaSlot& GetLocalFriendCodeSeedSlot(); } // namespace HW::RSA