├── .gitattributes ├── .github └── workflows │ ├── Build_CTRTool.yml │ └── Build_MakeROM.yml ├── .gitignore ├── .vs ├── ProjectSettings.json └── VSWorkspaceState.json ├── README.md ├── ctrtool ├── BUILDING.md ├── README.md ├── build │ └── visualstudio │ │ ├── CTRTool.sln │ │ └── CTRTool │ │ ├── CTRTool.vcxproj │ │ └── CTRTool.vcxproj.filters ├── deps │ ├── libbroadon-es │ │ ├── LICENSE │ │ ├── README.md │ │ ├── build │ │ │ └── visualstudio │ │ │ │ ├── libbroadon-es.sln │ │ │ │ └── libbroadon-es │ │ │ │ ├── libbroadon-es.vcxproj │ │ │ │ └── libbroadon-es.vcxproj.filters │ │ ├── include │ │ │ └── brd │ │ │ │ ├── es.h │ │ │ │ └── es │ │ │ │ ├── es_cert.h │ │ │ │ ├── es_sign.h │ │ │ │ ├── es_ticket.h │ │ │ │ ├── es_tmd.h │ │ │ │ └── types.h │ │ ├── makefile │ │ └── src │ │ │ └── Dummy.cpp │ ├── libfmt │ │ ├── LICENSE.rst │ │ ├── README.md │ │ ├── build │ │ │ └── visualstudio │ │ │ │ ├── libfmt.sln │ │ │ │ └── libfmt │ │ │ │ ├── libfmt.vcxproj │ │ │ │ └── libfmt.vcxproj.filters │ │ ├── include │ │ │ └── fmt │ │ │ │ ├── args.h │ │ │ │ ├── chrono.h │ │ │ │ ├── color.h │ │ │ │ ├── compile.h │ │ │ │ ├── core.h │ │ │ │ ├── format-inl.h │ │ │ │ ├── format.h │ │ │ │ ├── locale.h │ │ │ │ ├── os.h │ │ │ │ ├── ostream.h │ │ │ │ ├── printf.h │ │ │ │ ├── ranges.h │ │ │ │ └── xchar.h │ │ ├── makefile │ │ └── src │ │ │ ├── format.cc │ │ │ └── os.cc │ ├── libmbedtls │ │ ├── BUILDING.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── apache-2.0.txt │ │ ├── build │ │ │ └── visualstudio │ │ │ │ ├── libmbedtls.sln │ │ │ │ └── libmbedtls │ │ │ │ ├── libmbedtls.vcxproj │ │ │ │ └── libmbedtls.vcxproj.filters │ │ ├── include │ │ │ └── mbedtls │ │ │ │ ├── aes.h │ │ │ │ ├── aesni.h │ │ │ │ ├── arc4.h │ │ │ │ ├── aria.h │ │ │ │ ├── asn1.h │ │ │ │ ├── asn1write.h │ │ │ │ ├── base64.h │ │ │ │ ├── bignum.h │ │ │ │ ├── blowfish.h │ │ │ │ ├── bn_mul.h │ │ │ │ ├── camellia.h │ │ │ │ ├── ccm.h │ │ │ │ ├── certs.h │ │ │ │ ├── chacha20.h │ │ │ │ ├── chachapoly.h │ │ │ │ ├── check_config.h │ │ │ │ ├── cipher.h │ │ │ │ ├── cipher_internal.h │ │ │ │ ├── cmac.h │ │ │ │ ├── compat-1.3.h │ │ │ │ ├── config.h │ │ │ │ ├── ctr_drbg.h │ │ │ │ ├── debug.h │ │ │ │ ├── des.h │ │ │ │ ├── dhm.h │ │ │ │ ├── ecdh.h │ │ │ │ ├── ecdsa.h │ │ │ │ ├── ecjpake.h │ │ │ │ ├── ecp.h │ │ │ │ ├── ecp_internal.h │ │ │ │ ├── entropy.h │ │ │ │ ├── entropy_poll.h │ │ │ │ ├── error.h │ │ │ │ ├── gcm.h │ │ │ │ ├── havege.h │ │ │ │ ├── hkdf.h │ │ │ │ ├── hmac_drbg.h │ │ │ │ ├── md.h │ │ │ │ ├── md2.h │ │ │ │ ├── md4.h │ │ │ │ ├── md5.h │ │ │ │ ├── md_internal.h │ │ │ │ ├── memory_buffer_alloc.h │ │ │ │ ├── net.h │ │ │ │ ├── net_sockets.h │ │ │ │ ├── nist_kw.h │ │ │ │ ├── oid.h │ │ │ │ ├── padlock.h │ │ │ │ ├── pem.h │ │ │ │ ├── pk.h │ │ │ │ ├── pk_internal.h │ │ │ │ ├── pkcs11.h │ │ │ │ ├── pkcs12.h │ │ │ │ ├── pkcs5.h │ │ │ │ ├── platform.h │ │ │ │ ├── platform_time.h │ │ │ │ ├── platform_util.h │ │ │ │ ├── poly1305.h │ │ │ │ ├── ripemd160.h │ │ │ │ ├── rsa.h │ │ │ │ ├── rsa_internal.h │ │ │ │ ├── sha1.h │ │ │ │ ├── sha256.h │ │ │ │ ├── sha512.h │ │ │ │ ├── ssl.h │ │ │ │ ├── ssl_cache.h │ │ │ │ ├── ssl_ciphersuites.h │ │ │ │ ├── ssl_cookie.h │ │ │ │ ├── ssl_internal.h │ │ │ │ ├── ssl_ticket.h │ │ │ │ ├── threading.h │ │ │ │ ├── timing.h │ │ │ │ ├── version.h │ │ │ │ ├── x509.h │ │ │ │ ├── x509_crl.h │ │ │ │ ├── x509_crt.h │ │ │ │ ├── x509_csr.h │ │ │ │ └── xtea.h │ │ ├── makefile │ │ └── src │ │ │ ├── aes.c │ │ │ ├── aesni.c │ │ │ ├── arc4.c │ │ │ ├── aria.c │ │ │ ├── asn1parse.c │ │ │ ├── asn1write.c │ │ │ ├── base64.c │ │ │ ├── bignum.c │ │ │ ├── blowfish.c │ │ │ ├── camellia.c │ │ │ ├── ccm.c │ │ │ ├── certs.c │ │ │ ├── chacha20.c │ │ │ ├── chachapoly.c │ │ │ ├── cipher.c │ │ │ ├── cipher_wrap.c │ │ │ ├── cmac.c │ │ │ ├── ctr_drbg.c │ │ │ ├── debug.c │ │ │ ├── des.c │ │ │ ├── dhm.c │ │ │ ├── ecdh.c │ │ │ ├── ecdsa.c │ │ │ ├── ecjpake.c │ │ │ ├── ecp.c │ │ │ ├── ecp_curves.c │ │ │ ├── entropy.c │ │ │ ├── entropy_poll.c │ │ │ ├── error.c │ │ │ ├── gcm.c │ │ │ ├── havege.c │ │ │ ├── hkdf.c │ │ │ ├── hmac_drbg.c │ │ │ ├── md.c │ │ │ ├── md2.c │ │ │ ├── md4.c │ │ │ ├── md5.c │ │ │ ├── md_wrap.c │ │ │ ├── memory_buffer_alloc.c │ │ │ ├── net_sockets.c │ │ │ ├── nist_kw.c │ │ │ ├── oid.c │ │ │ ├── padlock.c │ │ │ ├── pem.c │ │ │ ├── pk.c │ │ │ ├── pk_wrap.c │ │ │ ├── pkcs11.c │ │ │ ├── pkcs12.c │ │ │ ├── pkcs5.c │ │ │ ├── pkparse.c │ │ │ ├── pkwrite.c │ │ │ ├── platform.c │ │ │ ├── platform_util.c │ │ │ ├── poly1305.c │ │ │ ├── ripemd160.c │ │ │ ├── rsa.c │ │ │ ├── rsa_internal.c │ │ │ ├── sha1.c │ │ │ ├── sha256.c │ │ │ ├── sha512.c │ │ │ ├── ssl_cache.c │ │ │ ├── ssl_ciphersuites.c │ │ │ ├── ssl_cli.c │ │ │ ├── ssl_cookie.c │ │ │ ├── ssl_srv.c │ │ │ ├── ssl_ticket.c │ │ │ ├── ssl_tls.c │ │ │ ├── threading.c │ │ │ ├── timing.c │ │ │ ├── version.c │ │ │ ├── version_features.c │ │ │ ├── x509.c │ │ │ ├── x509_create.c │ │ │ ├── x509_crl.c │ │ │ ├── x509_crt.c │ │ │ ├── x509_csr.c │ │ │ ├── x509write_crt.c │ │ │ ├── x509write_csr.c │ │ │ └── xtea.c │ ├── libnintendo-n3ds │ │ ├── LICENSE │ │ ├── README.md │ │ ├── build │ │ │ └── visualstudio │ │ │ │ ├── libnintendo-n3ds.sln │ │ │ │ └── libnintendo-n3ds │ │ │ │ ├── libnintendo-n3ds.vcxproj │ │ │ │ └── libnintendo-n3ds.vcxproj.filters │ │ ├── include │ │ │ └── ntd │ │ │ │ ├── n3ds.h │ │ │ │ └── n3ds │ │ │ │ ├── CciFsSnapshotGenerator.h │ │ │ │ ├── CiaFsSnapshotGenerator.h │ │ │ │ ├── CtrKeyGenerator.h │ │ │ │ ├── ExeFsSnapshotGenerator.h │ │ │ │ ├── IvfcStream.h │ │ │ │ ├── RomFsSnapshotGenerator.h │ │ │ │ ├── bcwav.h │ │ │ │ ├── cci.h │ │ │ │ ├── cia.h │ │ │ │ ├── cro.h │ │ │ │ ├── crr.h │ │ │ │ ├── es.h │ │ │ │ ├── es │ │ │ │ ├── Certificate.h │ │ │ │ ├── ISigner.h │ │ │ │ ├── RsaSigner.h │ │ │ │ ├── Signature.h │ │ │ │ ├── Ticket.h │ │ │ │ └── TitleMetaData.h │ │ │ │ ├── exefs.h │ │ │ │ ├── exheader.h │ │ │ │ ├── firm.h │ │ │ │ ├── ivfc.h │ │ │ │ ├── ncch.h │ │ │ │ ├── romfs.h │ │ │ │ ├── smdh.h │ │ │ │ └── systemupdater.h │ │ ├── makefile │ │ └── src │ │ │ ├── CciFsSnapshotGenerator.cpp │ │ │ ├── CiaFsSnapshotGenerator.cpp │ │ │ ├── CtrKeyGenerator.cpp │ │ │ ├── ExeFsSnapshotGenerator.cpp │ │ │ ├── IvfcStream.cpp │ │ │ ├── RomFsSnapshotGenerator.cpp │ │ │ └── es │ │ │ ├── Certificate.cpp │ │ │ ├── RsaSigner.cpp │ │ │ ├── Signature.cpp │ │ │ ├── Ticket.cpp │ │ │ └── TitleMetaData.cpp │ └── libtoolchain │ │ ├── BUILDING.md │ │ ├── Doxyfile │ │ ├── DoxygenMainpage.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── build │ │ └── visualstudio │ │ │ ├── libtoolchain-test │ │ │ ├── libtoolchain-test.vcxproj │ │ │ └── libtoolchain-test.vcxproj.filters │ │ │ ├── libtoolchain.sln │ │ │ └── libtoolchain │ │ │ ├── libtoolchain.vcxproj │ │ │ └── libtoolchain.vcxproj.filters │ │ ├── include │ │ ├── tc.h │ │ └── tc │ │ │ ├── AccessViolationException.h │ │ │ ├── ArgumentException.h │ │ │ ├── ArgumentNullException.h │ │ │ ├── ArgumentOutOfRangeException.h │ │ │ ├── ArithmeticException.h │ │ │ ├── ByteData.h │ │ │ ├── Exception.h │ │ │ ├── InvalidOperationException.h │ │ │ ├── NotImplementedException.h │ │ │ ├── NotSupportedException.h │ │ │ ├── ObjectDisposedException.h │ │ │ ├── Optional.h │ │ │ ├── OutOfMemoryException.h │ │ │ ├── OverflowException.h │ │ │ ├── PlatformErrorHandlingUtil.h │ │ │ ├── ResourceStatus.h │ │ │ ├── SecurityException.h │ │ │ ├── UnauthorisedAccessException.h │ │ │ ├── bn.h │ │ │ ├── bn │ │ │ ├── binary_utils.h │ │ │ ├── bitarray.h │ │ │ ├── endian_types.h │ │ │ ├── pad.h │ │ │ └── string.h │ │ │ ├── cli.h │ │ │ ├── cli │ │ │ ├── FormatUtil.h │ │ │ └── OptionParser.h │ │ │ ├── crypto.h │ │ │ ├── crypto │ │ │ ├── Aes128CbcEncryptedStream.h │ │ │ ├── Aes128CbcEncryptor.h │ │ │ ├── Aes128CtrEncryptedStream.h │ │ │ ├── Aes128CtrEncryptor.h │ │ │ ├── Aes128EcbEncryptor.h │ │ │ ├── Aes128XtsEncryptor.h │ │ │ ├── Aes192CbcEncryptor.h │ │ │ ├── Aes192CtrEncryptor.h │ │ │ ├── Aes192EcbEncryptor.h │ │ │ ├── Aes256CbcEncryptor.h │ │ │ ├── Aes256CtrEncryptor.h │ │ │ ├── Aes256EcbEncryptor.h │ │ │ ├── Aes256XtsEncryptor.h │ │ │ ├── AesEncryptor.h │ │ │ ├── CbcEncryptor.h │ │ │ ├── CryptoException.h │ │ │ ├── CtrEncryptor.h │ │ │ ├── EcbEncryptor.h │ │ │ ├── HmacGenerator.h │ │ │ ├── HmacMd5Generator.h │ │ │ ├── HmacSha1Generator.h │ │ │ ├── HmacSha256Generator.h │ │ │ ├── HmacSha512Generator.h │ │ │ ├── Md5Generator.h │ │ │ ├── Pbkdf1KeyDeriver.h │ │ │ ├── Pbkdf1Md5KeyDeriver.h │ │ │ ├── Pbkdf1Sha1KeyDeriver.h │ │ │ ├── Pbkdf2KeyDeriver.h │ │ │ ├── Pbkdf2Sha1KeyDeriver.h │ │ │ ├── Pbkdf2Sha256KeyDeriver.h │ │ │ ├── Pbkdf2Sha512KeyDeriver.h │ │ │ ├── PseudoRandomByteGenerator.h │ │ │ ├── RsaKey.h │ │ │ ├── RsaKeyGenerator.h │ │ │ ├── RsaOaepEncryptor.h │ │ │ ├── RsaOaepSha256Encryptor.h │ │ │ ├── RsaOaepSha512Encryptor.h │ │ │ ├── RsaPkcs1Md5Signer.h │ │ │ ├── RsaPkcs1Sha1Signer.h │ │ │ ├── RsaPkcs1Sha256Signer.h │ │ │ ├── RsaPkcs1Sha512Signer.h │ │ │ ├── RsaPkcs1Signer.h │ │ │ ├── RsaPssSha256Signer.h │ │ │ ├── RsaPssSha512Signer.h │ │ │ ├── RsaPssSigner.h │ │ │ ├── Sha1Generator.h │ │ │ ├── Sha256Generator.h │ │ │ ├── Sha512Generator.h │ │ │ ├── XtsEncryptor.h │ │ │ └── detail │ │ │ │ ├── AesImpl.h │ │ │ │ ├── BlockUtilImpl.h │ │ │ │ ├── CbcModeImpl.h │ │ │ │ ├── CtrModeImpl.h │ │ │ │ ├── EcbModeImpl.h │ │ │ │ ├── HmacImpl.h │ │ │ │ ├── Md5Impl.h │ │ │ │ ├── Pbkdf1Impl.h │ │ │ │ ├── Pbkdf2Impl.h │ │ │ │ ├── PrbgImpl.h │ │ │ │ ├── RsaImpl.h │ │ │ │ ├── RsaKeyGeneratorImpl.h │ │ │ │ ├── RsaOaepPadding.h │ │ │ │ ├── RsaPkcs1Padding.h │ │ │ │ ├── RsaPssPadding.h │ │ │ │ ├── Sha1Impl.h │ │ │ │ ├── Sha2Impl.h │ │ │ │ └── XtsModeImpl.h │ │ │ ├── io.h │ │ │ ├── io │ │ │ ├── BasicPathResolver.h │ │ │ ├── ConcatenatedStream.h │ │ │ ├── DirectoryNotEmptyException.h │ │ │ ├── DirectoryNotFoundException.h │ │ │ ├── FileAccess.h │ │ │ ├── FileExistsException.h │ │ │ ├── FileMode.h │ │ │ ├── FileNotFoundException.h │ │ │ ├── FileStream.h │ │ │ ├── IFileSystem.h │ │ │ ├── IOException.h │ │ │ ├── IOUtil.h │ │ │ ├── IPathResolver.h │ │ │ ├── IPortablePathResolver.h │ │ │ ├── IReadableSink.h │ │ │ ├── ISink.h │ │ │ ├── ISource.h │ │ │ ├── IStream.h │ │ │ ├── LocalFileSystem.h │ │ │ ├── MemorySource.h │ │ │ ├── MemoryStream.h │ │ │ ├── OverlayedSource.h │ │ │ ├── PaddingSource.h │ │ │ ├── Path.h │ │ │ ├── PathTooLongException.h │ │ │ ├── PathUtil.h │ │ │ ├── SeekOrigin.h │ │ │ ├── StreamSink.h │ │ │ ├── StreamSource.h │ │ │ ├── StreamUtil.h │ │ │ ├── SubFileSystem.h │ │ │ ├── SubSink.h │ │ │ ├── SubSource.h │ │ │ ├── SubStream.h │ │ │ └── VirtualFileSystem.h │ │ │ ├── os.h │ │ │ ├── os │ │ │ ├── Environment.h │ │ │ └── UnicodeMain.h │ │ │ ├── string.h │ │ │ ├── string │ │ │ ├── TranscodeUtil.h │ │ │ └── detail │ │ │ │ ├── utf16.h │ │ │ │ └── utf8.h │ │ │ └── types.h │ │ ├── makefile │ │ ├── src │ │ ├── ByteData.cpp │ │ ├── Exception.cpp │ │ ├── PlatformErrorHandlingUtil.cpp │ │ ├── cli │ │ │ ├── FormatUtil.cpp │ │ │ └── OptionParser.cpp │ │ ├── crypto │ │ │ ├── Aes128CbcEncryptedStream.cpp │ │ │ ├── Aes128CbcEncryptor.cpp │ │ │ ├── Aes128CtrEncryptedStream.cpp │ │ │ ├── Aes128CtrEncryptor.cpp │ │ │ ├── Aes128EcbEncryptor.cpp │ │ │ ├── Aes128XtsEncryptor.cpp │ │ │ ├── Aes192CbcEncryptor.cpp │ │ │ ├── Aes192CtrEncryptor.cpp │ │ │ ├── Aes192EcbEncryptor.cpp │ │ │ ├── Aes256CbcEncryptor.cpp │ │ │ ├── Aes256CtrEncryptor.cpp │ │ │ ├── Aes256EcbEncryptor.cpp │ │ │ ├── Aes256XtsEncryptor.cpp │ │ │ ├── HmacMd5Generator.cpp │ │ │ ├── HmacSha1Generator.cpp │ │ │ ├── HmacSha256Generator.cpp │ │ │ ├── HmacSha512Generator.cpp │ │ │ ├── Md5Generator.cpp │ │ │ ├── Pbkdf1Md5KeyDeriver.cpp │ │ │ ├── Pbkdf1Sha1KeyDeriver.cpp │ │ │ ├── Pbkdf2Sha1KeyDeriver.cpp │ │ │ ├── Pbkdf2Sha256KeyDeriver.cpp │ │ │ ├── Pbkdf2Sha512KeyDeriver.cpp │ │ │ ├── PseudoRandomByteGenerator.cpp │ │ │ ├── RsaKey.cpp │ │ │ ├── RsaKeyGenerator.cpp │ │ │ ├── RsaOaepSha256Encryptor.cpp │ │ │ ├── RsaOaepSha512Encryptor.cpp │ │ │ ├── RsaPkcs1Md5Signer.cpp │ │ │ ├── RsaPkcs1Sha1Signer.cpp │ │ │ ├── RsaPkcs1Sha256Signer.cpp │ │ │ ├── RsaPkcs1Sha512Signer.cpp │ │ │ ├── RsaPssSha256Signer.cpp │ │ │ ├── RsaPssSha512Signer.cpp │ │ │ ├── Sha1Generator.cpp │ │ │ ├── Sha256Generator.cpp │ │ │ ├── Sha512Generator.cpp │ │ │ └── detail │ │ │ │ ├── AesImpl.cpp │ │ │ │ ├── Md5Impl.cpp │ │ │ │ ├── PrbgImpl.cpp │ │ │ │ ├── RsaImpl.cpp │ │ │ │ ├── RsaKeyGeneratorImpl.cpp │ │ │ │ ├── Sha1Impl.cpp │ │ │ │ └── Sha2Impl.cpp │ │ ├── io │ │ │ ├── BasicPathResolver.cpp │ │ │ ├── ConcatenatedStream.cpp │ │ │ ├── FileStream.cpp │ │ │ ├── IOUtil.cpp │ │ │ ├── LocalFileSystem.cpp │ │ │ ├── MemorySource.cpp │ │ │ ├── MemoryStream.cpp │ │ │ ├── OverlayedSource.cpp │ │ │ ├── PaddingSource.cpp │ │ │ ├── Path.cpp │ │ │ ├── PathUtil.cpp │ │ │ ├── StreamSink.cpp │ │ │ ├── StreamSource.cpp │ │ │ ├── StreamUtil.cpp │ │ │ ├── SubFileSystem.cpp │ │ │ ├── SubSink.cpp │ │ │ ├── SubSource.cpp │ │ │ ├── SubStream.cpp │ │ │ └── VirtualFileSystem.cpp │ │ ├── os │ │ │ └── Environment.cpp │ │ ├── string │ │ │ └── TranscodeUtil.cpp │ │ └── types.cpp │ │ └── test │ │ ├── ByteData_TestClass.cpp │ │ ├── ByteData_TestClass.h │ │ ├── FileSystemTestUtil.cpp │ │ ├── FileSystemTestUtil.h │ │ ├── ITestClass.h │ │ ├── Optional_TestClass.cpp │ │ ├── Optional_TestClass.h │ │ ├── PbkdfUtil.cpp │ │ ├── PbkdfUtil.h │ │ ├── RsaOaepUtil.cpp │ │ ├── RsaOaepUtil.h │ │ ├── RsaPkcs1Util.cpp │ │ ├── RsaPkcs1Util.h │ │ ├── RsaPssUtil.cpp │ │ ├── RsaPssUtil.h │ │ ├── SinkTestUtil.cpp │ │ ├── SinkTestUtil.h │ │ ├── SourceTestUtil.cpp │ │ ├── SourceTestUtil.h │ │ ├── StreamTestUtil.cpp │ │ ├── StreamTestUtil.h │ │ ├── bn_binaryutils_TestClass.cpp │ │ ├── bn_binaryutils_TestClass.h │ │ ├── bn_bitarrayByteBEBitBE_TestClass.cpp │ │ ├── bn_bitarrayByteBEBitBE_TestClass.h │ │ ├── bn_bitarrayByteBEBitLE_TestClass.cpp │ │ ├── bn_bitarrayByteBEBitLE_TestClass.h │ │ ├── bn_bitarrayByteLEBitBE_TestClass.cpp │ │ ├── bn_bitarrayByteLEBitBE_TestClass.h │ │ ├── bn_bitarrayByteLEBitLE_TestClass.cpp │ │ ├── bn_bitarrayByteLEBitLE_TestClass.h │ │ ├── bn_endian_TestClass.cpp │ │ ├── bn_endian_TestClass.h │ │ ├── bn_pad_TestClass.cpp │ │ ├── bn_pad_TestClass.h │ │ ├── bn_string_TestClass.cpp │ │ ├── bn_string_TestClass.h │ │ ├── cli_FormatUtil_TestClass.cpp │ │ ├── cli_FormatUtil_TestClass.h │ │ ├── cli_OptionParser_TestClass.cpp │ │ ├── cli_OptionParser_TestClass.h │ │ ├── crypto_Aes128CbcEncryptedStream_TestClass.cpp │ │ ├── crypto_Aes128CbcEncryptedStream_TestClass.h │ │ ├── crypto_Aes128CbcEncryptor_TestClass.cpp │ │ ├── crypto_Aes128CbcEncryptor_TestClass.h │ │ ├── crypto_Aes128CtrEncryptedStream_TestClass.cpp │ │ ├── crypto_Aes128CtrEncryptedStream_TestClass.h │ │ ├── crypto_Aes128CtrEncryptor_TestClass.cpp │ │ ├── crypto_Aes128CtrEncryptor_TestClass.h │ │ ├── crypto_Aes128EcbEncryptor_TestClass.cpp │ │ ├── crypto_Aes128EcbEncryptor_TestClass.h │ │ ├── crypto_Aes128Encryptor_TestClass.cpp │ │ ├── crypto_Aes128Encryptor_TestClass.h │ │ ├── crypto_Aes128XtsEncryptor_TestClass.cpp │ │ ├── crypto_Aes128XtsEncryptor_TestClass.h │ │ ├── crypto_Aes192CbcEncryptor_TestClass.cpp │ │ ├── crypto_Aes192CbcEncryptor_TestClass.h │ │ ├── crypto_Aes192CtrEncryptor_TestClass.cpp │ │ ├── crypto_Aes192CtrEncryptor_TestClass.h │ │ ├── crypto_Aes192EcbEncryptor_TestClass.cpp │ │ ├── crypto_Aes192EcbEncryptor_TestClass.h │ │ ├── crypto_Aes192Encryptor_TestClass.cpp │ │ ├── crypto_Aes192Encryptor_TestClass.h │ │ ├── crypto_Aes256CbcEncryptor_TestClass.cpp │ │ ├── crypto_Aes256CbcEncryptor_TestClass.h │ │ ├── crypto_Aes256CtrEncryptor_TestClass.cpp │ │ ├── crypto_Aes256CtrEncryptor_TestClass.h │ │ ├── crypto_Aes256EcbEncryptor_TestClass.cpp │ │ ├── crypto_Aes256EcbEncryptor_TestClass.h │ │ ├── crypto_Aes256Encryptor_TestClass.cpp │ │ ├── crypto_Aes256Encryptor_TestClass.h │ │ ├── crypto_Aes256XtsEncryptor_TestClass.cpp │ │ ├── crypto_Aes256XtsEncryptor_TestClass.h │ │ ├── crypto_HmacMd5Generator_TestClass.cpp │ │ ├── crypto_HmacMd5Generator_TestClass.h │ │ ├── crypto_HmacSha1Generator_TestClass.cpp │ │ ├── crypto_HmacSha1Generator_TestClass.h │ │ ├── crypto_HmacSha256Generator_TestClass.cpp │ │ ├── crypto_HmacSha256Generator_TestClass.h │ │ ├── crypto_HmacSha512Generator_TestClass.cpp │ │ ├── crypto_HmacSha512Generator_TestClass.h │ │ ├── crypto_Md5Generator_TestClass.cpp │ │ ├── crypto_Md5Generator_TestClass.h │ │ ├── crypto_Pbkdf1Md5KeyDeriver_TestClass.cpp │ │ ├── crypto_Pbkdf1Md5KeyDeriver_TestClass.h │ │ ├── crypto_Pbkdf1Sha1KeyDeriver_TestClass.cpp │ │ ├── crypto_Pbkdf1Sha1KeyDeriver_TestClass.h │ │ ├── crypto_Pbkdf2Sha1KeyDeriver_TestClass.cpp │ │ ├── crypto_Pbkdf2Sha1KeyDeriver_TestClass.h │ │ ├── crypto_Pbkdf2Sha256KeyDeriver_TestClass.cpp │ │ ├── crypto_Pbkdf2Sha256KeyDeriver_TestClass.h │ │ ├── crypto_Pbkdf2Sha512KeyDeriver_TestClass.cpp │ │ ├── crypto_Pbkdf2Sha512KeyDeriver_TestClass.h │ │ ├── crypto_PseudoRandomByteGenerator_TestClass.cpp │ │ ├── crypto_PseudoRandomByteGenerator_TestClass.h │ │ ├── crypto_Rsa1024OaepSha256Encryptor_TestClass.cpp │ │ ├── crypto_Rsa1024OaepSha256Encryptor_TestClass.h │ │ ├── crypto_Rsa1024Pkcs1Md5Signer_TestClass.cpp │ │ ├── crypto_Rsa1024Pkcs1Md5Signer_TestClass.h │ │ ├── crypto_Rsa1024Pkcs1Sha1Signer_TestClass.cpp │ │ ├── crypto_Rsa1024Pkcs1Sha1Signer_TestClass.h │ │ ├── crypto_Rsa1024Pkcs1Sha256Signer_TestClass.cpp │ │ ├── crypto_Rsa1024Pkcs1Sha256Signer_TestClass.h │ │ ├── crypto_Rsa1024Pkcs1Sha512Signer_TestClass.cpp │ │ ├── crypto_Rsa1024Pkcs1Sha512Signer_TestClass.h │ │ ├── crypto_Rsa1024PssSha256Signer_TestClass.cpp │ │ ├── crypto_Rsa1024PssSha256Signer_TestClass.h │ │ ├── crypto_Rsa1024PssSha512Signer_TestClass.cpp │ │ ├── crypto_Rsa1024PssSha512Signer_TestClass.h │ │ ├── crypto_Rsa2048OaepSha256Encryptor_TestClass.cpp │ │ ├── crypto_Rsa2048OaepSha256Encryptor_TestClass.h │ │ ├── crypto_Rsa2048OaepSha512Encryptor_TestClass.cpp │ │ ├── crypto_Rsa2048OaepSha512Encryptor_TestClass.h │ │ ├── crypto_Rsa2048Pkcs1Md5Signer_TestClass.cpp │ │ ├── crypto_Rsa2048Pkcs1Md5Signer_TestClass.h │ │ ├── crypto_Rsa2048Pkcs1Sha1Signer_TestClass.cpp │ │ ├── crypto_Rsa2048Pkcs1Sha1Signer_TestClass.h │ │ ├── crypto_Rsa2048Pkcs1Sha256Signer_TestClass.cpp │ │ ├── crypto_Rsa2048Pkcs1Sha256Signer_TestClass.h │ │ ├── crypto_Rsa2048Pkcs1Sha512Signer_TestClass.cpp │ │ ├── crypto_Rsa2048Pkcs1Sha512Signer_TestClass.h │ │ ├── crypto_Rsa2048PssSha256Signer_TestClass.cpp │ │ ├── crypto_Rsa2048PssSha256Signer_TestClass.h │ │ ├── crypto_Rsa2048PssSha512Signer_TestClass.cpp │ │ ├── crypto_Rsa2048PssSha512Signer_TestClass.h │ │ ├── crypto_Rsa4096OaepSha256Encryptor_TestClass.cpp │ │ ├── crypto_Rsa4096OaepSha256Encryptor_TestClass.h │ │ ├── crypto_Rsa4096OaepSha512Encryptor_TestClass.cpp │ │ ├── crypto_Rsa4096OaepSha512Encryptor_TestClass.h │ │ ├── crypto_Rsa4096Pkcs1Md5Signer_TestClass.cpp │ │ ├── crypto_Rsa4096Pkcs1Md5Signer_TestClass.h │ │ ├── crypto_Rsa4096Pkcs1Sha1Signer_TestClass.cpp │ │ ├── crypto_Rsa4096Pkcs1Sha1Signer_TestClass.h │ │ ├── crypto_Rsa4096Pkcs1Sha256Signer_TestClass.cpp │ │ ├── crypto_Rsa4096Pkcs1Sha256Signer_TestClass.h │ │ ├── crypto_Rsa4096Pkcs1Sha512Signer_TestClass.cpp │ │ ├── crypto_Rsa4096Pkcs1Sha512Signer_TestClass.h │ │ ├── crypto_Rsa4096PssSha256Signer_TestClass.cpp │ │ ├── crypto_Rsa4096PssSha256Signer_TestClass.h │ │ ├── crypto_Rsa4096PssSha512Signer_TestClass.cpp │ │ ├── crypto_Rsa4096PssSha512Signer_TestClass.h │ │ ├── crypto_Sha1Generator_TestClass.cpp │ │ ├── crypto_Sha1Generator_TestClass.h │ │ ├── crypto_Sha256Generator_TestClass.cpp │ │ ├── crypto_Sha256Generator_TestClass.h │ │ ├── crypto_Sha512Generator_TestClass.cpp │ │ ├── crypto_Sha512Generator_TestClass.h │ │ ├── io_BasicPathResolver_TestClass.cpp │ │ ├── io_BasicPathResolver_TestClass.h │ │ ├── io_ConcatenatedStream_TestClass.cpp │ │ ├── io_ConcatenatedStream_TestClass.h │ │ ├── io_FileStream_TestClass.cpp │ │ ├── io_FileStream_TestClass.h │ │ ├── io_LocalFileSystem_TestClass.cpp │ │ ├── io_LocalFileSystem_TestClass.h │ │ ├── io_MemorySource_TestClass.cpp │ │ ├── io_MemorySource_TestClass.h │ │ ├── io_MemoryStream_TestClass.cpp │ │ ├── io_MemoryStream_TestClass.h │ │ ├── io_OverlayedSource_TestClass.cpp │ │ ├── io_OverlayedSource_TestClass.h │ │ ├── io_PaddingSource_TestClass.cpp │ │ ├── io_PaddingSource_TestClass.h │ │ ├── io_Path_TestClass.cpp │ │ ├── io_Path_TestClass.h │ │ ├── io_StreamSink_TestClass.cpp │ │ ├── io_StreamSink_TestClass.h │ │ ├── io_StreamSource_TestClass.cpp │ │ ├── io_StreamSource_TestClass.h │ │ ├── io_SubFileSystem_TestClass.cpp │ │ ├── io_SubFileSystem_TestClass.h │ │ ├── io_SubSink_TestClass.cpp │ │ ├── io_SubSink_TestClass.h │ │ ├── io_SubSource_TestClass.cpp │ │ ├── io_SubSource_TestClass.h │ │ ├── io_SubStream_TestClass.cpp │ │ ├── io_SubStream_TestClass.h │ │ ├── io_VirtualFileSystem_TestClass.cpp │ │ ├── io_VirtualFileSystem_TestClass.h │ │ ├── main.cpp │ │ ├── string_TranscodeUtil_TestClass.cpp │ │ └── string_TranscodeUtil_TestClass.h ├── makefile └── src │ ├── CciProcess.cpp │ ├── CciProcess.h │ ├── CiaProcess.cpp │ ├── CiaProcess.h │ ├── CrrProcess.cpp │ ├── CrrProcess.h │ ├── ExHeaderProcess.cpp │ ├── ExHeaderProcess.h │ ├── ExeFsProcess.cpp │ ├── ExeFsProcess.h │ ├── FirmProcess.cpp │ ├── FirmProcess.h │ ├── IvfcProcess.cpp │ ├── IvfcProcess.h │ ├── KeyBag.cpp │ ├── KeyBag.h │ ├── LzssProcess.cpp │ ├── LzssProcess.h │ ├── NcchProcess.cpp │ ├── NcchProcess.h │ ├── RomFsProcess.cpp │ ├── RomFsProcess.h │ ├── Settings.cpp │ ├── Settings.h │ ├── TikProcess.cpp │ ├── TikProcess.h │ ├── TmdProcess.cpp │ ├── TmdProcess.h │ ├── cwav.h │ ├── lzss.c │ ├── lzss.h │ ├── main.cpp │ ├── types.h │ ├── util.cpp │ ├── util.h │ └── version.h ├── makefile └── makerom ├── BUILDING.md ├── LICENSE ├── README.md ├── build └── visualstudio │ ├── makerom.sln │ ├── makerom.vcxproj │ ├── makerom.vcxproj.filters │ └── readme.txt ├── deps ├── libblz │ ├── include │ │ └── blz.h │ ├── makefile │ └── src │ │ └── blz.c ├── libmbedtls │ ├── BUILDING.md │ ├── LICENSE │ ├── README.md │ ├── apache-2.0.txt │ ├── build │ │ └── visualstudio │ │ │ ├── libmbedtls.sln │ │ │ └── libmbedtls │ │ │ ├── libmbedtls.vcxproj │ │ │ └── libmbedtls.vcxproj.filters │ ├── include │ │ └── mbedtls │ │ │ ├── aes.h │ │ │ ├── aesni.h │ │ │ ├── arc4.h │ │ │ ├── aria.h │ │ │ ├── asn1.h │ │ │ ├── asn1write.h │ │ │ ├── base64.h │ │ │ ├── bignum.h │ │ │ ├── blowfish.h │ │ │ ├── bn_mul.h │ │ │ ├── camellia.h │ │ │ ├── ccm.h │ │ │ ├── certs.h │ │ │ ├── chacha20.h │ │ │ ├── chachapoly.h │ │ │ ├── check_config.h │ │ │ ├── cipher.h │ │ │ ├── cipher_internal.h │ │ │ ├── cmac.h │ │ │ ├── compat-1.3.h │ │ │ ├── config.h │ │ │ ├── ctr_drbg.h │ │ │ ├── debug.h │ │ │ ├── des.h │ │ │ ├── dhm.h │ │ │ ├── ecdh.h │ │ │ ├── ecdsa.h │ │ │ ├── ecjpake.h │ │ │ ├── ecp.h │ │ │ ├── ecp_internal.h │ │ │ ├── entropy.h │ │ │ ├── entropy_poll.h │ │ │ ├── error.h │ │ │ ├── gcm.h │ │ │ ├── havege.h │ │ │ ├── hkdf.h │ │ │ ├── hmac_drbg.h │ │ │ ├── md.h │ │ │ ├── md2.h │ │ │ ├── md4.h │ │ │ ├── md5.h │ │ │ ├── md_internal.h │ │ │ ├── memory_buffer_alloc.h │ │ │ ├── net.h │ │ │ ├── net_sockets.h │ │ │ ├── nist_kw.h │ │ │ ├── oid.h │ │ │ ├── padlock.h │ │ │ ├── pem.h │ │ │ ├── pk.h │ │ │ ├── pk_internal.h │ │ │ ├── pkcs11.h │ │ │ ├── pkcs12.h │ │ │ ├── pkcs5.h │ │ │ ├── platform.h │ │ │ ├── platform_time.h │ │ │ ├── platform_util.h │ │ │ ├── poly1305.h │ │ │ ├── ripemd160.h │ │ │ ├── rsa.h │ │ │ ├── rsa_internal.h │ │ │ ├── sha1.h │ │ │ ├── sha256.h │ │ │ ├── sha512.h │ │ │ ├── ssl.h │ │ │ ├── ssl_cache.h │ │ │ ├── ssl_ciphersuites.h │ │ │ ├── ssl_cookie.h │ │ │ ├── ssl_internal.h │ │ │ ├── ssl_ticket.h │ │ │ ├── threading.h │ │ │ ├── timing.h │ │ │ ├── version.h │ │ │ ├── x509.h │ │ │ ├── x509_crl.h │ │ │ ├── x509_crt.h │ │ │ ├── x509_csr.h │ │ │ └── xtea.h │ ├── makefile │ └── src │ │ ├── aes.c │ │ ├── aesni.c │ │ ├── arc4.c │ │ ├── aria.c │ │ ├── asn1parse.c │ │ ├── asn1write.c │ │ ├── base64.c │ │ ├── bignum.c │ │ ├── blowfish.c │ │ ├── camellia.c │ │ ├── ccm.c │ │ ├── certs.c │ │ ├── chacha20.c │ │ ├── chachapoly.c │ │ ├── cipher.c │ │ ├── cipher_wrap.c │ │ ├── cmac.c │ │ ├── ctr_drbg.c │ │ ├── debug.c │ │ ├── des.c │ │ ├── dhm.c │ │ ├── ecdh.c │ │ ├── ecdsa.c │ │ ├── ecjpake.c │ │ ├── ecp.c │ │ ├── ecp_curves.c │ │ ├── entropy.c │ │ ├── entropy_poll.c │ │ ├── error.c │ │ ├── gcm.c │ │ ├── havege.c │ │ ├── hkdf.c │ │ ├── hmac_drbg.c │ │ ├── md.c │ │ ├── md2.c │ │ ├── md4.c │ │ ├── md5.c │ │ ├── md_wrap.c │ │ ├── memory_buffer_alloc.c │ │ ├── net_sockets.c │ │ ├── nist_kw.c │ │ ├── oid.c │ │ ├── padlock.c │ │ ├── pem.c │ │ ├── pk.c │ │ ├── pk_wrap.c │ │ ├── pkcs11.c │ │ ├── pkcs12.c │ │ ├── pkcs5.c │ │ ├── pkparse.c │ │ ├── pkwrite.c │ │ ├── platform.c │ │ ├── platform_util.c │ │ ├── poly1305.c │ │ ├── ripemd160.c │ │ ├── rsa.c │ │ ├── rsa_internal.c │ │ ├── sha1.c │ │ ├── sha256.c │ │ ├── sha512.c │ │ ├── ssl_cache.c │ │ ├── ssl_ciphersuites.c │ │ ├── ssl_cli.c │ │ ├── ssl_cookie.c │ │ ├── ssl_srv.c │ │ ├── ssl_ticket.c │ │ ├── ssl_tls.c │ │ ├── threading.c │ │ ├── timing.c │ │ ├── version.c │ │ ├── version_features.c │ │ ├── x509.c │ │ ├── x509_create.c │ │ ├── x509_crl.c │ │ ├── x509_crt.c │ │ ├── x509_csr.c │ │ ├── x509write_crt.c │ │ ├── x509write_csr.c │ │ └── xtea.c └── libyaml │ ├── LICENSE │ ├── include │ └── libyaml │ │ └── yaml.h │ ├── makefile │ └── src │ ├── api.c │ ├── dumper.c │ ├── emitter.c │ ├── loader.c │ ├── parser.c │ ├── reader.c │ ├── scanner.c │ ├── writer.c │ └── yaml_private.h ├── makefile └── src ├── accessdesc.c ├── accessdesc.h ├── aes_keygen.c ├── aes_keygen.h ├── cardinfo.c ├── cardinfo.h ├── certs.c ├── certs.h ├── cia.c ├── cia.h ├── cia_build.h ├── cia_read.h ├── code.c ├── code.h ├── crr.h ├── crypto.c ├── crypto.h ├── ctr_utils.c ├── ctr_utils.h ├── desc ├── desc.h ├── dev_sigdata.h └── presets.h ├── elf.c ├── elf.h ├── exefs.c ├── exefs.h ├── exefs_build.h ├── exefs_read.h ├── exheader.c ├── exheader.h ├── exheader_build.h ├── exheader_read.h ├── keyset.c ├── keyset.h ├── lib.h ├── makerom.c ├── ncch.c ├── ncch.h ├── ncch_build.h ├── ncch_logo.h ├── ncch_read.h ├── ncsd.c ├── ncsd.h ├── ncsd_build.h ├── ncsd_read.h ├── oschar.c ├── oschar.h ├── pki ├── dev.h ├── dev_legacy.h ├── prod.h ├── prod_legacy.h ├── rsa_key.h └── test.h ├── romfs.c ├── romfs.h ├── romfs_fs.c ├── romfs_fs.h ├── romfs_gen.c ├── romfs_gen.h ├── romfs_import.c ├── romfs_import.h ├── rsf_settings.c ├── rsf_settings.h ├── srl.h ├── tik.c ├── tik.h ├── tik_build.h ├── tik_read.h ├── titleid.c ├── titleid.h ├── tmd.c ├── tmd.h ├── tmd_build.h ├── tmd_read.h ├── types.h ├── user_settings.c ├── user_settings.h ├── utils.c ├── utils.h ├── yaml_parser.c └── yaml_parser.h /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /.github/workflows/Build_MakeROM.yml: -------------------------------------------------------------------------------- 1 | name: Compile MakeROM (on master branch) 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | release: 9 | types: [ created ] 10 | workflow_dispatch: 11 | 12 | jobs: 13 | build: 14 | name: Compile ${{ matrix.prog }} for ${{ matrix.dist }} 15 | runs-on: ${{ matrix.os }} 16 | strategy: 17 | matrix: 18 | dist: [ubuntu_x86_64, macos_x86_64, macos_arm64, win_x86_64] 19 | prog: [makerom] 20 | include: 21 | - dist: ubuntu_x86_64 22 | os: ubuntu-latest 23 | arch: x86_64 24 | - dist: macos_x86_64 25 | os: macos-latest 26 | arch: x86_64 27 | - dist: macos_arm64 28 | os: macos-latest 29 | arch: arm64 30 | - dist: win_x86_64 31 | os: windows-latest 32 | arch: x86_64 33 | binExt: .exe 34 | steps: 35 | - uses: actions/checkout@v4 36 | with: 37 | fetch-depth: 0 38 | - name: Compile ${{ matrix.prog }} 39 | working-directory: ${{ matrix.prog }} 40 | run: make PROJECT_PLATFORM_ARCH=${{ matrix.arch }} deps all 41 | - uses: actions/upload-artifact@v4 42 | with: 43 | name: ${{ matrix.prog }}-${{ matrix.dist }} 44 | path: ./${{ matrix.prog }}/bin/${{ matrix.prog }}${{ matrix.binExt }} 45 | if-no-files-found: error 46 | -------------------------------------------------------------------------------- /.vs/ProjectSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "CurrentProjectSetting": null 3 | } -------------------------------------------------------------------------------- /.vs/VSWorkspaceState.json: -------------------------------------------------------------------------------- 1 | { 2 | "ExpandedNodes": [ 3 | "", 4 | "\\ctrtool", 5 | "\\makerom" 6 | ], 7 | "SelectedNode": "\\makerom\\keyset.c", 8 | "PreviewInSolutionExplorer": false 9 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Project_CTR 2 | Project CTR is a collection of custom Nintendo 3DS tools. 3 | 4 | ## Tools 5 | [ctrtool](ctrtool/README.md) - a tool to read/extract Nintendo 3DS files. ([download](https://github.com/3DSGuy/Project_CTR/releases/tag/ctrtool-v1.1.0)) 6 | 7 | [makerom](makerom/README.md) - creates CTR cxi/cfa/cci/cia files. ([download](https://github.com/3DSGuy/Project_CTR/releases/tag/makerom-v0.18.3)) 8 | -------------------------------------------------------------------------------- /ctrtool/BUILDING.md: -------------------------------------------------------------------------------- 1 | # Building 2 | ## Linux (incl. Windows Subsystem for Linux) & MacOS - Makefile 3 | ### Requirements 4 | * `make` 5 | * Terminal access 6 | * Typical GNU compatible development tools (e.g. `clang`, `g++`, `c++`, `ar` etc) with __C++11__ support 7 | 8 | ### Using Makefile 9 | * `make` (default) - Compile program 10 | * Compiling the program requires local dependencies to be compiled via `make deps` beforehand 11 | * `make clean` - Remove executable and object files 12 | * `make deps` - Compile locally included dependency libraries 13 | * `make clean_deps` - Remove compiled library binaries and object files 14 | 15 | ## Native Windows - Visual Studio 16 | ### Requirements 17 | * [Visual Studio Community](https://visualstudio.microsoft.com/vs/community/) 2015 / 2017 / 2019 18 | 19 | ### Compiling CTRTool 20 | * Open `build/visualstudio/CTRTool.sln` in Visual Studio 21 | * Select Target (e.g `Debug`|`Release` & `x86`|`x64`) 22 | * Navigate to `Build`->`Build Solution` -------------------------------------------------------------------------------- /ctrtool/deps/libbroadon-es/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Jack 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /ctrtool/deps/libbroadon-es/README.md: -------------------------------------------------------------------------------- 1 | # libbroadon-es 2 | C++ Library for processing Nintendo's ES DRM formats. 3 | -------------------------------------------------------------------------------- /ctrtool/deps/libbroadon-es/include/brd/es.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // definitions 4 | #include 5 | #include 6 | #include 7 | #include -------------------------------------------------------------------------------- /ctrtool/deps/libfmt/LICENSE.rst: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 - present, Victor Zverovich 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | --- Optional exception to the license --- 23 | 24 | As an exception, if, as a result of your compiling your source code, portions 25 | of this Software are embedded into a machine-executable object form of such 26 | source code, you may redistribute such embedded portions in such object form 27 | without including the above copyright and permission notices. -------------------------------------------------------------------------------- /ctrtool/deps/libfmt/README.md: -------------------------------------------------------------------------------- 1 | # libfmt 2 | Clone of {fmt} (https://github.com/fmtlib/fmt) 3 | -------------------------------------------------------------------------------- /ctrtool/deps/libfmt/build/visualstudio/libfmt.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.31229.75 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libfmt", "libfmt\libfmt.vcxproj", "{F4B0540E-0AAE-4006-944B-356944EF61FA}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {F4B0540E-0AAE-4006-944B-356944EF61FA}.Debug|x64.ActiveCfg = Debug|x64 17 | {F4B0540E-0AAE-4006-944B-356944EF61FA}.Debug|x64.Build.0 = Debug|x64 18 | {F4B0540E-0AAE-4006-944B-356944EF61FA}.Debug|x86.ActiveCfg = Debug|Win32 19 | {F4B0540E-0AAE-4006-944B-356944EF61FA}.Debug|x86.Build.0 = Debug|Win32 20 | {F4B0540E-0AAE-4006-944B-356944EF61FA}.Release|x64.ActiveCfg = Release|x64 21 | {F4B0540E-0AAE-4006-944B-356944EF61FA}.Release|x64.Build.0 = Release|x64 22 | {F4B0540E-0AAE-4006-944B-356944EF61FA}.Release|x86.ActiveCfg = Release|Win32 23 | {F4B0540E-0AAE-4006-944B-356944EF61FA}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {EA4E4F87-6367-4723-8641-6767757CD6DD} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /ctrtool/deps/libfmt/include/fmt/locale.h: -------------------------------------------------------------------------------- 1 | #include "xchar.h" 2 | #warning fmt/locale.h is deprecated, include fmt/format.h or fmt/xchar.h instead 3 | -------------------------------------------------------------------------------- /ctrtool/deps/libmbedtls/LICENSE: -------------------------------------------------------------------------------- 1 | Unless specifically indicated otherwise in a file, files are licensed 2 | under the Apache 2.0 license, as can be found in: apache-2.0.txt 3 | -------------------------------------------------------------------------------- /ctrtool/deps/libmbedtls/README.md: -------------------------------------------------------------------------------- 1 | # libmbedtls 2 | Cryptographic functions. Clone of [mbedtls 2.16.5](https://github.com/ARMmbed/mbedtls/tree/mbedtls-2.16). 3 | -------------------------------------------------------------------------------- /ctrtool/deps/libmbedtls/build/visualstudio/libmbedtls.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28010.2036 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libmbedtls", "libmbedtls\libmbedtls.vcxproj", "{7A7C66F3-2B5B-4E23-85D8-2A74FEDAD92C}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {7A7C66F3-2B5B-4E23-85D8-2A74FEDAD92C}.Debug|x64.ActiveCfg = Debug|x64 17 | {7A7C66F3-2B5B-4E23-85D8-2A74FEDAD92C}.Debug|x64.Build.0 = Debug|x64 18 | {7A7C66F3-2B5B-4E23-85D8-2A74FEDAD92C}.Debug|x86.ActiveCfg = Debug|Win32 19 | {7A7C66F3-2B5B-4E23-85D8-2A74FEDAD92C}.Debug|x86.Build.0 = Debug|Win32 20 | {7A7C66F3-2B5B-4E23-85D8-2A74FEDAD92C}.Release|x64.ActiveCfg = Release|x64 21 | {7A7C66F3-2B5B-4E23-85D8-2A74FEDAD92C}.Release|x64.Build.0 = Release|x64 22 | {7A7C66F3-2B5B-4E23-85D8-2A74FEDAD92C}.Release|x86.ActiveCfg = Release|Win32 23 | {7A7C66F3-2B5B-4E23-85D8-2A74FEDAD92C}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {339FDA10-37B3-49E3-B5F4-44515FFBBC6A} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /ctrtool/deps/libmbedtls/include/mbedtls/net.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file net.h 3 | * 4 | * \brief Deprecated header file that includes net_sockets.h 5 | * 6 | * \deprecated Superseded by mbedtls/net_sockets.h 7 | */ 8 | /* 9 | * Copyright (C) 2006-2016, ARM Limited, All Rights Reserved 10 | * SPDX-License-Identifier: Apache-2.0 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 13 | * not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * http://www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | * 24 | * This file is part of mbed TLS (https://tls.mbed.org) 25 | */ 26 | #if !defined(MBEDTLS_CONFIG_FILE) 27 | #include "config.h" 28 | #else 29 | #include MBEDTLS_CONFIG_FILE 30 | #endif 31 | 32 | #if !defined(MBEDTLS_DEPRECATED_REMOVED) 33 | #include "net_sockets.h" 34 | #if defined(MBEDTLS_DEPRECATED_WARNING) 35 | #warning "Deprecated header file: Superseded by mbedtls/net_sockets.h" 36 | #endif /* MBEDTLS_DEPRECATED_WARNING */ 37 | #endif /* !MBEDTLS_DEPRECATED_REMOVED */ 38 | -------------------------------------------------------------------------------- /ctrtool/deps/libnintendo-n3ds/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Jack 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /ctrtool/deps/libnintendo-n3ds/README.md: -------------------------------------------------------------------------------- 1 | # libnintendo-n3ds 2 | C++ Library for parsing Nintendo 3DS file formats 3 | -------------------------------------------------------------------------------- /ctrtool/deps/libnintendo-n3ds/include/ntd/n3ds.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // definitions 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | // Wrapped IStream 17 | #include 18 | 19 | // Utilities 20 | #include 21 | 22 | // VirtualFileSystem metadata generators 23 | #include 24 | #include 25 | #include 26 | #include -------------------------------------------------------------------------------- /ctrtool/deps/libnintendo-n3ds/include/ntd/n3ds/CciFsSnapshotGenerator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace ntd { namespace n3ds { 5 | 6 | struct CciFsShapshotGenerator : public tc::io::VirtualFileSystem::FileSystemSnapshot 7 | { 8 | public: 9 | CciFsShapshotGenerator(const std::shared_ptr& stream); 10 | private: 11 | CciFsShapshotGenerator(); 12 | 13 | std::shared_ptr mBaseStream; 14 | size_t mCurDir; 15 | 16 | void addFile(const std::string& name, int64_t offset, int64_t size); 17 | }; 18 | 19 | }} // namespace ntd::n3ds -------------------------------------------------------------------------------- /ctrtool/deps/libnintendo-n3ds/include/ntd/n3ds/CiaFsSnapshotGenerator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace ntd { namespace n3ds { 5 | 6 | struct CiaFsSnapshotGenerator : public tc::io::VirtualFileSystem::FileSystemSnapshot 7 | { 8 | public: 9 | CiaFsSnapshotGenerator(const std::shared_ptr& stream); 10 | private: 11 | CiaFsSnapshotGenerator(); 12 | 13 | std::shared_ptr mBaseStream; 14 | size_t mCurDir; 15 | 16 | void addFile(const std::string& name, int64_t offset, int64_t size); 17 | }; 18 | 19 | }} // namespace ntd::n3ds -------------------------------------------------------------------------------- /ctrtool/deps/libnintendo-n3ds/include/ntd/n3ds/CtrKeyGenerator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace ntd { namespace n3ds { 5 | 6 | class CtrKeyGenerator 7 | { 8 | public: 9 | static void GenerateKey(const uint8_t *x, const uint8_t *y, uint8_t *key); 10 | private: 11 | static int32_t wrap_index(int32_t i); 12 | static void n128_rrot(const uint8_t *in, uint32_t rot, uint8_t *out); 13 | static void n128_lrot(const uint8_t *in, uint32_t rot, uint8_t *out); 14 | static void n128_add(const uint8_t *a, const uint8_t *b, uint8_t *out); 15 | static void n128_sub(const uint8_t *a, const uint8_t *b, uint8_t *out); 16 | static void n128_xor(const uint8_t *a, const uint8_t *b, uint8_t *out); 17 | }; 18 | 19 | }} // namespace ntd::n3ds -------------------------------------------------------------------------------- /ctrtool/deps/libnintendo-n3ds/include/ntd/n3ds/ExeFsSnapshotGenerator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace ntd { namespace n3ds { 5 | 6 | struct ExeFsSnapshotGenerator : public tc::io::VirtualFileSystem::FileSystemSnapshot 7 | { 8 | public: 9 | ExeFsSnapshotGenerator(const std::shared_ptr& stream, bool verify_hashes = true); 10 | private: 11 | ExeFsSnapshotGenerator(); 12 | }; 13 | 14 | }} // namespace ntd::n3ds -------------------------------------------------------------------------------- /ctrtool/deps/libnintendo-n3ds/include/ntd/n3ds/RomFsSnapshotGenerator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | namespace ntd { namespace n3ds { 7 | 8 | struct RomFsSnapshotGenerator : public tc::io::VirtualFileSystem::FileSystemSnapshot 9 | { 10 | public: 11 | RomFsSnapshotGenerator(const std::shared_ptr& stream); 12 | private: 13 | RomFsSnapshotGenerator(); 14 | 15 | std::shared_ptr mBaseStream; 16 | 17 | int64_t mDataOffset; 18 | 19 | tc::ByteData mDirEntryTable; 20 | std::map mDirParentVaddrMap; 21 | inline ntd::n3ds::RomFsDirectoryEntry* getDirEntry(uint32_t vaddr) { return (ntd::n3ds::RomFsDirectoryEntry*)(mDirEntryTable.data() + vaddr); } 22 | 23 | tc::ByteData mFileEntryTable; 24 | inline ntd::n3ds::RomFsFileEntry* getFileEntry(uint32_t vaddr) { return (ntd::n3ds::RomFsFileEntry*)(mFileEntryTable.data() + vaddr); } 25 | 26 | void addFile(const ntd::n3ds::RomFsFileEntry* file_entry, size_t parent_dir); 27 | void addDirectory(const ntd::n3ds::RomFsDirectoryEntry* dir_entry, size_t parent_dir); 28 | }; 29 | 30 | }} // namespace ntd::n3ds -------------------------------------------------------------------------------- /ctrtool/deps/libnintendo-n3ds/include/ntd/n3ds/es.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | //#include 4 | #include 5 | #include -------------------------------------------------------------------------------- /ctrtool/deps/libnintendo-n3ds/include/ntd/n3ds/es/ISigner.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | namespace ntd { namespace n3ds { namespace es { 7 | 8 | class ISigner 9 | { 10 | public: 11 | virtual ~ISigner() = default; 12 | virtual const std::string& getIssuer() = 0; 13 | virtual brd::es::ESSigType getSigType() = 0; 14 | virtual bool signHash(const byte_t* hash, byte_t* signature) = 0; 15 | virtual bool verifyHash(const byte_t* hash, const byte_t* signature) = 0; 16 | }; 17 | 18 | }}} // namespace ntd::n3ds::es -------------------------------------------------------------------------------- /ctrtool/deps/libnintendo-n3ds/include/ntd/n3ds/es/RsaSigner.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | 10 | namespace ntd { namespace n3ds { namespace es { 11 | 12 | class RsaSigner : public ntd::n3ds::es::ISigner 13 | { 14 | public: 15 | RsaSigner(brd::es::ESSigType sig_type, const std::string& issuer, const tc::crypto::RsaKey& rsa_key); 16 | 17 | const std::string& getIssuer(); 18 | 19 | brd::es::ESSigType getSigType(); 20 | 21 | bool signHash(const byte_t* hash, byte_t* signature); 22 | 23 | bool verifyHash(const byte_t* hash, const byte_t* signature); 24 | private: 25 | brd::es::ESSigType mSigType; 26 | std::string mIssuer; 27 | tc::crypto::RsaKey mRsaKey; 28 | }; 29 | 30 | }}} // namespace ntd::n3ds::es -------------------------------------------------------------------------------- /ctrtool/deps/libnintendo-n3ds/include/ntd/n3ds/es/Signature.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | namespace ntd { namespace n3ds { namespace es { 13 | 14 | size_t getSignatureSizeFromSigType(brd::es::ESSigType sig_type); 15 | size_t getSignatureIssuerOffset(brd::es::ESSigType sig_type); 16 | 17 | struct Signature 18 | { 19 | public: 20 | Signature() : 21 | sig_type(), 22 | sig(), 23 | issuer() 24 | {} 25 | public: 26 | brd::es::ESSigType sig_type; 27 | tc::ByteData sig; 28 | std::string issuer; 29 | }; 30 | 31 | class SignatureDeserialiser : public Signature 32 | { 33 | public: 34 | // input stream 35 | SignatureDeserialiser(const std::shared_ptr& stream); 36 | private: 37 | std::string mModuleLabel; 38 | }; 39 | 40 | /* 41 | class SignatureSerialiser : public tc::io::IStream 42 | { 43 | public: 44 | SignatureSerialiser(); 45 | private: 46 | std::string mModuleLabel; 47 | } 48 | */ 49 | 50 | }}} // namespace ntd::n3ds::es -------------------------------------------------------------------------------- /ctrtool/deps/libnintendo-n3ds/include/ntd/n3ds/exefs.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace ntd { namespace n3ds { 5 | 6 | #pragma pack(push,1) 7 | 8 | struct ExeFsHeader 9 | { 10 | static const size_t kFileNum = 8; 11 | static const size_t kExeFsSectionAlignSize = 0x200; 12 | 13 | struct FileEntry 14 | { 15 | tc::bn::string<8> name; 16 | tc::bn::le32 offset; 17 | tc::bn::le32 size; 18 | }; 19 | 20 | using FileHash = std::array; 21 | 22 | std::array file_table; 23 | tc::bn::pad<0x80> reserved; 24 | std::array hash_table; 25 | 26 | // inline method to get pointer to file hash, since the ordering is unintuitive 27 | FileHash* getFileHash(size_t index) { return (index < kFileNum) ? &hash_table[kFileNum - 1 - index] : nullptr; } 28 | }; 29 | static_assert(sizeof(ExeFsHeader) == 0x200, "ExeFsHeader had invalid size"); 30 | 31 | #pragma pack(pop) 32 | 33 | }} // namespace ntd::n3ds -------------------------------------------------------------------------------- /ctrtool/deps/libnintendo-n3ds/include/ntd/n3ds/firm.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace ntd { namespace n3ds { 5 | 6 | #pragma pack(push,1) 7 | 8 | struct FirmwareHeader 9 | { 10 | static const uint32_t kStructMagic = tc::bn::make_struct_magic_uint32("FIRM"); 11 | 12 | struct SectionHeader 13 | { 14 | enum CopyMethod 15 | { 16 | CopyMethod_NDMA = 0, 17 | CopyMethod_XDMA = 1, 18 | CopyMethod_MEMCPY = 2 19 | }; 20 | 21 | tc::bn::le32 offset; 22 | tc::bn::le32 address; 23 | tc::bn::le32 size; 24 | tc::bn::le32 copy_method; 25 | std::array hash; // SHA2-256 over 0x000+offset - 0x000+offset+size-1 26 | }; 27 | 28 | tc::bn::le32 struct_magic; // FIRM 29 | tc::bn::le32 priority; 30 | tc::bn::le32 entrypoint_arm11; 31 | tc::bn::le32 entrypoint_arm9; 32 | tc::bn::pad<0x30> reserved1; 33 | std::array section; 34 | std::array signature; // RSA2048-PKCS1-SHA2-256 over 0x000-0x0ff 35 | }; 36 | static_assert(sizeof(FirmwareHeader) == 0x200, "FirmwareHeader had invalid size"); 37 | 38 | #pragma pack(pop) 39 | 40 | }} // namespace ntd::n3ds -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/DoxygenMainpage.md: -------------------------------------------------------------------------------- 1 | # libtoolchain - API Reference {#mainpage} 2 | Notice: __This API is currently under development and is subject to change without notice.__ 3 | 4 | -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/LICENSE: -------------------------------------------------------------------------------- 1 | libtoolchain 2 | Copyright (c) 2019-2020 Jack (jakcron) 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all 12 | copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | SOFTWARE. -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/include/tc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file tc.h 3 | * @brief Declaration of the libtoolchain namespace 4 | **/ 5 | #pragma once 6 | #include 7 | 8 | /** 9 | * @namespace tc 10 | * @brief Root namespace for libtoolchain 11 | **/ 12 | // classes 13 | #include 14 | #include 15 | 16 | // sub namespaces 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | // exceptions 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/include/tc/AccessViolationException.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file AccessViolationException.h 3 | * @brief Declaration of tc::AccessViolationException 4 | * @author Jack (jakcron) 5 | * @version 0.1 6 | * @date 2020/01/22 7 | **/ 8 | #pragma once 9 | #include 10 | 11 | namespace tc { 12 | 13 | /** 14 | * @class AccessViolationException 15 | * @brief The exception that is thrown when there is an attempt to read or write protected memory. 16 | **/ 17 | class AccessViolationException : public tc::Exception 18 | { 19 | public: 20 | /// Default Constructor 21 | AccessViolationException() noexcept : 22 | tc::Exception() 23 | { 24 | } 25 | 26 | /** 27 | * @brief Basic Parameterized Constructor 28 | * 29 | * @param[in] what Explanation for exception 30 | * 31 | * @post 32 | * - what() == what 33 | * - module() == "" 34 | * - error() == what 35 | **/ 36 | AccessViolationException(const std::string& what) noexcept : 37 | tc::Exception(what) 38 | {} 39 | 40 | /** 41 | * @brief Parameterized Constructor 42 | * 43 | * @param[in] module Name of module that threw the exception 44 | * @param[in] what Explanation for exception 45 | * 46 | * @post 47 | * - what() == "[" + module + " ERROR] " + what 48 | * - module() == module 49 | * - error() == what 50 | **/ 51 | AccessViolationException(const std::string& module, const std::string& what) noexcept : 52 | tc::Exception(module, what) 53 | { 54 | } 55 | }; 56 | 57 | } // namespace tc -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/include/tc/ArgumentException.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file ArgumentException.h 3 | * @brief Declaration of tc::ArgumentException 4 | * @author Jack (jakcron) 5 | * @version 0.1 6 | * @date 2020/01/22 7 | **/ 8 | #pragma once 9 | #include 10 | 11 | namespace tc { 12 | 13 | /** 14 | * @class ArgumentException 15 | * @brief The exception that is thrown when one of the arguments provided to a method is not valid. 16 | **/ 17 | class ArgumentException : public tc::Exception 18 | { 19 | public: 20 | /// Default Constructor 21 | ArgumentException() noexcept : 22 | tc::Exception() 23 | { 24 | } 25 | 26 | /** 27 | * @brief Basic Parameterized Constructor 28 | * 29 | * @param[in] what Explanation for exception 30 | * 31 | * @post 32 | * - what() == what 33 | * - module() == "" 34 | * - error() == what 35 | **/ 36 | ArgumentException(const std::string& what) noexcept : 37 | tc::Exception(what) 38 | {} 39 | 40 | /** 41 | * @brief Parameterized Constructor 42 | * 43 | * @param[in] module Name of module that threw the exception 44 | * @param[in] what Explanation for exception 45 | * 46 | * @post 47 | * - what() == "[" + module + " ERROR] " + what 48 | * - module() == module 49 | * - error() == what 50 | **/ 51 | ArgumentException(const std::string& module, const std::string& what) noexcept : 52 | tc::Exception(module, what) 53 | { 54 | } 55 | }; 56 | 57 | } // namespace tc -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/include/tc/ArithmeticException.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file ArithmeticException.h 3 | * @brief Declaration of tc::ArithmeticException 4 | * @author Jack (jakcron) 5 | * @version 0.1 6 | * @date 2020/01/22 7 | **/ 8 | #pragma once 9 | #include 10 | 11 | namespace tc { 12 | 13 | /** 14 | * @class ArithmeticException 15 | * @brief The exception that is thrown for errors in an arithmetic, casting, or conversion operation. 16 | **/ 17 | class ArithmeticException : public tc::Exception 18 | { 19 | public: 20 | /// Default Constructor 21 | ArithmeticException() noexcept : 22 | tc::Exception() 23 | { 24 | } 25 | 26 | /** 27 | * @brief Basic Parameterized Constructor 28 | * 29 | * @param[in] what Explanation for exception 30 | * 31 | * @post 32 | * - what() == what 33 | * - module() == "" 34 | * - error() == what 35 | **/ 36 | ArithmeticException(const std::string& what) noexcept : 37 | tc::Exception(what) 38 | {} 39 | 40 | /** 41 | * @brief Parameterized Constructor 42 | * 43 | * @param[in] module Name of module that threw the exception 44 | * @param[in] what Explanation for exception 45 | * 46 | * @post 47 | * - what() == "[" + module + " ERROR] " + what 48 | * - module() == module 49 | * - error() == what 50 | **/ 51 | ArithmeticException(const std::string& module, const std::string& what) noexcept : 52 | tc::Exception(module, what) 53 | { 54 | } 55 | }; 56 | 57 | } // namespace tc -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/include/tc/InvalidOperationException.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file InvalidOperationException.h 3 | * @brief Declaration of tc::InvalidOperationException 4 | * @author Jack (jakcron) 5 | * @version 0.1 6 | * @date 2020/01/22 7 | **/ 8 | #pragma once 9 | #include 10 | 11 | namespace tc { 12 | 13 | /** 14 | * @class InvalidOperationException 15 | * @brief The exception that is thrown when a method call is invalid for the object's current state. 16 | **/ 17 | class InvalidOperationException : public tc::Exception 18 | { 19 | public: 20 | /// Default Constructor 21 | InvalidOperationException() noexcept : 22 | tc::Exception() 23 | { 24 | } 25 | 26 | /** 27 | * @brief Basic Parameterized Constructor 28 | * 29 | * @param[in] what Explanation for exception 30 | * 31 | * @post 32 | * - what() == what 33 | * - module() == "" 34 | * - error() == what 35 | **/ 36 | InvalidOperationException(const std::string& what) noexcept : 37 | tc::Exception(what) 38 | {} 39 | 40 | /** 41 | * @brief Parameterized Constructor 42 | * 43 | * @param[in] module Name of module that threw the exception 44 | * @param[in] what Explanation for exception 45 | * 46 | * @post 47 | * - what() == "[" + module + " ERROR] " + what 48 | * - module() == module 49 | * - error() == what 50 | **/ 51 | InvalidOperationException(const std::string& module, const std::string& what) noexcept : 52 | tc::Exception(module, what) 53 | { 54 | } 55 | }; 56 | 57 | } // namespace tc -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/include/tc/NotImplementedException.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file NotImplementedException.h 3 | * @brief Declaration of tc::NotImplementedException 4 | * @author Jack (jakcron) 5 | * @version 0.1 6 | * @date 2020/01/22 7 | **/ 8 | #pragma once 9 | #include 10 | 11 | namespace tc { 12 | 13 | /** 14 | * @class NotImplementedException 15 | * @brief The exception that is thrown when a requested method or operation is not implemented. 16 | **/ 17 | class NotImplementedException : public tc::Exception 18 | { 19 | public: 20 | /// Default Constructor 21 | NotImplementedException() noexcept : 22 | tc::Exception() 23 | { 24 | } 25 | 26 | /** 27 | * @brief Basic Parameterized Constructor 28 | * 29 | * @param[in] what Explanation for exception 30 | * 31 | * @post 32 | * - what() == what 33 | * - module() == "" 34 | * - error() == what 35 | **/ 36 | NotImplementedException(const std::string& what) noexcept : 37 | tc::Exception(what) 38 | {} 39 | 40 | /** 41 | * @brief Parameterized Constructor 42 | * 43 | * @param[in] module Name of module that threw the exception 44 | * @param[in] what Explanation for exception 45 | * 46 | * @post 47 | * - what() == "[" + module + " ERROR] " + what 48 | * - module() == module 49 | * - error() == what 50 | **/ 51 | NotImplementedException(const std::string& module, const std::string& what) noexcept : 52 | tc::Exception(module, what) 53 | { 54 | } 55 | }; 56 | 57 | } // namespace tc -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/include/tc/OutOfMemoryException.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file OutOfMemoryException.h 3 | * @brief Declaration of tc::OutOfMemoryException 4 | * @author Jack (jakcron) 5 | * @version 0.1 6 | * @date 2020/01/22 7 | **/ 8 | #pragma once 9 | #include 10 | 11 | namespace tc { 12 | 13 | /** 14 | * @class OutOfMemoryException 15 | * @brief The exception that is thrown when there is not enough memory to continue the execution of a program. 16 | **/ 17 | class OutOfMemoryException : public tc::Exception 18 | { 19 | public: 20 | /// Default Constructor 21 | OutOfMemoryException() noexcept : 22 | tc::Exception() 23 | { 24 | } 25 | 26 | /** 27 | * @brief Basic Parameterized Constructor 28 | * 29 | * @param[in] what Explanation for exception 30 | * 31 | * @post 32 | * - what() == what 33 | * - module() == "" 34 | * - error() == what 35 | **/ 36 | OutOfMemoryException(const std::string& what) noexcept : 37 | tc::Exception(what) 38 | {} 39 | 40 | /** 41 | * @brief Parameterized Constructor 42 | * 43 | * @param[in] module Name of module that threw the exception 44 | * @param[in] what Explanation for exception 45 | * 46 | * @post 47 | * - what() == "[" + module + " ERROR] " + what 48 | * - module() == module 49 | * - error() == what 50 | **/ 51 | OutOfMemoryException(const std::string& module, const std::string& what) noexcept : 52 | tc::Exception(module, what) 53 | { 54 | } 55 | }; 56 | 57 | } // namespace tc -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/include/tc/OverflowException.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file OverflowException.h 3 | * @brief Declaration of tc::OverflowException 4 | * @author Jack (jakcron) 5 | * @version 0.1 6 | * @date 2020/01/22 7 | **/ 8 | #pragma once 9 | #include 10 | 11 | namespace tc { 12 | 13 | /** 14 | * @class OverflowException 15 | * @brief The exception that is thrown when an arithmetic, casting, or conversion operation in a checked context results in an overflow. 16 | **/ 17 | class OverflowException : public tc::ArithmeticException 18 | { 19 | public: 20 | /// Default Constructor 21 | OverflowException() noexcept : 22 | tc::ArithmeticException() 23 | { 24 | } 25 | 26 | /** 27 | * @brief Basic Parameterized Constructor 28 | * 29 | * @param[in] what Explanation for exception 30 | * 31 | * @post 32 | * - what() == what 33 | * - module() == "" 34 | * - error() == what 35 | **/ 36 | OverflowException(const std::string& what) noexcept : 37 | tc::ArithmeticException(what) 38 | {} 39 | 40 | /** 41 | * @brief Parameterized Constructor 42 | * 43 | * @param[in] module Name of module that threw the exception 44 | * @param[in] what Explanation for exception 45 | * 46 | * @post 47 | * - what() == "[" + module + " ERROR] " + what 48 | * - module() == module 49 | * - error() == what 50 | **/ 51 | OverflowException(const std::string& module, const std::string& what) noexcept : 52 | tc::ArithmeticException(module, what) 53 | { 54 | } 55 | }; 56 | 57 | } // namespace tc -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/include/tc/PlatformErrorHandlingUtil.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file PlatformErrorHandlingUtil.h 3 | * @brief Declaration of tc::PlatformErrorHandlingUtil 4 | * @author Jack (jakcron) 5 | * @version 0.1 6 | * @date 2020/04/09 7 | **/ 8 | #pragma once 9 | #include 10 | 11 | #ifdef _WIN32 12 | #include 13 | #endif 14 | 15 | namespace tc 16 | { 17 | /** 18 | * @class PlatformErrorHandlingUtil 19 | * @brief Platform specific error handling utilities. 20 | **/ 21 | class PlatformErrorHandlingUtil 22 | { 23 | public: 24 | #ifdef _WIN32 25 | /** 26 | * @brief Create a string from Win32 error code. 27 | * 28 | * @param[in] error Error code, returned from GetLastError(). 29 | * 30 | * @return Error as a localised string. 31 | **/ 32 | static std::string GetLastErrorString(DWORD error); 33 | #else 34 | /** 35 | * @brief Create a string from GNU error number. 36 | * 37 | * @param[in] errnum Error code, returned from @a errno macro. 38 | * 39 | * @return Error as a localised string. 40 | **/ 41 | static std::string GetGnuErrorNumString(int errnum); 42 | #endif 43 | 44 | }; 45 | 46 | } // namespace tc -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/include/tc/ResourceStatus.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file ResourceStatus.h 3 | * @brief Declaration of tc::ResourceStatus 4 | * @author Jack (jakcron) 5 | * @version 0.1 6 | * @date 2019/01/16 7 | **/ 8 | #pragma once 9 | #include 10 | 11 | namespace tc { 12 | 13 | /** 14 | * @enum ResourceStatusFlag 15 | * @brief Flags for ResourceStatus 16 | **/ 17 | enum ResourceStatusFlag 18 | { 19 | RESFLAG_READY, /**< Resource is ready for use */ 20 | RESFLAG_ERROR, /**< Resource encountered an error */ 21 | RESFLAG_NOINIT, /**< Resource is not initialized */ 22 | }; 23 | 24 | /** 25 | * @brief Bitset indicating resource state information (see @ref ResourceStatusFlag) 26 | **/ 27 | using ResourceStatus = std::bitset<32>; 28 | 29 | } // namespace tc -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/include/tc/SecurityException.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file SecurityException.h 3 | * @brief Declaration of tc::SecurityException 4 | * @author Jack (jakcron) 5 | * @version 0.1 6 | * @date 2022/02/06 7 | **/ 8 | #pragma once 9 | #include 10 | 11 | namespace tc { 12 | 13 | /** 14 | * @class SecurityException 15 | * @brief The exception that is thrown when a security error is detected. 16 | **/ 17 | class SecurityException : public tc::Exception 18 | { 19 | public: 20 | /// Default Constructor 21 | SecurityException() noexcept : 22 | tc::Exception() 23 | { 24 | } 25 | 26 | /** 27 | * @brief Basic Parameterized Constructor 28 | * 29 | * @param[in] what Explanation for exception 30 | * 31 | * @post 32 | * - what() == what 33 | * - module() == "" 34 | * - error() == what 35 | **/ 36 | SecurityException(const std::string& what) noexcept : 37 | tc::Exception(what) 38 | {} 39 | 40 | /** 41 | * @brief Parameterized Constructor 42 | * 43 | * @param[in] module Name of module that threw the exception 44 | * @param[in] what Explanation for exception 45 | * 46 | * @post 47 | * - what() == "[" + module + " ERROR] " + what 48 | * - module() == module 49 | * - error() == what 50 | **/ 51 | SecurityException(const std::string& module, const std::string& what) noexcept : 52 | tc::Exception(module, what) 53 | { 54 | } 55 | }; 56 | 57 | } // namespace tc -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/include/tc/bn.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file bn.h 3 | * @brief Declaration of the binary literals library 4 | */ 5 | #pragma once 6 | #include 7 | #include 8 | 9 | /** 10 | * @namespace tc::bn 11 | * @brief Namespace of the binary literals library 12 | */ 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/include/tc/bn/binary_utils.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file binary_utils.h 3 | * @brief Declaration of inlines and classes for literal bit manipulation and other low-level operations. 4 | * @author Jack (jakcron) 5 | * @version 0.1 6 | * @date 2020/12/20 7 | */ 8 | #pragma once 9 | #include 10 | 11 | namespace tc { namespace bn { 12 | 13 | /** 14 | * @brief Generate struct magic 32bit number. 15 | * @details This generates a little endian 32bit integer from char[4]. 16 | * 17 | * @param[in] magic Pointer to array of magic bytes. 18 | * 19 | * @return Little endian magic uint32_t. 20 | */ 21 | constexpr uint32_t make_struct_magic_uint32(const char magic[4]) 22 | { 23 | return uint32_t((uint32_t)(magic[3]) << 24 | (uint32_t)(magic[2]) << 16 | (uint32_t)(magic[1]) << 8 | (uint32_t)(magic[0])); 24 | } 25 | 26 | /** 27 | * @brief Generate struct magic 64bit number. 28 | * @details This generates a little endian 64bit integer from char[8]. 29 | * 30 | * @param[in] magic Pointer to array of magic bytes. 31 | * 32 | * @return Little endian magic uint64_t. 33 | */ 34 | constexpr uint64_t make_struct_magic_uint64(const char magic[8]) 35 | { 36 | return uint64_t((uint64_t)(magic[7]) << 56 | (uint64_t)(magic[6]) << 48 | (uint64_t)(magic[5]) << 40 | (uint64_t)(magic[4]) << 32 | (uint64_t)(magic[3]) << 24 | (uint64_t)(magic[2]) << 16 | (uint64_t)(magic[1]) << 8 | (uint64_t)(magic[0])); 37 | } 38 | 39 | }} // namespace tc::bn -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/include/tc/bn/pad.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file pad.h 3 | * @brief Declaration of tc::bn::pad 4 | * @author Jack (jakcron) 5 | * @version 0.2 6 | * @date 2022/02/05 7 | */ 8 | #pragma once 9 | #include 10 | 11 | namespace tc { namespace bn { 12 | 13 | /** 14 | * @class pad 15 | * @brief This class creates padding. 16 | * 17 | * @tparam T size in bytes of the padding. 18 | */ 19 | template 20 | class pad 21 | { 22 | public: 23 | /// Returns size of padding in bytes 24 | size_t size() const { return mArray.size(); } 25 | private: 26 | std::array mArray; 27 | }; 28 | 29 | }} // namespace tc::bn -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/include/tc/cli.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file cli.h 3 | * @brief Declaration of the command-line interface (CLI) library 4 | */ 5 | #pragma once 6 | #include 7 | #include 8 | 9 | /** 10 | * @namespace tc::cli 11 | * @brief Namespace of the command-line interface (CLI) library 12 | */ 13 | #include 14 | #include -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/include/tc/crypto/CryptoException.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file CryptoException.h 3 | * @brief Declaration of tc::crypto::CryptoException 4 | * @author Jack (jakcron) 5 | * @version 0.1 6 | * @date 2020/01/22 7 | **/ 8 | #pragma once 9 | #include 10 | 11 | namespace tc { namespace crypto { 12 | 13 | /** 14 | * @class CryptoException 15 | * @brief The exception that is thrown when an cryptography error occurs. 16 | **/ 17 | class CryptoException : public tc::Exception 18 | { 19 | public: 20 | /// Default Constructor 21 | CryptoException() noexcept : 22 | tc::Exception() 23 | { 24 | } 25 | 26 | /** 27 | * @brief Basic Parameterized Constructor 28 | * 29 | * @param[in] what Explanation for exception 30 | * 31 | * @post 32 | * - what() == what 33 | * - module() == "" 34 | * - error() == what 35 | **/ 36 | CryptoException(const std::string& what) noexcept : 37 | tc::Exception(what) 38 | {} 39 | 40 | /** 41 | * @brief Parameterized Constructor 42 | * 43 | * @param[in] module Name of module that threw the exception 44 | * @param[in] what Explanation for exception 45 | * 46 | * @post 47 | * - what() == "[" + module + " ERROR] " + what 48 | * - module() == module 49 | * - error() == what 50 | **/ 51 | CryptoException(const std::string& module, const std::string& what) noexcept : 52 | tc::Exception(module, what) 53 | { 54 | } 55 | }; 56 | 57 | }} // namespace tc::crypto -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/include/tc/crypto/detail/Md5Impl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Md5Impl.h 3 | * @brief Declaration of tc::crypto::detail::Md5Impl 4 | * @author Jack (jakcron) 5 | * @version 0.2 6 | * @date 2020/06/01 7 | **/ 8 | #pragma once 9 | #include 10 | 11 | namespace tc { namespace crypto { namespace detail { 12 | 13 | /** 14 | * @class Md5Impl 15 | * @brief This class implements the MD5 hash algorithm. 16 | */ 17 | class Md5Impl 18 | { 19 | public: 20 | static const size_t kHashSize = 16; 21 | static const size_t kBlockSize = 64; 22 | 23 | Md5Impl(); 24 | ~Md5Impl(); 25 | 26 | void initialize(); 27 | void update(const byte_t* data, size_t data_size); 28 | void getHash(byte_t* hash); 29 | private: 30 | enum class State 31 | { 32 | None, 33 | Initialized, 34 | Done 35 | }; 36 | 37 | State mState; 38 | std::array mHash; 39 | 40 | struct ImplCtx; 41 | std::unique_ptr mImplCtx; 42 | }; 43 | 44 | }}} // namespace tc::crypto::detail -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/include/tc/crypto/detail/Sha1Impl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Sha1Impl.h 3 | * @brief Declaration of tc::crypto::detail::Sha1Impl 4 | * @author Jack (jakcron) 5 | * @version 0.2 6 | * @date 2020/06/01 7 | **/ 8 | #pragma once 9 | #include 10 | 11 | namespace tc { namespace crypto { namespace detail { 12 | 13 | /** 14 | * @class Sha1Impl 15 | * @brief This class implements the SHA-1 hash algorithm. 16 | */ 17 | class Sha1Impl 18 | { 19 | public: 20 | static const size_t kHashSize = 20; 21 | static const size_t kBlockSize = 64; 22 | 23 | Sha1Impl(); 24 | ~Sha1Impl(); 25 | 26 | void initialize(); 27 | void update(const byte_t* data, size_t data_size); 28 | void getHash(byte_t* hash); 29 | private: 30 | enum class State 31 | { 32 | None, 33 | Initialized, 34 | Done 35 | }; 36 | 37 | State mState; 38 | std::array mHash; 39 | 40 | struct ImplCtx; 41 | std::unique_ptr mImplCtx; 42 | }; 43 | 44 | }}} // namespace tc::crypto::detail -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/include/tc/crypto/detail/Sha2Impl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Sha2Impl.h 3 | * @brief Declaration of tc::crypto::detail::Sha2Impl 4 | * @author Jack (jakcron) 5 | * @version 0.1 6 | * @date 2022/02/27 7 | **/ 8 | #pragma once 9 | #include 10 | 11 | #include 12 | 13 | namespace tc { namespace crypto { namespace detail { 14 | 15 | /** 16 | * @class Sha2Impl 17 | * @brief This class implements the SHA2 family of hash algorithms. 18 | */ 19 | class Sha2Impl 20 | { 21 | public: 22 | enum SHA2BitSize 23 | { 24 | SHA2BitSize_256 = 256, 25 | SHA2BitSize_512 = 512 26 | }; 27 | 28 | static const size_t kSha2_256_HashSize = 32; 29 | static const size_t kSha2_256_BlockSize = 64; 30 | 31 | static const size_t kSha2_512_HashSize = 64; 32 | static const size_t kSha2_512_BlockSize = 128; 33 | 34 | Sha2Impl(SHA2BitSize algo = SHA2BitSize_256); 35 | ~Sha2Impl(); 36 | 37 | void initialize(); 38 | void update(const byte_t* data, size_t data_size); 39 | void getHash(byte_t* hash); 40 | private: 41 | enum class State 42 | { 43 | None, 44 | Initialized, 45 | Done 46 | }; 47 | 48 | State mState; 49 | 50 | size_t mHashSize; 51 | std::array mHash; 52 | 53 | struct ImplCtx; 54 | std::unique_ptr mImplCtx; 55 | }; 56 | 57 | }}} // namespace tc::crypto::detail -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/include/tc/io.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file io.h 3 | * @brief Declaration of the input/output library 4 | **/ 5 | #pragma once 6 | #include 7 | #include 8 | 9 | /** 10 | * @namespace tc::io 11 | * @brief Namespace of the input/output library 12 | **/ 13 | #include 14 | #include 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | 42 | // Exceptions 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/include/tc/io/FileAccess.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file FileMode.h 3 | * @brief Declaration of tc::io::FileMode 4 | * @author Jack (jakcron) 5 | * @version 0.1 6 | * @date 2020/01/22 7 | **/ 8 | #pragma once 9 | 10 | namespace tc { namespace io { 11 | 12 | /** 13 | * @enum FileAccess 14 | * @brief Defines constants for read, write, or read/write access to a file. 15 | **/ 16 | enum class FileAccess 17 | { 18 | Read = 1, /**< Read access to the file. Data can be read from the file. Combine with Write for read/write access. */ 19 | Write = 2, /**< Write access to the file. Data can be written to the file. Combine with Read for read/write access. */ 20 | ReadWrite = Read|Write /**< Read and write access to the file. Data can be written to and read from the file. */ 21 | }; 22 | 23 | }} // namespace tc::io -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/include/tc/io/FileExistsException.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file FileExistsException.h 3 | * @brief Declaration of tc::io::FileExistsException 4 | * @author Jack (jakcron) 5 | * @version 0.1 6 | * @date 2020/01/26 7 | **/ 8 | #pragma once 9 | #include 10 | 11 | namespace tc { namespace io { 12 | 13 | /** 14 | * @class FileExistsException 15 | * @brief The exception that is thrown when an attempt to overwrite/remove a file that exists on disk fails. 16 | **/ 17 | class FileExistsException : public tc::io::IOException 18 | { 19 | public: 20 | /// Default Constructor 21 | FileExistsException() noexcept : 22 | tc::io::IOException() 23 | { 24 | } 25 | 26 | /** 27 | * @brief Basic Parameterized Constructor 28 | * 29 | * @param[in] what Explanation for exception 30 | * 31 | * @post 32 | * - what() == what 33 | * - module() == "" 34 | * - error() == what 35 | **/ 36 | FileExistsException(const std::string& what) noexcept : 37 | tc::io::IOException(what) 38 | {} 39 | 40 | /** 41 | * @brief Parameterized Constructor 42 | * 43 | * @param[in] module Name of module that threw the exception 44 | * @param[in] what Explanation for exception 45 | * 46 | * @post 47 | * - what() == "[" + module + " ERROR] " + what 48 | * - module() == module 49 | * - error() == what 50 | **/ 51 | FileExistsException(const std::string& module, const std::string& what) noexcept : 52 | tc::io::IOException(module, what) 53 | { 54 | } 55 | }; 56 | 57 | }} // namespace tc::io -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/include/tc/io/FileNotFoundException.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file FileNotFoundException.h 3 | * @brief Declaration of tc::io::FileNotFoundException 4 | * @author Jack (jakcron) 5 | * @version 0.1 6 | * @date 2020/01/22 7 | **/ 8 | #pragma once 9 | #include 10 | 11 | namespace tc { namespace io { 12 | 13 | /** 14 | * @class FileNotFoundException 15 | * @brief The exception that is thrown when an attempt to access a file that does not exist on disk fails. 16 | **/ 17 | class FileNotFoundException : public tc::io::IOException 18 | { 19 | public: 20 | /// Default Constructor 21 | FileNotFoundException() noexcept : 22 | tc::io::IOException() 23 | { 24 | } 25 | 26 | /** 27 | * @brief Basic Parameterized Constructor 28 | * 29 | * @param[in] what Explanation for exception 30 | * 31 | * @post 32 | * - what() == what 33 | * - module() == "" 34 | * - error() == what 35 | **/ 36 | FileNotFoundException(const std::string& what) noexcept : 37 | tc::io::IOException(what) 38 | {} 39 | 40 | /** 41 | * @brief Parameterized Constructor 42 | * 43 | * @param[in] module Name of module that threw the exception 44 | * @param[in] what Explanation for exception 45 | * 46 | * @post 47 | * - what() == "[" + module + " ERROR] " + what 48 | * - module() == module 49 | * - error() == what 50 | **/ 51 | FileNotFoundException(const std::string& module, const std::string& what) noexcept : 52 | tc::io::IOException(module, what) 53 | { 54 | } 55 | }; 56 | 57 | }} // namespace tc::io -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/include/tc/io/IOException.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file IOException.h 3 | * @brief Declaration of tc::io::IOException 4 | * @author Jack (jakcron) 5 | * @version 0.1 6 | * @date 2020/01/22 7 | **/ 8 | #pragma once 9 | #include 10 | 11 | namespace tc { namespace io { 12 | 13 | /** 14 | * @class IOException 15 | * @brief The exception that is thrown when an I/O error occurs. 16 | **/ 17 | class IOException : public tc::Exception 18 | { 19 | public: 20 | /// Default Constructor 21 | IOException() noexcept : 22 | tc::Exception() 23 | { 24 | } 25 | 26 | /** 27 | * @brief Basic Parameterized Constructor 28 | * 29 | * @param[in] what Explanation for exception 30 | * 31 | * @post 32 | * - what() == what 33 | * - module() == "" 34 | * - error() == what 35 | **/ 36 | IOException(const std::string& what) noexcept : 37 | tc::Exception(what) 38 | {} 39 | 40 | /** 41 | * @brief Parameterized Constructor 42 | * 43 | * @param[in] module Name of module that threw the exception 44 | * @param[in] what Explanation for exception 45 | * 46 | * @post 47 | * - what() == "[" + module + " ERROR] " + what 48 | * - module() == module 49 | * - error() == what 50 | **/ 51 | IOException(const std::string& module, const std::string& what) noexcept : 52 | tc::Exception(module, what) 53 | { 54 | } 55 | }; 56 | 57 | }} // namespace tc::io -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/include/tc/io/IPathResolver.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file IPathResolver.h 3 | * @brief Declaration of tc::io::IPathResolver 4 | * @author Jack (jakcron) 5 | * @version 0.2 6 | * @date 2022/02/22 7 | **/ 8 | #pragma once 9 | #include 10 | 11 | namespace tc { namespace io { 12 | 13 | /** 14 | * @class IPathResolver 15 | * @brief This is an interface for a class that resolves relative paths to canonical paths. 16 | */ 17 | class IPathResolver 18 | { 19 | public: 20 | virtual ~IPathResolver() = default; 21 | 22 | /** 23 | * @brief Resolve path to its canonical path 24 | * 25 | * @param path Input path. 26 | * @param canonical_path Output path to write resolved canonical path. 27 | */ 28 | virtual void resolveCanonicalPath(const tc::io::Path& path, tc::io::Path& canonical_path) const = 0; 29 | 30 | /** 31 | * @brief Resolve path to its canonical path 32 | * 33 | * @param path Input path. 34 | * 35 | * @return Resolved canonical path. 36 | */ 37 | virtual tc::io::Path resolveCanonicalPath(const tc::io::Path& path) const = 0; 38 | }; 39 | 40 | }} // namespace tc::io -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/include/tc/io/IPortablePathResolver.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file IPortablePathResolver.h 3 | * @brief Declaration of tc::io::IPortablePathResolver 4 | * @author Jack (jakcron) 5 | * @version 0.1 6 | * @date 2022/02/22 7 | **/ 8 | #pragma once 9 | #include 10 | 11 | namespace tc { namespace io { 12 | 13 | /** 14 | * @class IPortablePathResolver 15 | * @brief This is an extension for the IPathResolver interface that specifies additional methods for setting the current directory. For more information see @ref tc::io::IPathResolver. 16 | */ 17 | class IPortablePathResolver : public IPathResolver 18 | { 19 | public: 20 | virtual ~IPortablePathResolver() = default; 21 | 22 | /** 23 | * @brief Set the current directory path 24 | * 25 | * @param path Canonical current directory path. 26 | */ 27 | virtual void setCurrentDirectory(const tc::io::Path& path) = 0; 28 | 29 | /** 30 | * @brief Get the current directory path 31 | * 32 | * @return tc::io::Path Canonical current directory path. 33 | */ 34 | virtual const tc::io::Path& getCurrentDirectory() const = 0; 35 | }; 36 | 37 | }} // namespace tc::io -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/include/tc/io/IReadableSink.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file IReadableSink.h 3 | * @brief Declaration of tc::io::IReadableSink 4 | * @author Jack (jakcron) 5 | * @version 0.1 6 | * @date 2020/02/07 7 | **/ 8 | #pragma once 9 | #include 10 | #include 11 | 12 | namespace tc { namespace io { 13 | 14 | /** 15 | * @class IReadableSink 16 | * @brief An interface defining a byte data sink that can be also provide an ISource. 17 | **/ 18 | class IReadableSink : public tc::io::ISink 19 | { 20 | public: 21 | /// Destructor 22 | virtual ~IReadableSink() = default; 23 | 24 | /// Convert to ISource 25 | virtual std::shared_ptr& toSource() = 0; 26 | }; 27 | 28 | }} // namespace tc::io -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/include/tc/io/ISink.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file ISink.h 3 | * @brief Declaration of tc::io::ISink 4 | * @author Jack (jakcron) 5 | * @version 0.2 6 | * @date 2020/04/10 7 | **/ 8 | #pragma once 9 | #include 10 | #include 11 | #include 12 | 13 | namespace tc { namespace io { 14 | 15 | /** 16 | * @class ISink 17 | * @brief An interface defining a byte data sink. 18 | **/ 19 | class ISink 20 | { 21 | public: 22 | /// Destructor 23 | virtual ~ISink() = default; 24 | 25 | /// Gets the length of the sink. 26 | virtual int64_t length() = 0; 27 | 28 | /** 29 | * @brief Sets the length of the sink. 30 | * 31 | * @param[in] length The desired length of the sink in bytes. 32 | **/ 33 | virtual void setLength(int64_t length) = 0; 34 | 35 | /** 36 | * @brief Push data to the sink. 37 | * 38 | * @param[in] data Data to be pushed to the sink. 39 | * @param[in] offset Zero-based offset in sink to push data. 40 | * 41 | * @return Number of bytes pushed to sink. 42 | **/ 43 | virtual size_t pushData(const tc::ByteData& data, int64_t offset) = 0; 44 | }; 45 | 46 | }} // namespace tc::io -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/include/tc/io/ISource.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file ISource.h 3 | * @brief Declaration of tc::io::ISource 4 | * @author Jack (jakcron) 5 | * @version 0.1 6 | * @date 2020/01/27 7 | **/ 8 | #pragma once 9 | #include 10 | #include 11 | #include 12 | 13 | namespace tc { namespace io { 14 | 15 | /** 16 | * @class ISource 17 | * @brief An interface defining a byte data source. 18 | **/ 19 | class ISource 20 | { 21 | public: 22 | /// Destructor 23 | virtual ~ISource() = default; 24 | 25 | /// Gets the length of the source. 26 | virtual int64_t length() = 0; 27 | 28 | /** 29 | * @brief Pull data from the source. 30 | * 31 | * @param[in] offset Zero-based offset in source to pull data. 32 | * @param[in] count The maximum number of bytes to be pull from the source. 33 | * 34 | * @return ByteData containing data pulled from source. 35 | **/ 36 | virtual tc::ByteData pullData(int64_t offset, size_t count) = 0; 37 | }; 38 | 39 | }} // namespace tc::io -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/include/tc/io/PathUtil.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file PathUtil.h 3 | * @brief Declaration of tc::io::PathUtil 4 | * @author Jack (jakcron) 5 | * @version 0.2 6 | * @date 2020/03/22 7 | */ 8 | #pragma once 9 | #include 10 | #include 11 | #include 12 | 13 | namespace tc { namespace io { 14 | 15 | /** 16 | * @class PathUtil 17 | * @brief Collection of utilities related to tc::io::Path 18 | **/ 19 | class PathUtil 20 | { 21 | public: 22 | /** 23 | * @brief Format a Path as a Windows style UTF-16 string 24 | * @param[in] path Source Path 25 | * @param[out] out Destination UTF-16 string 26 | * @note See @ref tc::io::Path 27 | **/ 28 | static void pathToWindowsUTF16(const tc::io::Path& path, std::u16string& out); 29 | 30 | /** 31 | * @brief Format a Path as a Unix/Linux style UTF-8 string 32 | * @param[in] path Source Path 33 | * @param[out] out Destination UTF-8 string 34 | * @note See @ref tc::io::Path 35 | **/ 36 | static void pathToUnixUTF8(const tc::io::Path& path, std::string& out); 37 | }; 38 | 39 | }} // namespace tc::io -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/include/tc/io/SeekOrigin.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file SeekOrigin.h 3 | * @brief Declaration of tc::io::SeekOrigin 4 | * @author Jack (jakcron) 5 | * @version 0.1 6 | * @date 2020/01/22 7 | **/ 8 | #pragma once 9 | 10 | namespace tc { namespace io { 11 | 12 | /** 13 | * @enum SeekOrigin 14 | * @brief Specifies the position in a stream to use for seeking. 15 | **/ 16 | enum class SeekOrigin 17 | { 18 | Begin = 0, /**< Specifies the beginning of a stream. */ 19 | Current = 1, /**< Specifies the current position within a stream. */ 20 | End = 2 /**< Specifies the end of a stream. */ 21 | }; 22 | 23 | }} // namespace tc::io -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/include/tc/io/StreamUtil.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file StreamUtil.h 3 | * @brief Declaration of tc::io::StreamUtil 4 | * @author Jack (jakcron) 5 | * @version 0.2 6 | * @date 2020/04/06 7 | **/ 8 | #pragma once 9 | #include 10 | 11 | #include 12 | 13 | namespace tc { namespace io { 14 | 15 | /** 16 | * @class StreamUtil 17 | * @brief Utility class for IStream objects. 18 | **/ 19 | class StreamUtil 20 | { 21 | public: 22 | /** 23 | * @brief Get the logical result for seek(), given the current position and stream length. 24 | * 25 | * @param[in] offset A byte offset relative to the origin parameter. 26 | * @param[in] origin A value of type @ref tc::io::SeekOrigin indicating the reference point used to obtain the new position. 27 | * @param[in] current_position The current byte offset relative to the beginning of the stream. 28 | * @param[in] stream_length The length of the stream. 29 | * 30 | * @return The new position within the stream. 31 | * 32 | * @throw tc::ArgumentOutOfRangeException @p origin has an illegal value. 33 | **/ 34 | static int64_t getSeekResult(int64_t offset, tc::io::SeekOrigin origin, int64_t current_position, int64_t stream_length); 35 | }; 36 | 37 | }} // namespace tc::io -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/include/tc/os.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file os.h 3 | * @brief Declaration of the operating system (OS) library 4 | */ 5 | #pragma once 6 | #include 7 | #include 8 | 9 | /** 10 | * @namespace tc::os 11 | * @brief Namespace of the operating system (OS) library 12 | */ 13 | #include -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/include/tc/os/Environment.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Environment.h 3 | * @brief Declarations for API resources for accessing run-time environment 4 | * @author Jack (jakcron) 5 | * @version 0.1 6 | * @date 2020/06/12 7 | **/ 8 | #pragma once 9 | #include 10 | #include 11 | 12 | namespace tc { namespace os { 13 | 14 | /** 15 | * @brief Get environment variable. 16 | * 17 | * @details This function supports UTF-8 encoding 18 | * 19 | * @param[in] name Name of environment variable. 20 | * @param[out] value Reference to string to populate with variable. 21 | * 22 | * @post @p value will contain the environment variable if it exists. 23 | * 24 | * @return true if operation was successful. 25 | */ 26 | bool getEnvVar(const std::string& name, std::string& value); 27 | 28 | }} // namespace tc::cli -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/include/tc/string.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file string.h 3 | * @brief Declaration of the string library 4 | **/ 5 | #pragma once 6 | #include 7 | 8 | /** 9 | * @namespace tc::string 10 | * @brief Namespace of the string library 11 | **/ 12 | #include -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/include/tc/string/detail/utf16.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file utf16.h 3 | * @brief Declaration of UTF-16 constants and macros 4 | * @author Jack (jakcron) 5 | * @version 0.1 6 | * @date 2019/01/15 7 | */ 8 | #pragma once 9 | #include 10 | 11 | namespace tc { namespace string { namespace detail { 12 | 13 | static const char32_t kUtf16EncodeMax = 0x10FFFF; 14 | static const char32_t kUtf16NonNativeStart = 0x10000; 15 | static const char16_t kUtf16SurrogateBits = 10; 16 | static const char16_t kUtf16SurrogateMask = (1 << kUtf16SurrogateBits) - 1; 17 | static const char16_t kUtf16HighSurrogateStart = 0xD800; 18 | static const char16_t kUtf16HighSurrogateEnd = kUtf16HighSurrogateStart | kUtf16SurrogateMask; 19 | static const char16_t kUtf16LowSurrogateStart = 0xDC00; 20 | static const char16_t kUtf16LowSurrogateEnd = kUtf16LowSurrogateStart | kUtf16SurrogateMask; 21 | 22 | }}} // namespace tc::string::detail -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/src/Exception.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | tc::Exception::Exception() noexcept : 4 | what_(""), 5 | module_(""), 6 | error_("") 7 | { 8 | 9 | } 10 | 11 | tc::Exception::Exception(const std::string & what) noexcept : 12 | what_(what), 13 | module_(""), 14 | error_(what) 15 | { 16 | } 17 | 18 | tc::Exception::Exception(const std::string & module, const std::string & what) noexcept : 19 | what_(""), 20 | module_(module), 21 | error_(what) 22 | { 23 | if (module_.length() > 0) 24 | { 25 | what_ = "[" + module_ + " ERROR] " + error_; 26 | } 27 | else 28 | { 29 | what_ = error_; 30 | } 31 | } 32 | 33 | const char* tc::Exception::what() const noexcept 34 | { 35 | return what_.c_str(); 36 | } 37 | 38 | const char* tc::Exception::module() const noexcept 39 | { 40 | return module_.c_str(); 41 | } 42 | 43 | const char * tc::Exception::error() const noexcept 44 | { 45 | return error_.c_str(); 46 | } 47 | -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/src/PlatformErrorHandlingUtil.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #ifdef _WIN32 5 | std::string tc::PlatformErrorHandlingUtil::GetLastErrorString(DWORD error) 6 | { 7 | if (error) 8 | { 9 | LPVOID lpMsgBuf; 10 | DWORD bufLen = FormatMessage( 11 | FORMAT_MESSAGE_ALLOCATE_BUFFER | 12 | FORMAT_MESSAGE_FROM_SYSTEM | 13 | FORMAT_MESSAGE_IGNORE_INSERTS, 14 | NULL, 15 | error, 16 | MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), 17 | (LPTSTR) &lpMsgBuf, 18 | 0, NULL ); 19 | 20 | if (bufLen) 21 | { 22 | LPCSTR lpMsgStr = (LPCSTR)lpMsgBuf; 23 | std::string result(lpMsgStr, lpMsgStr+bufLen); 24 | 25 | LocalFree(lpMsgBuf); 26 | 27 | // remove CR+LF from string 28 | result.erase(std::remove(result.begin(), result.end(), '\n'), result.end()); 29 | result.erase(std::remove(result.begin(), result.end(), '\r'), result.end()); 30 | 31 | return result; 32 | } 33 | } 34 | return std::string(); 35 | } 36 | #else 37 | std::string tc::PlatformErrorHandlingUtil::GetGnuErrorNumString(int errnum) 38 | { 39 | return std::string(strerror(errnum)); 40 | } 41 | #endif -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/src/crypto/Aes128CbcEncryptor.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void tc::crypto::EncryptAes128Cbc(byte_t* dst, const byte_t* src, size_t size, const byte_t* key, size_t key_size, const byte_t* iv, size_t iv_size) 4 | { 5 | tc::crypto::Aes128CbcEncryptor crypt; 6 | crypt.initialize(key, key_size, iv, iv_size); 7 | crypt.encrypt(dst, src, size); 8 | } 9 | 10 | void tc::crypto::DecryptAes128Cbc(byte_t* dst, const byte_t* src, size_t size, const byte_t* key, size_t key_size, const byte_t* iv, size_t iv_size) 11 | { 12 | tc::crypto::Aes128CbcEncryptor crypt; 13 | crypt.initialize(key, key_size, iv, iv_size); 14 | crypt.decrypt(dst, src, size); 15 | } -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/src/crypto/Aes128CtrEncryptor.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void tc::crypto::EncryptAes128Ctr(byte_t* dst, const byte_t* src, size_t size, uint64_t block_number, const byte_t* key, size_t key_size, const byte_t* iv, size_t iv_size) 4 | { 5 | tc::crypto::Aes128CtrEncryptor crypt; 6 | crypt.initialize(key, key_size, iv, iv_size); 7 | crypt.encrypt(dst, src, size, block_number); 8 | } 9 | 10 | void tc::crypto::DecryptAes128Ctr(byte_t* dst, const byte_t* src, size_t size, uint64_t block_number, const byte_t* key, size_t key_size, const byte_t* iv, size_t iv_size) 11 | { 12 | tc::crypto::Aes128CtrEncryptor crypt; 13 | crypt.initialize(key, key_size, iv, iv_size); 14 | crypt.decrypt(dst, src, size, block_number); 15 | } 16 | 17 | void tc::crypto::IncrementCounterAes128Ctr(byte_t* counter, uint64_t incr) 18 | { 19 | if (counter == nullptr) 20 | { 21 | throw tc::ArgumentOutOfRangeException("counter was null."); 22 | } 23 | tc::crypto::detail::incr_counter<16>(counter, incr); 24 | } -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/src/crypto/Aes128EcbEncryptor.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void tc::crypto::EncryptAes128Ecb(byte_t* dst, const byte_t* src, size_t size, const byte_t* key, size_t key_size) 4 | { 5 | tc::crypto::Aes128EcbEncryptor crypt; 6 | crypt.initialize(key, key_size); 7 | crypt.encrypt(dst, src, size); 8 | } 9 | 10 | void tc::crypto::DecryptAes128Ecb(byte_t* dst, const byte_t* src, size_t size, const byte_t* key, size_t key_size) 11 | { 12 | tc::crypto::Aes128EcbEncryptor crypt; 13 | crypt.initialize(key, key_size); 14 | crypt.decrypt(dst, src, size); 15 | } -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/src/crypto/Aes128XtsEncryptor.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void tc::crypto::EncryptAes128Xts(byte_t* dst, const byte_t* src, size_t size, uint64_t sector_number, const byte_t* key1, size_t key1_size, const byte_t* key2, size_t key2_size, size_t sector_size, bool tweak_word_order) 4 | { 5 | tc::crypto::Aes128XtsEncryptor crypt; 6 | crypt.initialize(key1, key1_size, key2, key2_size, sector_size, tweak_word_order); 7 | crypt.encrypt(dst, src, size, sector_number); 8 | } 9 | 10 | void tc::crypto::DecryptAes128Xts(byte_t* dst, const byte_t* src, size_t size, uint64_t sector_number, const byte_t* key1, size_t key1_size, const byte_t* key2, size_t key2_size, size_t sector_size, bool tweak_word_order) 11 | { 12 | tc::crypto::Aes128XtsEncryptor crypt; 13 | crypt.initialize(key1, key1_size, key2, key2_size, sector_size, tweak_word_order); 14 | crypt.decrypt(dst, src, size, sector_number); 15 | } -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/src/crypto/Aes192CbcEncryptor.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void tc::crypto::EncryptAes192Cbc(byte_t* dst, const byte_t* src, size_t size, const byte_t* key, size_t key_size, const byte_t* iv, size_t iv_size) 4 | { 5 | tc::crypto::Aes192CbcEncryptor crypt; 6 | crypt.initialize(key, key_size, iv, iv_size); 7 | crypt.encrypt(dst, src, size); 8 | } 9 | 10 | void tc::crypto::DecryptAes192Cbc(byte_t* dst, const byte_t* src, size_t size, const byte_t* key, size_t key_size, const byte_t* iv, size_t iv_size) 11 | { 12 | tc::crypto::Aes192CbcEncryptor crypt; 13 | crypt.initialize(key, key_size, iv, iv_size); 14 | crypt.decrypt(dst, src, size); 15 | } -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/src/crypto/Aes192CtrEncryptor.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void tc::crypto::EncryptAes192Ctr(byte_t* dst, const byte_t* src, size_t size, uint64_t block_number, const byte_t* key, size_t key_size, const byte_t* iv, size_t iv_size) 4 | { 5 | tc::crypto::Aes192CtrEncryptor crypt; 6 | crypt.initialize(key, key_size, iv, iv_size); 7 | crypt.encrypt(dst, src, size, block_number); 8 | } 9 | 10 | void tc::crypto::DecryptAes192Ctr(byte_t* dst, const byte_t* src, size_t size, uint64_t block_number, const byte_t* key, size_t key_size, const byte_t* iv, size_t iv_size) 11 | { 12 | tc::crypto::Aes192CtrEncryptor crypt; 13 | crypt.initialize(key, key_size, iv, iv_size); 14 | crypt.decrypt(dst, src, size, block_number); 15 | } 16 | 17 | void tc::crypto::IncrementCounterAes192Ctr(byte_t* counter, uint64_t incr) 18 | { 19 | if (counter == nullptr) 20 | { 21 | throw tc::ArgumentOutOfRangeException("counter was null."); 22 | } 23 | tc::crypto::detail::incr_counter<16>(counter, incr); 24 | } -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/src/crypto/Aes192EcbEncryptor.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void tc::crypto::EncryptAes192Ecb(byte_t* dst, const byte_t* src, size_t size, const byte_t* key, size_t key_size) 4 | { 5 | tc::crypto::Aes192EcbEncryptor crypt; 6 | crypt.initialize(key, key_size); 7 | crypt.encrypt(dst, src, size); 8 | } 9 | 10 | void tc::crypto::DecryptAes192Ecb(byte_t* dst, const byte_t* src, size_t size, const byte_t* key, size_t key_size) 11 | { 12 | tc::crypto::Aes192EcbEncryptor crypt; 13 | crypt.initialize(key, key_size); 14 | crypt.decrypt(dst, src, size); 15 | } -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/src/crypto/Aes256CbcEncryptor.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void tc::crypto::EncryptAes256Cbc(byte_t* dst, const byte_t* src, size_t size, const byte_t* key, size_t key_size, const byte_t* iv, size_t iv_size) 4 | { 5 | tc::crypto::Aes256CbcEncryptor crypt; 6 | crypt.initialize(key, key_size, iv, iv_size); 7 | crypt.encrypt(dst, src, size); 8 | } 9 | 10 | void tc::crypto::DecryptAes256Cbc(byte_t* dst, const byte_t* src, size_t size, const byte_t* key, size_t key_size, const byte_t* iv, size_t iv_size) 11 | { 12 | tc::crypto::Aes256CbcEncryptor crypt; 13 | crypt.initialize(key, key_size, iv, iv_size); 14 | crypt.decrypt(dst, src, size); 15 | } -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/src/crypto/Aes256CtrEncryptor.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void tc::crypto::EncryptAes256Ctr(byte_t* dst, const byte_t* src, size_t size, uint64_t block_number, const byte_t* key, size_t key_size, const byte_t* iv, size_t iv_size) 4 | { 5 | tc::crypto::Aes256CtrEncryptor crypt; 6 | crypt.initialize(key, key_size, iv, iv_size); 7 | crypt.encrypt(dst, src, size, block_number); 8 | } 9 | 10 | void tc::crypto::DecryptAes256Ctr(byte_t* dst, const byte_t* src, size_t size, uint64_t block_number, const byte_t* key, size_t key_size, const byte_t* iv, size_t iv_size) 11 | { 12 | tc::crypto::Aes256CtrEncryptor crypt; 13 | crypt.initialize(key, key_size, iv, iv_size); 14 | crypt.decrypt(dst, src, size, block_number); 15 | } 16 | 17 | void tc::crypto::IncrementCounterAes256Ctr(byte_t* counter, uint64_t incr) 18 | { 19 | if (counter == nullptr) 20 | { 21 | throw tc::ArgumentOutOfRangeException("counter was null."); 22 | } 23 | tc::crypto::detail::incr_counter<16>(counter, incr); 24 | } -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/src/crypto/Aes256EcbEncryptor.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void tc::crypto::EncryptAes256Ecb(byte_t* dst, const byte_t* src, size_t size, const byte_t* key, size_t key_size) 4 | { 5 | tc::crypto::Aes256EcbEncryptor crypt; 6 | crypt.initialize(key, key_size); 7 | crypt.encrypt(dst, src, size); 8 | } 9 | 10 | void tc::crypto::DecryptAes256Ecb(byte_t* dst, const byte_t* src, size_t size, const byte_t* key, size_t key_size) 11 | { 12 | tc::crypto::Aes256EcbEncryptor crypt; 13 | crypt.initialize(key, key_size); 14 | crypt.decrypt(dst, src, size); 15 | } -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/src/crypto/Aes256XtsEncryptor.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void tc::crypto::EncryptAes256Xts(byte_t* dst, const byte_t* src, size_t size, uint64_t sector_number, const byte_t* key1, size_t key1_size, const byte_t* key2, size_t key2_size, size_t sector_size, bool tweak_word_order) 4 | { 5 | tc::crypto::Aes256XtsEncryptor crypt; 6 | crypt.initialize(key1, key1_size, key2, key2_size, sector_size, tweak_word_order); 7 | crypt.encrypt(dst, src, size, sector_number); 8 | } 9 | 10 | void tc::crypto::DecryptAes256Xts(byte_t* dst, const byte_t* src, size_t size, uint64_t sector_number, const byte_t* key1, size_t key1_size, const byte_t* key2, size_t key2_size, size_t sector_size, bool tweak_word_order) 11 | { 12 | tc::crypto::Aes256XtsEncryptor crypt; 13 | crypt.initialize(key1, key1_size, key2, key2_size, sector_size, tweak_word_order); 14 | crypt.decrypt(dst, src, size, sector_number); 15 | } -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/src/crypto/HmacMd5Generator.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void tc::crypto::GenerateHmacMd5Mac(byte_t* mac, const byte_t* data, size_t data_size, const byte_t* key, size_t key_size) 4 | { 5 | tc::crypto::HmacMd5Generator impl; 6 | impl.initialize(key, key_size); 7 | impl.update(data, data_size); 8 | impl.getMac(mac); 9 | } -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/src/crypto/HmacSha1Generator.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void tc::crypto::GenerateHmacSha1Mac(byte_t* mac, const byte_t* data, size_t data_size, const byte_t* key, size_t key_size) 4 | { 5 | tc::crypto::HmacSha1Generator impl; 6 | impl.initialize(key, key_size); 7 | impl.update(data, data_size); 8 | impl.getMac(mac); 9 | } -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/src/crypto/HmacSha256Generator.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void tc::crypto::GenerateHmacSha256Mac(byte_t* mac, const byte_t* data, size_t data_size, const byte_t* key, size_t key_size) 4 | { 5 | tc::crypto::HmacSha256Generator impl; 6 | impl.initialize(key, key_size); 7 | impl.update(data, data_size); 8 | impl.getMac(mac); 9 | } -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/src/crypto/HmacSha512Generator.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void tc::crypto::GenerateHmacSha512Mac(byte_t* mac, const byte_t* data, size_t data_size, const byte_t* key, size_t key_size) 4 | { 5 | tc::crypto::HmacSha512Generator impl; 6 | impl.initialize(key, key_size); 7 | impl.update(data, data_size); 8 | impl.getMac(mac); 9 | } -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/src/crypto/Md5Generator.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | const std::array tc::crypto::Md5Generator::kAsn1OidData = {0x30, 0x20, 0x30, 0x0C, 0x06, 0x08, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x02, 0x05, 0x05, 0x00, 0x04, 0x10}; 4 | 5 | void tc::crypto::GenerateMd5Hash(byte_t* hash, const byte_t* data, size_t data_size) 6 | { 7 | tc::crypto::Md5Generator impl; 8 | impl.initialize(); 9 | impl.update(data, data_size); 10 | impl.getHash(hash); 11 | } -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/src/crypto/Pbkdf1Md5KeyDeriver.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void tc::crypto::DeriveKeyPbkdf1Md5(byte_t* key, size_t key_size, const byte_t* password, size_t password_size, const byte_t* salt, size_t salt_size, size_t n_rounds) 4 | { 5 | tc::crypto::Pbkdf1Md5KeyDeriver impl; 6 | impl.initialize(password, password_size, salt, salt_size, n_rounds); 7 | impl.getBytes(key, key_size); 8 | } -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/src/crypto/Pbkdf1Sha1KeyDeriver.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void tc::crypto::DeriveKeyPbkdf1Sha1(byte_t* key, size_t key_size, const byte_t* password, size_t password_size, const byte_t* salt, size_t salt_size, size_t n_rounds) 4 | { 5 | tc::crypto::Pbkdf1Sha1KeyDeriver impl; 6 | impl.initialize(password, password_size, salt, salt_size, n_rounds); 7 | impl.getBytes(key, key_size); 8 | } -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/src/crypto/Pbkdf2Sha1KeyDeriver.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void tc::crypto::DeriveKeyPbkdf2Sha1(byte_t* key, size_t key_size, const byte_t* password, size_t password_size, const byte_t* salt, size_t salt_size, size_t n_rounds) 4 | { 5 | tc::crypto::Pbkdf2Sha1KeyDeriver impl; 6 | impl.initialize(password, password_size, salt, salt_size, n_rounds); 7 | impl.getBytes(key, key_size); 8 | } -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/src/crypto/Pbkdf2Sha256KeyDeriver.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void tc::crypto::DeriveKeyPbkdf2Sha256(byte_t* key, size_t key_size, const byte_t* password, size_t password_size, const byte_t* salt, size_t salt_size, size_t n_rounds) 4 | { 5 | tc::crypto::Pbkdf2Sha256KeyDeriver impl; 6 | impl.initialize(password, password_size, salt, salt_size, n_rounds); 7 | impl.getBytes(key, key_size); 8 | } -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/src/crypto/Pbkdf2Sha512KeyDeriver.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void tc::crypto::DeriveKeyPbkdf2Sha512(byte_t* key, size_t key_size, const byte_t* password, size_t password_size, const byte_t* salt, size_t salt_size, size_t n_rounds) 4 | { 5 | tc::crypto::Pbkdf2Sha512KeyDeriver impl; 6 | impl.initialize(password, password_size, salt, salt_size, n_rounds); 7 | impl.getBytes(key, key_size); 8 | } -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/src/crypto/PseudoRandomByteGenerator.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void tc::crypto::GeneratePseudoRandomBytes(byte_t* data, size_t data_size) 4 | { 5 | tc::crypto::PseudoRandomByteGenerator impl; 6 | impl.getBytes(data, data_size); 7 | } -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/src/crypto/RsaKey.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | tc::crypto::RsaPublicKey::RsaPublicKey(const byte_t* modulus, size_t modulus_size) 4 | { 5 | static const byte_t kPublicExponent[3] = { 0x01, 0x00, 0x01 }; 6 | 7 | if (modulus != nullptr && modulus_size != 0) 8 | { 9 | this->n = tc::ByteData(modulus, modulus_size); 10 | this->e = tc::ByteData(kPublicExponent, sizeof(kPublicExponent)); 11 | } 12 | } 13 | 14 | tc::crypto::RsaPrivateKey::RsaPrivateKey(const byte_t* modulus, size_t modulus_size, const byte_t* private_exponent, size_t private_exponent_size) 15 | { 16 | static const byte_t kPublicExponent[3] = { 0x01, 0x00, 0x01 }; 17 | 18 | if (modulus != nullptr && modulus_size != 0 && private_exponent != nullptr && private_exponent_size != 0) 19 | { 20 | this->n = tc::ByteData(modulus, modulus_size); 21 | this->d = tc::ByteData(private_exponent, private_exponent_size); 22 | this->e = tc::ByteData(kPublicExponent, sizeof(kPublicExponent)); 23 | } 24 | } 25 | 26 | tc::crypto::RsaKey tc::crypto::RsaPrivateKey::getPublicKey() 27 | { 28 | return RsaPublicKey(this->n.data(), this->n.size()); 29 | } -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/src/crypto/RsaKeyGenerator.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void tc::crypto::GenerateRsaKey(RsaKey& key, size_t key_bit_size) 4 | { 5 | tc::crypto::RsaKeyGenerator impl; 6 | impl.generateKey(key, key_bit_size); 7 | } -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/src/crypto/Sha1Generator.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | const std::array tc::crypto::Sha1Generator::kAsn1OidData = {0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x0E, 0x03, 0x02, 0x1A, 0x05, 0x00, 0x04, 0x14}; 4 | 5 | 6 | void tc::crypto::GenerateSha1Hash(byte_t* hash, const byte_t* data, size_t data_size) 7 | { 8 | tc::crypto::Sha1Generator impl; 9 | impl.initialize(); 10 | impl.update(data, data_size); 11 | impl.getHash(hash); 12 | } -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/src/crypto/Sha256Generator.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | const std::array tc::crypto::Sha256Generator::kAsn1OidData = {0x30, 0x31, 0x30, 0x0D, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05, 0x00, 0x04, 0x20}; 4 | 5 | void tc::crypto::GenerateSha256Hash(byte_t* hash, const byte_t* data, size_t data_size) 6 | { 7 | tc::crypto::Sha256Generator impl; 8 | impl.initialize(); 9 | impl.update(data, data_size); 10 | impl.getHash(hash); 11 | } -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/src/crypto/Sha512Generator.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | const std::array tc::crypto::Sha512Generator::kAsn1OidData = {0x30, 0x51, 0x30, 0x0D, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03, 0x05, 0x00, 0x04, 0x40}; 4 | 5 | void tc::crypto::GenerateSha512Hash(byte_t* hash, const byte_t* data, size_t data_size) 6 | { 7 | tc::crypto::Sha512Generator impl; 8 | impl.initialize(); 9 | impl.update(data, data_size); 10 | impl.getHash(hash); 11 | } -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/src/crypto/detail/Md5Impl.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | struct tc::crypto::detail::Md5Impl::ImplCtx 5 | { 6 | mbedtls_md_context_t mMdContext; 7 | }; 8 | 9 | tc::crypto::detail::Md5Impl::Md5Impl() : 10 | mState(State::None), 11 | mImplCtx(new ImplCtx()) 12 | { 13 | mbedtls_md_init(&(mImplCtx->mMdContext)); 14 | mbedtls_md_setup(&(mImplCtx->mMdContext), mbedtls_md_info_from_type(MBEDTLS_MD_MD5), 0); 15 | } 16 | 17 | tc::crypto::detail::Md5Impl::~Md5Impl() 18 | { 19 | mbedtls_md_free(&(mImplCtx->mMdContext)); 20 | } 21 | 22 | void tc::crypto::detail::Md5Impl::initialize() 23 | { 24 | mbedtls_md_starts(&(mImplCtx->mMdContext)); 25 | mState = State::Initialized; 26 | } 27 | 28 | void tc::crypto::detail::Md5Impl::update(const byte_t* src, size_t src_size) 29 | { 30 | mbedtls_md_update(&(mImplCtx->mMdContext), src, src_size); 31 | } 32 | 33 | void tc::crypto::detail::Md5Impl::getHash(byte_t* hash) 34 | { 35 | if (mState == State::Initialized) 36 | { 37 | mbedtls_md_finish(&(mImplCtx->mMdContext), mHash.data()); 38 | mState = State::Done; 39 | } 40 | if (mState == State::Done) 41 | { 42 | memcpy(hash, mHash.data(), mHash.size()); 43 | } 44 | } -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/src/crypto/detail/Sha1Impl.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | struct tc::crypto::detail::Sha1Impl::ImplCtx 5 | { 6 | mbedtls_md_context_t mMdContext; 7 | }; 8 | 9 | tc::crypto::detail::Sha1Impl::Sha1Impl() : 10 | mState(State::None), 11 | mImplCtx(new ImplCtx()) 12 | { 13 | mbedtls_md_init(&(mImplCtx->mMdContext)); 14 | mbedtls_md_setup(&(mImplCtx->mMdContext), mbedtls_md_info_from_type(MBEDTLS_MD_SHA1), 0); 15 | } 16 | 17 | tc::crypto::detail::Sha1Impl::~Sha1Impl() 18 | { 19 | mbedtls_md_free(&(mImplCtx->mMdContext)); 20 | } 21 | 22 | void tc::crypto::detail::Sha1Impl::initialize() 23 | { 24 | mbedtls_md_starts(&(mImplCtx->mMdContext)); 25 | mState = State::Initialized; 26 | } 27 | 28 | void tc::crypto::detail::Sha1Impl::update(const byte_t* src, size_t src_size) 29 | { 30 | mbedtls_md_update(&(mImplCtx->mMdContext), src, src_size); 31 | } 32 | 33 | void tc::crypto::detail::Sha1Impl::getHash(byte_t* hash) 34 | { 35 | if (mState == State::Initialized) 36 | { 37 | mbedtls_md_finish(&(mImplCtx->mMdContext), mHash.data()); 38 | mState = State::Done; 39 | } 40 | if (mState == State::Done) 41 | { 42 | memcpy(hash, mHash.data(), mHash.size()); 43 | } 44 | } -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/src/io/IOUtil.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int64_t tc::io::IOUtil::castSizeToInt64(size_t size) 4 | { 5 | if (std::numeric_limits::digits > std::numeric_limits::digits) 6 | size = std::min(size, size_t(std::numeric_limits::max())); 7 | 8 | return int64_t(size); 9 | } 10 | 11 | size_t tc::io::IOUtil::castInt64ToSize(int64_t length) 12 | { 13 | if (length < 0) 14 | return 0; 15 | 16 | if (std::numeric_limits::digits < std::numeric_limits::digits) 17 | length = std::min(length, int64_t(std::numeric_limits::max())); 18 | 19 | return size_t(length); 20 | } 21 | 22 | size_t tc::io::IOUtil::getAvailableSize(int64_t data_length, int64_t data_offset) 23 | { 24 | if (data_length < 0 || data_offset < 0) 25 | return 0; 26 | 27 | int64_t readable_length = (data_offset < data_length) ? (data_length - data_offset) : 0; 28 | 29 | return castInt64ToSize(readable_length); 30 | } 31 | 32 | size_t tc::io::IOUtil::getReadableCount(int64_t data_length, int64_t data_offset, size_t requested_read_count) 33 | { 34 | return std::min(getAvailableSize(data_length, data_offset), requested_read_count); 35 | } 36 | 37 | size_t tc::io::IOUtil::getWritableCount(int64_t data_length, int64_t data_offset, size_t requested_write_count) 38 | { 39 | return getReadableCount(data_length, data_offset, requested_write_count); 40 | } -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/src/io/MemorySource.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | const std::string tc::io::MemorySource::kClassName = "tc::io::MemorySource"; 5 | 6 | tc::io::MemorySource::MemorySource() : 7 | mData() 8 | { 9 | 10 | } 11 | 12 | tc::io::MemorySource::MemorySource(const tc::ByteData& byte_data) : 13 | mData(byte_data) 14 | { 15 | 16 | } 17 | 18 | tc::io::MemorySource::MemorySource(tc::ByteData&& byte_data) : 19 | mData(std::move(byte_data)) 20 | { 21 | 22 | } 23 | 24 | 25 | tc::io::MemorySource::MemorySource(const byte_t* data, size_t len) : 26 | mData(data, len) 27 | { 28 | } 29 | 30 | int64_t tc::io::MemorySource::length() 31 | { 32 | return int64_t(mData.size()); 33 | } 34 | 35 | tc::ByteData tc::io::MemorySource::pullData(int64_t offset, size_t count) 36 | { 37 | size_t read_len = IOUtil::getReadableCount(this->length(), offset, count); 38 | 39 | // if the read length is zero then return now. 40 | if (read_len == 0) 41 | return tc::ByteData(); 42 | 43 | 44 | tc::ByteData out(read_len); 45 | 46 | memcpy(out.data(), mData.data() + offset, read_len); 47 | 48 | return out; 49 | } 50 | -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/src/io/PaddingSource.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | const std::string tc::io::PaddingSource::kClassName = "tc::io::PaddingSource"; 5 | 6 | tc::io::PaddingSource::PaddingSource() : 7 | mSourceLength(0), 8 | mPaddingByte(0) 9 | { 10 | } 11 | 12 | tc::io::PaddingSource::PaddingSource(byte_t padding_byte, int64_t size) : 13 | mSourceLength(size), 14 | mPaddingByte(padding_byte) 15 | { 16 | if (size < 0) 17 | { 18 | throw tc::ArgumentOutOfRangeException(kClassName, "length is negative"); 19 | } 20 | } 21 | 22 | int64_t tc::io::PaddingSource::length() 23 | { 24 | return mSourceLength; 25 | } 26 | 27 | tc::ByteData tc::io::PaddingSource::pullData(int64_t offset, size_t count) 28 | { 29 | tc::ByteData data(IOUtil::getReadableCount(mSourceLength, offset, count)); 30 | 31 | memset(data.data(), mPaddingByte, data.size()); 32 | 33 | return data; 34 | } -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/src/io/PathUtil.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void tc::io::PathUtil::pathToWindowsUTF16(const tc::io::Path& path, std::u16string& out) 5 | { 6 | out = path.to_u16string(tc::io::Path::Format::Win32); 7 | } 8 | 9 | void tc::io::PathUtil::pathToUnixUTF8(const tc::io::Path& path, std::string& out) 10 | { 11 | out = path.to_string(tc::io::Path::Format::POSIX); 12 | } 13 | -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/src/io/StreamUtil.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int64_t tc::io::StreamUtil::getSeekResult(int64_t offset, tc::io::SeekOrigin origin, int64_t current_position, int64_t stream_length) 4 | { 5 | int64_t new_pos = 0; 6 | switch (origin) 7 | { 8 | case (SeekOrigin::Begin): 9 | new_pos = offset; 10 | break; 11 | case (SeekOrigin::Current): 12 | new_pos = current_position + offset; 13 | break; 14 | case (SeekOrigin::End): 15 | new_pos = stream_length + offset; 16 | break; 17 | default: 18 | throw tc::ArgumentOutOfRangeException("Illegal value for origin."); 19 | } 20 | 21 | return new_pos; 22 | } -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/src/os/Environment.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | bool tc::os::getEnvVar(const std::string& name, std::string& value) 5 | { 6 | bool did_find_variable = false; 7 | #ifdef _WIN32 8 | // convert utf-8 to utf-16 for wide char functions 9 | std::u16string utf16_name; 10 | tc::string::TranscodeUtil::UTF8ToUTF16(name, utf16_name); 11 | 12 | // get size of environment variable 13 | size_t required_size = 0; 14 | _wgetenv_s(&required_size, nullptr, 0, (wchar_t*)utf16_name.c_str()); 15 | 16 | // set output if variable was found 17 | if (required_size != 0) 18 | { 19 | // get environment variable 20 | std::shared_ptr utf16_value(new wchar_t[required_size]); 21 | _wgetenv_s(&required_size, utf16_value.get(), required_size, (wchar_t*)utf16_name.c_str()); 22 | 23 | // transcode back to utf-8 24 | tc::string::TranscodeUtil::UTF16ToUTF8((char16_t*)utf16_value.get(), value); 25 | 26 | did_find_variable = true; 27 | } 28 | #else 29 | // get ptr to env variable 30 | char* env_ptr = getenv(name.c_str()); 31 | 32 | // set output if variable was found 33 | if (env_ptr != nullptr) 34 | { 35 | value = std::string(env_ptr); 36 | did_find_variable = true; 37 | } 38 | #endif 39 | return did_find_variable; 40 | } -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/src/types.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | bool tc::is_size_t_not_64bit() 4 | { 5 | return uint64_t(std::numeric_limits::max()) < std::numeric_limits::max(); 6 | } 7 | 8 | bool tc::is_size_t_too_large_for_int64_t(size_t val) 9 | { 10 | return uint64_t(std::numeric_limits::max()) < uint64_t(val); 11 | } 12 | 13 | bool tc::is_uint64_t_too_large_for_int64_t(uint64_t val) 14 | { 15 | return uint64_t(std::numeric_limits::max()) < val; 16 | } 17 | 18 | bool tc::is_int64_t_too_large_for_size_t(int64_t val) 19 | { 20 | return uint64_t(std::numeric_limits::max()) < uint64_t(val) || val < 0; 21 | } 22 | 23 | bool tc::is_uint64_t_too_large_for_size_t(uint64_t val) 24 | { 25 | return uint64_t(std::numeric_limits::max()) < val; 26 | } -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/ByteData_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | #include 4 | 5 | class ByteData_TestClass : public ITestClass 6 | { 7 | public: 8 | void runAllTests(); 9 | private: 10 | void test_Constructor_DefaultConstructor(); 11 | void test_Constructor_InitializerList(); 12 | void test_Constructor_CreateZeroSized(); 13 | void test_Constructor_CreateSmallSized(); 14 | void test_Constructor_CreateLargeSized(); 15 | void test_Constructor_ThrowExceptForBadAlloc(); 16 | void test_Constructor_CreateFromPtr(); 17 | void test_ImplicitCopy_CopyInSameScope(); 18 | void test_ImplicitCopy_CopyOntoInitiallisedByteData(); 19 | void test_ImplicitMove_CopyInSameScope(); 20 | void test_ImplicitMove_MoveOntoInitiallisedByteData(); 21 | void test_EqualityOperator(); 22 | void test_InequalityOperator(); 23 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/FileSystemTestUtil.cpp: -------------------------------------------------------------------------------- 1 | #include "FileSystemTestUtil.h" 2 | 3 | const std::string FileSystemTestUtil::DummyFileSystemBase::kClassName = "DummyFileSystemBase"; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/ITestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class ITestClass 4 | { 5 | public: 6 | virtual ~ITestClass() = default; 7 | virtual void runAllTests() = 0; 8 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/Optional_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | #include 5 | 6 | class Optional_TestClass : public ITestClass 7 | { 8 | public: 9 | void runAllTests(); 10 | private: 11 | void testDefaultConstructor(); 12 | void testWrapConstructor(); 13 | void testCopyConstructorFromNullOptional(); 14 | void testCopyConstructorFromExistingOptional(); 15 | void testWrapOperator(); 16 | void testCopyOperatorFromNullOptional(); 17 | void testCopyOperatorFromExistingOptional(); 18 | void testMakeNullOnNullOptional(); 19 | void testMakeNullOnExistingOptional(); 20 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/PbkdfUtil.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | class PbkdfUtil 6 | { 7 | public: 8 | struct TestVector 9 | { 10 | std::string test_name; 11 | 12 | std::string in_password; 13 | std::string in_salt; 14 | size_t in_rounds; 15 | size_t in_dk_len; 16 | tc::ByteData out_dk; 17 | }; 18 | 19 | enum HashAlgo 20 | { 21 | MD4, 22 | MD5, 23 | SHA1, 24 | SHA224, 25 | SHA256, 26 | SHA384, 27 | SHA512 28 | }; 29 | 30 | static void generatePbkdf1TestVectors_Custom(std::vector& test_list, PbkdfUtil::HashAlgo hash_algo); 31 | 32 | /// Implementation of https://gist.github.com/jakcron/ab05a200e5a6b53c77f28ebfc6342885 33 | static void generatePbkdf2TestVectors_RFC6070(std::vector& test_list, PbkdfUtil::HashAlgo hash_algo); 34 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/RsaOaepUtil.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | class RsaOaepUtil 6 | { 7 | public: 8 | struct TestVector 9 | { 10 | std::string test_name; 11 | 12 | tc::ByteData key_modulus; 13 | tc::ByteData key_private_exponent; 14 | tc::ByteData label; 15 | bool label_is_digested; 16 | tc::ByteData dec_message; 17 | tc::ByteData enc_seed; 18 | tc::ByteData enc_message; 19 | }; 20 | 21 | enum HashAlgo 22 | { 23 | MD4, 24 | MD5, 25 | SHA1, 26 | SHA224, 27 | SHA256, 28 | SHA384, 29 | SHA512 30 | }; 31 | 32 | /// Implementation of https://gist.github.com/jakcron/1c00ed37089743e38df46da2d9ccf6a0 33 | static void generateRsaOaepTestVectors_Custom(std::vector& test_list, size_t key_size, RsaOaepUtil::HashAlgo hash_algo); 34 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/RsaPkcs1Util.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | class RsaPkcs1Util 6 | { 7 | public: 8 | struct TestVector 9 | { 10 | std::string test_name; 11 | 12 | tc::ByteData key_modulus; 13 | tc::ByteData key_private_exponent; 14 | tc::ByteData message_digest; 15 | tc::ByteData signature; 16 | }; 17 | 18 | enum HashAlgo 19 | { 20 | MD4, 21 | MD5, 22 | SHA1, 23 | SHA224, 24 | SHA256, 25 | SHA384, 26 | SHA512 27 | }; 28 | 29 | /// Implementation of https://gist.github.com/jakcron/1c00ed37089743e38df46da2d9ccf6a0 30 | static void generateRsaPkcs1TestVectors_Custom(std::vector& test_list, size_t key_size, RsaPkcs1Util::HashAlgo hash_algo); 31 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/RsaPssUtil.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | class RsaPssUtil 6 | { 7 | public: 8 | struct TestVector 9 | { 10 | std::string test_name; 11 | 12 | tc::ByteData key_modulus; 13 | tc::ByteData key_private_exponent; 14 | tc::ByteData message_digest; 15 | tc::ByteData salt; 16 | tc::ByteData signature; 17 | }; 18 | 19 | enum HashAlgo 20 | { 21 | MD4, 22 | MD5, 23 | SHA1, 24 | SHA224, 25 | SHA256, 26 | SHA384, 27 | SHA512 28 | }; 29 | 30 | /// Implementation of https://gist.github.com/jakcron/1c00ed37089743e38df46da2d9ccf6a0 31 | static void generateRsaPssTestVectors_Custom(std::vector& test_list, size_t key_size, RsaPssUtil::HashAlgo hash_algo); 32 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/SinkTestUtil.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | class SinkTestUtil 8 | { 9 | public: 10 | static void testSinkLength(tc::io::ISink& source, int64_t expected_len); 11 | 12 | class DummySinkBase : public tc::io::ISink 13 | { 14 | public: 15 | DummySinkBase(); 16 | DummySinkBase(int64_t length); 17 | DummySinkBase(int64_t length, bool canSetLength); 18 | 19 | void init(int64_t length, bool canSetLength); 20 | 21 | int64_t length(); 22 | void setLength(int64_t length); 23 | virtual size_t pushData(const tc::ByteData& data, int64_t offset); 24 | private: 25 | static const std::string kClassName; 26 | bool mCanSetLength; 27 | int64_t mLength; 28 | }; 29 | 30 | class DummySinkTestablePushData : public DummySinkBase 31 | { 32 | public: 33 | DummySinkTestablePushData(); 34 | 35 | void setExpectedPushDataCfg(const tc::ByteData& data, int64_t offset); 36 | 37 | size_t pushData(const tc::ByteData& data, int64_t offset); 38 | private: 39 | std::shared_ptr expected_data; 40 | std::shared_ptr expected_offset; 41 | }; 42 | }; 43 | -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/SourceTestUtil.cpp: -------------------------------------------------------------------------------- 1 | #include "SourceTestUtil.h" 2 | #include 3 | 4 | void SourceTestUtil::testSourceLength(tc::io::ISource& source, int64_t expected_len) 5 | { 6 | std::stringstream error_ss; 7 | int64_t actual_len = source.length(); 8 | if (actual_len != expected_len) 9 | { 10 | error_ss << "length() returned: " << actual_len << ", when it should have been " << expected_len << "."; 11 | throw tc::Exception(error_ss.str()); 12 | } 13 | } 14 | 15 | void SourceTestUtil::pullTestHelper(tc::io::ISource& source, int64_t offset, size_t len, size_t expected_len, const byte_t* expected_data) 16 | { 17 | std::stringstream error_ss; 18 | 19 | tc::ByteData data = source.pullData(offset, len); 20 | 21 | if (data.size() != expected_len) 22 | { 23 | error_ss << "pullData(offset: " << offset << ", len:" << len << ") returned ByteData with size(): " << data.size() << ", when it should have been " << expected_len; 24 | throw tc::Exception(error_ss.str()); 25 | } 26 | 27 | if (expected_data != nullptr && memcmp(data.data(), expected_data, expected_len) != 0) 28 | { 29 | error_ss << "pullData(offset: " << offset << ", len:" << len << ") returned ByteData with incorrect layout"; 30 | throw tc::Exception(error_ss.str()); 31 | } 32 | } -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/SourceTestUtil.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | class SourceTestUtil 5 | { 6 | public: 7 | static void testSourceLength(tc::io::ISource& source, int64_t expected_len); 8 | static void pullTestHelper(tc::io::ISource& source, int64_t offset, size_t len, size_t expected_len, const byte_t* expected_data); 9 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/bn_binaryutils_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class bn_binaryutils_TestClass : public ITestClass 9 | { 10 | public: 11 | void runAllTests(); 12 | private: 13 | void test_RoundUpFunc(); 14 | void util_RoundUpFuncTestCase(uint32_t value, uint32_t alignment, uint32_t expected_result); 15 | 16 | void test_AlignFunc(); 17 | void util_AlignFuncTestCase(uint32_t value, uint32_t alignment, uint32_t expected_result); 18 | 19 | void test_MakeStructMagicU32Func(); 20 | void util_MakeStructMagicU32FuncTestCase(const char* struct_magic_str, uint32_t expected_result); 21 | 22 | void test_MakeStructMagicU64Func(); 23 | void util_MakeStructMagicU64FuncTestCase(const char* struct_magic_str, uint64_t expected_result); 24 | 25 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/bn_bitarrayByteBEBitBE_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | #include 4 | 5 | class bn_bitarrayByteBEBitBE_TestClass : public ITestClass 6 | { 7 | public: 8 | void runAllTests(); 9 | private: 10 | void test_Size(); 11 | void test_TestBit(); 12 | void test_SetBit(); 13 | void test_ResetBit(); 14 | void test_FlipBit(); 15 | 16 | using testtype_t = tc::bn::bitarray; 17 | 18 | void helper_TestBit(const std::string& test_name, const testtype_t& bitarray, const std::vector& expected_set_bits); 19 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/bn_bitarrayByteBEBitLE_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | #include 4 | 5 | class bn_bitarrayByteBEBitLE_TestClass : public ITestClass 6 | { 7 | public: 8 | void runAllTests(); 9 | private: 10 | void test_Size(); 11 | void test_TestBit(); 12 | void test_SetBit(); 13 | void test_ResetBit(); 14 | void test_FlipBit(); 15 | 16 | using testtype_t = tc::bn::bitarray; 17 | 18 | void helper_TestBit(const std::string& test_name, const testtype_t& bitarray, const std::vector& expected_set_bits); 19 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/bn_bitarrayByteLEBitBE_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | #include 4 | 5 | class bn_bitarrayByteLEBitBE_TestClass : public ITestClass 6 | { 7 | public: 8 | void runAllTests(); 9 | private: 10 | void test_Size(); 11 | void test_TestBit(); 12 | void test_SetBit(); 13 | void test_ResetBit(); 14 | void test_FlipBit(); 15 | 16 | using testtype_t = tc::bn::bitarray; 17 | 18 | void helper_TestBit(const std::string& test_name, const testtype_t& bitarray, const std::vector& expected_set_bits); 19 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/bn_bitarrayByteLEBitLE_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | #include 4 | 5 | class bn_bitarrayByteLEBitLE_TestClass : public ITestClass 6 | { 7 | public: 8 | void runAllTests(); 9 | private: 10 | void test_Size(); 11 | void test_TestBit(); 12 | void test_SetBit(); 13 | void test_ResetBit(); 14 | void test_FlipBit(); 15 | 16 | using testtype_t = tc::bn::bitarray; 17 | 18 | void helper_TestBit(const std::string& test_name, const testtype_t& bitarray, const std::vector& expected_set_bits); 19 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/bn_endian_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | class bn_endian_TestClass : public ITestClass 5 | { 6 | public: 7 | void runAllTests(); 8 | private: 9 | void testLocalBSwap16(); 10 | void testLocalBSwap32(); 11 | void testLocalBSwap64(); 12 | void testBeUint64Inline(); 13 | void testBeUint32Inline(); 14 | void testBeUint16Inline(); 15 | void testLeUint64Inline(); 16 | void testLeUint32Inline(); 17 | void testLeUint16Inline(); 18 | 19 | void testBeSwap64Inline(); 20 | void testBeSwap32Inline(); 21 | void testBeSwap16Inline(); 22 | void testLeSwap64Inline(); 23 | void testLeSwap32Inline(); 24 | void testLeSwap16Inline(); 25 | 26 | void testBe64TemplateClass(); 27 | void testBe32TemplateClass(); 28 | void testBe16TemplateClass(); 29 | void testLe64TemplateClass(); 30 | void testLe32TemplateClass(); 31 | void testLe16TemplateClass(); 32 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/bn_pad_TestClass.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "bn_pad_TestClass.h" 5 | 6 | void bn_pad_TestClass::runAllTests(void) 7 | { 8 | std::cout << "[tc::bn::pad] START" << std::endl; 9 | test_CorrectSize(); 10 | std::cout << "[tc::bn::pad] END" << std::endl; 11 | } 12 | 13 | void bn_pad_TestClass::test_CorrectSize() 14 | { 15 | std::cout << "[tc::bn::pad] test_CorrectSize : " << std::flush; 16 | try 17 | { 18 | try 19 | { 20 | tc::bn::pad<5> test_pad0; 21 | 22 | if (sizeof(test_pad0) != 5) 23 | { 24 | throw tc::Exception("tc::bn::pad<5> had incorrect sizeof()"); 25 | } 26 | 27 | if (test_pad0.size() != 5) 28 | { 29 | throw tc::Exception("tc::bn::pad<5> had incorrect pad::size() result"); 30 | } 31 | 32 | tc::bn::pad<0x200> test_pad1; 33 | 34 | if (sizeof(test_pad1) != 0x200) 35 | { 36 | throw tc::Exception("tc::bn::pad<0x200> had incorrect sizeof()"); 37 | } 38 | 39 | if (test_pad1.size() != 0x200) 40 | { 41 | throw tc::Exception("tc::bn::pad<0x200> had incorrect pad::size() result"); 42 | } 43 | 44 | std::cout << "PASS" << std::endl; 45 | } 46 | catch (const tc::Exception& e) 47 | { 48 | std::cout << "FAIL (" << e.error() << ")" << std::endl; 49 | } 50 | } 51 | catch (const std::exception& e) 52 | { 53 | std::cout << "UNHANDLED EXCEPTION (" << e.what() << ")" << std::endl; 54 | } 55 | } -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/bn_pad_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class bn_pad_TestClass : public ITestClass 9 | { 10 | public: 11 | void runAllTests(); 12 | private: 13 | void test_CorrectSize(); 14 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/bn_string_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class bn_string_TestClass : public ITestClass 9 | { 10 | public: 11 | void runAllTests(); 12 | private: 13 | void test_EncodedSizeVersusLogicalSize(); 14 | void test_StringSizeNeverExceedsLogicalSize(); 15 | void test_EncodeStringRespectsLogicalSize(); 16 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/cli_FormatUtil_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | #include 4 | 5 | class cli_FormatUtil_TestClass : public ITestClass 6 | { 7 | public: 8 | void runAllTests(); 9 | private: 10 | void testHexStringToBytes(); 11 | void testFormatBytesAsString(); 12 | void testFormatBytesAsStringWithLineLimit(); 13 | void testFormatListWithLineLimit(); 14 | void testFormatBytesAsHxdHexString(); 15 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/cli_OptionParser_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | #include 4 | 5 | class cli_OptionParser_TestClass : public ITestClass 6 | { 7 | public: 8 | void runAllTests(); 9 | private: 10 | void test_Constructor_DefaultConstructor(); 11 | void test_ProcessNoOptionsWithNoHandlers(); 12 | void test_ProcessOptionsWithNoHandlers(); 13 | void test_ProcessOptionsWithOnlyUnkHandler(); 14 | void test_ProcessOptionsWithLiteralHandlers(); 15 | void test_ProcessOptionsWithRegexHandlers(); 16 | void test_ProcessOptionsWithLiteralAndRegexHandlers(); 17 | void test_NullHandlerSupplied(); 18 | void test_RegularHandlerProvidesNoOptionLiteralOrRegex(); 19 | void test_ProcessMalformedOptions(); 20 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/crypto_Aes128CbcEncryptedStream_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class crypto_Aes128CbcEncryptedStream_TestClass : public ITestClass 9 | { 10 | public: 11 | void runAllTests(); 12 | private: 13 | void test_CreateEmptyStream_DefaultConstructor(); 14 | void test_CreateValidStream_CreateConstructor(); 15 | void test_RunTestCases(); 16 | 17 | struct TestCase 18 | { 19 | std::string test_name; 20 | tc::ByteData key; 21 | tc::ByteData iv; 22 | tc::ByteData ciphertext; 23 | int64_t read_offset; 24 | size_t read_size; 25 | tc::ByteData read_plaintext; 26 | }; 27 | 28 | void util_Setup_TestCases(std::vector& test_cases); 29 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/crypto_Aes128CbcEncryptor_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | #include 5 | #include 6 | 7 | class crypto_Aes128CbcEncryptor_TestClass : public ITestClass 8 | { 9 | public: 10 | void runAllTests(); 11 | private: 12 | void test_Constants(); 13 | void test_UseClassEnc(); 14 | void test_UseClassDec(); 15 | void test_UseUtilFuncEnc(); 16 | void test_UseUtilFuncDec(); 17 | 18 | void test_DoesNothingWhenNotInit(); 19 | void test_InitializeThrowsExceptionOnBadInput(); 20 | void test_EncryptThrowsExceptionOnBadInput(); 21 | void test_DecryptThrowsExceptionOnBadInput(); 22 | 23 | struct TestCase 24 | { 25 | std::string test_name; 26 | tc::ByteData key; 27 | tc::ByteData iv; 28 | tc::ByteData plaintext; 29 | tc::ByteData ciphertext; 30 | }; 31 | 32 | void util_Setup_TestCases(std::vector& test_cases); 33 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/crypto_Aes128CtrEncryptedStream_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class crypto_Aes128CtrEncryptedStream_TestClass : public ITestClass 9 | { 10 | public: 11 | void runAllTests(); 12 | private: 13 | void test_CreateEmptyStream_DefaultConstructor(); 14 | void test_CreateValidStream_CreateConstructor(); 15 | void test_RunTestCases(); 16 | 17 | struct TestCase 18 | { 19 | std::string test_name; 20 | tc::ByteData key; 21 | tc::ByteData counter; 22 | tc::ByteData ciphertext; 23 | int64_t read_offset; 24 | size_t read_size; 25 | tc::ByteData read_plaintext; 26 | }; 27 | 28 | void util_Setup_TestCases(std::vector& test_cases); 29 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/crypto_Aes128CtrEncryptor_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | #include 5 | #include 6 | 7 | class crypto_Aes128CtrEncryptor_TestClass : public ITestClass 8 | { 9 | public: 10 | void runAllTests(); 11 | private: 12 | void test_Constants(); 13 | void test_UseClassEnc(); 14 | void test_UseClassDec(); 15 | void test_UseUtilFuncEnc(); 16 | void test_UseUtilFuncDec(); 17 | 18 | void test_DoesNothingWhenNotInit(); 19 | void test_InitializeThrowsExceptionOnBadInput(); 20 | void test_EncryptThrowsExceptionOnBadInput(); 21 | void test_DecryptThrowsExceptionOnBadInput(); 22 | 23 | struct TestCase 24 | { 25 | std::string test_name; 26 | tc::ByteData key; 27 | tc::ByteData iv; 28 | uint64_t block_number; 29 | tc::ByteData plaintext; 30 | tc::ByteData ciphertext; 31 | }; 32 | 33 | void util_Setup_TestCases(std::vector& test_cases); 34 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/crypto_Aes128EcbEncryptor_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | #include 5 | #include 6 | 7 | class crypto_Aes128EcbEncryptor_TestClass : public ITestClass 8 | { 9 | public: 10 | void runAllTests(); 11 | private: 12 | void test_Constants(); 13 | void test_UseClassEnc(); 14 | void test_UseClassDec(); 15 | void test_UseUtilFuncEnc(); 16 | void test_UseUtilFuncDec(); 17 | 18 | void test_DoesNothingWhenNotInit(); 19 | void test_InitializeThrowsExceptionOnBadInput(); 20 | void test_EncryptThrowsExceptionOnBadInput(); 21 | void test_DecryptThrowsExceptionOnBadInput(); 22 | 23 | struct TestCase 24 | { 25 | std::string test_name; 26 | tc::ByteData key; 27 | tc::ByteData plaintext; 28 | tc::ByteData ciphertext; 29 | }; 30 | 31 | void util_Setup_TestCases(std::vector& test_cases); 32 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/crypto_Aes128Encryptor_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | #include 5 | #include 6 | 7 | class crypto_Aes128Encryptor_TestClass : public ITestClass 8 | { 9 | public: 10 | void runAllTests(); 11 | private: 12 | void test_Constants(); 13 | void test_UseClassEnc(); 14 | void test_UseClassDec(); 15 | 16 | void test_DoesNothingWhenNotInit(); 17 | void test_InitializeThrowsExceptionOnBadInput(); 18 | void test_EncryptThrowsExceptionOnBadInput(); 19 | void test_DecryptThrowsExceptionOnBadInput(); 20 | 21 | struct TestCase 22 | { 23 | std::string test_name; 24 | tc::ByteData key; 25 | tc::ByteData plaintext; 26 | tc::ByteData ciphertext; 27 | }; 28 | 29 | void util_Setup_TestCases(std::vector& test_cases); 30 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/crypto_Aes128XtsEncryptor_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | #include 5 | #include 6 | 7 | class crypto_Aes128XtsEncryptor_TestClass : public ITestClass 8 | { 9 | public: 10 | void runAllTests(); 11 | private: 12 | void test_Constants(); 13 | void test_UseClassEnc(); 14 | void test_UseClassDec(); 15 | void test_UseUtilFuncEnc(); 16 | void test_UseUtilFuncDec(); 17 | 18 | void test_DoesNothingWhenNotInit(); 19 | void test_InitializeThrowsExceptionOnBadInput(); 20 | void test_EncryptThrowsExceptionOnBadInput(); 21 | void test_DecryptThrowsExceptionOnBadInput(); 22 | 23 | struct TestCase 24 | { 25 | std::string test_name; 26 | tc::ByteData key1; 27 | tc::ByteData key2; 28 | uint64_t data_unit; 29 | uint64_t data_unit_sequence_number; 30 | tc::ByteData plaintext; 31 | tc::ByteData ciphertext; 32 | }; 33 | 34 | void util_Setup_IEEE1619_2007_TestCases(std::vector& test_cases); 35 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/crypto_Aes192CbcEncryptor_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | #include 5 | #include 6 | 7 | class crypto_Aes192CbcEncryptor_TestClass : public ITestClass 8 | { 9 | public: 10 | void runAllTests(); 11 | private: 12 | void test_Constants(); 13 | void test_UseClassEnc(); 14 | void test_UseClassDec(); 15 | void test_UseUtilFuncEnc(); 16 | void test_UseUtilFuncDec(); 17 | 18 | void test_DoesNothingWhenNotInit(); 19 | void test_InitializeThrowsExceptionOnBadInput(); 20 | void test_EncryptThrowsExceptionOnBadInput(); 21 | void test_DecryptThrowsExceptionOnBadInput(); 22 | 23 | struct TestCase 24 | { 25 | std::string test_name; 26 | tc::ByteData key; 27 | tc::ByteData iv; 28 | tc::ByteData plaintext; 29 | tc::ByteData ciphertext; 30 | }; 31 | 32 | void util_Setup_TestCases(std::vector& test_cases); 33 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/crypto_Aes192CtrEncryptor_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | #include 5 | #include 6 | 7 | class crypto_Aes192CtrEncryptor_TestClass : public ITestClass 8 | { 9 | public: 10 | void runAllTests(); 11 | private: 12 | void test_Constants(); 13 | void test_UseClassEnc(); 14 | void test_UseClassDec(); 15 | void test_UseUtilFuncEnc(); 16 | void test_UseUtilFuncDec(); 17 | 18 | void test_DoesNothingWhenNotInit(); 19 | void test_InitializeThrowsExceptionOnBadInput(); 20 | void test_EncryptThrowsExceptionOnBadInput(); 21 | void test_DecryptThrowsExceptionOnBadInput(); 22 | 23 | struct TestCase 24 | { 25 | std::string test_name; 26 | tc::ByteData key; 27 | tc::ByteData iv; 28 | uint64_t block_number; 29 | tc::ByteData plaintext; 30 | tc::ByteData ciphertext; 31 | }; 32 | 33 | void util_Setup_TestCases(std::vector& test_cases); 34 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/crypto_Aes192EcbEncryptor_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | #include 5 | #include 6 | 7 | class crypto_Aes192EcbEncryptor_TestClass : public ITestClass 8 | { 9 | public: 10 | void runAllTests(); 11 | private: 12 | void test_Constants(); 13 | void test_UseClassEnc(); 14 | void test_UseClassDec(); 15 | void test_UseUtilFuncEnc(); 16 | void test_UseUtilFuncDec(); 17 | 18 | void test_DoesNothingWhenNotInit(); 19 | void test_InitializeThrowsExceptionOnBadInput(); 20 | void test_EncryptThrowsExceptionOnBadInput(); 21 | void test_DecryptThrowsExceptionOnBadInput(); 22 | 23 | struct TestCase 24 | { 25 | std::string test_name; 26 | tc::ByteData key; 27 | tc::ByteData plaintext; 28 | tc::ByteData ciphertext; 29 | }; 30 | 31 | void util_Setup_TestCases(std::vector& test_cases); 32 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/crypto_Aes192Encryptor_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | #include 5 | #include 6 | 7 | class crypto_Aes192Encryptor_TestClass : public ITestClass 8 | { 9 | public: 10 | void runAllTests(); 11 | private: 12 | void test_Constants(); 13 | void test_UseClassEnc(); 14 | void test_UseClassDec(); 15 | 16 | void test_DoesNothingWhenNotInit(); 17 | void test_InitializeThrowsExceptionOnBadInput(); 18 | void test_EncryptThrowsExceptionOnBadInput(); 19 | void test_DecryptThrowsExceptionOnBadInput(); 20 | 21 | struct TestCase 22 | { 23 | std::string test_name; 24 | tc::ByteData key; 25 | tc::ByteData plaintext; 26 | tc::ByteData ciphertext; 27 | }; 28 | 29 | void util_Setup_TestCases(std::vector& test_cases); 30 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/crypto_Aes256CbcEncryptor_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | #include 5 | #include 6 | 7 | class crypto_Aes256CbcEncryptor_TestClass : public ITestClass 8 | { 9 | public: 10 | void runAllTests(); 11 | private: 12 | void test_Constants(); 13 | void test_UseClassEnc(); 14 | void test_UseClassDec(); 15 | void test_UseUtilFuncEnc(); 16 | void test_UseUtilFuncDec(); 17 | 18 | void test_DoesNothingWhenNotInit(); 19 | void test_InitializeThrowsExceptionOnBadInput(); 20 | void test_EncryptThrowsExceptionOnBadInput(); 21 | void test_DecryptThrowsExceptionOnBadInput(); 22 | 23 | struct TestCase 24 | { 25 | std::string test_name; 26 | tc::ByteData key; 27 | tc::ByteData iv; 28 | tc::ByteData plaintext; 29 | tc::ByteData ciphertext; 30 | }; 31 | 32 | void util_Setup_TestCases(std::vector& test_cases); 33 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/crypto_Aes256CtrEncryptor_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | #include 5 | #include 6 | 7 | class crypto_Aes256CtrEncryptor_TestClass : public ITestClass 8 | { 9 | public: 10 | void runAllTests(); 11 | private: 12 | void test_Constants(); 13 | void test_UseClassEnc(); 14 | void test_UseClassDec(); 15 | void test_UseUtilFuncEnc(); 16 | void test_UseUtilFuncDec(); 17 | 18 | void test_DoesNothingWhenNotInit(); 19 | void test_InitializeThrowsExceptionOnBadInput(); 20 | void test_EncryptThrowsExceptionOnBadInput(); 21 | void test_DecryptThrowsExceptionOnBadInput(); 22 | 23 | struct TestCase 24 | { 25 | std::string test_name; 26 | tc::ByteData key; 27 | tc::ByteData iv; 28 | uint64_t block_number; 29 | tc::ByteData plaintext; 30 | tc::ByteData ciphertext; 31 | }; 32 | 33 | void util_Setup_TestCases(std::vector& test_cases); 34 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/crypto_Aes256EcbEncryptor_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | #include 5 | #include 6 | 7 | class crypto_Aes256EcbEncryptor_TestClass : public ITestClass 8 | { 9 | public: 10 | void runAllTests(); 11 | private: 12 | void test_Constants(); 13 | void test_UseClassEnc(); 14 | void test_UseClassDec(); 15 | void test_UseUtilFuncEnc(); 16 | void test_UseUtilFuncDec(); 17 | 18 | void test_DoesNothingWhenNotInit(); 19 | void test_InitializeThrowsExceptionOnBadInput(); 20 | void test_EncryptThrowsExceptionOnBadInput(); 21 | void test_DecryptThrowsExceptionOnBadInput(); 22 | 23 | struct TestCase 24 | { 25 | std::string test_name; 26 | tc::ByteData key; 27 | tc::ByteData plaintext; 28 | tc::ByteData ciphertext; 29 | }; 30 | 31 | void util_Setup_TestCases(std::vector& test_cases); 32 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/crypto_Aes256Encryptor_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | #include 5 | #include 6 | 7 | class crypto_Aes256Encryptor_TestClass : public ITestClass 8 | { 9 | public: 10 | void runAllTests(); 11 | private: 12 | void test_Constants(); 13 | void test_UseClassEnc(); 14 | void test_UseClassDec(); 15 | 16 | void test_DoesNothingWhenNotInit(); 17 | void test_InitializeThrowsExceptionOnBadInput(); 18 | void test_EncryptThrowsExceptionOnBadInput(); 19 | void test_DecryptThrowsExceptionOnBadInput(); 20 | 21 | struct TestCase 22 | { 23 | std::string test_name; 24 | tc::ByteData key; 25 | tc::ByteData plaintext; 26 | tc::ByteData ciphertext; 27 | }; 28 | 29 | void util_Setup_TestCases(std::vector& test_cases); 30 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/crypto_Aes256XtsEncryptor_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | #include 5 | #include 6 | 7 | class crypto_Aes256XtsEncryptor_TestClass : public ITestClass 8 | { 9 | public: 10 | void runAllTests(); 11 | private: 12 | void test_Constants(); 13 | void test_UseClassEnc(); 14 | void test_UseClassDec(); 15 | void test_UseUtilFuncEnc(); 16 | void test_UseUtilFuncDec(); 17 | 18 | void test_DoesNothingWhenNotInit(); 19 | void test_InitializeThrowsExceptionOnBadInput(); 20 | void test_EncryptThrowsExceptionOnBadInput(); 21 | void test_DecryptThrowsExceptionOnBadInput(); 22 | 23 | struct TestCase 24 | { 25 | std::string test_name; 26 | tc::ByteData key1; 27 | tc::ByteData key2; 28 | size_t data_unit; 29 | uint64_t data_unit_sequence_number; 30 | tc::ByteData plaintext; 31 | tc::ByteData ciphertext; 32 | }; 33 | 34 | void util_Setup_IEEE1619_2007_TestCases(std::vector& test_cases); 35 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/crypto_HmacMd5Generator_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | #include 5 | #include 6 | 7 | class crypto_HmacMd5Generator_TestClass : public ITestClass 8 | { 9 | public: 10 | void runAllTests(); 11 | private: 12 | void test_Constants(); 13 | void test_SingleUpdateCall(); 14 | void test_MultiUpdateCall(); 15 | void test_UtilFunc(); 16 | 17 | void test_NoInitNoUpdateDoMac(); 18 | void test_NoInitDoUpdateDoMac(); 19 | void test_DoInitNoUpdateDoMac(); 20 | void test_DoInitNoKeyDoUpdateDoMac(); 21 | void test_DoInitNoKeyNoUpdateDoMac(); 22 | 23 | void test_CallGetMacRepeatedly(); 24 | 25 | struct TestCase 26 | { 27 | std::string test_name; 28 | tc::ByteData in_data; 29 | tc::ByteData in_key; 30 | tc::ByteData out_mac; 31 | }; 32 | 33 | void util_Setup_Rfc2202_TestCases(std::vector& test_cases); 34 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/crypto_HmacSha1Generator_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | #include 5 | #include 6 | 7 | class crypto_HmacSha1Generator_TestClass : public ITestClass 8 | { 9 | public: 10 | void runAllTests(); 11 | private: 12 | void test_Constants(); 13 | void test_SingleUpdateCall(); 14 | void test_MultiUpdateCall(); 15 | void test_UtilFunc(); 16 | 17 | void test_NoInitNoUpdateDoMac(); 18 | void test_NoInitDoUpdateDoMac(); 19 | void test_DoInitNoUpdateDoMac(); 20 | void test_DoInitNoKeyDoUpdateDoMac(); 21 | void test_DoInitNoKeyNoUpdateDoMac(); 22 | 23 | void test_CallGetMacRepeatedly(); 24 | 25 | struct TestCase 26 | { 27 | std::string test_name; 28 | tc::ByteData in_data; 29 | tc::ByteData in_key; 30 | tc::ByteData out_mac; 31 | }; 32 | 33 | void util_Setup_Rfc2202_TestCases(std::vector& test_cases); 34 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/crypto_HmacSha256Generator_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | #include 5 | #include 6 | 7 | class crypto_HmacSha256Generator_TestClass : public ITestClass 8 | { 9 | public: 10 | void runAllTests(); 11 | private: 12 | void test_Constants(); 13 | void test_SingleUpdateCall(); 14 | void test_MultiUpdateCall(); 15 | void test_UtilFunc(); 16 | 17 | void test_NoInitNoUpdateDoMac(); 18 | void test_NoInitDoUpdateDoMac(); 19 | void test_DoInitNoUpdateDoMac(); 20 | void test_DoInitNoKeyDoUpdateDoMac(); 21 | void test_DoInitNoKeyNoUpdateDoMac(); 22 | 23 | void test_CallGetMacRepeatedly(); 24 | 25 | struct TestCase 26 | { 27 | std::string test_name; 28 | tc::ByteData in_data; 29 | tc::ByteData in_key; 30 | tc::ByteData out_mac; 31 | }; 32 | 33 | void util_Setup_Rfc4231_TestCases(std::vector& test_cases); 34 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/crypto_HmacSha512Generator_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | #include 5 | #include 6 | 7 | class crypto_HmacSha512Generator_TestClass : public ITestClass 8 | { 9 | public: 10 | void runAllTests(); 11 | private: 12 | void test_Constants(); 13 | void test_SingleUpdateCall(); 14 | void test_MultiUpdateCall(); 15 | void test_UtilFunc(); 16 | 17 | void test_NoInitNoUpdateDoMac(); 18 | void test_NoInitDoUpdateDoMac(); 19 | void test_DoInitNoUpdateDoMac(); 20 | void test_DoInitNoKeyDoUpdateDoMac(); 21 | void test_DoInitNoKeyNoUpdateDoMac(); 22 | 23 | void test_CallGetMacRepeatedly(); 24 | 25 | struct TestCase 26 | { 27 | std::string test_name; 28 | tc::ByteData in_data; 29 | tc::ByteData in_key; 30 | tc::ByteData out_mac; 31 | }; 32 | 33 | void util_Setup_Rfc4231_TestCases(std::vector& test_cases); 34 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/crypto_Md5Generator_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | class crypto_Md5Generator_TestClass : public ITestClass 5 | { 6 | public: 7 | void runAllTests(); 8 | private: 9 | void test_Constants(); 10 | void test_SingleUpdateCall(); 11 | void test_MultiUpdateCall(); 12 | void test_UtilFunc(); 13 | 14 | void test_NoInitNoUpdateDoHash(); 15 | void test_NoInitDoUpdateDoHash(); 16 | void test_DoInitNoUpdateDoHash(); 17 | void test_CallGetHashRepeatedly(); 18 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/crypto_Pbkdf1Md5KeyDeriver_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | class crypto_Pbkdf1Md5KeyDeriver_TestClass : public ITestClass 5 | { 6 | public: 7 | void runAllTests(); 8 | private: 9 | void test_Constants(); 10 | void test_ConfirmTestVector_Class(); 11 | void test_ConfirmTestVector_UtilFunc(); 12 | void test_WillThrowExceptionOnZeroRounds(); 13 | void test_WillThrowExceptionOnTooLargeDkSize(); 14 | void test_GetBytesWithoutInitDoesNothing(); 15 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/crypto_Pbkdf1Sha1KeyDeriver_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | class crypto_Pbkdf1Sha1KeyDeriver_TestClass : public ITestClass 5 | { 6 | public: 7 | void runAllTests(); 8 | private: 9 | void test_Constants(); 10 | void test_ConfirmTestVector_Class(); 11 | void test_ConfirmTestVector_UtilFunc(); 12 | void test_WillThrowExceptionOnZeroRounds(); 13 | void test_WillThrowExceptionOnTooLargeDkSize(); 14 | void test_GetBytesWithoutInitDoesNothing(); 15 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/crypto_Pbkdf2Sha1KeyDeriver_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | class crypto_Pbkdf2Sha1KeyDeriver_TestClass : public ITestClass 5 | { 6 | public: 7 | void runAllTests(); 8 | private: 9 | void test_Constants(); 10 | void test_ConfirmTestVector_Class(); 11 | void test_ConfirmTestVector_UtilFunc(); 12 | void test_WillThrowExceptionOnZeroRounds(); 13 | void test_WillThrowExceptionOnTooLargeDkSize(); 14 | void test_GetBytesWithoutInitDoesNothing(); 15 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/crypto_Pbkdf2Sha256KeyDeriver_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | class crypto_Pbkdf2Sha256KeyDeriver_TestClass : public ITestClass 5 | { 6 | public: 7 | void runAllTests(); 8 | private: 9 | void test_Constants(); 10 | void test_ConfirmTestVector_Class(); 11 | void test_ConfirmTestVector_UtilFunc(); 12 | void test_WillThrowExceptionOnZeroRounds(); 13 | void test_WillThrowExceptionOnTooLargeDkSize(); 14 | void test_GetBytesWithoutInitDoesNothing(); 15 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/crypto_Pbkdf2Sha512KeyDeriver_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | class crypto_Pbkdf2Sha512KeyDeriver_TestClass : public ITestClass 5 | { 6 | public: 7 | void runAllTests(); 8 | private: 9 | void test_Constants(); 10 | void test_ConfirmTestVector_Class(); 11 | void test_ConfirmTestVector_UtilFunc(); 12 | void test_WillThrowExceptionOnZeroRounds(); 13 | void test_WillThrowExceptionOnTooLargeDkSize(); 14 | void test_GetBytesWithoutInitDoesNothing(); 15 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/crypto_PseudoRandomByteGenerator_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | class crypto_PseudoRandomByteGenerator_TestClass : public ITestClass 5 | { 6 | public: 7 | void runAllTests(); 8 | private: 9 | void test_Class(); 10 | void test_UtilFunc(); 11 | 12 | void test_MultipleObjectsCreateDifferentData(); 13 | void test_RepeatedCallsCreateDifferentData(); 14 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/crypto_Rsa1024OaepSha256Encryptor_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | #include 5 | #include 6 | 7 | class crypto_Rsa1024OaepSha256Encryptor_TestClass : public ITestClass 8 | { 9 | public: 10 | void runAllTests(); 11 | private: 12 | void test_Constants(); 13 | void test_UseClassDec(); 14 | void test_UseClassEnc(); 15 | void test_UseUtilFuncDec(); 16 | void test_UseUtilFuncEnc(); 17 | void test_UnspecifiedSeedProducesDifferentBlock(); 18 | 19 | void test_DoesNothingWhenNotInit(); 20 | void test_InitializeThrowsExceptionOnBadInput(); 21 | void test_EncryptReturnsFalseOnBadInput(); 22 | void test_DecryptReturnsFalseOnBadInput(); 23 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/crypto_Rsa1024Pkcs1Md5Signer_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | #include 5 | #include 6 | 7 | class crypto_Rsa1024Pkcs1Md5Signer_TestClass : public ITestClass 8 | { 9 | public: 10 | void runAllTests(); 11 | private: 12 | void test_Constants(); 13 | void test_UseClassSign(); 14 | void test_UseClassVerify(); 15 | void test_UseUtilFuncSign(); 16 | void test_UseUtilFuncVerify(); 17 | 18 | void test_DoesNothingWhenNotInit(); 19 | void test_InitializeThrowsExceptionOnBadInput(); 20 | void test_SignReturnsFalseOnBadInput(); 21 | void test_VerifyReturnsFalseOnBadInput(); 22 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/crypto_Rsa1024Pkcs1Sha1Signer_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | #include 5 | #include 6 | 7 | class crypto_Rsa1024Pkcs1Sha1Signer_TestClass : public ITestClass 8 | { 9 | public: 10 | void runAllTests(); 11 | private: 12 | void test_Constants(); 13 | void test_UseClassSign(); 14 | void test_UseClassVerify(); 15 | void test_UseUtilFuncSign(); 16 | void test_UseUtilFuncVerify(); 17 | 18 | void test_DoesNothingWhenNotInit(); 19 | void test_InitializeThrowsExceptionOnBadInput(); 20 | void test_SignReturnsFalseOnBadInput(); 21 | void test_VerifyReturnsFalseOnBadInput(); 22 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/crypto_Rsa1024Pkcs1Sha256Signer_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | #include 5 | #include 6 | 7 | class crypto_Rsa1024Pkcs1Sha256Signer_TestClass : public ITestClass 8 | { 9 | public: 10 | void runAllTests(); 11 | private: 12 | void test_Constants(); 13 | void test_UseClassSign(); 14 | void test_UseClassVerify(); 15 | void test_UseUtilFuncSign(); 16 | void test_UseUtilFuncVerify(); 17 | 18 | void test_DoesNothingWhenNotInit(); 19 | void test_InitializeThrowsExceptionOnBadInput(); 20 | void test_SignReturnsFalseOnBadInput(); 21 | void test_VerifyReturnsFalseOnBadInput(); 22 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/crypto_Rsa1024Pkcs1Sha512Signer_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | #include 5 | #include 6 | 7 | class crypto_Rsa1024Pkcs1Sha512Signer_TestClass : public ITestClass 8 | { 9 | public: 10 | void runAllTests(); 11 | private: 12 | void test_Constants(); 13 | void test_UseClassSign(); 14 | void test_UseClassVerify(); 15 | void test_UseUtilFuncSign(); 16 | void test_UseUtilFuncVerify(); 17 | 18 | void test_DoesNothingWhenNotInit(); 19 | void test_InitializeThrowsExceptionOnBadInput(); 20 | void test_SignReturnsFalseOnBadInput(); 21 | void test_VerifyReturnsFalseOnBadInput(); 22 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/crypto_Rsa1024PssSha256Signer_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | #include 5 | #include 6 | 7 | class crypto_Rsa1024PssSha256Signer_TestClass : public ITestClass 8 | { 9 | public: 10 | void runAllTests(); 11 | private: 12 | void test_Constants(); 13 | void test_UseClassSign(); 14 | void test_UseClassVerify(); 15 | void test_UseUtilFuncSign(); 16 | void test_UseUtilFuncVerify(); 17 | 18 | void test_DoesNothingWhenNotInit(); 19 | void test_InitializeThrowsExceptionOnBadInput(); 20 | void test_SignReturnsFalseOnBadInput(); 21 | void test_VerifyReturnsFalseOnBadInput(); 22 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/crypto_Rsa1024PssSha512Signer_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | #include 5 | #include 6 | 7 | class crypto_Rsa1024PssSha512Signer_TestClass : public ITestClass 8 | { 9 | public: 10 | void runAllTests(); 11 | private: 12 | void test_Constants(); 13 | void test_UseClassSign(); 14 | void test_UseClassVerify(); 15 | void test_UseUtilFuncSign(); 16 | void test_UseUtilFuncVerify(); 17 | 18 | void test_DoesNothingWhenNotInit(); 19 | void test_InitializeThrowsExceptionOnBadInput(); 20 | void test_SignReturnsFalseOnBadInput(); 21 | void test_VerifyReturnsFalseOnBadInput(); 22 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/crypto_Rsa2048OaepSha256Encryptor_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | #include 5 | #include 6 | 7 | class crypto_Rsa2048OaepSha256Encryptor_TestClass : public ITestClass 8 | { 9 | public: 10 | void runAllTests(); 11 | private: 12 | void test_Constants(); 13 | void test_UseClassDec(); 14 | void test_UseClassEnc(); 15 | void test_UseUtilFuncDec(); 16 | void test_UseUtilFuncEnc(); 17 | void test_UnspecifiedSeedProducesDifferentBlock(); 18 | 19 | void test_DoesNothingWhenNotInit(); 20 | void test_InitializeThrowsExceptionOnBadInput(); 21 | void test_EncryptReturnsFalseOnBadInput(); 22 | void test_DecryptReturnsFalseOnBadInput(); 23 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/crypto_Rsa2048OaepSha512Encryptor_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | #include 5 | #include 6 | 7 | class crypto_Rsa2048OaepSha512Encryptor_TestClass : public ITestClass 8 | { 9 | public: 10 | void runAllTests(); 11 | private: 12 | void test_Constants(); 13 | void test_UseClassDec(); 14 | void test_UseClassEnc(); 15 | void test_UseUtilFuncDec(); 16 | void test_UseUtilFuncEnc(); 17 | void test_UnspecifiedSeedProducesDifferentBlock(); 18 | 19 | void test_DoesNothingWhenNotInit(); 20 | void test_InitializeThrowsExceptionOnBadInput(); 21 | void test_EncryptReturnsFalseOnBadInput(); 22 | void test_DecryptReturnsFalseOnBadInput(); 23 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/crypto_Rsa2048Pkcs1Md5Signer_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | #include 5 | #include 6 | 7 | class crypto_Rsa2048Pkcs1Md5Signer_TestClass : public ITestClass 8 | { 9 | public: 10 | void runAllTests(); 11 | private: 12 | void test_Constants(); 13 | void test_UseClassSign(); 14 | void test_UseClassVerify(); 15 | void test_UseUtilFuncSign(); 16 | void test_UseUtilFuncVerify(); 17 | 18 | void test_DoesNothingWhenNotInit(); 19 | void test_InitializeThrowsExceptionOnBadInput(); 20 | void test_SignReturnsFalseOnBadInput(); 21 | void test_VerifyReturnsFalseOnBadInput(); 22 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/crypto_Rsa2048Pkcs1Sha1Signer_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | #include 5 | #include 6 | 7 | class crypto_Rsa2048Pkcs1Sha1Signer_TestClass : public ITestClass 8 | { 9 | public: 10 | void runAllTests(); 11 | private: 12 | void test_Constants(); 13 | void test_UseClassSign(); 14 | void test_UseClassVerify(); 15 | void test_UseUtilFuncSign(); 16 | void test_UseUtilFuncVerify(); 17 | 18 | void test_DoesNothingWhenNotInit(); 19 | void test_InitializeThrowsExceptionOnBadInput(); 20 | void test_SignReturnsFalseOnBadInput(); 21 | void test_VerifyReturnsFalseOnBadInput(); 22 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/crypto_Rsa2048Pkcs1Sha256Signer_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | #include 5 | #include 6 | 7 | class crypto_Rsa2048Pkcs1Sha256Signer_TestClass : public ITestClass 8 | { 9 | public: 10 | void runAllTests(); 11 | private: 12 | void test_Constants(); 13 | void test_UseClassSign(); 14 | void test_UseClassVerify(); 15 | void test_UseUtilFuncSign(); 16 | void test_UseUtilFuncVerify(); 17 | 18 | void test_DoesNothingWhenNotInit(); 19 | void test_InitializeThrowsExceptionOnBadInput(); 20 | void test_SignReturnsFalseOnBadInput(); 21 | void test_VerifyReturnsFalseOnBadInput(); 22 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/crypto_Rsa2048Pkcs1Sha512Signer_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | #include 5 | #include 6 | 7 | class crypto_Rsa2048Pkcs1Sha512Signer_TestClass : public ITestClass 8 | { 9 | public: 10 | void runAllTests(); 11 | private: 12 | void test_Constants(); 13 | void test_UseClassSign(); 14 | void test_UseClassVerify(); 15 | void test_UseUtilFuncSign(); 16 | void test_UseUtilFuncVerify(); 17 | 18 | void test_DoesNothingWhenNotInit(); 19 | void test_InitializeThrowsExceptionOnBadInput(); 20 | void test_SignReturnsFalseOnBadInput(); 21 | void test_VerifyReturnsFalseOnBadInput(); 22 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/crypto_Rsa2048PssSha256Signer_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | #include 5 | #include 6 | 7 | class crypto_Rsa2048PssSha256Signer_TestClass : public ITestClass 8 | { 9 | public: 10 | void runAllTests(); 11 | private: 12 | void test_Constants(); 13 | void test_UseClassSign(); 14 | void test_UseClassVerify(); 15 | void test_UseUtilFuncSign(); 16 | void test_UseUtilFuncVerify(); 17 | 18 | void test_DoesNothingWhenNotInit(); 19 | void test_InitializeThrowsExceptionOnBadInput(); 20 | void test_SignReturnsFalseOnBadInput(); 21 | void test_VerifyReturnsFalseOnBadInput(); 22 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/crypto_Rsa2048PssSha512Signer_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | #include 5 | #include 6 | 7 | class crypto_Rsa2048PssSha512Signer_TestClass : public ITestClass 8 | { 9 | public: 10 | void runAllTests(); 11 | private: 12 | void test_Constants(); 13 | void test_UseClassSign(); 14 | void test_UseClassVerify(); 15 | void test_UseUtilFuncSign(); 16 | void test_UseUtilFuncVerify(); 17 | 18 | void test_DoesNothingWhenNotInit(); 19 | void test_InitializeThrowsExceptionOnBadInput(); 20 | void test_SignReturnsFalseOnBadInput(); 21 | void test_VerifyReturnsFalseOnBadInput(); 22 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/crypto_Rsa4096OaepSha256Encryptor_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | #include 5 | #include 6 | 7 | class crypto_Rsa4096OaepSha256Encryptor_TestClass : public ITestClass 8 | { 9 | public: 10 | void runAllTests(); 11 | private: 12 | void test_Constants(); 13 | void test_UseClassDec(); 14 | void test_UseClassEnc(); 15 | void test_UseUtilFuncDec(); 16 | void test_UseUtilFuncEnc(); 17 | void test_UnspecifiedSeedProducesDifferentBlock(); 18 | 19 | void test_DoesNothingWhenNotInit(); 20 | void test_InitializeThrowsExceptionOnBadInput(); 21 | void test_EncryptReturnsFalseOnBadInput(); 22 | void test_DecryptReturnsFalseOnBadInput(); 23 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/crypto_Rsa4096OaepSha512Encryptor_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | #include 5 | #include 6 | 7 | class crypto_Rsa4096OaepSha512Encryptor_TestClass : public ITestClass 8 | { 9 | public: 10 | void runAllTests(); 11 | private: 12 | void test_Constants(); 13 | void test_UseClassDec(); 14 | void test_UseClassEnc(); 15 | void test_UseUtilFuncDec(); 16 | void test_UseUtilFuncEnc(); 17 | void test_UnspecifiedSeedProducesDifferentBlock(); 18 | 19 | void test_DoesNothingWhenNotInit(); 20 | void test_InitializeThrowsExceptionOnBadInput(); 21 | void test_EncryptReturnsFalseOnBadInput(); 22 | void test_DecryptReturnsFalseOnBadInput(); 23 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/crypto_Rsa4096Pkcs1Md5Signer_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | #include 5 | #include 6 | 7 | class crypto_Rsa4096Pkcs1Md5Signer_TestClass : public ITestClass 8 | { 9 | public: 10 | void runAllTests(); 11 | private: 12 | void test_Constants(); 13 | void test_UseClassSign(); 14 | void test_UseClassVerify(); 15 | void test_UseUtilFuncSign(); 16 | void test_UseUtilFuncVerify(); 17 | 18 | void test_DoesNothingWhenNotInit(); 19 | void test_InitializeThrowsExceptionOnBadInput(); 20 | void test_SignReturnsFalseOnBadInput(); 21 | void test_VerifyReturnsFalseOnBadInput(); 22 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/crypto_Rsa4096Pkcs1Sha1Signer_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | #include 5 | #include 6 | 7 | class crypto_Rsa4096Pkcs1Sha1Signer_TestClass : public ITestClass 8 | { 9 | public: 10 | void runAllTests(); 11 | private: 12 | void test_Constants(); 13 | void test_UseClassSign(); 14 | void test_UseClassVerify(); 15 | void test_UseUtilFuncSign(); 16 | void test_UseUtilFuncVerify(); 17 | 18 | void test_DoesNothingWhenNotInit(); 19 | void test_InitializeThrowsExceptionOnBadInput(); 20 | void test_SignReturnsFalseOnBadInput(); 21 | void test_VerifyReturnsFalseOnBadInput(); 22 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/crypto_Rsa4096Pkcs1Sha256Signer_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | #include 5 | #include 6 | 7 | class crypto_Rsa4096Pkcs1Sha256Signer_TestClass : public ITestClass 8 | { 9 | public: 10 | void runAllTests(); 11 | private: 12 | void test_Constants(); 13 | void test_UseClassSign(); 14 | void test_UseClassVerify(); 15 | void test_UseUtilFuncSign(); 16 | void test_UseUtilFuncVerify(); 17 | 18 | void test_DoesNothingWhenNotInit(); 19 | void test_InitializeThrowsExceptionOnBadInput(); 20 | void test_SignReturnsFalseOnBadInput(); 21 | void test_VerifyReturnsFalseOnBadInput(); 22 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/crypto_Rsa4096Pkcs1Sha512Signer_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | #include 5 | #include 6 | 7 | class crypto_Rsa4096Pkcs1Sha512Signer_TestClass : public ITestClass 8 | { 9 | public: 10 | void runAllTests(); 11 | private: 12 | void test_Constants(); 13 | void test_UseClassSign(); 14 | void test_UseClassVerify(); 15 | void test_UseUtilFuncSign(); 16 | void test_UseUtilFuncVerify(); 17 | 18 | void test_DoesNothingWhenNotInit(); 19 | void test_InitializeThrowsExceptionOnBadInput(); 20 | void test_SignReturnsFalseOnBadInput(); 21 | void test_VerifyReturnsFalseOnBadInput(); 22 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/crypto_Rsa4096PssSha256Signer_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | #include 5 | #include 6 | 7 | class crypto_Rsa4096PssSha256Signer_TestClass : public ITestClass 8 | { 9 | public: 10 | void runAllTests(); 11 | private: 12 | void test_Constants(); 13 | void test_UseClassSign(); 14 | void test_UseClassVerify(); 15 | void test_UseUtilFuncSign(); 16 | void test_UseUtilFuncVerify(); 17 | 18 | void test_DoesNothingWhenNotInit(); 19 | void test_InitializeThrowsExceptionOnBadInput(); 20 | void test_SignReturnsFalseOnBadInput(); 21 | void test_VerifyReturnsFalseOnBadInput(); 22 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/crypto_Rsa4096PssSha512Signer_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | #include 5 | #include 6 | 7 | class crypto_Rsa4096PssSha512Signer_TestClass : public ITestClass 8 | { 9 | public: 10 | void runAllTests(); 11 | private: 12 | void test_Constants(); 13 | void test_UseClassSign(); 14 | void test_UseClassVerify(); 15 | void test_UseUtilFuncSign(); 16 | void test_UseUtilFuncVerify(); 17 | 18 | void test_DoesNothingWhenNotInit(); 19 | void test_InitializeThrowsExceptionOnBadInput(); 20 | void test_SignReturnsFalseOnBadInput(); 21 | void test_VerifyReturnsFalseOnBadInput(); 22 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/crypto_Sha1Generator_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | class crypto_Sha1Generator_TestClass : public ITestClass 5 | { 6 | public: 7 | void runAllTests(); 8 | private: 9 | void test_Constants(); 10 | void test_SingleUpdateCall(); 11 | void test_MultiUpdateCall(); 12 | void test_UtilFunc(); 13 | 14 | void test_NoInitNoUpdateDoHash(); 15 | void test_NoInitDoUpdateDoHash(); 16 | void test_DoInitNoUpdateDoHash(); 17 | void test_CallGetHashRepeatedly(); 18 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/crypto_Sha256Generator_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | class crypto_Sha256Generator_TestClass : public ITestClass 5 | { 6 | public: 7 | void runAllTests(); 8 | private: 9 | void test_Constants(); 10 | void test_SingleUpdateCall(); 11 | void test_MultiUpdateCall(); 12 | void test_UtilFunc(); 13 | 14 | void test_NoInitNoUpdateDoHash(); 15 | void test_NoInitDoUpdateDoHash(); 16 | void test_DoInitNoUpdateDoHash(); 17 | void test_CallGetHashRepeatedly(); 18 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/crypto_Sha512Generator_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | class crypto_Sha512Generator_TestClass : public ITestClass 5 | { 6 | public: 7 | void runAllTests(); 8 | private: 9 | void test_Constants(); 10 | void test_SingleUpdateCall(); 11 | void test_MultiUpdateCall(); 12 | void test_UtilFunc(); 13 | 14 | void test_NoInitNoUpdateDoHash(); 15 | void test_NoInitDoUpdateDoHash(); 16 | void test_DoInitNoUpdateDoHash(); 17 | void test_CallGetHashRepeatedly(); 18 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/io_BasicPathResolver_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | #include 5 | 6 | class io_BasicPathResolver_TestClass : public ITestClass 7 | { 8 | public: 9 | void runAllTests(); 10 | private: 11 | void test_EmptyStateAfterDefaultConstructor(); 12 | void test_setCurrentDirectory(); 13 | void test_setExplicitRootLabels(); 14 | void test_ResolveRootDirRelativePaths(); 15 | void test_ResolveWorkingDirectoryRelativePaths(); 16 | void test_ResolvePathsWithCustomRootLabels(); 17 | 18 | void util_RunResolutionTest(const tc::io::Path& in_path, const tc::io::Path& in_working_dir_path, const tc::io::Path& expected_resolved_path); 19 | void util_RunResolutionTest(const tc::io::Path& in_path, const tc::io::Path& in_working_dir_path, const std::vector& root_labels, const tc::io::Path& expected_resolved_path); 20 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/io_LocalFileSystem_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | class io_LocalFileSystem_TestClass : public ITestClass 5 | { 6 | public: 7 | void runAllTests(); 8 | private: 9 | void test_CreateFile_NotExist(); 10 | void test_CreateFile_DoesExist(); 11 | void test_CreateFile_UnicodePath(); 12 | void test_RemoveFile_DoesExist(); 13 | void test_RemoveFile_NotExist(); 14 | void test_RemoveFile_UnicodePath(); 15 | void test_CreateDirectory_NotExist(); 16 | void test_CreateDirectory_DoesExist(); 17 | void test_CreateDirectory_UnicodePath(); 18 | void test_RemoveDirectory_DoesExist(); 19 | void test_RemoveDirectory_NotExist(); 20 | void test_RemoveDirectory_UnicodePath(); 21 | void test_RemoveDirectory_HasChildren(); 22 | void test_RemoveDirectory_NotDirectoryActuallyFile(); 23 | void test_GetDirectoryListing_DoesExist(); 24 | void test_GetDirectoryListing_NotExist(); 25 | void test_GetDirectoryListing_UnicodePath(); 26 | void test_ChangeWorkingDirectory_DoesExist(); 27 | void test_ChangeWorkingDirectory_NotExist(); 28 | void test_ChangeWorkingDirectory_UnicodePath(); 29 | 30 | static std::string kDirPath; 31 | static std::string kUtf8DirPath; 32 | static std::string kAsciiFilePath; 33 | static std::string kUtf8TestPath; 34 | static std::string kNotExistFilePath; 35 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/io_MemorySource_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | #include 5 | 6 | class io_MemorySource_TestClass : public ITestClass 7 | { 8 | public: 9 | void runAllTests(); 10 | private: 11 | void testDefaultConstructor(); 12 | void testInitializeByCopyWithByteData(); 13 | void testInitializeByMoveWithByteData(); 14 | void testInitializeByCopyWithMemoryPointer(); 15 | void testNegativeOffset(); 16 | void testTooLargeOffset(); 17 | }; 18 | -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/io_MemoryStream_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | #include 5 | 6 | class io_MemoryStream_TestClass : public ITestClass 7 | { 8 | public: 9 | void runAllTests(); 10 | private: 11 | void testCreateEmptyStream_DefaultConstructor(); 12 | void testCreateEmptyStream_SizedConstructor(); 13 | void testCreatePopulatedStream(); 14 | void testInitializeByCopyWithByteData(); 15 | void testInitializeByMoveWithByteData(); 16 | void testInitializeByCopyWithMemoryPointer(); 17 | void testSeekBeginToZero(); 18 | void testSeekBeginToMiddle(); 19 | void testSeekBeginToEnd(); 20 | void testSeekBeginPastEnd(); 21 | void testSeekBeginNegative(); 22 | void testSeekCurrentByZero(); 23 | void testSeekCurrentToMiddle(); 24 | void testSeekCurrentToEnd(); 25 | void testSeekCurrentPastEnd(); 26 | void testSeekCurrentNegative(); 27 | void testSeekEndByZero(); 28 | void testSeekEndPastEnd(); 29 | void testSeekEndNegative(); 30 | void testSeekEndTooNegative(); 31 | void testReadAllDataAvailable(); 32 | void testReadRequestsSubsetOfAvailableData(); 33 | void testReadSomeDataAvailable(); 34 | void testReadNoDataAvailable(); 35 | void testWriteAllDataWritable(); 36 | void testWriteToSomeOfDataAvailable(); 37 | void testWriteSomeDataWritable(); 38 | void testWriteNoDataWritable(); 39 | void testWriteReadDataPersistence(); 40 | void testResizeStreamLarger(); 41 | void testResizeStreamSmaller(); 42 | void testDispose(); 43 | }; 44 | -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/io_OverlayedSource_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | #include 5 | 6 | class io_OverlayedSource_TestClass : public ITestClass 7 | { 8 | public: 9 | void runAllTests(); 10 | private: 11 | void testDefaultConstructor(); 12 | void testSingleOverlayConstructor(); 13 | void testMultiOverlayConstructor(); 14 | void testNullBaseStream(); 15 | void testNullOverlayStream(); 16 | void testOverlayStreamTooSmallForOverlayRegion(); 17 | void testOverlayRegionBeforeBaseStream(); 18 | void testOverlayRegionPartlyBeforeBaseStream(); 19 | void testOverlayRegionAfterBaseStream(); 20 | void testOverlayRegionPartlyAfterBaseStream(); 21 | }; 22 | -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/io_PaddingSource_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | class io_PaddingSource_TestClass : public ITestClass 5 | { 6 | public: 7 | void runAllTests(); 8 | private: 9 | void testDefaultConstructor(); 10 | void testCreateConstructor(); 11 | void testNegativeOffset(); 12 | void testTooLargeOffset(); 13 | }; 14 | -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/io_Path_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | #include 4 | #include 5 | 6 | class io_Path_TestClass : public ITestClass 7 | { 8 | public: 9 | void runAllTests(); 10 | private: 11 | void test_Constructor_Default(); 12 | void test_Constructor_InitializerList(); 13 | void test_Constructor_u8string(); 14 | void test_Constructor_u16string(); 15 | void test_Constructor_u32string(); 16 | void test_Method_pop_front(); 17 | void test_Method_pop_back(); 18 | void test_Method_push_front(); 19 | void test_Method_push_back(); 20 | void test_Method_clear(); 21 | void test_Method_substr_withPosLen(); 22 | void test_Method_substr_withIterator(); 23 | void test_Method_to_string(); 24 | void test_Method_to_u16string(); 25 | void test_Method_to_u32string(); 26 | void test_Operator_string(); 27 | void test_Operator_u16string(); 28 | void test_Operator_u32string(); 29 | void test_Operator_Addition(); 30 | void test_Operator_Append(); 31 | void test_Scenario_AppendStressTest(); 32 | void test_Operator_EqualityTest(); 33 | void test_Operator_InequalityTest(); 34 | void test_Operator_LessThanTest(); 35 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/io_StreamSink_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | #include 5 | #include 6 | 7 | class io_StreamSink_TestClass : public ITestClass 8 | { 9 | public: 10 | void runAllTests(); 11 | private: 12 | void testDefaultConstructor(); 13 | void testCreateConstructor(); 14 | void testCreateFromNullStream(); 15 | void testCreateFromStreamWithoutSeek(); 16 | void testCreateFromStreamWithoutRead(); 17 | void testCreateFromStreamWithoutWrite(); 18 | void testSetLengthOnDisposedBase(); 19 | void testPushDataOnDisposedBase(); 20 | void testPushDataOutsideOfBaseRange(); 21 | 22 | void pushTestHelper(tc::io::ISink& sink, const std::shared_ptr& base_stream, tc::ByteData& expected_data, int64_t push_offset); 23 | }; 24 | -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/io_StreamSource_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | class io_StreamSource_TestClass : public ITestClass 5 | { 6 | public: 7 | void runAllTests(); 8 | private: 9 | void testDefaultConstructor(); 10 | void testCreateConstructor(); 11 | void testCreateFromStreamWithoutSeek(); 12 | void testCreateFromStreamWithoutRead(); 13 | void testCreateFromStreamWithoutWrite(); 14 | void testNegativeOffset(); 15 | void testTooLargeOffset(); 16 | }; 17 | -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/io_SubFileSystem_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | class io_SubFileSystem_TestClass : public ITestClass 5 | { 6 | public: 7 | void runAllTests(); 8 | private: 9 | void testBaseFileSystemRetainsWorkingDirectory(); 10 | void testGetSetWorkingDirectory(); 11 | void testCreateFile(); 12 | void testOpenFile(); 13 | void testRemoveFile(); 14 | void testCreateDirectory(); 15 | void testRemoveDirectory(); 16 | void testGetDirectoryListing(); 17 | void testNavigateUpSubFileSystemEscape(); 18 | void testOpenFileOutsideSubFileSystem(); 19 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/io_SubSink_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | #include 5 | #include "SinkTestUtil.h" 6 | 7 | class io_SubSink_TestClass : public ITestClass 8 | { 9 | public: 10 | void runAllTests(); 11 | private: 12 | void testDefaultConstructor(); 13 | void testCreateConstructor(); 14 | void testCreateFromNullBase(); 15 | void testCreateWithNegativeSubSinkOffset(); 16 | void testCreateWithNegativeSubSinkLength(); 17 | void testCreateWithExcessiveSubSink(); 18 | void testCreateThenSetLength(); 19 | void testSetLengthOnDisposedBase(); 20 | void testPushDataOnDisposedBase(); 21 | void testPushDataOutsideOfBaseRange(); 22 | 23 | void pushDataTestHelper(tc::io::ISink& sub_sink, const std::shared_ptr& base_sink, int64_t sub_base_offset, int64_t sub_push_offset, tc::ByteData& push_data, tc::ByteData& expected_data); 24 | }; 25 | -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/io_SubSource_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | class io_SubSource_TestClass : public ITestClass 5 | { 6 | public: 7 | void runAllTests(); 8 | private: 9 | void testDefaultConstructor(); 10 | void testCreateConstructor(); 11 | void testNegativeOffset(); 12 | void testTooLargeOffset(); 13 | }; 14 | -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/io_SubStream_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class io_SubStream_TestClass : public ITestClass 9 | { 10 | public: 11 | void runAllTests(); 12 | private: 13 | void testProperties(); 14 | void testSize(); 15 | void testSeekPos(); 16 | void testRead(); 17 | void testWrite(); 18 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/io_VirtualFileSystem_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | class io_VirtualFileSystem_TestClass : public ITestClass 5 | { 6 | public: 7 | void runAllTests(); 8 | private: 9 | void test_CreateUninitializedFs_DefaultConstructor(); 10 | void test_BadFsSnapshot_CreateConstructor(); 11 | void test_CreateFs_CreateConstructor(); 12 | void test_ThrowsOnBadPermissions_OpenFile(); 13 | void test_ThrowsOnBadFileEntry_OpenFile(); 14 | void test_ThrowsOnBadFileEntry_GetDirectoryListing(); 15 | void test_ThrowsOnBadFileEntry_SetWorkingDirectory(); 16 | void test_WorksForAllValidPaths_OpenFile(); 17 | void test_WorksForAllValidPaths_GetDirectoryListing(); 18 | void test_WorksForAllValidPaths_SetWorkingDirectory(); 19 | void test_WorksForAllValidPaths_GetWorkingDirectory(); 20 | void test_DisposeWillChangeStateToUninitialized(); 21 | }; -------------------------------------------------------------------------------- /ctrtool/deps/libtoolchain/test/string_TranscodeUtil_TestClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ITestClass.h" 3 | 4 | #include 5 | 6 | class string_TranscodeUtil_TestClass : public ITestClass 7 | { 8 | public: 9 | void runAllTests(); 10 | private: 11 | void testUtf8ToUtf16(); 12 | void testUtf16ToUtf8(); 13 | }; -------------------------------------------------------------------------------- /ctrtool/src/CrrProcess.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "types.h" 3 | #include "KeyBag.h" 4 | #include 5 | #include 6 | 7 | namespace ctrtool { 8 | 9 | class CrrProcess 10 | { 11 | public: 12 | CrrProcess(); 13 | 14 | void setInputStream(const std::shared_ptr& input_stream); 15 | void setKeyBag(const ctrtool::KeyBag& key_bag); 16 | void setCliOutputMode(bool show_info); 17 | void setVerboseMode(bool verbose); 18 | void setVerifyMode(bool verify); 19 | 20 | void process(); 21 | private: 22 | std::string mModuleLabel; 23 | 24 | std::shared_ptr mInputStream; 25 | ctrtool::KeyBag mKeyBag; 26 | bool mShowInfo; 27 | bool mVerbose; 28 | bool mVerify; 29 | 30 | ntd::n3ds::CrrHeader mHeader; 31 | ntd::n3ds::CrrBodyHeader mBodyHeader; 32 | tc::ByteData mCrrData; 33 | 34 | byte_t mValidCertificateSignature; 35 | byte_t mValidBodySignature; 36 | byte_t mValidUniqueId; 37 | 38 | void importData(); 39 | void verifyData(); 40 | void printData(); 41 | 42 | // string utils 43 | std::string getValidString(byte_t validstate); 44 | }; 45 | 46 | } -------------------------------------------------------------------------------- /ctrtool/src/ExeFsProcess.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "types.h" 3 | #include 4 | #include 5 | #include 6 | 7 | namespace ctrtool { 8 | 9 | class ExeFsProcess 10 | { 11 | public: 12 | ExeFsProcess(); 13 | 14 | void setInputStream(const std::shared_ptr& input_stream); 15 | void setCliOutputMode(bool show_header_info, bool show_fs); 16 | void setVerboseMode(bool verbose); 17 | void setVerifyMode(bool verify); 18 | void setRawMode(bool raw); 19 | void setDecompressCode(bool decompress_code); 20 | void setExtractPath(const tc::io::Path& extract_path); 21 | 22 | void process(); 23 | private: 24 | std::string mModuleLabel; 25 | 26 | std::shared_ptr mInputStream; 27 | bool mShowHeaderInfo; 28 | bool mShowFs; 29 | bool mVerbose; 30 | bool mVerify; 31 | bool mRaw; 32 | bool mDecompressCode; 33 | tc::Optional mExtractPath; 34 | 35 | ntd::n3ds::ExeFsHeader mHeader; 36 | std::shared_ptr mFsReader; 37 | std::array mSectionValidation; 38 | 39 | void importHeader(); 40 | void verifyFs(); 41 | void printHeader(); 42 | void printFs(); 43 | void extractFs(); 44 | 45 | // string utils 46 | std::string getValidString(byte_t validstate); 47 | }; 48 | 49 | } -------------------------------------------------------------------------------- /ctrtool/src/IvfcProcess.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "types.h" 3 | #include "KeyBag.h" 4 | #include "RomFsProcess.h" 5 | #include 6 | #include 7 | #include 8 | 9 | namespace ctrtool { 10 | 11 | class IvfcProcess 12 | { 13 | public: 14 | IvfcProcess(); 15 | 16 | void setInputStream(const std::shared_ptr& input_stream); 17 | void setKeyBag(const ctrtool::KeyBag& key_bag); 18 | void setCliOutputMode(bool show_header_info, bool show_fs); 19 | void setVerboseMode(bool verbose); 20 | void setVerifyMode(bool verify); 21 | void setExtractPath(const tc::io::Path& extract_path); 22 | 23 | void process(); 24 | private: 25 | std::string mModuleLabel; 26 | 27 | std::shared_ptr mInputStream; 28 | ctrtool::KeyBag mKeyBag; 29 | bool mShowHeaderInfo; 30 | bool mShowFs; 31 | bool mVerbose; 32 | bool mVerify; 33 | tc::Optional mExtractPath; 34 | 35 | ntd::n3ds::IvfcCtrRomfsHeader mHeader; 36 | ctrtool::RomFsProcess mRomFsProcess; 37 | int64_t mMasterHashOffset; 38 | std::array mActualLevelOffsets; 39 | std::array mLevelValidation; 40 | 41 | void processHeader(); 42 | void verifyLevels(); 43 | void printHeader(); 44 | void processRomFs(); 45 | 46 | // string utils 47 | std::string getValidString(byte_t validstate); 48 | }; 49 | 50 | } -------------------------------------------------------------------------------- /ctrtool/src/LzssProcess.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "types.h" 3 | #include 4 | #include 5 | #include 6 | 7 | namespace ctrtool { 8 | 9 | class LzssProcess 10 | { 11 | public: 12 | LzssProcess(); 13 | 14 | void setInputStream(const std::shared_ptr& input_stream); 15 | void setExtractPath(const tc::io::Path& extract_path); 16 | 17 | void process(); 18 | private: 19 | std::string mModuleLabel; 20 | 21 | std::shared_ptr mInputStream; 22 | tc::Optional mExtractPath; 23 | }; 24 | 25 | } -------------------------------------------------------------------------------- /ctrtool/src/RomFsProcess.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "types.h" 3 | #include "KeyBag.h" 4 | #include 5 | #include 6 | #include 7 | 8 | namespace ctrtool { 9 | 10 | class RomFsProcess 11 | { 12 | public: 13 | RomFsProcess(); 14 | 15 | void setInputStream(const std::shared_ptr& input_stream); 16 | void setKeyBag(const ctrtool::KeyBag& key_bag); 17 | void setCliOutputMode(bool show_header_info, bool show_fs); 18 | void setVerboseMode(bool verbose); 19 | void setVerifyMode(bool verify); 20 | void setExtractPath(const tc::io::Path& extract_path); 21 | 22 | 23 | void process(); 24 | private: 25 | std::string mModuleLabel; 26 | 27 | std::shared_ptr mInputStream; 28 | ctrtool::KeyBag mKeyBag; 29 | bool mShowHeaderInfo; 30 | bool mShowFs; 31 | bool mVerbose; 32 | bool mVerify; 33 | tc::Optional mExtractPath; 34 | 35 | ntd::n3ds::RomFsHeader mHeader; 36 | std::shared_ptr mFsReader; 37 | std::shared_ptr mStaticCrr; 38 | 39 | void processHeader(); 40 | void printHeader(); 41 | void processCrr(); 42 | void printFs(); 43 | void extractFs(); 44 | 45 | void visitDir(const tc::io::Path& v_path, const tc::io::Path& l_path, bool extract_fs, bool print_fs); 46 | }; 47 | 48 | } -------------------------------------------------------------------------------- /ctrtool/src/lzss.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | uint32_t lzss_get_decompressed_size(uint8_t* compressed, uint32_t compressedsize); 9 | int lzss_decompress(uint8_t* compressed, uint32_t compressedsize, uint8_t* decompressed, uint32_t decompressedsize); 10 | 11 | #ifdef __cplusplus 12 | } 13 | #endif -------------------------------------------------------------------------------- /ctrtool/src/types.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | 6 | namespace ctrtool { 7 | 8 | enum ValidState : byte_t 9 | { 10 | Unchecked, 11 | Good, 12 | Fail 13 | }; 14 | 15 | } -------------------------------------------------------------------------------- /ctrtool/src/util.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "types.h" 3 | #include 4 | 5 | namespace ctrtool 6 | { 7 | 8 | void writeSubStreamToFile(const std::shared_ptr& in_stream, int64_t offset, int64_t length, const tc::io::Path& out_path, tc::ByteData& cache); 9 | void writeSubStreamToFile(const std::shared_ptr& in_stream, int64_t offset, int64_t length, const tc::io::Path& out_path, size_t cache_size = 0x10000); 10 | void writeStreamToFile(const std::shared_ptr& in_stream, const tc::io::Path& out_path, tc::ByteData& cache); 11 | void writeStreamToFile(const std::shared_ptr& in_stream, const tc::io::Path& out_path, size_t cache_size = 0x10000); 12 | void writeStreamToStream(const std::shared_ptr& in_stream, const std::shared_ptr& out_stream, tc::ByteData& cache); 13 | void writeStreamToStream(const std::shared_ptr& in_stream, const std::shared_ptr& out_stream, size_t cache_size = 0x10000); 14 | 15 | } -------------------------------------------------------------------------------- /ctrtool/src/version.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #define APP_NAME "CTRTool" 3 | #define BIN_NAME "ctrtool" 4 | #define VER_MAJOR 1 5 | #define VER_MINOR 2 6 | #define VER_PATCH 1 7 | #define AUTHORS "jakcron" 8 | -------------------------------------------------------------------------------- /makefile: -------------------------------------------------------------------------------- 1 | # Project Name 2 | PROJECT_NAME = Project_CTR 3 | 4 | # Project Relative Paths 5 | PROJECT_PATH = $(CURDIR) 6 | PROJECT_PROGRAM_LOCAL_DIR = ctrtool makerom 7 | 8 | # Detect Platform 9 | ifeq ($(PROJECT_PLATFORM),) 10 | ifeq ($(OS), Windows_NT) 11 | export PROJECT_PLATFORM = WIN32 12 | else 13 | UNAME = $(shell uname -s) 14 | ifeq ($(UNAME), Darwin) 15 | export PROJECT_PLATFORM = MACOS 16 | else 17 | export PROJECT_PLATFORM = GNU 18 | endif 19 | endif 20 | endif 21 | 22 | # Detect Architecture 23 | ifeq ($(PROJECT_PLATFORM_ARCH),) 24 | ifeq ($(PROJECT_PLATFORM), WIN32) 25 | export PROJECT_PLATFORM_ARCH = x86_64 26 | else ifeq ($(PROJECT_PLATFORM), GNU) 27 | export PROJECT_PLATFORM_ARCH = $(shell uname -m) 28 | else ifeq ($(PROJECT_PLATFORM), MACOS) 29 | export PROJECT_PLATFORM_ARCH = $(shell uname -m) 30 | else 31 | export PROJECT_PLATFORM_ARCH = x86_64 32 | endif 33 | endif 34 | 35 | # all is the default, user should specify what the default should do 36 | # - 'deps' for building local dependencies. 37 | # - 'program' for building executable programs. 38 | all: progs 39 | 40 | clean: clean_progs 41 | 42 | # Programs 43 | .PHONY: progs 44 | progs: 45 | @$(foreach prog,$(PROJECT_PROGRAM_LOCAL_DIR), cd "$(prog)" && $(MAKE) deps program && cd "$(PROJECT_PATH)";) 46 | 47 | .PHONY: clean_progs 48 | clean_progs: 49 | @$(foreach prog,$(PROJECT_PROGRAM_LOCAL_DIR), cd "$(prog)" && $(MAKE) clean_deps clean && cd "$(PROJECT_PATH)";) -------------------------------------------------------------------------------- /makerom/BUILDING.md: -------------------------------------------------------------------------------- 1 | # Building 2 | ## Linux (incl. Windows Subsystem for Linux) & MacOS & Windows (MinGW)- Makefile 3 | ### Requirements 4 | * `make` 5 | * Terminal access 6 | * Typical GNU compatible development tools (e.g. `clang`, `gcc`, `ar` etc) with __C11__ support 7 | 8 | ### Using Makefile 9 | * `make` (default) - Compile program 10 | * Compiling the program requires local dependencies to be compiled via `make deps` beforehand 11 | * `make clean` - Remove executable and object files 12 | * `make deps` - Compile locally included dependency libraries 13 | * `make clean_deps` - Remove compiled library binaries and object files -------------------------------------------------------------------------------- /makerom/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2014 3DSGuy 4 | Copyright (c) 2014 applestash 5 | Copyright (c) 2015-2022 Jakcron 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. -------------------------------------------------------------------------------- /makerom/build/visualstudio/makerom.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.24720.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "makerom", "makerom.vcxproj", "{21926330-F5A5-4643-AD32-D4F167CE226B}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {21926330-F5A5-4643-AD32-D4F167CE226B}.Debug|x64.ActiveCfg = Debug|x64 17 | {21926330-F5A5-4643-AD32-D4F167CE226B}.Debug|x64.Build.0 = Debug|x64 18 | {21926330-F5A5-4643-AD32-D4F167CE226B}.Debug|x86.ActiveCfg = Debug|Win32 19 | {21926330-F5A5-4643-AD32-D4F167CE226B}.Debug|x86.Build.0 = Debug|Win32 20 | {21926330-F5A5-4643-AD32-D4F167CE226B}.Release|x64.ActiveCfg = Release|x64 21 | {21926330-F5A5-4643-AD32-D4F167CE226B}.Release|x64.Build.0 = Release|x64 22 | {21926330-F5A5-4643-AD32-D4F167CE226B}.Release|x86.ActiveCfg = Release|Win32 23 | {21926330-F5A5-4643-AD32-D4F167CE226B}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /makerom/build/visualstudio/readme.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | MAKEFILE PROJECT : makerom Project Overview 3 | ======================================================================== 4 | 5 | AppWizard has created this makerom project for you. 6 | 7 | This file contains a summary of what you will find in each of the files that 8 | make up your makerom project. 9 | 10 | 11 | makerom.vcxproj 12 | This is the main project file for VC++ projects generated using an Application Wizard. 13 | It contains information about the version of Visual C++ that generated the file, and 14 | information about the platforms, configurations, and project features selected with the 15 | Application Wizard. 16 | 17 | makerom.vcxproj.filters 18 | This is the filters file for VC++ projects generated using an Application Wizard. 19 | It contains information about the association between the files in your project 20 | and the filters. This association is used in the IDE to show grouping of files with 21 | similar extensions under a specific node (for e.g. ".cpp" files are associated with the 22 | "Source Files" filter). 23 | 24 | This project allows you to build/clean/rebuild from within Visual Studio by calling the commands you have input 25 | in the wizard. The build command can be nmake or any other tool you use. 26 | 27 | This project does not contain any files, so there are none displayed in Solution Explorer. 28 | 29 | ///////////////////////////////////////////////////////////////////////////// 30 | -------------------------------------------------------------------------------- /makerom/deps/libblz/include/blz.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #define BLZ_NORMAL 0 // normal mode 9 | #define BLZ_BEST 1 // best mode 10 | 11 | uint8_t *BLZ_Code(uint8_t *raw_buffer, int raw_len, uint32_t *new_len, int best); 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif -------------------------------------------------------------------------------- /makerom/deps/libmbedtls/LICENSE: -------------------------------------------------------------------------------- 1 | Unless specifically indicated otherwise in a file, files are licensed 2 | under the Apache 2.0 license, as can be found in: apache-2.0.txt 3 | -------------------------------------------------------------------------------- /makerom/deps/libmbedtls/README.md: -------------------------------------------------------------------------------- 1 | # libmbedtls 2 | Cryptographic functions. Clone of [mbedtls 2.16.5](https://github.com/ARMmbed/mbedtls/tree/mbedtls-2.16). 3 | -------------------------------------------------------------------------------- /makerom/deps/libmbedtls/include/mbedtls/net.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file net.h 3 | * 4 | * \brief Deprecated header file that includes net_sockets.h 5 | * 6 | * \deprecated Superseded by mbedtls/net_sockets.h 7 | */ 8 | /* 9 | * Copyright (C) 2006-2016, ARM Limited, All Rights Reserved 10 | * SPDX-License-Identifier: Apache-2.0 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 13 | * not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * http://www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | * 24 | * This file is part of mbed TLS (https://tls.mbed.org) 25 | */ 26 | #if !defined(MBEDTLS_CONFIG_FILE) 27 | #include "config.h" 28 | #else 29 | #include MBEDTLS_CONFIG_FILE 30 | #endif 31 | 32 | #if !defined(MBEDTLS_DEPRECATED_REMOVED) 33 | #include "net_sockets.h" 34 | #if defined(MBEDTLS_DEPRECATED_WARNING) 35 | #warning "Deprecated header file: Superseded by mbedtls/net_sockets.h" 36 | #endif /* MBEDTLS_DEPRECATED_WARNING */ 37 | #endif /* !MBEDTLS_DEPRECATED_REMOVED */ 38 | -------------------------------------------------------------------------------- /makerom/deps/libyaml/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2006 Kirill Simonov 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 7 | of the Software, and to permit persons to whom the Software is furnished to do 8 | so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | -------------------------------------------------------------------------------- /makerom/src/accessdesc.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | int set_AccessDesc(exheader_settings *exhdrset); -------------------------------------------------------------------------------- /makerom/src/aes_keygen.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | /* 5 | AES Key generator for the Nintendo 3DS (CTR) Consoles 6 | */ 7 | 8 | void ctr_aes_keygen(const uint8_t *x, const uint8_t *y, uint8_t *key); 9 | -------------------------------------------------------------------------------- /makerom/src/cardinfo.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | typedef struct 4 | { 5 | u8 reserved0[0xf8]; 6 | u8 mediaSizeUsed[8]; 7 | u8 reserved1[0x8]; 8 | u8 unknown[0x4]; 9 | u8 reserved2[0xc]; 10 | u8 cverTitleId[8]; 11 | u8 cverTitleVersion[2]; 12 | u8 reserved3[0xcd6]; 13 | } cardinfo_notes; // reserved[0xDF8]; 14 | 15 | typedef struct 16 | { 17 | u8 writableAddress[4]; 18 | u8 cardInfoBitmask[4]; 19 | cardinfo_notes notes; 20 | u8 cardSeedKeyY[0x10]; 21 | u8 encCardSeed[0x10]; 22 | u8 cardSeedMac[0x10]; 23 | u8 cardSeedNonce[0xc]; 24 | u8 reserved1[0xc4]; 25 | u8 ncch0Hdr[0x100]; 26 | } cardinfo_hdr; 27 | 28 | typedef struct 29 | { 30 | u8 cardDeviceReserved1[0x200]; 31 | u8 titleKey[0x10]; 32 | u8 cardDeviceReserved2[0xf0]; 33 | } devcardinfo_hdr; 34 | 35 | static const u8 stock_card_seed_mac[0x30] = 36 | { 37 | 0xAD, 0x88, 0xAC, 0x41, 0xA2, 0xB1, 0x5E, 0x8F, 0x66, 0x9C, 0x97, 0xE5, 0xE1, 0x5E, 0xA3, 0xEB 38 | }; 39 | 40 | static const u8 stock_title_key[0x10] = 41 | { 42 | 0x6E, 0xC7, 0x5F, 0xB2, 0xE2, 0xB4, 43 | 0x87, 0x46, 0x1E, 0xDD, 0xCB, 0xB8, 44 | 0x97, 0x11, 0x92, 0xBA 45 | }; 46 | 47 | int GenCardInfoHdr(cci_settings *set); -------------------------------------------------------------------------------- /makerom/src/certs.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | typedef struct 4 | { 5 | u8 issuer[0x40]; 6 | u8 keyType[4]; 7 | u8 name[0x40]; 8 | u8 id[4]; 9 | } cert_hdr; 10 | 11 | typedef struct 12 | { 13 | u8 modulus[0x200]; 14 | u8 pubExponent[4]; 15 | u8 padding[0x34]; 16 | } rsa_4096_pubk_struct; 17 | 18 | typedef struct 19 | { 20 | u8 modulus[0x100]; 21 | u8 pubExponent[4]; 22 | u8 padding[0x34]; 23 | } rsa_2048_pubk_struct; 24 | 25 | typedef struct 26 | { 27 | u8 pubK[0x3C]; 28 | u8 padding[0x3C]; 29 | } ecc_pubk_struct; 30 | 31 | // Cert Sizes 32 | u32 GetCertSize(u8 *cert); 33 | u32 GetCertPubkSectionSize(pubk_types type); 34 | 35 | // Issuer/Name Functions 36 | u8 *GetCertIssuer(u8 *cert); 37 | u8 *GetCertName(u8 *cert); 38 | void GenCertChildIssuer(u8 *dest, u8 *cert); 39 | 40 | // Pubk 41 | pubk_types GetCertPubkType(u8 *cert); 42 | u8 *GetCertPubk(u8 *cert); 43 | 44 | bool VerifyCert(u8 *cert, u8 *pubk); -------------------------------------------------------------------------------- /makerom/src/cia.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Structs 4 | typedef struct 5 | { 6 | u8 hdrSize[4]; 7 | u8 type[2]; 8 | u8 version[2]; 9 | u8 certChainSize[4]; 10 | u8 tikSize[4]; 11 | u8 tmdSize[4]; 12 | u8 metaSize[4]; 13 | u8 contentSize[8]; 14 | u8 contentIndex[0x2000]; 15 | } cia_hdr; 16 | 17 | typedef struct 18 | { 19 | u8 dependencyList[0x30*0x8]; 20 | u8 padding0[0x180]; 21 | u8 coreVersion[4]; 22 | u8 padding1[0xfc]; 23 | } cia_metadata; 24 | 25 | int CryptContent(u8 *input, u8 *output, u64 size, u8 *title_key, u16 index, u8 mode); 26 | 27 | -------------------------------------------------------------------------------- /makerom/src/cia_read.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "cia.h" 3 | 4 | // Cia Read Functions 5 | bool IsCia(u8 *cia); 6 | u64 GetCiaCertOffset(cia_hdr *hdr); 7 | u64 GetCiaCertSize(cia_hdr *hdr); 8 | u64 GetCiaTikOffset(cia_hdr *hdr); 9 | u64 GetCiaTikSize(cia_hdr *hdr); 10 | u64 GetCiaTmdOffset(cia_hdr *hdr); 11 | u64 GetCiaTmdSize(cia_hdr *hdr); 12 | u64 GetCiaContentOffset(cia_hdr *hdr); 13 | u64 GetCiaContentSize(cia_hdr *hdr); 14 | u64 GetCiaMetaOffset(cia_hdr *hdr); 15 | u64 GetCiaMetaSize(cia_hdr *hdr); 16 | 17 | u8* GetCiaCert(u8 *cia); 18 | u8* GetCiaTik(u8 *cia); 19 | u8* GetCiaTmd(u8 *cia); 20 | u8* GetCiaContent(u8 *cia); 21 | u8* GetCiaMeta(u8 *cia); 22 | -------------------------------------------------------------------------------- /makerom/src/code.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | int BuildExeFsCode(ncch_settings *ncchset); -------------------------------------------------------------------------------- /makerom/src/crr.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | typedef struct 4 | { 5 | u8 magic[4]; 6 | u8 reserved0[4]; 7 | u8 node0[4]; 8 | u8 node1[4]; 9 | u8 debugInfoOffset[4]; //s32 10 | u8 debugInfoSize[4]; //s32 11 | u8 reserved1[8]; 12 | u8 uniqueIdMask[4]; 13 | u8 uniqueIdPattern[4]; 14 | u8 reserved2[0x18]; 15 | u8 signPublicKey[0x100]; 16 | u8 signPublicKeySign[0x100]; 17 | u8 sign[0x100]; 18 | u8 uniqueId[4]; 19 | u8 size[4]; 20 | u8 reserved3[8]; 21 | u8 hashOffset[4]; 22 | u8 numHash[4]; 23 | u8 moduleIdOffset[4]; 24 | u8 moduleIdSize[4]; 25 | } crr_hdr; -------------------------------------------------------------------------------- /makerom/src/crypto.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | typedef enum 4 | { 5 | RSA_4096_SHA1 = 0x00010000, 6 | RSA_2048_SHA1 = 0x00010001, 7 | ECC_SHA1 = 0x00010002, 8 | RSA_4096_SHA256 = 0x00010003, 9 | RSA_2048_SHA256 = 0x00010004, 10 | ECC_SHA256 = 0x00010005 11 | } ctr_sig_types; 12 | 13 | typedef enum 14 | { 15 | CTR_RSA_VERIFY, 16 | CTR_RSA_SIGN, 17 | } ctr_rsa_mode; 18 | 19 | typedef enum 20 | { 21 | RSA_4096, 22 | RSA_2048, 23 | ECC, 24 | INVALID_SIG_TYPE, 25 | } sig_types; 26 | 27 | typedef enum 28 | { 29 | CTR_SHA_1, 30 | CTR_SHA_256, 31 | } ctr_sha_modes; 32 | 33 | typedef enum 34 | { 35 | SHA_1_LEN = 0x14, 36 | SHA_256_LEN = 0x20, 37 | } sha_hash_len; 38 | 39 | typedef enum 40 | { 41 | RSA_4096_PUBK = 0, 42 | RSA_2048_PUBK, 43 | ECC_PUBK 44 | } pubk_types; 45 | 46 | typedef enum 47 | { 48 | ENC, 49 | DEC 50 | } aes_mode; 51 | 52 | 53 | #ifdef __cplusplus 54 | extern "C" { 55 | #endif 56 | // SHA 57 | bool VerifySha256(void *data, u64 size, u8 hash[32]); 58 | void ShaCalc(void *data, u64 size, u8 *hash, int mode); 59 | // AES 60 | void AesCtrCrypt(u8 *key, u8 *ctr, u8 *input, u8 *output, u64 length, u64 offset); 61 | void AesCbcCrypt(u8 *key, u8 *iv, u8 *input, u8 *output, u64 length, u8 mode); 62 | // RSA 63 | int RsaSignVerify(void *data, u64 len, u8 *sign, u8 *mod, u8 *priv_exp, u32 sig_type, u8 rsa_mode); 64 | 65 | 66 | 67 | #ifdef __cplusplus 68 | } 69 | #endif -------------------------------------------------------------------------------- /makerom/src/ctr_utils.c: -------------------------------------------------------------------------------- 1 | #include "lib.h" 2 | 3 | u32 GetCtrBlockSize(u8 flag) 4 | { 5 | return 1 << (flag + 9); 6 | } 7 | 8 | u8 GetCtrBlockSizeFlag(u32 size) 9 | { 10 | u8 ret = 0; 11 | for(u32 tmp = size; tmp > 0x200; tmp = tmp >> 1) 12 | ret++; 13 | return ret; 14 | } -------------------------------------------------------------------------------- /makerom/src/ctr_utils.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | u32 GetCtrBlockSize(u8 flag); 4 | u8 GetCtrBlockSizeFlag(u32 size); -------------------------------------------------------------------------------- /makerom/src/desc/desc.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | enum SdkAppTypes { 5 | desc_NotSpecified, 6 | desc_Application, 7 | desc_DlpChild, 8 | desc_Demo, 9 | desc_EcApplication, // intergrated in (Ext)Application since SDK 7 10 | desc_ExtApplication, // Snake equivalent of desc_Application (128MB/804MHz/L2 Cache) 11 | desc_ExtDlpChild, // Snake equivalent of desc_DlpChild (128MB/804MHz/L2 Cache) 12 | desc_ExtDemo // Snake equivalent of desc_Demo (128MB/804MHz/L2 Cache) 13 | }; 14 | 15 | typedef struct CtrSdkDepList { 16 | uint32_t fw_minor; 17 | uint8_t dependency[0x180]; 18 | } CtrSdkDepList; 19 | 20 | typedef struct CtrSdkDesc { 21 | uint32_t type; 22 | uint32_t fw_minor; 23 | uint8_t exheader_desc[0x200]; 24 | uint8_t signed_desc[0x200]; 25 | } CtrSdkDesc; 26 | 27 | typedef struct CtrSdkDescSignData { 28 | uint32_t type; 29 | uint32_t fw_minor; 30 | uint8_t modulus[0x100]; 31 | uint8_t priv_exponent[0x100]; 32 | uint8_t access_desc_signature[0x100]; 33 | } CtrSdkDescSignData; -------------------------------------------------------------------------------- /makerom/src/exefs.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define MAX_EXEFS_SECTIONS 8 4 | 5 | typedef struct 6 | { 7 | char name[8]; 8 | u8 offset[4]; 9 | u8 size[4]; 10 | } exefs_filehdr; 11 | 12 | typedef struct 13 | { 14 | exefs_filehdr fileHdr[MAX_EXEFS_SECTIONS]; 15 | u8 reserved[0x80]; 16 | u8 fileHashes[MAX_EXEFS_SECTIONS][0x20]; 17 | } exefs_hdr; 18 | -------------------------------------------------------------------------------- /makerom/src/exefs_build.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "exefs.h" 3 | 4 | typedef enum 5 | { 6 | PTR_ERROR = -10, 7 | EXEFS_MAX_REACHED = -11, 8 | EXEFS_SECTION_NAME_ERROR = -12, 9 | } exefs_errors; 10 | 11 | typedef struct 12 | { 13 | //Input 14 | int fileCount; 15 | u8 *file[MAX_EXEFS_SECTIONS]; 16 | u32 fileSize[MAX_EXEFS_SECTIONS]; 17 | u32 fileOffset[MAX_EXEFS_SECTIONS]; 18 | char fileName[MAX_EXEFS_SECTIONS][8]; 19 | u32 blockSize; 20 | 21 | //Working Data 22 | exefs_filehdr fileHdr[MAX_EXEFS_SECTIONS]; 23 | u8 fileHashes[MAX_EXEFS_SECTIONS][0x20]; 24 | 25 | } exefs_buildctx; 26 | 27 | /* ExeFs Build Functions */ 28 | int BuildExeFs(ncch_settings *ncchset); -------------------------------------------------------------------------------- /makerom/src/exefs_read.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "exefs.h" 3 | 4 | /* ExeFs Read Functions */ 5 | bool DoesExeFsSectionExist(char *section, u8 *ExeFs); 6 | u8* GetExeFsSection(char *section, u8 *ExeFs); 7 | u8* GetExeFsSectionHash(char *section, u8 *ExeFs); 8 | u32 GetExeFsSectionSize(char *section, u8 *ExeFs); 9 | u32 GetExeFsSectionOffset(char *section, u8 *ExeFs); -------------------------------------------------------------------------------- /makerom/src/exheader_build.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "exheader.h" 3 | 4 | typedef enum 5 | { 6 | COMMON_HEADER_KEY_NOT_FOUND = -10, 7 | EXHDR_BAD_RSF_OPT = -11, 8 | CANNOT_SIGN_ACCESSDESC = -12 9 | } exheader_errors; 10 | 11 | typedef struct 12 | { 13 | keys_struct *keys; 14 | rsf_settings *rsf; 15 | bool useAccessDescPreset; 16 | 17 | /* Output, these ptrs where created originally in ncchset */ 18 | extended_hdr *exHdr; 19 | access_descriptor *acexDesc; 20 | } exheader_settings; 21 | 22 | /* ExHeader Build Functions */ 23 | int BuildExHeader(ncch_settings *ncchset); -------------------------------------------------------------------------------- /makerom/src/exheader_read.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "exheader.h" 3 | 4 | /* ExHeader Binary Print Functions */ 5 | void exhdr_Print_ServiceAccessControl(extended_hdr *hdr); 6 | 7 | /* ExHeader Binary Read Functions */ 8 | u8* GetAcexRsaSig(access_descriptor *acexDesc); 9 | u8* GetAcexNcchPubKey(access_descriptor *acexDesc); 10 | u16 GetRemasterVersion_frm_exhdr(extended_hdr *hdr); 11 | u64 GetSaveDataSize_frm_exhdr(extended_hdr *hdr); 12 | int GetDependencyList_frm_exhdr(u8 *Dest,extended_hdr *hdr); 13 | void GetCoreVersion_frm_exhdr(u8 *Dest, extended_hdr *hdr); 14 | -------------------------------------------------------------------------------- /makerom/src/lib.h: -------------------------------------------------------------------------------- 1 | #define _LARGEFILE_SOURCE 2 | #define _LARGEFILE64_SOURCE 3 | #define _FILE_OFFSET_BITS 64 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | 21 | #ifdef _WIN32 22 | #include 23 | #include 24 | #include 25 | #endif 26 | 27 | 28 | #include "types.h" 29 | #include "utils.h" 30 | #include "ctr_utils.h" 31 | #include "crypto.h" 32 | 33 | #include "keyset.h" 34 | #include "user_settings.h" 35 | #include "yaml_parser.h" 36 | #include "rsf_settings.h" 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /makerom/src/ncch_read.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ncch.h" -------------------------------------------------------------------------------- /makerom/src/ncsd.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | typedef enum 4 | { 5 | cciflag_BACKUP_WRITE_WAIT_TIME = 0, 6 | cciflag_FW6_SAVE_CRYPTO = 1, 7 | cciflag_CARD_DEVICE = 3, 8 | cciflag_MEDIA_PLATFORM = 4, 9 | cciflag_MEDIA_TYPE = 5, 10 | cciflag_MEDIA_BLOCK_SIZE = 6, 11 | cciflag_CARD_DEVICE_OLD = 7 12 | } cci_flagindex; 13 | 14 | typedef enum 15 | { 16 | carddevice_NOR_FLASH = 1, 17 | carddevice_NONE = 2, 18 | carddevice_BT = 3 19 | } cci_carddevice; 20 | 21 | typedef enum 22 | { 23 | cciplatform_CTR = 1, 24 | } cci_platform; 25 | 26 | typedef enum 27 | { 28 | mediatype_INNER_DEVICE, // NAND 29 | mediatype_CARD1, 30 | mediatype_CARD2, 31 | mediatype_EXTENDED_DEVICE 32 | } cci_mediatype; 33 | 34 | // Structs 35 | typedef struct 36 | { 37 | u8 offset[4]; 38 | u8 size[4]; 39 | } ncch_offsetsize; 40 | 41 | typedef struct 42 | { 43 | u8 signature[0x100]; 44 | u8 magic[4]; 45 | u8 mediaSize[4]; 46 | u8 titleId[8]; 47 | u8 padding0[0x10]; 48 | ncch_offsetsize offset_sizeTable[8]; 49 | u8 padding1[0x28]; 50 | u8 flags[8]; 51 | u8 ncchIdTable[8][8]; 52 | u8 padding2[0x30]; 53 | } cci_hdr; 54 | 55 | -------------------------------------------------------------------------------- /makerom/src/ncsd_build.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ncsd.h" 3 | #include "tmd_read.h" 4 | 5 | 6 | // Enums 7 | typedef enum 8 | { 9 | NCSD_NO_NCCH0 = -1, 10 | NCSD_INVALID_NCCH0 = -2, 11 | NCSD_INVALID_NCCH = -3, 12 | INVALID_RSF_OPT = -4, 13 | GEN_HDR_FAIL = -5, 14 | INCOMPAT_CIA = -6, 15 | CCI_CONFIG_FAIL = -7, 16 | } ncsd_errors; 17 | 18 | typedef struct 19 | { 20 | rsf_settings *rsf; 21 | keys_struct *keys; 22 | 23 | FILE *out; 24 | 25 | struct{ 26 | bool verbose; 27 | bool padCci; 28 | bool noModTid; 29 | bool useExternalSdkCardInfo; 30 | bool closeAlignWR; 31 | 32 | u8 cverDataType; 33 | char *cverDataPath; 34 | tmd_hdr *tmdHdr; 35 | } options; 36 | 37 | struct{ 38 | u32 blockSize; 39 | 40 | u64 mediaSize; 41 | u64 usedSize; 42 | 43 | u8 mediaType; 44 | u8 cardDevice; 45 | u64 saveSize; 46 | u64 card2SaveOffset; 47 | } romInfo; 48 | 49 | struct{ 50 | u8 *data; 51 | u64 dataLen; 52 | infile_type dataType; 53 | 54 | char **path; 55 | 56 | bool active[CCI_MAX_CONTENT]; 57 | u64 dOffset[CCI_MAX_CONTENT]; 58 | u64 *dSize; 59 | u64 titleId[CCI_MAX_CONTENT]; 60 | 61 | u64 cOffset[CCI_MAX_CONTENT]; 62 | } content; 63 | 64 | struct{ 65 | buffer_struct ccihdr; 66 | buffer_struct cardinfohdr; 67 | } headers; 68 | } cci_settings; 69 | 70 | // Public Prototypes 71 | // Build Functions 72 | int build_CCI(user_settings *usrset); -------------------------------------------------------------------------------- /makerom/src/ncsd_read.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ncsd.h" 3 | 4 | // Read Functions 5 | bool IsCci(u8 *ncsd); 6 | u8* GetPartition(u8 *ncsd, u8 index); 7 | u64 GetPartitionOffset(u8 *ncsd, u8 index); 8 | u64 GetPartitionSize(u8 *ncsd, u8 index); -------------------------------------------------------------------------------- /makerom/src/pki/prod_legacy.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // AES Keys 4 | static const unsigned char rvl_common_etd_key_ppki[2][16] = 5 | { 6 | {0xEB, 0xE4, 0x2A, 0x22, 0x5E, 0x85, 0x93, 0xE4, 0x48, 0xD9, 0xC5, 0x45, 0x73, 0x81, 0xAA, 0xF7} , // 0 - Normal 7 | {0x63, 0xB8, 0x2B, 0xB4, 0xF4, 0x61, 0x4E, 0x2E, 0x13, 0xF2, 0xFE, 0xFB, 0xBA, 0x4C, 0x9B, 0x7E} , // 1 - Korean 8 | }; 9 | 10 | static const unsigned char twl_common_etd_key_ppki[1][16] = 11 | { 12 | {0xAF, 0x1B, 0xF5, 0x16, 0xA8, 0x07, 0xD2, 0x1A, 0xEA, 0x45, 0x98, 0x4F, 0x04, 0x74, 0x28, 0x61} , // 0 - Normal 13 | }; 14 | 15 | // RSA Keys 16 | 17 | // Certificates -------------------------------------------------------------------------------- /makerom/src/pki/rsa_key.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | typedef struct CtrRsa2048Key { 5 | uint8_t modulus[0x100]; 6 | uint8_t priv_exponent[0x100]; 7 | //uint8_t pub_exponent[0x3]; 8 | } CtrRsa2048Key; 9 | 10 | typedef struct CtrRsa4096Key { 11 | uint8_t modulus[0x200]; 12 | uint8_t priv_exponent[0x200]; 13 | //uint8_t pub_exponent[0x3]; 14 | } CtrRsa4096Key; -------------------------------------------------------------------------------- /makerom/src/romfs.c: -------------------------------------------------------------------------------- 1 | #include "lib.h" 2 | #include "ncch_build.h" 3 | #include "romfs.h" 4 | #include "romfs_gen.h" 5 | #include "romfs_import.h" 6 | 7 | void FreeRomFsCtx(romfs_buildctx *ctx); 8 | 9 | // RomFs Build Functions 10 | int SetupRomFs(ncch_settings *ncchset, romfs_buildctx *ctx) 11 | { 12 | ctx->verbose = ncchset->options.verbose; 13 | ctx->output = NULL; 14 | ctx->romfsSize = 0; 15 | 16 | // If Not Using RomFS Return 17 | if(!ncchset->options.UseRomFS) 18 | return 0; 19 | 20 | if(ncchset->componentFilePtrs.romfs)// The user has specified a pre-built RomFs Binary 21 | return PrepareImportRomFsBinaryFromFile(ncchset,ctx); 22 | 23 | else // Otherwise build ROMFS 24 | return PrepareBuildRomFsBinary(ncchset,ctx); 25 | 26 | } 27 | 28 | int BuildRomFs(romfs_buildctx *ctx) 29 | { 30 | // If Not Using RomFS Return 31 | if(!ctx->romfsSize) 32 | return 0; 33 | 34 | int result = 0; 35 | 36 | if(ctx->ImportRomfsBinary) // The user has specified a pre-built RomFs Binary 37 | result = ImportRomFsBinaryFromFile(ctx); 38 | else // Otherwise build ROMFS 39 | result = BuildRomFsBinary(ctx); 40 | 41 | FreeRomFsCtx(ctx); 42 | 43 | return result; 44 | } 45 | 46 | void FreeRomFsCtx(romfs_buildctx *ctx) 47 | { 48 | if(ctx->fs){ 49 | FreeDir(ctx->fs); 50 | free(ctx->fs); 51 | } 52 | } -------------------------------------------------------------------------------- /makerom/src/romfs_fs.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "oschar.h" 3 | 4 | struct romfs_file 5 | { 6 | oschar_t *path; 7 | utf16char_t *name; 8 | u32 namesize; 9 | u64 size; 10 | }; 11 | 12 | struct romfs_dir 13 | { 14 | oschar_t *path; 15 | utf16char_t *name; 16 | u32 namesize; 17 | 18 | struct romfs_dir *child; 19 | u32 m_child; 20 | u32 u_child; 21 | 22 | struct romfs_file *file; 23 | u32 m_file; 24 | u32 u_file; 25 | }; 26 | 27 | typedef struct romfs_file romfs_file; 28 | typedef struct romfs_dir romfs_dir; 29 | 30 | static const utf16char_t ROMFS_EMPTY_PATH[2] = { 0 }; 31 | static const oschar_t OS_EMPTY_PATH[2] = { 0 }; 32 | static const oschar_t OS_CURRENT_DIR_PATH[2] = { '.' }; 33 | static const oschar_t OS_PARENT_DIR_PATH[3] = { '.', '.' }; 34 | 35 | int OpenRootDir(const char *path, romfs_dir *dir); 36 | void PrintDir(romfs_dir *dir, u32 depth); 37 | void FreeDir(romfs_dir *dir); -------------------------------------------------------------------------------- /makerom/src/romfs_gen.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "romfs.h" 3 | 4 | int PrepareBuildRomFsBinary(ncch_settings *ncchset, romfs_buildctx *ctx); 5 | int BuildRomFsBinary(romfs_buildctx *ctx); 6 | -------------------------------------------------------------------------------- /makerom/src/romfs_import.c: -------------------------------------------------------------------------------- 1 | #include "lib.h" 2 | #include "romfs_fs.h" 3 | #include "ncch_build.h" 4 | #include "romfs.h" 5 | 6 | int PrepareImportRomFsBinaryFromFile(ncch_settings *ncchset, romfs_buildctx *ctx) 7 | { 8 | ctx->ImportRomfsBinary = true; 9 | ctx->romfsSize = ncchset->componentFilePtrs.romfsSize; 10 | ctx->romfsBinary = ncchset->componentFilePtrs.romfs; 11 | 12 | ivfc_hdr *hdr = calloc(1,sizeof(ivfc_hdr)); 13 | 14 | ReadFile64(hdr,sizeof(ivfc_hdr),0,ctx->romfsBinary); 15 | if(memcmp(hdr->magic,"IVFC",4) != 0){ 16 | fprintf(stderr,"[ROMFS ERROR] Invalid RomFS Binary.\n"); 17 | return INVALID_ROMFS_FILE; 18 | } 19 | 20 | ctx->romfsHeaderSize = align(sizeof(ivfc_hdr),0x10) + (u64)u8_to_u32(hdr->masterHashSize,LE); 21 | 22 | return 0; 23 | } 24 | 25 | int ImportRomFsBinaryFromFile(romfs_buildctx *ctx) 26 | { 27 | ReadFile64(ctx->output,ctx->romfsSize,0,ctx->romfsBinary); 28 | if(memcmp(ctx->output,"IVFC",4) != 0){ 29 | fprintf(stderr,"[ROMFS ERROR] Invalid RomFS Binary.\n"); 30 | return INVALID_ROMFS_FILE; 31 | } 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /makerom/src/romfs_import.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | int PrepareImportRomFsBinaryFromFile(ncch_settings *ncchset, romfs_buildctx *ctx); 4 | int ImportRomFsBinaryFromFile(romfs_buildctx *ctx); -------------------------------------------------------------------------------- /makerom/src/rsf_settings.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void EvaluateRSF(rsf_settings *rsf, ctr_yaml_context *ctx); 4 | void free_RsfSettings(rsf_settings *set); -------------------------------------------------------------------------------- /makerom/src/tik.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | typedef enum 4 | { 5 | lic_Permanent = 0, 6 | lic_Demo = 1, 7 | lic_Trial = 2, 8 | lic_Rental = 3, 9 | lic_Subscription = 4, 10 | lic_Service = 5, 11 | lic_Mask = 15 12 | } tik_license_type; 13 | 14 | typedef enum 15 | { 16 | right_Permanent = 1, 17 | right_Subscription = 2, 18 | right_Content = 3, 19 | right_ContentConsumption = 4, 20 | right_AccessTitle = 5 21 | } tik_item_rights; 22 | 23 | typedef struct 24 | { 25 | u8 unk0[4]; 26 | u8 totalSize[4]; 27 | u8 unk1[4]; 28 | u8 unk2[4]; 29 | u8 unk3[4]; 30 | u8 hdrSize[4]; 31 | u8 segNum[4]; 32 | u8 segSize[4]; 33 | u8 segTotalSize[4]; 34 | u8 unk4[4]; 35 | } tik_content_index_hdr; 36 | 37 | typedef struct 38 | { 39 | u8 level[4]; 40 | u8 index[0x80]; 41 | } tik_content_index_struct; 42 | 43 | typedef struct 44 | { 45 | u8 sigType[4]; 46 | u8 data[0x100]; 47 | u8 padding[0x3C]; 48 | } tik_signature; 49 | 50 | typedef struct 51 | { 52 | u8 issuer[0x40]; 53 | u8 eccPubKey[0x3c]; 54 | u8 formatVersion; 55 | u8 caCrlVersion; 56 | u8 signerCrlVersion; 57 | u8 encryptedTitleKey[0x10]; 58 | u8 padding0; 59 | u8 ticketId[8]; 60 | u8 deviceId[4]; 61 | u8 titleId[8]; 62 | u8 padding1[2]; 63 | u8 ticketVersion[2]; 64 | u8 padding2[8]; 65 | u8 licenceType; 66 | u8 keyId; 67 | u8 propertyMask[2]; 68 | u8 customData[0x14]; 69 | u8 padding3[0x14]; 70 | u8 eshopAccId[4]; 71 | u8 padding4; 72 | u8 audit; 73 | u8 padding5[0x42]; 74 | u8 limits[0x40]; 75 | } tik_hdr; 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /makerom/src/tik_build.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "tik.h" 3 | 4 | // Prototypes 5 | int BuildTicket(cia_settings *ciaset); -------------------------------------------------------------------------------- /makerom/src/tik_read.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "tik.h" 3 | 4 | tik_hdr *GetTikHdr(u8 *tik); 5 | bool GetTikTitleKey(u8 *titleKey, tik_hdr *hdr, keys_struct *keys); -------------------------------------------------------------------------------- /makerom/src/tmd.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | typedef enum 4 | { 5 | TYPE_CTR = 0x40, 6 | TYPE_DATA = 0x8 7 | } tmd_title_type; 8 | 9 | typedef enum 10 | { 11 | content_Encrypted = 0x0001, 12 | content_Optional = 0x4000, 13 | content_Shared = 0x8000 14 | } tmd_content_types; 15 | 16 | typedef struct 17 | { 18 | u8 id[4]; 19 | u8 index[2]; 20 | u8 flags[2]; 21 | u8 size[8]; 22 | u8 hash[0x20]; // SHA 256 23 | } tmd_content_chunk; 24 | 25 | typedef struct 26 | { 27 | u8 contentIndexOffset[2]; 28 | u8 contentCommandCount[2]; 29 | u8 contentChunkHash[0x20]; // SHA 256 30 | } tmd_content_info_record; 31 | 32 | typedef struct 33 | { 34 | u8 sigType[4]; 35 | u8 data[0x100]; 36 | u8 padding[0x3C]; 37 | } tmd_signature; 38 | 39 | typedef struct 40 | { 41 | u8 issuer[0x40]; 42 | u8 formatVersion; 43 | u8 caCrlVersion; 44 | u8 signerCrlVersion; 45 | u8 padding0; 46 | u8 systemVersion[8]; 47 | u8 titleID[8]; 48 | u8 titleType[4]; 49 | u8 groupID[2]; 50 | u8 savedataSize[4]; 51 | u8 privSavedataSize[4]; // Zero for CXI Content0 52 | u8 padding1[4]; 53 | u8 twlFlag; // Zero for CXI Content0 54 | u8 padding2[0x31]; 55 | u8 accessRights[4]; 56 | u8 titleVersion[2]; 57 | u8 contentCount[2]; 58 | u8 bootContent[2]; 59 | u8 padding3[2]; 60 | u8 infoRecordHash[0x20]; // SHA-256 61 | } tmd_hdr; -------------------------------------------------------------------------------- /makerom/src/tmd_build.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "tmd.h" 3 | 4 | // Prototypes 5 | u32 PredictTMDSize(u16 ContentCount); 6 | int BuildTMD(cia_settings *ciaset); 7 | -------------------------------------------------------------------------------- /makerom/src/tmd_read.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "tmd.h" 3 | 4 | // Read TMD 5 | tmd_hdr *GetTmdHdr(u8 *tmd); 6 | tmd_content_chunk* GetTmdContentInfo(u8 *tmd); 7 | u64 GetTmdTitleId(tmd_hdr *hdr); 8 | u32 GetTmdSaveSize(tmd_hdr *hdr); 9 | u16 GetTmdContentCount(tmd_hdr *hdr); 10 | u16 GetTmdVersion(tmd_hdr *hdr); 11 | 12 | u32 GetTmdContentId(tmd_content_chunk info); 13 | u16 GetTmdContentIndex(tmd_content_chunk info); 14 | u16 GetTmdContentFlags(tmd_content_chunk info); 15 | u64 GetTmdContentSize(tmd_content_chunk info); 16 | u8* GetTmdContentHash(tmd_content_chunk info); 17 | 18 | bool IsTmdContentEncrypted(tmd_content_chunk info); 19 | bool ValidateTmdContent(u8 *data, tmd_content_chunk info); -------------------------------------------------------------------------------- /makerom/src/types.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | //Bools 4 | typedef enum 5 | { 6 | Good, 7 | Fail 8 | } return_basic; 9 | 10 | typedef enum 11 | { 12 | MEM_ERROR = -1, 13 | FAILED_TO_OPEN_FILE = -2, 14 | FAILED_TO_IMPORT_FILE = -3, 15 | FAILED_TO_CREATE_OUTFILE = -4, 16 | } global_errors; 17 | 18 | typedef enum 19 | { 20 | BE = 0, 21 | LE = 1 22 | } endianness_flag; 23 | 24 | typedef enum 25 | { 26 | KB = 1024, 27 | MB = 1048576, 28 | GB = 1073741824 29 | } file_unit_size; 30 | 31 | typedef enum 32 | { 33 | MAX_U8 = 0xff, 34 | MAX_U16 = 0xffff, 35 | MAX_U32 = 0xffffffff, 36 | MAX_U64 = 0xffffffffffffffff, 37 | } data_type_max; 38 | 39 | typedef uint8_t u8; 40 | typedef uint16_t u16; 41 | typedef uint32_t u32; 42 | typedef uint64_t u64; 43 | 44 | typedef int8_t s8; 45 | typedef int16_t s16; 46 | typedef int32_t s32; 47 | typedef int64_t s64; --------------------------------------------------------------------------------