mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Move decryption option to Settings + formatting fixes
This commit is contained in:
@@ -96,9 +96,8 @@ namespace Aaru.Core.Devices.Dumping
|
||||
int _speed;
|
||||
int _speedMultiplier;
|
||||
bool _supportsPlextorD8;
|
||||
bool _decryption;
|
||||
bool _storeEncrypted;
|
||||
bool _titleKeys;
|
||||
readonly bool _storeEncrypted;
|
||||
readonly bool _titleKeys;
|
||||
|
||||
/// <summary>Initializes dumpers</summary>
|
||||
/// <param name="doResume">Should resume?</param>
|
||||
@@ -135,12 +134,11 @@ namespace Aaru.Core.Devices.Dumping
|
||||
/// <param name="generateSubchannels">Generate missing subchannels</param>
|
||||
/// <param name="maximumReadable">Number of maximum blocks to be read at once (can be overriden by database)</param>
|
||||
/// <param name="useBufferedReads">
|
||||
/// <param name="decryption">If decryption should be used.</param>
|
||||
/// <param name="storeEncrypted">Store encrypted data as is</param>
|
||||
/// <param name="titleKeys">Dump DVD CSS title keys</param>
|
||||
/// If MMC/SD does not support CMD23, use OS buffered reads instead of multiple single block
|
||||
/// commands
|
||||
/// </param>
|
||||
/// <param name="storeEncrypted">Store encrypted data as is</param>
|
||||
/// <param name="titleKeys">Dump DVD CSS title keys</param>
|
||||
public Dump(bool doResume, Device dev, string devicePath, IWritableImage outputPlugin, ushort retryPasses,
|
||||
bool force, bool dumpRaw, bool persistent, bool stopOnError, Resume resume, DumpLog dumpLog,
|
||||
Encoding encoding, string outputPrefix, string outputPath, Dictionary<string, string> formatOptions,
|
||||
@@ -148,7 +146,7 @@ namespace Aaru.Core.Devices.Dumping
|
||||
bool fixOffset, bool debug, DumpSubchannel subchannel, int speed, bool @private,
|
||||
bool fixSubchannelPosition, bool retrySubchannel, bool fixSubchannel, bool fixSubchannelCrc,
|
||||
bool skipCdireadyHole, ErrorLog errorLog, bool generateSubchannels, uint maximumReadable,
|
||||
bool useBufferedReads, bool decryption, bool storeEncrypted, bool titleKeys)
|
||||
bool useBufferedReads, bool storeEncrypted, bool titleKeys)
|
||||
{
|
||||
_doResume = doResume;
|
||||
_dev = dev;
|
||||
@@ -186,7 +184,6 @@ namespace Aaru.Core.Devices.Dumping
|
||||
_errorLog = errorLog;
|
||||
_generateSubchannels = generateSubchannels;
|
||||
_useBufferedReads = useBufferedReads;
|
||||
_decryption = decryption;
|
||||
_storeEncrypted = storeEncrypted;
|
||||
_titleKeys = titleKeys;
|
||||
}
|
||||
|
||||
@@ -514,16 +514,12 @@ namespace Aaru.Core.Devices.Dumping
|
||||
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)
|
||||
{
|
||||
if(!Settings.Settings.Current.EnableDecryption)
|
||||
UpdateStatus?.Invoke("Drive reports the disc uses copy protection. " +
|
||||
"The dump might be incorrect unless decryption is enabled.");
|
||||
}
|
||||
"The dump will be incorrect unless decryption is enabled.");
|
||||
else
|
||||
{
|
||||
if(cmi!.Value.CopyrightType == CopyrightType.CSS)
|
||||
@@ -568,15 +564,9 @@ namespace Aaru.Core.Devices.Dumping
|
||||
|
||||
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");
|
||||
}
|
||||
UpdateStatus?.Invoke(CSS.CheckRegion(rpc.Value, cmi.Value)
|
||||
? "Disc and drive regions match."
|
||||
: "Disc and drive regions do not match. The dump will be incorrect");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -596,7 +586,6 @@ namespace Aaru.Core.Devices.Dumping
|
||||
mediaTags.Add(MediaTagType.DVD_DiscKey_Decrypted, discKey);
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateStatus?.Invoke("Decryption of disc key failed.");
|
||||
}
|
||||
}
|
||||
@@ -604,12 +593,11 @@ namespace Aaru.Core.Devices.Dumping
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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.");
|
||||
"This is not yet supported and the dump will be incorrect.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,22 +105,18 @@ namespace Aaru.Core.Devices.Dumping
|
||||
if(!sense &&
|
||||
!_dev.Error)
|
||||
{
|
||||
if(_decryption)
|
||||
if(Settings.Settings.Current.EnableDecryption)
|
||||
{
|
||||
if(_titleKeys && discKey != null)
|
||||
{
|
||||
for(ulong j = 0; j < blocksToRead; j++)
|
||||
{
|
||||
if(_aborted)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if(!_resume.MissingTitleKeys.Contains(i + j))
|
||||
{
|
||||
// Key is already dumped.
|
||||
continue;
|
||||
}
|
||||
|
||||
byte[] tmpBuf;
|
||||
|
||||
@@ -133,15 +129,14 @@ namespace Aaru.Core.Devices.Dumping
|
||||
CSS_CPRM.TitleKey? titleKey = CSS.DecodeTitleKey(tmpBuf, dvdDecrypt.BusKey);
|
||||
|
||||
if(titleKey.HasValue)
|
||||
{
|
||||
_outputPlugin.WriteSectorTag(new[]
|
||||
{
|
||||
titleKey.Value.CMI
|
||||
}, i + j, SectorTagType.DvdCmi);
|
||||
}
|
||||
else
|
||||
continue;
|
||||
|
||||
// If the CMI bit is 1, the sector is using copy protection, else it is not
|
||||
if((titleKey.Value.CMI & 0x80) >> 7 == 0)
|
||||
{
|
||||
// The CMI indicates this sector is not encrypted.
|
||||
@@ -160,10 +155,10 @@ namespace Aaru.Core.Devices.Dumping
|
||||
continue;
|
||||
}
|
||||
|
||||
if(titleKey.Value.Key.All(k => k == 0))
|
||||
{
|
||||
// According to libdvdcss, if the key is all zeroes, the sector is actually
|
||||
// not encrypted even if the CMI says it is.
|
||||
if(titleKey.Value.Key.All(k => k == 0))
|
||||
{
|
||||
_outputPlugin.WriteSectorTag(new byte[]
|
||||
{
|
||||
0, 0, 0, 0, 0
|
||||
@@ -189,7 +184,6 @@ namespace Aaru.Core.Devices.Dumping
|
||||
}
|
||||
|
||||
if(!_storeEncrypted && _titleKeys)
|
||||
{
|
||||
// Todo: Flag in the _outputPlugin that a sector has been decrypted
|
||||
buffer = CSS.DecryptSector(buffer,
|
||||
_outputPlugin.ReadSectorsTag(i, blocksToRead, SectorTagType.DvdCmi),
|
||||
@@ -197,7 +191,6 @@ namespace Aaru.Core.Devices.Dumping
|
||||
SectorTagType.DvdTitleKeyDecrypted),
|
||||
blocksToRead, blockSize);
|
||||
}
|
||||
}
|
||||
|
||||
mhddLog.Write(i, cmdDuration);
|
||||
ibgLog.Write(i, currentSpeed * 1024);
|
||||
|
||||
@@ -668,7 +668,7 @@ namespace Aaru.Core.Devices.Dumping
|
||||
|
||||
bool newTrim = false;
|
||||
|
||||
if(_decryption && _titleKeys)
|
||||
if(Settings.Settings.Current.EnableDecryption && _titleKeys)
|
||||
{
|
||||
UpdateStatus?.Invoke("Title keys dumping is enabled. This will be very slow.");
|
||||
_resume.MissingTitleKeys ??= new List<ulong>(Enumerable.Range(0, (int)blocks).Select(n => (ulong)n));
|
||||
@@ -681,7 +681,9 @@ namespace Aaru.Core.Devices.Dumping
|
||||
else
|
||||
ReadSbcData(blocks, blocksToRead, blockSize, currentTry, extents, ref currentSpeed, ref minSpeed,
|
||||
ref maxSpeed, ref totalDuration, scsiReader, mhddLog, ibgLog, ref imageWriteDuration,
|
||||
ref newTrim, ref dvdDecrypt, mediaTags[MediaTagType.DVD_DiscKey_Decrypted]);
|
||||
ref newTrim, ref dvdDecrypt,
|
||||
mediaTags.ContainsKey(MediaTagType.DVD_DiscKey_Decrypted)
|
||||
? mediaTags[MediaTagType.DVD_DiscKey_Decrypted] : null);
|
||||
|
||||
end = DateTime.UtcNow;
|
||||
mhddLog.Close();
|
||||
@@ -735,7 +737,7 @@ namespace Aaru.Core.Devices.Dumping
|
||||
if(_resume.MissingTitleKeys.Count > 0 &&
|
||||
!_aborted &&
|
||||
_retryPasses > 0 &&
|
||||
_decryption &&
|
||||
Settings.Settings.Current.EnableDecryption &&
|
||||
_titleKeys)
|
||||
RetryTitleKeys(dvdDecrypt, mediaTags[MediaTagType.DVD_DiscKey_Decrypted], ref totalDuration);
|
||||
#endregion Error handling
|
||||
|
||||
@@ -359,6 +359,8 @@ namespace Aaru.Core.Devices.Dumping
|
||||
titleKey.Value.CMI
|
||||
}, missingKey, SectorTagType.DvdCmi);
|
||||
|
||||
// If the CMI bit is 1, the sector is using copy protection, else it is not
|
||||
// If the decoded title key is zeroed, there should be no copy protection
|
||||
if((titleKey.Value.CMI & 0x80) >> 7 == 0 ||
|
||||
titleKey.Value.Key.All(k => k == 0))
|
||||
{
|
||||
|
||||
@@ -810,7 +810,7 @@ namespace Aaru.Gui.ViewModels.Windows
|
||||
Persistent, StopOnError, _resume, dumpLog, encoding, _outputPrefix, Destination,
|
||||
parsedOptions, _sidecar, (uint)Skipped, ExistingMetadata == false, Trim == false,
|
||||
Track1Pregap, true, false, DumpSubchannel.Any, 0, false, false, false, false, false,
|
||||
true, errorLog, false, 64, true, false, true, false);
|
||||
true, errorLog, false, 64, true, true, false);
|
||||
|
||||
new Thread(DoWork).Start();
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2021 Natalia Portillo
|
||||
// Copyright © 2021 Rebecca Wallander
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
@@ -55,6 +56,8 @@ namespace Aaru.Settings
|
||||
public bool SaveReportsGlobally;
|
||||
/// <summary>If set to <c>true</c>, reports will be sent to Aaru.Server</summary>
|
||||
public bool ShareReports;
|
||||
/// <summary>If set to <c>true</c>, enables the ability to decrypt encrypted data</summary>
|
||||
public bool EnableDecryption;
|
||||
/// <summary>Statistics</summary>
|
||||
public StatsSettings Stats;
|
||||
}
|
||||
@@ -299,6 +302,9 @@ namespace Aaru.Settings
|
||||
Current.ShareReports = parsedPreferences.TryGetValue("ShareReports", out obj) &&
|
||||
((NSNumber)obj).ToBool();
|
||||
|
||||
Current.EnableDecryption = parsedPreferences.TryGetValue("EnableDecryption", out obj) &&
|
||||
((NSNumber)obj).ToBool();
|
||||
|
||||
if(parsedPreferences.TryGetValue("Stats", out obj))
|
||||
{
|
||||
var stats = (NSDictionary)obj;
|
||||
@@ -375,6 +381,7 @@ namespace Aaru.Settings
|
||||
Current.SaveReportsGlobally = Convert.ToBoolean(dicKey.GetValue("SaveReportsGlobally"));
|
||||
Current.ShareReports = Convert.ToBoolean(dicKey.GetValue("ShareReports"));
|
||||
Current.GdprCompliance = Convert.ToUInt64(dicKey.GetValue("GdprCompliance"));
|
||||
Current.EnableDecryption = Convert.ToBoolean(dicKey.GetValue("EnableDecryption"));
|
||||
|
||||
stats = Convert.ToBoolean(dicKey.GetValue("Statistics"));
|
||||
|
||||
@@ -411,6 +418,7 @@ namespace Aaru.Settings
|
||||
Current.SaveReportsGlobally = Convert.ToBoolean(key.GetValue("SaveReportsGlobally"));
|
||||
Current.ShareReports = Convert.ToBoolean(key.GetValue("ShareReports"));
|
||||
Current.GdprCompliance = Convert.ToUInt64(key.GetValue("GdprCompliance"));
|
||||
Current.EnableDecryption = Convert.ToBoolean(key.GetValue("EnableDecryption"));
|
||||
|
||||
stats = Convert.ToBoolean(key.GetValue("Statistics"));
|
||||
|
||||
@@ -509,6 +517,9 @@ namespace Aaru.Settings
|
||||
},
|
||||
{
|
||||
"GdprCompliance", Current.GdprCompliance
|
||||
},
|
||||
{
|
||||
"EnableDecryption", Current.EnableDecryption
|
||||
}
|
||||
};
|
||||
|
||||
@@ -582,6 +593,7 @@ namespace Aaru.Settings
|
||||
key.SetValue("SaveReportsGlobally", Current.SaveReportsGlobally);
|
||||
key.SetValue("ShareReports", Current.ShareReports);
|
||||
key.SetValue("GdprCompliance", Current.GdprCompliance);
|
||||
key.SetValue("EnableDecryption", Current.EnableDecryption);
|
||||
|
||||
if(Current.Stats != null)
|
||||
{
|
||||
@@ -654,6 +666,7 @@ namespace Aaru.Settings
|
||||
SaveReportsGlobally = true,
|
||||
ShareReports = true,
|
||||
GdprCompliance = 0,
|
||||
EnableDecryption = true,
|
||||
Stats = new StatsSettings
|
||||
{
|
||||
CommandStats = true,
|
||||
|
||||
@@ -317,7 +317,7 @@ namespace Aaru.Commands.Media
|
||||
uint skip, byte speed, bool stopOnError, string format, string subchannel,
|
||||
bool @private, bool fixSubchannelPosition, bool retrySubchannel, bool fixSubchannel,
|
||||
bool fixSubchannelCrc, bool generateSubchannels, bool skipCdiReadyHole, bool eject,
|
||||
uint maxBlocks, bool useBufferedReads, bool decryption, bool storeEncrypted,
|
||||
uint maxBlocks, bool useBufferedReads, bool storeEncrypted,
|
||||
bool titleKeys)
|
||||
{
|
||||
MainClass.PrintCopyright();
|
||||
@@ -658,7 +658,7 @@ namespace Aaru.Commands.Media
|
||||
firstPregap, fixOffset, debug, wantedSubchannel, speed, @private,
|
||||
fixSubchannelPosition, retrySubchannel, fixSubchannel, fixSubchannelCrc,
|
||||
skipCdiReadyHole, errorLog, generateSubchannels, maxBlocks, useBufferedReads,
|
||||
decryption, storeEncrypted, titleKeys);
|
||||
storeEncrypted, titleKeys);
|
||||
|
||||
dumper.UpdateStatus += Progress.UpdateStatus;
|
||||
dumper.ErrorMessage += Progress.ErrorMessage;
|
||||
|
||||
@@ -175,13 +175,6 @@ namespace Aaru
|
||||
{
|
||||
Argument = new Argument<bool>(() => false)
|
||||
},
|
||||
new Option(new[]
|
||||
{
|
||||
"--decryption"
|
||||
}, "Enables the ability to decrypt encrypted data.")
|
||||
{
|
||||
Argument = new Argument<bool>(() => true)
|
||||
}
|
||||
};
|
||||
|
||||
rootCommand.Description =
|
||||
|
||||
Reference in New Issue
Block a user