Put everything back.

This commit is contained in:
jakcron
2022-04-16 21:27:49 +08:00
parent 5d62e839e7
commit bc04de6d09
844 changed files with 114383 additions and 29 deletions
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2021 Jack
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+2
View File
@@ -0,0 +1,2 @@
# libbroadon-es
C++ Library for processing Nintendo's ES DRM formats.
@@ -0,0 +1,62 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31229.75
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libbroadon-es", "libbroadon-es\libbroadon-es.vcxproj", "{8A35D7DC-293A-4669-9C1E-4F45ABFE8838}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libfmt", "..\..\deps\libfmt\build\visualstudio\libfmt\libfmt.vcxproj", "{F4B0540E-0AAE-4006-944B-356944EF61FA}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libmbedtls", "..\..\deps\libmbedtls\build\visualstudio\libmbedtls\libmbedtls.vcxproj", "{7A7C66F3-2B5B-4E23-85D8-2A74FEDAD92C}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libtoolchain", "..\..\deps\libtoolchain\build\visualstudio\libtoolchain\libtoolchain.vcxproj", "{E194E4B8-1482-40A2-901B-75D4387822E9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8A35D7DC-293A-4669-9C1E-4F45ABFE8838}.Debug|x64.ActiveCfg = Debug|x64
{8A35D7DC-293A-4669-9C1E-4F45ABFE8838}.Debug|x64.Build.0 = Debug|x64
{8A35D7DC-293A-4669-9C1E-4F45ABFE8838}.Debug|x86.ActiveCfg = Debug|Win32
{8A35D7DC-293A-4669-9C1E-4F45ABFE8838}.Debug|x86.Build.0 = Debug|Win32
{8A35D7DC-293A-4669-9C1E-4F45ABFE8838}.Release|x64.ActiveCfg = Release|x64
{8A35D7DC-293A-4669-9C1E-4F45ABFE8838}.Release|x64.Build.0 = Release|x64
{8A35D7DC-293A-4669-9C1E-4F45ABFE8838}.Release|x86.ActiveCfg = Release|Win32
{8A35D7DC-293A-4669-9C1E-4F45ABFE8838}.Release|x86.Build.0 = Release|Win32
{7A7C66F3-2B5B-4E23-85D8-2A74FEDAD92C}.Debug|x64.ActiveCfg = Debug|x64
{7A7C66F3-2B5B-4E23-85D8-2A74FEDAD92C}.Debug|x64.Build.0 = Debug|x64
{7A7C66F3-2B5B-4E23-85D8-2A74FEDAD92C}.Debug|x86.ActiveCfg = Debug|Win32
{7A7C66F3-2B5B-4E23-85D8-2A74FEDAD92C}.Debug|x86.Build.0 = Debug|Win32
{7A7C66F3-2B5B-4E23-85D8-2A74FEDAD92C}.Release|x64.ActiveCfg = Release|x64
{7A7C66F3-2B5B-4E23-85D8-2A74FEDAD92C}.Release|x64.Build.0 = Release|x64
{7A7C66F3-2B5B-4E23-85D8-2A74FEDAD92C}.Release|x86.ActiveCfg = Release|Win32
{7A7C66F3-2B5B-4E23-85D8-2A74FEDAD92C}.Release|x86.Build.0 = Release|Win32
{E194E4B8-1482-40A2-901B-75D4387822E9}.Debug|x64.ActiveCfg = Debug|x64
{E194E4B8-1482-40A2-901B-75D4387822E9}.Debug|x64.Build.0 = Debug|x64
{E194E4B8-1482-40A2-901B-75D4387822E9}.Debug|x86.ActiveCfg = Debug|Win32
{E194E4B8-1482-40A2-901B-75D4387822E9}.Debug|x86.Build.0 = Debug|Win32
{E194E4B8-1482-40A2-901B-75D4387822E9}.Release|x64.ActiveCfg = Release|x64
{E194E4B8-1482-40A2-901B-75D4387822E9}.Release|x64.Build.0 = Release|x64
{E194E4B8-1482-40A2-901B-75D4387822E9}.Release|x86.ActiveCfg = Release|Win32
{E194E4B8-1482-40A2-901B-75D4387822E9}.Release|x86.Build.0 = Release|Win32
{F4B0540E-0AAE-4006-944B-356944EF61FA}.Debug|x64.ActiveCfg = Debug|x64
{F4B0540E-0AAE-4006-944B-356944EF61FA}.Debug|x64.Build.0 = Debug|x64
{F4B0540E-0AAE-4006-944B-356944EF61FA}.Debug|x86.ActiveCfg = Debug|Win32
{F4B0540E-0AAE-4006-944B-356944EF61FA}.Debug|x86.Build.0 = Debug|Win32
{F4B0540E-0AAE-4006-944B-356944EF61FA}.Release|x64.ActiveCfg = Release|x64
{F4B0540E-0AAE-4006-944B-356944EF61FA}.Release|x64.Build.0 = Release|x64
{F4B0540E-0AAE-4006-944B-356944EF61FA}.Release|x86.ActiveCfg = Release|Win32
{F4B0540E-0AAE-4006-944B-356944EF61FA}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {76A6C1B6-F1C0-467F-B3A1-D7BDCBAA4FC0}
EndGlobalSection
EndGlobal
@@ -0,0 +1,151 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{8a35d7dc-293a-4669-9c1e-4f45abfe8838}</ProjectGuid>
<RootNamespace>libnintendoesdrm</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(SolutionDir)..\..\deps\libfmt\include;$(SolutionDir)..\..\deps\libmbedtls\include;$(SolutionDir)..\..\deps\libtoolchain\include;$(ProjectDir)..\..\..\include</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(SolutionDir)..\..\deps\libfmt\include;$(SolutionDir)..\..\deps\libmbedtls\include;$(SolutionDir)..\..\deps\libtoolchain\include;$(ProjectDir)..\..\..\include</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(SolutionDir)..\..\deps\libfmt\include;$(SolutionDir)..\..\deps\libmbedtls\include;$(SolutionDir)..\..\deps\libtoolchain\include;$(ProjectDir)..\..\..\include</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(SolutionDir)..\..\deps\libfmt\include;$(SolutionDir)..\..\deps\libmbedtls\include;$(SolutionDir)..\..\deps\libtoolchain\include;$(ProjectDir)..\..\..\include</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\..\src\Dummy.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\include\brd\es.h" />
<ClInclude Include="..\..\..\include\brd\es\es_cert.h" />
<ClInclude Include="..\..\..\include\brd\es\es_sign.h" />
<ClInclude Include="..\..\..\include\brd\es\es_ticket.h" />
<ClInclude Include="..\..\..\include\brd\es\es_tmd.h" />
<ClInclude Include="..\..\..\include\brd\es\types.h" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="$(SolutionDir)..\..\deps\libmbedtls\build\visualstudio\libmbedtls\libmbedtls.vcxproj">
<Project>{7a7c66f3-2b5b-4e23-85d8-2a74fedad92c}</Project>
</ProjectReference>
<ProjectReference Include="$(SolutionDir)..\..\deps\libtoolchain\build\visualstudio\libtoolchain\libtoolchain.vcxproj">
<Project>{e194e4b8-1482-40a2-901b-75d4387822e9}</Project>
</ProjectReference>
<ProjectReference Include="$(SolutionDir)..\..\deps\libfmt\build\visualstudio\libfmt\libfmt.vcxproj">
<Project>{f4b0540e-0aae-4006-944b-356944ef61fa}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="Header Files\brd">
<UniqueIdentifier>{ba10896d-aa46-41de-9331-2c89a9ddf64a}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\brd\es">
<UniqueIdentifier>{c67a3de1-eb64-4733-a6e6-cdcb7be43b60}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\src\Dummy.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\include\brd\es\es_cert.h">
<Filter>Header Files\brd\es</Filter>
</ClInclude>
<ClInclude Include="..\..\..\include\brd\es\es_sign.h">
<Filter>Header Files\brd\es</Filter>
</ClInclude>
<ClInclude Include="..\..\..\include\brd\es\es_ticket.h">
<Filter>Header Files\brd\es</Filter>
</ClInclude>
<ClInclude Include="..\..\..\include\brd\es\es_tmd.h">
<Filter>Header Files\brd\es</Filter>
</ClInclude>
<ClInclude Include="..\..\..\include\brd\es\types.h">
<Filter>Header Files\brd\es</Filter>
</ClInclude>
<ClInclude Include="..\..\..\include\brd\es.h">
<Filter>Header Files\brd</Filter>
</ClInclude>
</ItemGroup>
</Project>
@@ -0,0 +1,7 @@
#pragma once
// definitions
#include <brd/es/es_sign.h>
#include <brd/es/es_cert.h>
#include <brd/es/es_ticket.h>
#include <brd/es/es_tmd.h>
@@ -0,0 +1,101 @@
#pragma once
#include <brd/es/es_sign.h>
namespace brd { namespace es {
/**
@enum ESCertPubKeyType
@brief ES Certificate public key type definition
*/
enum class ESCertPubKeyType : uint32_t
{
RSA4096 = 0, /* RSA 4096 bit key */
RSA2048 = 1, /* RSA 2048 bit key */
ECC = 2, /* ECC pub key 512 bits */
};
static const size_t ES_CERT_NAME_SIZE = 64;
using ESCertName = tc::bn::string<ES_CERT_NAME_SIZE>;
using ESServerId = ESCertName;
using ESDeviceId = ESCertName;
template <size_t _size>
using ESPubKeyPad = std::array<byte_t, _size>;
/* pack to 4 byte boundaries */
#pragma pack(push,4)
struct ESCertHeader
{
tc::bn::be32<ESCertPubKeyType> pubKeyType; // ESCertPubKeyType
union {
ESServerId serverId;
ESDeviceId deviceId;
} name;
tc::bn::be32<uint32_t> date; // unix time-stamp
};
static_assert(sizeof(ESCertHeader) == 72, "ESCertHeader size");
struct ESCertRsa2048PublicKey
{
Rsa2048PublicKey pubKey;
ESPubKeyPad<52> pad;
};
static_assert(sizeof(ESCertRsa2048PublicKey) == 312, "ESCertRsa2048PublicKey size");
struct ESCertRsa4096PublicKey
{
Rsa4096PublicKey pubKey;
ESPubKeyPad<52> pad;
};
static_assert(sizeof(ESCertRsa4096PublicKey) == 568, "ESCertRsa4096PublicKey size");
struct ESCertEcc233PublicKey
{
Ecc233PublicKey pubKey;
ESPubKeyPad<60> pad;
};
static_assert(sizeof(ESCertEcc233PublicKey) == 120, "ESCertEcc233PublicKey size");
struct ESRootCert
{
ESSigRsa4096 sig;
ESCertHeader head;
ESCertRsa4096PublicKey body;
};
static_assert(sizeof(ESRootCert) == 1280, "ESRootCert size");
struct ESCACert
{
ESSigRsa4096 sig;
ESCertHeader head;
ESCertRsa2048PublicKey body;
};
static_assert(sizeof(ESCACert) == 1024, "ESCACert size");
struct ESCASignedCert
{
ESSigRsa2048 sig;
ESCertHeader head;
ESCertRsa2048PublicKey body;
};
static_assert(sizeof(ESCASignedCert) == 768, "ESCASignedCert size");
struct ESDeviceCert
{
ESSigRsa2048 sig;
ESCertHeader head;
ESCertEcc233PublicKey body;
};
static_assert(sizeof(ESDeviceCert) == 576, "ESDeviceCert size");
struct ESDeviceSignedCert
{
ESSigEcc233 sig;
ESCertHeader head;
ESCertEcc233PublicKey body;
};
static_assert(sizeof(ESDeviceSignedCert) == 384, "ESDeviceSignedCert size");
#pragma pack(pop)
}} // namespace brd::es
@@ -0,0 +1,73 @@
#pragma once
#include <brd/es/types.h>
namespace brd { namespace es {
/**
@enum ESSigType
@brief ES Signature type definition
*/
enum class ESSigType : uint32_t
{
RSA4096_SHA1 = 0x00010000, /* RSA 4096 bit signature */
RSA2048_SHA1 = 0x00010001, /* RSA 2048 bit signature */
ECC_SHA1 = 0x00010002, /* ECC signature 512 bits */
RSA4096_SHA256 = 0x00010003, /* RSA 4096 bit sig using SHA-256 */
RSA2048_SHA256 = 0x00010004, /* RSA 2048 bit sig using SHA-256 */ // note that Switch Ticket has this word swapped
ECC_SHA256 = 0x00010005, /* ECC sig 512 bits using SHA-256 */
HMAC_SHA1 = 0x00010006, /* HMAC-SHA1 160 bit signature */
};
static const size_t ES_ISSUER_SIZE = 64;
/**
* @class ESIssuer
* @brief The signature issuer ASCII encoded certificate hierarchy. Padded with nulls.
*
* Examples:
* Root (issued by Root)
* Root-CAxxxxxxxx (issued by Certifcate Authority server xxxxxxxx)
* Root-CAxxxxxxxx-XSxxxxxxxx (issued by Ticket/Transaction server xxxxxxxx)
* Root-CAxxxxxxxx-CPxxxxxxxx (issued by Content Publishing server xxxxxxxx)
* Root-CAxxxxxxxx-MSxxxxxxxx (issued by Manufacturing server xxxxxxxx)
* Root-CAxxxxxxxx-MSxxxxxxxx-YYxxxxxxxx (issued by Device with of type YY and serial number xxxxxxxx)
*
* xxxxxxxx represents the server/device serial number encoded in hex. (e.g. XS0000000f is ticket server 15).
*/
using ESIssuer = tc::bn::string<ES_ISSUER_SIZE>;
template <size_t _size>
using ESSigPad = tc::bn::pad<_size>;
/* pack to 4 byte boundaries */
#pragma pack(push,4)
struct ESSigRsa2048
{
tc::bn::be32<ESSigType> sigType;
Rsa2048Sig sig;
ESSigPad<60> pad;
ESIssuer issuer;
};
static_assert(sizeof(ESSigRsa2048) == 384, "ESSigRsa2048 size");
struct ESSigRsa4096
{
tc::bn::be32<ESSigType> sigType;
Rsa4096Sig sig;
ESSigPad<60> pad;
ESIssuer issuer;
};
static_assert(sizeof(ESSigRsa4096) == 640, "ESSigRsa4096 size");
struct ESSigEcc233
{
tc::bn::be32<ESSigType> sigType;
Ecc233Sig sig;
ESSigPad<64> pad;
ESIssuer issuer;
};
static_assert(sizeof(ESSigEcc233) == 192, "ESSigEcc233 size");
#pragma pack(pop)
}} // namespace brd::es
@@ -0,0 +1,232 @@
#pragma once
#include <brd/es/es_sign.h>
namespace brd { namespace es {
// ES license types
enum class ESLicenseType : uint8_t
{
PERMANENT = 0,
DEMO = 1,
TRIAL = 2,
RENTAL = 3,
SUBSCRIPTION = 4,
SERVICE = 5,
};
static const uint8_t ES_LICENSE_MASK = 0xf;
// ES title-level limit codes
enum class ESLimitCode : uint32_t
{
DURATION_TIME = 1,
ABSOLUTE_TIME = 2,
NUM_TITLES = 3,
NUM_LAUNCH = 4,
ELAPSED_TIME = 5,
};
static const uint32_t ES_MAX_LIMIT_TYPE = 8;
// ES item-level rights
enum class ESItemType : uint32_t
{
PERMANENT = 1,
SUBSCRIPTION = 2,
CONTENT = 3,
CONTENT_CONSUMPTION = 4,
ACCESS_TITLE = 5,
LIMITED_RESOURCE = 6,
};
enum class ESPropertyMaskFlag : uint16_t
{
PRE_INSTALL = 0x1, // bit0
SHARED_TITLE = 0x2, // bit1
ALLOW_ALL_CONTENT = 0x4, // bit2
DEVICE_LINK_INDEPENDENT = 0x8, // bit3
VOLATILE = 0x10, // bit4
ELICENSE_REQUIRED = 0x20, // bit5
};
enum class ESV1SectionHeaderFlag : uint16_t
{
COMPRESSED = 0x1 // ironically this is defined but not supported, probably for future use
};
enum class ESV2TitleKekType : byte_t
{
AES128_CBC,
RSA2048
};
#pragma pack(push, 4)
#ifdef _WIN32
#pragma warning(disable : 4200) // silence warnings for usage of empty arrays in stucts
#endif
struct ESLimitedPlayEntry
{
tc::bn::be32<uint32_t> code; //ESLimitCode
tc::bn::be32<uint32_t> limit;
};
static_assert(sizeof(ESLimitedPlayEntry) == 8, "ESLimitedPlayEntry size");
using ESSysAccessMask = std::array<byte_t, 2>;
using ESTicketCustomData = std::array<byte_t, 20>;
using ESTicketReserved = std::array<byte_t, 25>;
using ESCidxMask = std::array<byte_t, 64>;
using ESLimitedPlayArray = std::array<ESLimitedPlayEntry, 8>;
using ESReferenceId = std::array<byte_t, 16>;
using ESV1CidxMask = std::array<byte_t, 128>;
using ESV2TitleKey = std::array<byte_t, kRsa2048Size>;
using ESRightsId = std::array<byte_t, 16>;
using ESV2TicketReserved = std::array<byte_t, 8>;
struct ESTicket
{
ESSigRsa2048 sig; // RSA 2048-bit sign of the ticket
Ecc233PublicKey serverPubKey; // Ticketing server public key
uint8_t version; // Ticket data structure version number
uint8_t caCrlVersion; // CA CRL version number
uint8_t signerCrlVersion; // Signer CRL version number
Aes128Key titleKey; // Published title key
/* 1 byte alignment padding */
tc::bn::be64<uint64_t> ticketId; // Unique 64bit ticket ID
tc::bn::be32<uint32_t> deviceId; // Unique 32bit device ID
tc::bn::be64<uint64_t> titleId; // Unique 64bit title ID
ESSysAccessMask sysAccessMask; // 16-bit cidx mask to indicate which
// of the first 16 pieces of contents
// can be accessed by the system app
tc::bn::be16<uint16_t> ticketVersion; // 16-bit ticket version
tc::bn::be32<uint32_t> accessTitleId; // 32-bit title ID for access control
tc::bn::be32<uint32_t> accessTitleMask; // 32-bit title ID mask
uint8_t licenseType; //
uint8_t keyId; // Common key ID
tc::bn::be16<uint16_t> propertyMask; // 16-bit property mask
ESTicketCustomData customData; // 20-byte custom data
ESTicketReserved reserved; // 25-byte reserved info
uint8_t audit; //
ESCidxMask cidxMask; // Bit-mask of the content indices
/* 2 bytes alignment padding */
ESLimitedPlayArray limits; // Limited play entries
};
static_assert(sizeof(ESTicket) == 676, "ESTicket size");
struct ESV1TicketHeader
{
tc::bn::be16<uint16_t> hdrVersion; // Version of the ticket header
tc::bn::be16<uint16_t> hdrSize; // Size of ticket header
tc::bn::be32<uint32_t> ticketSize; // Size of the v1 portion of the ticket
tc::bn::be32<uint32_t> sectHdrOfst; // Offset of the section header table
tc::bn::be16<uint16_t> nSectHdrs; // Number of section headers
tc::bn::be16<uint16_t> sectHdrEntrySize; // Size of each section header
tc::bn::be32<uint32_t> flags; // Miscellaneous attributes
};
static_assert(sizeof(ESV1TicketHeader) == 20, "ESV1TicketHeader size");
struct ESV1SectionHeader
{
tc::bn::be32<uint32_t> sectOfst; // Offset of this section
tc::bn::be32<uint32_t> nRecords; // Number of records in this section
tc::bn::be32<uint32_t> recordSize; // Size of each record
tc::bn::be32<uint32_t> sectionSize; // Total size of this section
tc::bn::be16<uint16_t> sectionType; // Type code of this section
tc::bn::be16<uint16_t> flags; // Miscellaneous attributes
};
static_assert(sizeof(ESV1SectionHeader) == 20, "ESV1SectionHeader size");
struct ESV1Ticket
{
ESTicket head;
ESV1TicketHeader v1Head;
ESV1SectionHeader sectHdrs[];
};
static_assert(sizeof(ESV1Ticket) == 696, "ESV1Ticket size");
struct ESV1PermanentRecord
{
ESReferenceId referenceId; // Reference ID
tc::bn::be32<uint32_t> referenceIdAttr; // Reference ID attributes
};
static_assert(sizeof(ESV1PermanentRecord) == 20, "ESV1PermanentRecord size");
struct ESV1SubscriptionRecord
{
tc::bn::be32<uint32_t> limit; // Expiration time
ESReferenceId referenceId; // Reference ID
tc::bn::be32<uint32_t> referenceIdAttr; // Reference ID attributes
};
static_assert(sizeof(ESV1SubscriptionRecord) == 24, "ESV1SubscriptionRecord size");
struct ESV1ContentRecord
{
tc::bn::be32<uint32_t> offset; // Offset content index
ESV1CidxMask accessMask; // Access mask
};
static_assert(sizeof(ESV1ContentRecord) == 132, "ESV1ContentRecord size");
struct ESV1ContentConsumptionRecord
{
tc::bn::be16<uint16_t> index; // Content index
tc::bn::be16<uint16_t> code; // Limit code
tc::bn::be32<uint32_t> limit; // Limit value
};
static_assert(sizeof(ESV1ContentConsumptionRecord) == 8, "ESV1ContentConsumptionRecord size");
struct ESV1AccessTitleRecord
{
tc::bn::be64<uint64_t> accessTitleId; // Access title ID
tc::bn::be64<uint64_t> accessTitleMask; // Access title mask
};
static_assert(sizeof(ESV1AccessTitleRecord) == 16, "ESV1AccessTitleRecord size");
struct ESV1LimitedResourceRecord
{
tc::bn::be32<uint32_t> limit; // Expiration time
ESReferenceId referenceId; // Reference ID
tc::bn::be32<uint32_t> referenceIdAttr; // Reference ID attributes
};
static_assert(sizeof(ESV1LimitedResourceRecord) == 24, "ESV1LimitedResourceRecord size");
struct ESV2Ticket
{
ESSigRsa2048 sig; // RSA 2048-bit sign of the ticket
ESV2TitleKey titleKey; // Published title key
uint8_t version; // Ticket data structure version number
uint8_t keyType; // Title key encryption key type
tc::bn::le16<uint16_t> ticketVersion; // 16-bit ticket version
uint8_t licenseType;
uint8_t keyId; // Common key ID
tc::bn::le16<uint16_t> propertyMask; // 16-bit property mask
ESV2TicketReserved reservedRegion; // probably the accessTitleId & mask
tc::bn::le64<uint64_t> ticketId; // Unique 64bit ticket ID
tc::bn::le64<uint64_t> deviceId; // Unique 64bit device ID
ESRightsId rightsId; // Unique 128bit rights ID
tc::bn::le32<uint32_t> accountId; // Unique 32bit account ID
tc::bn::le32<uint32_t> sectTotalSize; // Total size of sections
tc::bn::le32<uint32_t> sectHdrOffset; // Offset of the section header table
tc::bn::le16<uint16_t> nSectHdrs; // Number of section headers
tc::bn::le16<uint16_t> nSectHdrEntrySize; // Size of each section header
};
static_assert(sizeof(ESV2Ticket) == 704, "ESV2Ticket size");
struct ESV2SectionHeader
{
tc::bn::le32<uint32_t> sectOfst; // Offset of this section
tc::bn::le32<uint32_t> recordSize; // Size of each record
tc::bn::le32<uint32_t> sectionSize; // Total size of this section
tc::bn::le16<uint16_t> nRecords; // Number of records in this section
tc::bn::le16<uint16_t> sectionType; // Type code of this section
};
static_assert(sizeof(ESV2SectionHeader) == 16, "ESV2SectionHeader size");
#ifdef _WIN32
#pragma warning(default : 4200)
#endif
#pragma pack(pop)
}} // namespace brd::es
@@ -0,0 +1,129 @@
#pragma once
#include <brd/es/es_sign.h>
namespace brd { namespace es {
// ES title type
enum class ESTitleType : uint32_t
{
NC_TITLE = 0x1, // bit0 NetCard - End-of-life
NG_TITLE = 0x2, // bit1 Wii/NDEV
DS_TITLE = 0x4, // bit2 TWL/DSi
DATA = 0x8, // bit3 boring data title
CT_TITLE = 0x40, // bit6 CTR/3DS
GVM_TITLE = 0x80, // bit7 GVM = ? (from BroadOn libraries)
CAFE_TITLE = 0x100, // bit8 WiiU (from WiiU sdk)
};
// ES content type
enum ESContentType : uint16_t
{
ESContentType_ENCRYPTED = 0x1, // bit0 (from broadOn & b4)
ESContentType_DISC = 0x2, // bit1 (from broadOn & b4)
ESContentType_HASHED = 0x2, // bit1 (from b4)
ESContentType_CFM = 0x4, // bit3 (from broadOn & b4)
ESContentType_SHA1_HASH = 0x2000, // bit13 from b4 (wiiu sdk)
ESContentType_OPTIONAL = 0x4000, // bit14 (from broadOn & b4)
ESContentType_SHARED = 0x8000, // bit15 (from broadOn & b4)
};
//
// Maximum possible content index value is 64K - 2, since
// the maximum number of contents per title is 64K - 1
//
static const size_t ES_CONTENT_INDEX_MAX = 65534;
// There are a maximum of 64 CMD groups, each with a maximum of 1K CMDs
static const size_t ES_MAX_CMDS_IN_GROUP = 1024;
static const size_t ES_MAX_CMD_GROUPS = 64;
#pragma pack(push, 4)
#ifdef _WIN32
#pragma warning(disable : 4200) // silence warnings for usage of empty arrays in stucts
#endif
struct ESContentMeta
{
tc::bn::be32<uint32_t> cid; // 32-bit content ID
tc::bn::be16<uint16_t> index; // Content index, unique per title
tc::bn::be16<uint16_t> type; // Content type
tc::bn::be64<uint64_t> size; // Unencrypted content size in bytes
Sha1Hash hash; // Hash of the content
};
static_assert(sizeof(ESContentMeta) == 36, "ESContentMeta size");
struct ESV1ContentMeta
{
tc::bn::be32<uint32_t> cid; // 32-bit content ID
tc::bn::be16<uint16_t> index; // Content index, unique per title
tc::bn::be16<uint16_t> type; // Content type
tc::bn::be64<uint64_t> size; // Unencrypted content size in bytes
Sha256Hash hash; // Hash of the content
};
static_assert(sizeof(ESV1ContentMeta) == 48, "ESV1ContentMeta size");
struct ESTitleMetaHeader
{
using ESTmdCustomData = std::array<uint8_t, 32>;
using ESTmdReserved = std::array<uint8_t, 30>;
uint8_t version; // TMD version number
uint8_t caCrlVersion; // CA CRL version number
uint8_t signerCrlVersion; // Signer CRL version number
tc::bn::be64<uint64_t> sysVersion; // System software version number
tc::bn::be64<uint64_t> titleId; // 64-bit title id
tc::bn::be32<ESTitleType> type; // 32-bit title type
tc::bn::be16<uint16_t> groupId;
ESTmdCustomData customData; // 32-byte custom data
ESTmdReserved reserved; // 30-byte reserved info
tc::bn::be32<uint32_t> accessRights; // Rights to system resources
tc::bn::be16<uint16_t> titleVersion; // 16-bit title version
tc::bn::be16<uint16_t> numContents; // Number of contents
tc::bn::be16<uint16_t> bootIndex; // Boot content index
tc::bn::be16<uint16_t> minorTitleVersion; // 16-bit minor title version
};
static_assert(sizeof(ESTitleMetaHeader) == 100, "ESTitleMetaHeader size");
struct ESV1ContentMetaGroup
{
tc::bn::be16<uint16_t> offset; // Offset content index
tc::bn::be16<uint16_t> nCmds; // Number of CMDs in this group
Sha256Hash groupHash; // Hash for this group of CMDs
};
static_assert(sizeof(ESV1ContentMetaGroup) == 36, "ESV1ContentMetaGroup size");
struct ESV1TitleMetaHeader
{
using ESV1ContentMetaGroupArray = std::array<ESV1ContentMetaGroup, ES_MAX_CMD_GROUPS>;
Sha256Hash hash; // Hash for the CMD groups
ESV1ContentMetaGroupArray cmdGroups;
};
static_assert(sizeof(ESV1TitleMetaHeader) == 2336, "ESV1TitleMetaHeader size");
struct ESTitleMeta
{
ESSigRsa2048 sig; // RSA 2048-bit sign of the TMD header
ESTitleMetaHeader head;
ESContentMeta contents[]; // CMD array sorted by content index
};
static_assert(sizeof(ESTitleMeta) == 484, "ESTitleMeta size");
struct ESV1TitleMeta
{
ESSigRsa2048 sig; // RSA 2048-bit sign of the TMD header
ESTitleMetaHeader head;
ESV1TitleMetaHeader v1Head; // Extension to the v0 TMD header
ESV1ContentMeta contents[]; // CMD array sorted by content index
};
static_assert(sizeof(ESV1TitleMeta) == 2820, "ESV1TitleMeta size");
#ifdef _WIN32
#pragma warning(default : 4200)
#endif
#pragma pack(pop)
}} // namespace brd::es
@@ -0,0 +1,73 @@
#pragma once
#include <tc/types.h>
namespace brd { namespace es {
#pragma pack(push,4)
static const size_t kAes128KeySize = 16;
using Aes128Key = std::array<uint8_t, kAes128KeySize>;
static const size_t kAes192KeySize = 24;
using Aes192Key = std::array<uint8_t, kAes192KeySize>;
static const size_t kAes256KeySize = 32;
using Aes256Key = std::array<uint8_t, kAes256KeySize>;
static const size_t kSha1Size = 20;
using Sha1Hash = std::array<uint8_t, kSha1Size>;
using Sha1Hmac = std::array<uint8_t, kSha1Size>;
static const size_t kSha256Size = 32;
using Sha256Hash = std::array<uint8_t, kSha256Size>;
using Sha256Hmac = std::array<uint8_t, kSha256Size>;
static const size_t kRsaPublicExponentSize = 4;
using RsaPublicExponent = std::array<uint8_t, kRsaPublicExponentSize>;
static const size_t kRsa2048Size = 0x100;
using Rsa2048Integer = std::array<uint8_t, kRsa2048Size>;
struct Rsa2048PublicKey
{
Rsa2048Integer m; // modulus
RsaPublicExponent e; // public_exponent
};
struct Rsa2048PrivateKey
{
Rsa2048Integer m; // modulus
Rsa2048Integer d; // private_exponent
};
using Rsa2048Sig = Rsa2048Integer;
static const size_t kRsa4096Size = 0x200;
using Rsa4096Integer = std::array<uint8_t, kRsa4096Size>;
struct Rsa4096PublicKey
{
Rsa4096Integer m; // modulus
RsaPublicExponent e; // public_exponent
};
struct Rsa4096PrivateKey
{
Rsa4096Integer m; // modulus
Rsa4096Integer d; // private_exponent
};
using Rsa4096Sig = Rsa4096Integer;
static const size_t kEcc233Size = 60;
using Ecc233Integer = std::array<uint8_t, kEcc233Size / 2>;
struct Ecc233Point
{
Ecc233Integer x;
Ecc233Integer y;
};
using Ecc233PrivateKey = Ecc233Integer;
using Ecc233PublicKey = Ecc233Point;
struct Ecc233Sig
{
Ecc233Integer r;
Ecc233Integer s;
};
#pragma pack(pop)
}} // namespace brd::es
+197
View File
@@ -0,0 +1,197 @@
# C++/C Recursive Project Makefile
# (c) Jack
# Version 6 (20211110)
# Project Name
PROJECT_NAME = libbroadon-es
# Project Relative Paths
PROJECT_PATH = $(CURDIR)
PROJECT_SRC_PATH = src
PROJECT_SRC_SUBDIRS = $(PROJECT_SRC_PATH)
PROJECT_INCLUDE_PATH = include
#PROJECT_TESTSRC_PATH = test
#PROJECT_TESTSRC_SUBDIRS = $(PROJECT_TESTSRC_PATH)
PROJECT_BIN_PATH = bin
#PROJECT_DOCS_PATH = docs
#PROJECT_DOXYFILE_PATH = Doxyfile
# Determine if the root makefile has been established, and if not establish this makefile as the root makefile
ifeq ($(ROOT_PROJECT_NAME),)
export ROOT_PROJECT_NAME = $(PROJECT_NAME)
export ROOT_PROJECT_PATH = $(PROJECT_PATH)
export ROOT_PROJECT_DEPENDENCY_PATH = $(ROOT_PROJECT_PATH)/deps
endif
# Shared Library Definitions
PROJECT_SO_VER_MAJOR = 0
PROJECT_SO_VER_MINOR = 1
PROJECT_SO_VER_PATCH = 0
PROJECT_SONAME = $(PROJECT_NAME).so.$(PROJECT_SO_VER_MAJOR)
PROJECT_SO_FILENAME = $(PROJECT_SONAME).$(PROJECT_SO_VER_MINOR).$(PROJECT_SO_VER_PATCH)
# Project Dependencies
PROJECT_DEPEND = toolchain mbedtls fmt
PROJECT_DEPEND_LOCAL_DIR = libtoolchain libmbedtls libfmt
# Generate compiler flags for including project include path
ifneq ($(PROJECT_INCLUDE_PATH),)
INC += -I"$(PROJECT_INCLUDE_PATH)"
endif
# Generate compiler flags for local included dependencies
ifneq ($(PROJECT_DEPEND_LOCAL_DIR),)
LIB += $(foreach dep,$(PROJECT_DEPEND_LOCAL_DIR), -L"$(ROOT_PROJECT_DEPENDENCY_PATH)/$(dep)/bin")
INC += $(foreach dep,$(PROJECT_DEPEND_LOCAL_DIR), -I"$(ROOT_PROJECT_DEPENDENCY_PATH)/$(dep)/include")
endif
# Generate compiler flags for external dependencies
ifneq ($(PROJECT_DEPEND),)
LIB += $(foreach dep,$(PROJECT_DEPEND), -l$(dep))
endif
# Detect Platform
ifeq ($(PROJECT_PLATFORM),)
ifeq ($(OS), Windows_NT)
export PROJECT_PLATFORM = WIN32
else
UNAME = $(shell uname -s)
ifeq ($(UNAME), Darwin)
export PROJECT_PLATFORM = MACOS
else
export PROJECT_PLATFORM = GNU
endif
endif
endif
# Detect Architecture
ifeq ($(PROJECT_PLATFORM_ARCH),)
ifeq ($(PROJECT_PLATFORM), WIN32)
export PROJECT_PLATFORM_ARCH = x86_64
else ifeq ($(PROJECT_PLATFORM), GNU)
export PROJECT_PLATFORM_ARCH = $(shell uname -m)
else ifeq ($(PROJECT_PLATFORM), MACOS)
export PROJECT_PLATFORM_ARCH = $(shell uname -m)
else
export PROJECT_PLATFORM_ARCH = x86_64
endif
endif
# Generate platform specific compiler flags
ifeq ($(PROJECT_PLATFORM), WIN32)
# Windows Flags/Libs
CC = x86_64-w64-mingw32-gcc
CXX = x86_64-w64-mingw32-g++
WARNFLAGS = -Wall -Wno-unused-value -Wno-unused-but-set-variable
ARCHFLAGS =
INC +=
LIB += -static
ARFLAGS = cr -o
else ifeq ($(PROJECT_PLATFORM), GNU)
# GNU/Linux Flags/Libs
#CC =
#CXX =
WARNFLAGS = -Wall -Wno-unused-value -Wno-unused-but-set-variable
ARCHFLAGS =
INC +=
LIB +=
ARFLAGS = cr -o
else ifeq ($(PROJECT_PLATFORM), MACOS)
# MacOS Flags/Libs
#CC =
#CXX =
WARNFLAGS = -Wall -Wno-unused-value -Wno-unused-private-field
ARCHFLAGS = -arch $(PROJECT_PLATFORM_ARCH)
INC +=
LIB +=
ARFLAGS = rc
endif
# Compiler Flags
CXXFLAGS = -std=c++11 $(INC) $(WARNFLAGS) $(ARCHFLAGS) -fPIC
CFLAGS = -std=c11 $(INC) $(WARNFLAGS) $(ARCHFLAGS) -fPIC
# Object Files
SRC_OBJ = $(foreach dir,$(PROJECT_SRC_SUBDIRS),$(subst .cpp,.o,$(wildcard $(dir)/*.cpp))) $(foreach dir,$(PROJECT_SRC_SUBDIRS),$(subst .cc,.o,$(wildcard $(dir)/*.cc))) $(foreach dir,$(PROJECT_SRC_SUBDIRS),$(subst .c,.o,$(wildcard $(dir)/*.c)))
TESTSRC_OBJ = $(foreach dir,$(PROJECT_TESTSRC_SUBDIRS),$(subst .cpp,.o,$(wildcard $(dir)/*.cpp))) $(foreach dir,$(PROJECT_TESTSRC_SUBDIRS),$(subst .cc,.o,$(wildcard $(dir)/*.cc))) $(foreach dir,$(PROJECT_TESTSRC_SUBDIRS),$(subst .c,.o,$(wildcard $(dir)/*.c)))
# all is the default, user should specify what the default should do
# - 'static_lib' for building static library
# - 'shared_lib' for building shared library
# - 'program' for building the program
# - 'test_program' for building the test program
# These can typically be used together however *_lib and program should not be used together
all: static_lib
clean: clean_object_files remove_binary_dir
# Object Compile Rules
%.o: %.c
@echo CC $<
@$(CC) $(CFLAGS) -c $< -o $@
%.o: %.cpp
@echo CXX $<
@$(CXX) $(CXXFLAGS) -c $< -o $@
%.o: %.cc
@echo CXX $<
@$(CXX) $(CXXFLAGS) -c $< -o $@
# Binary Directory
.PHONY: create_binary_dir
create_binary_dir:
@mkdir -p "$(PROJECT_BIN_PATH)"
.PHONY: remove_binary_dir
remove_binary_dir:
ifneq ($(PROJECT_BIN_PATH),)
@rm -rf "$(PROJECT_BIN_PATH)"
endif
.PHONY: clean_object_files
clean_object_files:
@rm -f $(SRC_OBJ) $(TESTSRC_OBJ)
# Build Library
static_lib: $(SRC_OBJ) create_binary_dir
@echo LINK $(PROJECT_BIN_PATH)/$(PROJECT_NAME).a
@ar $(ARFLAGS) "$(PROJECT_BIN_PATH)/$(PROJECT_NAME).a" $(SRC_OBJ)
shared_lib: $(SRC_OBJ) create_binary_dir
@echo LINK $(PROJECT_BIN_PATH)/$(PROJECT_SO_FILENAME)
@gcc -shared -Wl,-soname,$(PROJECT_SONAME) -o "$(PROJECT_BIN_PATH)/$(PROJECT_SO_FILENAME)" $(SRC_OBJ)
# Build Program
program: $(SRC_OBJ) create_binary_dir
@echo LINK $(PROJECT_BIN_PATH)/$(PROJECT_NAME)
@$(CXX) $(ARCHFLAGS) $(SRC_OBJ) $(LIB) -o "$(PROJECT_BIN_PATH)/$(PROJECT_NAME)"
# Build Test Program
test_program: $(TESTSRC_OBJ) $(SRC_OBJ) create_binary_dir
ifneq ($(PROJECT_TESTSRC_PATH),)
@echo LINK $(PROJECT_BIN_PATH)/$(PROJECT_NAME)_test
@$(CXX) $(ARCHFLAGS) $(TESTSRC_OBJ) $(SRC_OBJ) $(LIB) -o "$(PROJECT_BIN_PATH)/$(PROJECT_NAME)_test"
endif
# Documentation
.PHONY: docs
docs:
ifneq ($(PROJECT_DOCS_PATH),)
doxygen "$(PROJECT_DOXYFILE_PATH)"
endif
.PHONY: clean_docs
clean_docs:
ifneq ($(PROJECT_DOCS_PATH),)
@rm -rf "$(PROJECT_DOCS_PATH)"
endif
# Dependencies
.PHONY: deps
deps:
@$(foreach lib,$(PROJECT_DEPEND_LOCAL_DIR), cd "$(ROOT_PROJECT_DEPENDENCY_PATH)/$(lib)" && $(MAKE) static_lib && cd "$(PROJECT_PATH)";)
.PHONY: clean_deps
clean_deps:
@$(foreach lib,$(PROJECT_DEPEND_LOCAL_DIR), cd "$(ROOT_PROJECT_DEPENDENCY_PATH)/$(lib)" && $(MAKE) clean && cd "$(PROJECT_PATH)";)
+138
View File
@@ -0,0 +1,138 @@
#include <iostream>
#include <brd/es.h>
#ifdef _WIN32
#pragma warning(disable : 4101) // silence warnings for unused local variables
#endif
namespace brd {
namespace es {
int dummy_method1a()
{
// types
brd::es::Aes128Key Aes128Key_var;
brd::es::Aes192Key Aes192Key_var;
brd::es::Aes256Key Aes256Key_var;
brd::es::Sha1Hash Sha1Hash_var;
brd::es::Sha1Hmac Sha1Hmac_var;
brd::es::Sha256Hash Sha256Hash_var;
brd::es::Sha256Hmac Sha256Hmac_var;
brd::es::RsaPublicExponent RsaPublicExponent_var;
brd::es::Rsa2048Integer Rsa2048Integer_var;
brd::es::Rsa2048PublicKey Rsa2048PublicKey_var;
brd::es::Rsa2048PrivateKey Rsa2048PrivateKey_var;
brd::es::Rsa2048Sig Rsa2048Sig_var;
return 11;
}
int dummy_method1b()
{
// types
brd::es::Rsa4096Integer Rsa4096Integer_var;
brd::es::Rsa4096PublicKey Rsa4096PublicKey_var;
brd::es::Rsa4096PrivateKey Rsa4096PrivateKey_var;
brd::es::Rsa4096Sig Rsa4096Sig_var;
brd::es::Ecc233Integer Ecc233Integer_var;
brd::es::Ecc233Point Ecc233Point_var;
brd::es::Ecc233PrivateKey Ecc233PrivateKey_var;
brd::es::Ecc233PublicKey Ecc233PublicKey_var;
brd::es::Ecc233Sig Ecc233Sig_var;
return 01323;
}
int dummy_method2()
{
// sign
brd::es::ESSigType ESSigType_var;
size_t ES_ISSUER_SIZE_var = brd::es::ES_ISSUER_SIZE;
brd::es::ESIssuer ESIssuer_var;
brd::es::ESSigRsa2048 ESSigRsa2048_struct;
brd::es::ESSigRsa4096 ESSigRsa4096_struct;
brd::es::ESSigEcc233 ESSigEcc233_struct;
return 1232;
}
int dummy_method3()
{
// cert
brd::es::ESCertPubKeyType ESCertPubKeyType_var;
size_t ES_CERT_NAME_SIZE_var = brd::es::ES_CERT_NAME_SIZE;
brd::es::ESCertName ESCertName_var;
brd::es::ESServerId ESServerId_var;
brd::es::ESDeviceId ESDeviceId_var;
brd::es::ESCertHeader ESCertHeader_struct;
brd::es::ESCertRsa2048PublicKey ESCertRsa2048PublicKey_struct;
brd::es::ESCertRsa4096PublicKey ESCertRsa4096PublicKey_struct;
brd::es::ESCertEcc233PublicKey ESCertEcc233PublicKey_struct;
brd::es::ESRootCert ESRootCert_struct;
brd::es::ESCACert ESCACert_struct;
brd::es::ESCASignedCert ESCASignedCert_struct;
brd::es::ESDeviceCert ESDeviceCert_struct;
brd::es::ESDeviceSignedCert ESDeviceSignedCert_struct;
return 55;
}
int dummy_method4()
{
// tik
brd::es::ESLicenseType ESLicenseType_var;
uint8_t ES_LICENSE_MASK_var = brd::es::ES_LICENSE_MASK;
brd::es::ESLimitCode ESLimitCode_var;
uint32_t ES_MAX_LIMIT_TYPE_var = brd::es::ES_MAX_LIMIT_TYPE;
brd::es::ESItemType ESItemType_var;
brd::es::ESPropertyMaskFlag ESPropertyMaskFlag_var;
brd::es::ESV1SectionHeaderFlag ESV1SectionHeaderFlag_var;
brd::es::ESV2TitleKekType ESV2TitleKekType_var;
brd::es::ESLimitedPlayEntry ESLimitedPlayEntry_struct;
brd::es::ESSysAccessMask ESSysAccessMask_var;
brd::es::ESTicketCustomData ESTicketCustomData_var;
brd::es::ESTicketReserved ESTicketReserved_var;
brd::es::ESCidxMask ESCidxMask_var;
brd::es::ESLimitedPlayArray ESLimitedPlayArray_var;
brd::es::ESReferenceId ESReferenceId_var;
brd::es::ESV1CidxMask ESV1CidxMask_var;
brd::es::ESV2TitleKey ESV2TitleKey_var;
brd::es::ESRightsId ESRightsId_var;
brd::es::ESV2TicketReserved ESV2TicketReserved_var;
brd::es::ESTicket ESTicket_struct;
brd::es::ESV1TicketHeader ESV1TicketHeader_struct;
brd::es::ESV1SectionHeader ESV1SectionHeader_struct;
brd::es::ESV1Ticket ESV1Ticket_struct;
brd::es::ESV1PermanentRecord ESV1PermanentRecord_struct;
brd::es::ESV1SubscriptionRecord ESV1SubscriptionRecord_struct;
brd::es::ESV1ContentRecord ESV1ContentRecord_struct;
brd::es::ESV1ContentConsumptionRecord ESV1ContentConsumptionRecord_struct;
brd::es::ESV1AccessTitleRecord ESV1AccessTitleRecord_struct;
brd::es::ESV1LimitedResourceRecord ESV1LimitedResourceRecord_struct;
brd::es::ESV2Ticket ESV2Ticket_struct;
brd::es::ESV2SectionHeader ESV2SectionHeader_struct;
return 0;
}
int dummy_method5()
{
// tmd
brd::es::ESTitleType ESTitleType_var;
brd::es::ESContentType ESContentType_var;
size_t ES_CONTENT_INDEX_MAX_var = brd::es::ES_CONTENT_INDEX_MAX;
size_t ES_MAX_CMDS_IN_GROUP_var = brd::es::ES_MAX_CMDS_IN_GROUP;
brd::es::ESContentMeta ESContentMeta_struct;
brd::es::ESV1ContentMeta ESV1ContentMeta_struct;
brd::es::ESTitleMetaHeader ESTitleMetaHeader_struct;
brd::es::ESV1ContentMetaGroup ESV1ContentMetaGroup_struct;
brd::es::ESV1TitleMetaHeader ESV1TitleMetaHeader_struct;
brd::es::ESTitleMeta ESTitleMeta_struct;
brd::es::ESV1TitleMeta ESV1TitleMeta_struct;
return 54;
}
}
}
#ifdef _WIN32
#pragma warning(default : 4101)
#endif