General code cleanup and style refactor.

This commit is contained in:
2022-11-15 15:58:41 +00:00
parent 42e2251131
commit 8e64a9f10c
4 changed files with 109 additions and 111 deletions

View File

@@ -1,51 +1,51 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<SchemaVersion>2.0</SchemaVersion> <SchemaVersion>2.0</SchemaVersion>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<RootNamespace>Aaru.Decryption</RootNamespace> <RootNamespace>Aaru.Decryption</RootNamespace>
<AssemblyName>Aaru.Decryption</AssemblyName> <AssemblyName>Aaru.Decryption</AssemblyName>
<ReleaseVersion>$(Version)</ReleaseVersion> <ReleaseVersion>$(Version)</ReleaseVersion>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo> <GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<Version>6.0.0-alpha8</Version> <Version>6.0.0-alpha8</Version>
<Company>Claunia.com</Company> <Company>Claunia.com</Company>
<Copyright>Copyright © 2011-2022 Natalia Portillo</Copyright> <Copyright>Copyright © 2011-2022 Natalia Portillo</Copyright>
<Product>Aaru Data Preservation Suite</Product> <Product>Aaru Data Preservation Suite</Product>
<Title>Aaru.Decryption</Title> <Title>Aaru.Decryption</Title>
<ApplicationVersion>$(Version)</ApplicationVersion> <ApplicationVersion>$(Version)</ApplicationVersion>
<TargetFramework>net7.0</TargetFramework> <TargetFramework>net7.0</TargetFramework>
<LangVersion>11</LangVersion> <LangVersion>11</LangVersion>
<Description>Decryption algorithms used by the Aaru Data Preservation Suite.</Description> <Description>Decryption algorithms used by the Aaru Data Preservation Suite.</Description>
<PackageProjectUrl>https://github.com/aaru-dps/</PackageProjectUrl> <PackageProjectUrl>https://github.com/aaru-dps/</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression> <PackageLicenseExpression>MIT</PackageLicenseExpression>
<RepositoryUrl>https://github.com/aaru-dps/Aaru.Decryption</RepositoryUrl> <RepositoryUrl>https://github.com/aaru-dps/Aaru.Decryption</RepositoryUrl>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<NeutralLanguage>en-US</NeutralLanguage> <NeutralLanguage>en-US</NeutralLanguage>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
<IncludeSymbols>true</IncludeSymbols> <IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat> <SymbolPackageFormat>snupkg</SymbolPackageFormat>
<Authors>Rebecca Wallander &lt;sakcheen@gmail.com&gt;</Authors> <Authors>Rebecca Wallander &lt;sakcheen@gmail.com&gt;</Authors>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<DisableImplicitNamespaceImports>true</DisableImplicitNamespaceImports> <DisableImplicitNamespaceImports>true</DisableImplicitNamespaceImports>
<EnableTrimAnalyzer>true</EnableTrimAnalyzer> <EnableTrimAnalyzer>true</EnableTrimAnalyzer>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<NoWarn>CS1591;CS1574</NoWarn> <NoWarn>CS1591;CS1574</NoWarn>
</PropertyGroup> </PropertyGroup>
<ItemGroup Condition=" '$(Configuration)' == 'Debug' "> <ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
<InternalsVisibleTo Include="Aaru.Tests"/> <InternalsVisibleTo Include="Aaru.Tests"/>
<InternalsVisibleTo Include="Aaru.Tests.Devices"/> <InternalsVisibleTo Include="Aaru.Tests.Devices"/>
</ItemGroup> </ItemGroup>
<PropertyGroup> <PropertyGroup>
<NrtRevisionFormat>$(Version)+{chash:8}</NrtRevisionFormat> <NrtRevisionFormat>$(Version)+{chash:8}</NrtRevisionFormat>
<NrtResolveSimpleAttributes>true</NrtResolveSimpleAttributes> <NrtResolveSimpleAttributes>true</NrtResolveSimpleAttributes>
<NrtShowRevision>true</NrtShowRevision> <NrtShowRevision>true</NrtShowRevision>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Aaru.Decoders\Aaru.Decoders.csproj"/> <ProjectReference Include="..\Aaru.Decoders\Aaru.Decoders.csproj"/>
<ProjectReference Include="..\Aaru.Devices\Aaru.Devices.csproj"/> <ProjectReference Include="..\Aaru.Devices\Aaru.Devices.csproj"/>
<ProjectReference Include="..\Aaru.Images\Aaru.Images.csproj"/> <ProjectReference Include="..\Aaru.Images\Aaru.Images.csproj"/>
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@@ -43,12 +43,12 @@
// libdvdcpxm (https://offog.org/git/dvdaexplorer/src/libdvdcpxm/) // libdvdcpxm (https://offog.org/git/dvdaexplorer/src/libdvdcpxm/)
// libdvdcss (https://www.videolan.org/developers/libdvdcss.html) // libdvdcss (https://www.videolan.org/developers/libdvdcss.html)
namespace Aaru.Decryption.DVD;
using System; using System;
using System.Linq; using System.Linq;
using Aaru.Decoders.DVD; using Aaru.Decoders.DVD;
namespace Aaru.Decryption.DVD;
public class CSS public class CSS
{ {
static readonly byte[,] _playerKeys = static readonly byte[,] _playerKeys =
@@ -386,7 +386,7 @@ public class CSS
byte[] key = response.Skip(4).Take(2048).ToArray(); byte[] key = response.Skip(4).Take(2048).ToArray();
for(uint i = 0; i < key.Length; i++) for(uint i = 0; i < key.Length; i++)
key[i] ^= busKey[4 - i % busKey.Length]; key[i] ^= busKey[4 - (i % busKey.Length)];
return new CSS_CPRM.DiscKey return new CSS_CPRM.DiscKey
{ {
@@ -413,7 +413,7 @@ public class CSS
byte[] key = response.Skip(5).Take(5).ToArray(); byte[] key = response.Skip(5).Take(5).ToArray();
for(uint i = 0; i < key.Length; i++) for(uint i = 0; i < key.Length; i++)
key[i] ^= busKey[4 - i % busKey.Length]; key[i] ^= busKey[4 - (i % busKey.Length)];
return new CSS_CPRM.TitleKey return new CSS_CPRM.TitleKey
{ {
@@ -435,38 +435,38 @@ public class CSS
/// <returns>The encrypted key.</returns> /// <returns>The encrypted key.</returns>
public static void EncryptKey(DvdCssKeyType keyType, uint variant, byte[] challenge, out byte[] key) public static void EncryptKey(DvdCssKeyType keyType, uint variant, byte[] challenge, out byte[] key)
{ {
var bits = new byte[30]; byte[] bits = new byte[30];
var scratch = new byte[10]; byte[] scratch = new byte[10];
byte index = sizeof(byte) * 30; byte index = sizeof(byte) * 30;
var temp1 = new byte[5]; byte[] temp1 = new byte[5];
var temp2 = new byte[5]; byte[] temp2 = new byte[5];
byte carry = 0; byte carry = 0;
key = new byte[5]; key = new byte[5];
for(var i = 9; i >= 0; --i) for(int i = 9; i >= 0; --i)
scratch[i] = challenge[_permutationChallenge[(uint)keyType, i]]; scratch[i] = challenge[_permutationChallenge[(uint)keyType, i]];
var cssVariant = (byte)(keyType == 0 ? variant : _permutationVariant[(uint)keyType - 1, variant]); byte cssVariant = (byte)(keyType == 0 ? variant : _permutationVariant[(uint)keyType - 1, variant]);
for(var i = 5; --i >= 0;) for(int i = 5; --i >= 0;)
temp1[i] = (byte)(scratch[5 + i] ^ _secret[i] ^ _encryptTable2[i]); temp1[i] = (byte)(scratch[5 + i] ^ _secret[i] ^ _encryptTable2[i]);
var lfsr0 = (uint)((temp1[0] << 17) | (temp1[1] << 9) | ((temp1[2] & ~7) << 1) | 8 | (temp1[2] & 7)); uint lfsr0 = (uint)((temp1[0] << 17) | (temp1[1] << 9) | ((temp1[2] & ~7) << 1) | 8 | (temp1[2] & 7));
var lfsr1 = (uint)((temp1[3] << 9) | 0x100 | temp1[4]); uint lfsr1 = (uint)((temp1[3] << 9) | 0x100 | temp1[4]);
do do
{ {
byte val = 0; byte val = 0;
for(var bit = 0; bit < 8; ++bit) for(int bit = 0; bit < 8; ++bit)
{ {
var oLfsr0 = (byte)(((lfsr0 >> 24) ^ (lfsr0 >> 21) ^ (lfsr0 >> 20) ^ (lfsr0 >> 12)) & 1); byte oLfsr0 = (byte)(((lfsr0 >> 24) ^ (lfsr0 >> 21) ^ (lfsr0 >> 20) ^ (lfsr0 >> 12)) & 1);
lfsr0 = (lfsr0 << 1) | oLfsr0; lfsr0 = (lfsr0 << 1) | oLfsr0;
var oLfsr1 = (byte)(((lfsr1 >> 16) ^ (lfsr1 >> 2)) & 1); byte oLfsr1 = (byte)(((lfsr1 >> 16) ^ (lfsr1 >> 2)) & 1);
lfsr1 = (lfsr1 << 1) | oLfsr1; lfsr1 = (lfsr1 << 1) | oLfsr1;
var combined = (byte)(Convert.ToByte(oLfsr1 == 0) + carry + Convert.ToByte(oLfsr0 == 0)); byte combined = (byte)(Convert.ToByte(oLfsr1 == 0) + carry + Convert.ToByte(oLfsr0 == 0));
carry = (byte)((combined >> 1) & 1); carry = (byte)((combined >> 1) & 1);
val |= (byte)((combined & 1) << bit); val |= (byte)((combined & 1) << bit);
} }
@@ -474,10 +474,10 @@ public class CSS
bits[--index] = val; bits[--index] = val;
} while(index > 0); } while(index > 0);
var cse = (byte)(_variants[cssVariant] ^ _encryptTable2[cssVariant]); byte cse = (byte)(_variants[cssVariant] ^ _encryptTable2[cssVariant]);
var term = 0; int term = 0;
for(var i = 5; --i >= 0; term = scratch[i]) for(int i = 5; --i >= 0; term = scratch[i])
{ {
index = (byte)(bits[25 + i] ^ scratch[i]); index = (byte)(bits[25 + i] ^ scratch[i]);
index = (byte)(_encryptTable1[index] ^ ~_encryptTable2[index] ^ cse); index = (byte)(_encryptTable1[index] ^ ~_encryptTable2[index] ^ cse);
@@ -488,7 +488,7 @@ public class CSS
temp1[4] ^= temp1[0]; temp1[4] ^= temp1[0];
term = 0; term = 0;
for(var i = 5; --i >= 0; term = temp1[i]) for(int i = 5; --i >= 0; term = temp1[i])
{ {
index = (byte)(bits[20 + i] ^ temp1[i]); index = (byte)(bits[20 + i] ^ temp1[i]);
index = (byte)(_encryptTable1[index] ^ ~_encryptTable2[index] ^ cse); index = (byte)(_encryptTable1[index] ^ ~_encryptTable2[index] ^ cse);
@@ -499,7 +499,7 @@ public class CSS
temp2[4] ^= temp2[0]; temp2[4] ^= temp2[0];
term = 0; term = 0;
for(var i = 5; --i >= 0; term = temp2[i]) for(int i = 5; --i >= 0; term = temp2[i])
{ {
index = (byte)(bits[15 + i] ^ temp2[i]); index = (byte)(bits[15 + i] ^ temp2[i]);
index = (byte)(_encryptTable1[index] ^ ~_encryptTable2[index] ^ cse); index = (byte)(_encryptTable1[index] ^ ~_encryptTable2[index] ^ cse);
@@ -511,7 +511,7 @@ public class CSS
temp1[4] ^= temp1[0]; temp1[4] ^= temp1[0];
term = 0; term = 0;
for(var i = 5; --i >= 0; term = temp1[i]) for(int i = 5; --i >= 0; term = temp1[i])
{ {
index = (byte)(bits[10 + i] ^ temp1[i]); index = (byte)(bits[10 + i] ^ temp1[i]);
index = (byte)(_encryptTable1[index] ^ ~_encryptTable2[index] ^ cse); index = (byte)(_encryptTable1[index] ^ ~_encryptTable2[index] ^ cse);
@@ -523,7 +523,7 @@ public class CSS
temp2[4] ^= temp2[0]; temp2[4] ^= temp2[0];
term = 0; term = 0;
for(var i = 5; --i >= 0; term = temp2[i]) for(int i = 5; --i >= 0; term = temp2[i])
{ {
index = (byte)(bits[5 + i] ^ temp2[i]); index = (byte)(bits[5 + i] ^ temp2[i]);
index = (byte)(_encryptTable1[index] ^ ~_encryptTable2[index] ^ cse); index = (byte)(_encryptTable1[index] ^ ~_encryptTable2[index] ^ cse);
@@ -534,7 +534,7 @@ public class CSS
temp1[4] ^= temp1[0]; temp1[4] ^= temp1[0];
term = 0; term = 0;
for(var i = 5; --i >= 0; term = temp1[i]) for(int i = 5; --i >= 0; term = temp1[i])
{ {
index = (byte)(bits[i] ^ temp1[i]); index = (byte)(bits[i] ^ temp1[i]);
index = (byte)(_encryptTable1[index] ^ ~_encryptTable2[index] ^ cse); index = (byte)(_encryptTable1[index] ^ ~_encryptTable2[index] ^ cse);
@@ -551,12 +551,13 @@ public class CSS
public static void DecryptKey(byte invert, byte[] cryptoKey, byte[] encryptedKey, out byte[] decryptedKey) public static void DecryptKey(byte invert, byte[] cryptoKey, byte[] encryptedKey, out byte[] decryptedKey)
{ {
decryptedKey = new byte[5]; decryptedKey = new byte[5];
var k = new byte[5]; byte[] k = new byte[5];
var lfsr1Lo = (uint)(cryptoKey[0] | 0x100); uint lfsr1Lo = (uint)(cryptoKey[0] | 0x100);
uint lfsr1Hi = cryptoKey[1]; uint lfsr1Hi = cryptoKey[1];
var lfsr0 = (uint)(((cryptoKey[4] << 17) | (cryptoKey[3] << 9) | (cryptoKey[2] << 1)) + 8 - (cryptoKey[2] & 7)); uint lfsr0 = (uint)(((cryptoKey[4] << 17) | (cryptoKey[3] << 9) | (cryptoKey[2] << 1)) + 8 -
(cryptoKey[2] & 7));
lfsr0 = (uint)((_cssTable4[lfsr0 & 0xff] << 24) | (_cssTable4[(lfsr0 >> 8) & 0xff] << 16) | lfsr0 = (uint)((_cssTable4[lfsr0 & 0xff] << 24) | (_cssTable4[(lfsr0 >> 8) & 0xff] << 16) |
(_cssTable4[(lfsr0 >> 16) & 0xff] << 8) | _cssTable4[(lfsr0 >> 24) & 0xff]); (_cssTable4[(lfsr0 >> 16) & 0xff] << 8) | _cssTable4[(lfsr0 >> 24) & 0xff]);
@@ -565,11 +566,11 @@ public class CSS
for(uint i = 0; i < 5; i++) for(uint i = 0; i < 5; i++)
{ {
var oLfsr1 = (byte)(_cssTable2[lfsr1Hi] ^ _cssTable3[lfsr1Lo]); byte oLfsr1 = (byte)(_cssTable2[lfsr1Hi] ^ _cssTable3[lfsr1Lo]);
lfsr1Hi = lfsr1Lo >> 1; lfsr1Hi = lfsr1Lo >> 1;
lfsr1Lo = ((lfsr1Lo & 1) << 8) ^ oLfsr1; lfsr1Lo = ((lfsr1Lo & 1) << 8) ^ oLfsr1;
oLfsr1 = _cssTable4[oLfsr1]; oLfsr1 = _cssTable4[oLfsr1];
var oLfsr0 = (byte)(((((((lfsr0 >> 8) ^ lfsr0) >> 1) ^ lfsr0) >> 3) ^ lfsr0) >> 7); byte oLfsr0 = (byte)(((((((lfsr0 >> 8) ^ lfsr0) >> 1) ^ lfsr0) >> 3) ^ lfsr0) >> 7);
lfsr0 = (lfsr0 >> 8) | ((uint)oLfsr0 << 24); lfsr0 = (lfsr0 >> 8) | ((uint)oLfsr0 << 24);
combined += (uint)((oLfsr0 ^ invert) + oLfsr1); combined += (uint)((oLfsr0 ^ invert) + oLfsr1);
k[i] = (byte)(combined & 0xff); k[i] = (byte)(combined & 0xff);
@@ -636,7 +637,7 @@ public class CSS
keyData.All(k => k == 0)) keyData.All(k => k == 0))
return sectorData; return sectorData;
var decryptedBuffer = new byte[sectorData.Length]; byte[] decryptedBuffer = new byte[sectorData.Length];
for(uint j = 0; j < blocks; j++) for(uint j = 0; j < blocks; j++)
{ {
@@ -659,11 +660,11 @@ public class CSS
uint lfsr1Lo = (uint)(currentKey[0] ^ currentSector[0x54]) | 0x100; uint lfsr1Lo = (uint)(currentKey[0] ^ currentSector[0x54]) | 0x100;
uint lfsr1Hi = (uint)currentKey[1] ^ currentSector[0x55]; uint lfsr1Hi = (uint)currentKey[1] ^ currentSector[0x55];
var lfsr0 = (uint)((currentKey[2] | (currentKey[3] << 8) | (currentKey[4] << 16)) ^ uint lfsr0 = (uint)((currentKey[2] | (currentKey[3] << 8) | (currentKey[4] << 16)) ^
(sectorData[0x56] | (sectorData[0x57] << 8) | (sectorData[0x58] << 16))); (sectorData[0x56] | (sectorData[0x57] << 8) | (sectorData[0x58] << 16)));
uint oLfsr1 = lfsr0 & 7; uint oLfsr1 = lfsr0 & 7;
lfsr0 = lfsr0 * 2 + 8 - oLfsr1; lfsr0 = (lfsr0 * 2) + 8 - oLfsr1;
uint combined = 0; uint combined = 0;
@@ -698,13 +699,13 @@ public class CSS
if(cmi.RegionInformation is 0xFF or 0x00) if(cmi.RegionInformation is 0xFF or 0x00)
return true; return true;
return (rpc.RegionMask & 0x01) == (cmi.RegionInformation & 0x01) && (rpc.RegionMask & 0x01) != 0x01 || return ((rpc.RegionMask & 0x01) == (cmi.RegionInformation & 0x01) && (rpc.RegionMask & 0x01) != 0x01) ||
(rpc.RegionMask & 0x02) == (cmi.RegionInformation & 0x02) && (rpc.RegionMask & 0x02) != 0x02 || ((rpc.RegionMask & 0x02) == (cmi.RegionInformation & 0x02) && (rpc.RegionMask & 0x02) != 0x02) ||
(rpc.RegionMask & 0x04) == (cmi.RegionInformation & 0x04) && (rpc.RegionMask & 0x04) != 0x04 || ((rpc.RegionMask & 0x04) == (cmi.RegionInformation & 0x04) && (rpc.RegionMask & 0x04) != 0x04) ||
(rpc.RegionMask & 0x08) == (cmi.RegionInformation & 0x08) && (rpc.RegionMask & 0x08) != 0x08 || ((rpc.RegionMask & 0x08) == (cmi.RegionInformation & 0x08) && (rpc.RegionMask & 0x08) != 0x08) ||
(rpc.RegionMask & 0x10) == (cmi.RegionInformation & 0x10) && (rpc.RegionMask & 0x10) != 0x10 || ((rpc.RegionMask & 0x10) == (cmi.RegionInformation & 0x10) && (rpc.RegionMask & 0x10) != 0x10) ||
(rpc.RegionMask & 0x20) == (cmi.RegionInformation & 0x20) && (rpc.RegionMask & 0x20) != 0x20 || ((rpc.RegionMask & 0x20) == (cmi.RegionInformation & 0x20) && (rpc.RegionMask & 0x20) != 0x20) ||
(rpc.RegionMask & 0x40) == (cmi.RegionInformation & 0x40) && (rpc.RegionMask & 0x40) != 0x40 || ((rpc.RegionMask & 0x40) == (cmi.RegionInformation & 0x40) && (rpc.RegionMask & 0x40) != 0x40) ||
(rpc.RegionMask & 0x80) == (cmi.RegionInformation & 0x80) && (rpc.RegionMask & 0x80) != 0x80; ((rpc.RegionMask & 0x80) == (cmi.RegionInformation & 0x80) && (rpc.RegionMask & 0x80) != 0x80);
} }
} }

View File

@@ -34,14 +34,14 @@
// Copyright © 2020-2022 Rebecca Wallander // Copyright © 2020-2022 Rebecca Wallander
// ****************************************************************************/ // ****************************************************************************/
namespace Aaru.Decryption.DVD;
using System; using System;
using System.Linq; using System.Linq;
using Aaru.Console; using Aaru.Console;
using Aaru.Decoders.DVD; using Aaru.Decoders.DVD;
using Aaru.Devices; using Aaru.Devices;
namespace Aaru.Decryption.DVD;
public sealed class Dump public sealed class Dump
{ {
const byte KEY_SIZE = 5; const byte KEY_SIZE = 5;
@@ -69,7 +69,7 @@ public sealed class Dump
out double duration) out double duration)
{ {
senseBuffer = new byte[64]; senseBuffer = new byte[64];
var cdb = new byte[12]; byte[] cdb = new byte[12];
buffer = new byte[8]; buffer = new byte[8];
cdb[0] = (byte)ScsiCommands.ReportKey; cdb[0] = (byte)ScsiCommands.ReportKey;
@@ -97,7 +97,7 @@ public sealed class Dump
out double duration) out double duration)
{ {
senseBuffer = new byte[64]; senseBuffer = new byte[64];
var cdb = new byte[12]; byte[] cdb = new byte[12];
buffer = new byte[8]; buffer = new byte[8];
cdb[0] = (byte)ScsiCommands.ReportKey; cdb[0] = (byte)ScsiCommands.ReportKey;
@@ -125,7 +125,7 @@ public sealed class Dump
out double duration) out double duration)
{ {
senseBuffer = new byte[64]; senseBuffer = new byte[64];
var cdb = new byte[12]; byte[] cdb = new byte[12];
buffer = Array.Empty<byte>(); buffer = Array.Empty<byte>();
cdb[0] = (byte)ScsiCommands.ReportKey; cdb[0] = (byte)ScsiCommands.ReportKey;
@@ -154,7 +154,7 @@ public sealed class Dump
out double duration) out double duration)
{ {
senseBuffer = new byte[64]; senseBuffer = new byte[64];
var cdb = new byte[12]; byte[] cdb = new byte[12];
buffer = new byte[8]; buffer = new byte[8];
cdb[0] = (byte)ScsiCommands.ReportKey; cdb[0] = (byte)ScsiCommands.ReportKey;
@@ -183,7 +183,7 @@ public sealed class Dump
out double duration) out double duration)
{ {
senseBuffer = new byte[64]; senseBuffer = new byte[64];
var cdb = new byte[12]; byte[] cdb = new byte[12];
buffer = new byte[12]; buffer = new byte[12];
cdb[0] = (byte)ScsiCommands.ReportKey; cdb[0] = (byte)ScsiCommands.ReportKey;
@@ -211,7 +211,7 @@ public sealed class Dump
out double duration) out double duration)
{ {
senseBuffer = new byte[64]; senseBuffer = new byte[64];
var cdb = new byte[12]; byte[] cdb = new byte[12];
buffer = new byte[16]; buffer = new byte[16];
cdb[0] = (byte)ScsiCommands.ReportKey; cdb[0] = (byte)ScsiCommands.ReportKey;
@@ -241,7 +241,7 @@ public sealed class Dump
uint timeout, out double duration) uint timeout, out double duration)
{ {
senseBuffer = new byte[64]; senseBuffer = new byte[64];
var cdb = new byte[12]; byte[] cdb = new byte[12];
buffer = new byte[16]; buffer = new byte[16];
cdb[0] = (byte)ScsiCommands.SendKey; cdb[0] = (byte)ScsiCommands.SendKey;
@@ -284,7 +284,7 @@ public sealed class Dump
out double duration) out double duration)
{ {
senseBuffer = new byte[64]; senseBuffer = new byte[64];
var cdb = new byte[12]; byte[] cdb = new byte[12];
buffer = new byte[12]; buffer = new byte[12];
cdb[0] = (byte)ScsiCommands.SendKey; cdb[0] = (byte)ScsiCommands.SendKey;
@@ -319,7 +319,7 @@ public sealed class Dump
public bool ReadDiscKey(out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration) public bool ReadDiscKey(out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration)
{ {
senseBuffer = new byte[64]; senseBuffer = new byte[64];
var cdb = new byte[12]; byte[] cdb = new byte[12];
buffer = new byte[2052]; buffer = new byte[2052];
cdb[0] = (byte)ScsiCommands.ReadDiscStructure; cdb[0] = (byte)ScsiCommands.ReadDiscStructure;
@@ -349,10 +349,10 @@ public sealed class Dump
buffer = Array.Empty<byte>(); buffer = Array.Empty<byte>();
senseBuffer = new byte[64]; senseBuffer = new byte[64];
var sense = false; bool sense = false;
var challenge = new byte[CHALLENGE_SIZE]; byte[] challenge = new byte[CHALLENGE_SIZE];
var key1 = new byte[KEY_SIZE]; byte[] key1 = new byte[KEY_SIZE];
byte variant = 0; byte variant = 0;
for(byte i = 0; i < 4; i++) for(byte i = 0; i < 4; i++)
{ {
@@ -460,7 +460,7 @@ public sealed class Dump
BusKey = buffer; BusKey = buffer;
senseBuffer = new byte[64]; senseBuffer = new byte[64];
var cdb = new byte[12]; byte[] cdb = new byte[12];
buffer = new byte[12]; buffer = new byte[12];
cdb[0] = (byte)ScsiCommands.ReportKey; cdb[0] = (byte)ScsiCommands.ReportKey;

View File

@@ -2,13 +2,10 @@ namespace Aaru.Decryption;
public enum DvdCssKeyClass : byte public enum DvdCssKeyClass : byte
{ {
DvdCssCppmOrCprm = 0, DvdCssCppmOrCprm = 0, RewritableSecurityServicesA = 1
RewritableSecurityServicesA = 1
} }
public enum DvdCssKeyType public enum DvdCssKeyType
{ {
Key1 = 0, Key1 = 0, Key2 = 1, BusKey = 2
Key2 = 1,
BusKey = 2
} }