VolumeWiiCrypted.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // Copyright 2008 Dolphin Emulator Project
  2. // Licensed under GPLv2+
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include <map>
  6. #include <memory>
  7. #include <string>
  8. #include <vector>
  9. #include <polarssl/aes.h>
  10. #include "Common/CommonTypes.h"
  11. #include "DiscIO/Volume.h"
  12. // --- this volume type is used for encrypted Wii images ---
  13. namespace DiscIO
  14. {
  15. class IBlobReader;
  16. class CVolumeWiiCrypted : public IVolume
  17. {
  18. public:
  19. CVolumeWiiCrypted(IBlobReader* _pReader, u64 _VolumeOffset, const unsigned char* _pVolumeKey);
  20. ~CVolumeWiiCrypted();
  21. bool Read(u64 _Offset, u64 _Length, u8* _pBuffer, bool decrypt) const override;
  22. bool GetTitleID(u8* _pBuffer) const override;
  23. virtual std::unique_ptr<u8[]> GetTMD(u32 *_sz) const override;
  24. std::string GetUniqueID() const override;
  25. std::string GetMakerID() const override;
  26. u16 GetRevision() const override;
  27. std::string GetInternalName() const override;
  28. std::map<IVolume::ELanguage, std::string> GetNames(bool prefer_long) const override;
  29. u64 GetFSTSize() const override;
  30. std::string GetApploaderDate() const override;
  31. u8 GetDiscNumber() const override;
  32. EPlatform GetVolumeType() const override;
  33. bool SupportsIntegrityCheck() const override { return true; }
  34. bool CheckIntegrity() const override;
  35. bool ChangePartition(u64 offset) override;
  36. ECountry GetCountry() const override;
  37. u64 GetSize() const override;
  38. u64 GetRawSize() const override;
  39. private:
  40. static const unsigned int s_block_header_size = 0x0400;
  41. static const unsigned int s_block_data_size = 0x7C00;
  42. static const unsigned int s_block_total_size = s_block_header_size + s_block_data_size;
  43. std::unique_ptr<IBlobReader> m_pReader;
  44. std::unique_ptr<aes_context> m_AES_ctx;
  45. u8* m_pBuffer;
  46. u64 m_VolumeOffset;
  47. u64 m_dataOffset;
  48. mutable u64 m_LastDecryptedBlockOffset;
  49. mutable unsigned char m_LastDecryptedBlock[s_block_data_size];
  50. };
  51. } // namespace