mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Identify CSS, read and get disc key
This commit is contained in:
Submodule Aaru.CommonTypes updated: ec8e09f881...1e523e4a7a
@@ -149,6 +149,7 @@
|
||||
<Name>Aaru.Console</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Aaru.Database\Aaru.Database.csproj" />
|
||||
<ProjectReference Include="..\Aaru.Decryption\Aaru.Decryption.csproj" />
|
||||
<ProjectReference Include="..\Aaru.Dto\Aaru.Dto.csproj" />
|
||||
<ProjectReference Include="..\Aaru.Filesystems\Aaru.Filesystems.csproj">
|
||||
<Project>{D7016DF2-5A5E-4524-B40D-BA2D59576688}</Project>
|
||||
|
||||
@@ -39,12 +39,15 @@ using Aaru.Decoders.Bluray;
|
||||
using Aaru.Decoders.DVD;
|
||||
using Aaru.Decoders.SCSI;
|
||||
using Aaru.Decoders.SCSI.MMC;
|
||||
using Aaru.Decryption;
|
||||
using Aaru.Decryption.DVD;
|
||||
using Aaru.Devices;
|
||||
using Schemas;
|
||||
using DDS = Aaru.Decoders.DVD.DDS;
|
||||
using DMI = Aaru.Decoders.Xbox.DMI;
|
||||
using Inquiry = Aaru.CommonTypes.Structs.Devices.SCSI.Inquiry;
|
||||
using Spare = Aaru.Decoders.DVD.Spare;
|
||||
using DVDDecryption = Aaru.Decryption.DVD.Dump;
|
||||
|
||||
// ReSharper disable JoinDeclarationAndInitializer
|
||||
|
||||
@@ -505,6 +508,109 @@ namespace Aaru.Core.Devices.Dumping
|
||||
tmpBuf = new byte[cmdBuf.Length - 4];
|
||||
Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
|
||||
mediaTags.Add(MediaTagType.DVD_CMI, tmpBuf);
|
||||
|
||||
CSS_CPRM.LeadInCopyright? cmi = CSS_CPRM.DecodeLeadInCopyright(cmdBuf);
|
||||
|
||||
if(cmi!.Value.CopyrightType == CopyrightType.NoProtection)
|
||||
{
|
||||
UpdateStatus?.Invoke("Drive reports no copy protection on disc.");
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!_decryption)
|
||||
{
|
||||
UpdateStatus?.Invoke("Drive reports the disc uses copy protection. " +
|
||||
"The dump might be incorrect unless decryption is enabled.");
|
||||
}
|
||||
else
|
||||
{
|
||||
if(cmi!.Value.CopyrightType == CopyrightType.CSS)
|
||||
{
|
||||
UpdateStatus?.Invoke("Drive reports disc uses CSS copy protection.");
|
||||
|
||||
var dvdDecrypt = new DVDDecryption(_dev);
|
||||
|
||||
sense = dvdDecrypt.ReadBusKey(out cmdBuf, out _,
|
||||
CSS_CPRM.DecodeLeadInCopyright(cmdBuf)!.Value.
|
||||
CopyrightType, _dev.Timeout, out _);
|
||||
|
||||
if(!sense)
|
||||
{
|
||||
byte[] busKey = cmdBuf;
|
||||
|
||||
UpdateStatus?.Invoke("Reading disc key.");
|
||||
sense = dvdDecrypt.ReadDiscKey(out cmdBuf, out _, _dev.Timeout, out _);
|
||||
|
||||
if(!sense)
|
||||
{
|
||||
CSS_CPRM.DiscKey? decodedDiscKey = CSS.DecodeDiscKey(cmdBuf, busKey);
|
||||
|
||||
sense = dvdDecrypt.ReadAsf(out cmdBuf, out _,
|
||||
DvdCssKeyClass.DvdCssCppmOrCprm, _dev.Timeout,
|
||||
out _);
|
||||
|
||||
if(!sense)
|
||||
{
|
||||
if(cmdBuf[7] == 1)
|
||||
{
|
||||
UpdateStatus?.Invoke("Disc and drive authentication succeeded.");
|
||||
|
||||
sense = dvdDecrypt.ReadRpc(out cmdBuf, out _,
|
||||
DvdCssKeyClass.DvdCssCppmOrCprm,
|
||||
_dev.Timeout, out _);
|
||||
|
||||
if(!sense)
|
||||
{
|
||||
CSS_CPRM.RegionalPlaybackControlState? rpc =
|
||||
CSS_CPRM.DecodeRegionalPlaybackControlState(cmdBuf);
|
||||
|
||||
if(rpc.HasValue)
|
||||
{
|
||||
if(CSS.CheckRegion(rpc.Value, cmi.Value))
|
||||
{
|
||||
UpdateStatus?.Invoke("Disc and drive regions match.");
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateStatus?.
|
||||
Invoke("Disc and drive regions do not match. The dump might be incorrect");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(decodedDiscKey.HasValue)
|
||||
{
|
||||
mediaTags.Add(MediaTagType.DVD_DiscKey,
|
||||
decodedDiscKey.Value.Key);
|
||||
|
||||
UpdateStatus?.Invoke("Decrypting disc key.");
|
||||
|
||||
CSS.DecryptDiscKey(decodedDiscKey.Value.Key,
|
||||
out byte[] discKey);
|
||||
|
||||
if(discKey != null)
|
||||
{
|
||||
UpdateStatus?.Invoke("Decryption of disc key succeeded.");
|
||||
mediaTags.Add(MediaTagType.DVD_DiscKey_Decrypted, discKey);
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateStatus?.Invoke("Decryption of disc key failed.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateStatus?.
|
||||
Invoke($"Drive reports disc uses {CSS_CPRM.DecodeLeadInCopyright(cmdBuf)!.Value.CopyrightType.ToString()} copy protection. " +
|
||||
"This is not yet supported and the dump might be incorrect.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion DVD-ROM
|
||||
|
||||
@@ -2885,4 +2885,17 @@ namespace Aaru.Devices
|
||||
{
|
||||
LogicalBlockAddress = 0, LogicalTrackNumber = 1, SessionNumber = 2
|
||||
}
|
||||
|
||||
public enum CssReportKeyFormat : byte
|
||||
{
|
||||
AgidForCssCppm = 0x00, ChallengeKey = 0x01, Key1 = 0x02,
|
||||
TitleKey = 0x04, Asf = 0x05, RpcState = 0x08,
|
||||
AgidForCprm = 0x11, InvalidateAgid = 0x3f
|
||||
}
|
||||
|
||||
public enum CssSendKeyFormat : byte
|
||||
{
|
||||
ChallengeKey = 0x01, Key2 = 0x03, RpcStructure = 0x06,
|
||||
InvalidateAgid = 0x3f
|
||||
}
|
||||
}
|
||||
10
Aaru.sln
10
Aaru.sln
@@ -44,6 +44,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aaru.Tests.Devices", "Aaru.
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CUETools.Codecs.Flake", "cuetools.net\CUETools.Codecs.Flake\CUETools.Codecs.Flake.csproj", "{69FAC887-A3DE-4C23-84A5-9C5F64E4C3E1}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aaru.Decryption", "Aaru.Decryption\Aaru.Decryption.csproj", "{B609D333-80C5-4503-BF46-8B9B91F04E97}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -220,6 +222,14 @@ Global
|
||||
{69FAC887-A3DE-4C23-84A5-9C5F64E4C3E1}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{69FAC887-A3DE-4C23-84A5-9C5F64E4C3E1}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{69FAC887-A3DE-4C23-84A5-9C5F64E4C3E1}.Release|x86.Build.0 = Release|Any CPU
|
||||
{B609D333-80C5-4503-BF46-8B9B91F04E97}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B609D333-80C5-4503-BF46-8B9B91F04E97}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B609D333-80C5-4503-BF46-8B9B91F04E97}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{B609D333-80C5-4503-BF46-8B9B91F04E97}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{B609D333-80C5-4503-BF46-8B9B91F04E97}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B609D333-80C5-4503-BF46-8B9B91F04E97}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{B609D333-80C5-4503-BF46-8B9B91F04E97}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{B609D333-80C5-4503-BF46-8B9B91F04E97}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
Reference in New Issue
Block a user