mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-09-23 23:45:14 +00:00
fix tests
This commit is contained in:
@@ -130,12 +130,12 @@ public class SevenZipArchive : AbstractArchive<SevenZipArchiveEntry, SevenZipVol
|
||||
IEnumerable<SevenZipVolume> volumes
|
||||
)
|
||||
{
|
||||
var stream = volumes.Single().Stream;
|
||||
LoadFactory(stream);
|
||||
if (database is null)
|
||||
{
|
||||
return Enumerable.Empty<SevenZipArchiveEntry>();
|
||||
}
|
||||
var stream = volumes.Single().Stream;
|
||||
LoadFactory(stream);
|
||||
var entries = new SevenZipArchiveEntry[database._files.Count];
|
||||
for (var i = 0; i < database._files.Count; i++)
|
||||
{
|
||||
@@ -260,6 +260,6 @@ public class SevenZipArchive : AbstractArchive<SevenZipArchiveEntry, SevenZipVol
|
||||
|
||||
public PasswordProvider(string? password) => _password = password;
|
||||
|
||||
public string CryptoGetTextPassword() => _password.NotNull();
|
||||
public string? CryptoGetTextPassword() => _password;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,8 @@ internal sealed class AesDecoderStream : DecoderStream2
|
||||
|
||||
public AesDecoderStream(Stream input, byte[] info, IPasswordProvider pass, long limit)
|
||||
{
|
||||
if (pass.CryptoGetTextPassword() == null)
|
||||
var password = pass.CryptoGetTextPassword();
|
||||
if (password == null)
|
||||
{
|
||||
throw new SharpCompress.Common.CryptographicException(
|
||||
"Encrypted 7Zip archive has no password specified."
|
||||
@@ -37,8 +38,8 @@ internal sealed class AesDecoderStream : DecoderStream2
|
||||
|
||||
Init(info, out var numCyclesPower, out var salt, out var seed);
|
||||
|
||||
var password = Encoding.Unicode.GetBytes(pass.CryptoGetTextPassword());
|
||||
var key = InitKey(numCyclesPower, salt, password);
|
||||
var passwordBytes = Encoding.Unicode.GetBytes(password);
|
||||
var key = InitKey(numCyclesPower, salt, passwordBytes);
|
||||
if (key == null)
|
||||
{
|
||||
throw new InvalidOperationException("Initialized with null key");
|
||||
|
||||
@@ -2,5 +2,5 @@ namespace SharpCompress.Compressors.LZMA.Utilites;
|
||||
|
||||
internal interface IPasswordProvider
|
||||
{
|
||||
string CryptoGetTextPassword();
|
||||
string? CryptoGetTextPassword();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user