diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml
index d5630331f..463b5d6fb 100644
--- a/.github/workflows/build-test.yml
+++ b/.github/workflows/build-test.yml
@@ -18,11 +18,8 @@ jobs:
strategy:
fail-fast: false
matrix:
- os: [ubuntu-latest, windows-2019, macos-latest]
- target: [netstandard2.0, netstandard2.1]
- include:
- - os: windows-2019
- target: net45
+ os: [ubuntu-latest, windows-latest, macos-latest]
+ target: [netstandard2.0, netstandard2.1, net6.0]
env:
LIB_PROJ: src/ICSharpCode.SharpZipLib/ICSharpCode.SharpZipLib.csproj
steps:
@@ -31,10 +28,10 @@ jobs:
ref: ${{ github.events.inputs.tag }}
fetch-depth: 0
- - name: Setup .NET Core
+ - name: Setup .NET
uses: actions/setup-dotnet@v1
with:
- dotnet-version: '3.1.x'
+ dotnet-version: '6.0.x'
- name: Show .NET info
run: dotnet --info
@@ -52,17 +49,17 @@ jobs:
matrix:
# Windows testing is combined with code coverage
os: [ubuntu, macos]
- target: [netcoreapp3.1]
+ target: [net6.0]
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup .NET Core
- if: matrix.target == 'netcoreapp3.1'
+ if: matrix.target == 'net6.0'
uses: actions/setup-dotnet@v1
with:
- dotnet-version: '3.1.x'
+ dotnet-version: '6.0.x'
- name: Restore test dependencies
run: dotnet restore
@@ -89,7 +86,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
- dotnet-version: '3.1.x'
+ dotnet-version: '6.0.x'
# NOTE: This is the temporary fix for https://github.com/actions/virtual-environments/issues/1090
- name: Cleanup before restore
@@ -120,7 +117,7 @@ jobs:
Pack:
needs: [Build, Test, CodeCov]
- runs-on: windows-2019
+ runs-on: windows-latest
env:
PKG_SUFFIX: ''
PKG_PROJ: src/ICSharpCode.SharpZipLib/ICSharpCode.SharpZipLib.csproj
@@ -135,14 +132,14 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
- dotnet-version: '5.0.x'
+ dotnet-version: '6.0.x'
- name: Build library for .NET Standard 2.0
run: dotnet build -c Release -f netstandard2.0 ${{ env.PKG_PROPS }} ${{ env.PKG_PROJ }}
- name: Build library for .NET Standard 2.1
run: dotnet build -c Release -f netstandard2.1 ${{ env.PKG_PROPS }} ${{ env.PKG_PROJ }}
- - name: Build library for .NET Framework 4.5
- run: dotnet build -c Release -f net45 ${{ env.PKG_PROPS }} ${{ env.PKG_PROJ }}
+ - name: Build library for .NET 6.0
+ run: dotnet build -c Release -f net6.0 ${{ env.PKG_PROPS }} ${{ env.PKG_PROJ }}
- name: Add PR suffix to package
if: ${{ github.event_name == 'pull_request' }}
diff --git a/benchmark/ICSharpCode.SharpZipLib.Benchmark/ICSharpCode.SharpZipLib.Benchmark.csproj b/benchmark/ICSharpCode.SharpZipLib.Benchmark/ICSharpCode.SharpZipLib.Benchmark.csproj
index 81a8ad598..7688d0ff2 100644
--- a/benchmark/ICSharpCode.SharpZipLib.Benchmark/ICSharpCode.SharpZipLib.Benchmark.csproj
+++ b/benchmark/ICSharpCode.SharpZipLib.Benchmark/ICSharpCode.SharpZipLib.Benchmark.csproj
@@ -2,7 +2,7 @@
Exe
- netcoreapp2.1;netcoreapp3.1;net461
+ net6.0;netcoreapp3.1;net462
diff --git a/src/ICSharpCode.SharpZipLib/Encryption/ZipAESStream.cs b/src/ICSharpCode.SharpZipLib/Encryption/ZipAESStream.cs
index 80ce0b4ab..346b5484b 100644
--- a/src/ICSharpCode.SharpZipLib/Encryption/ZipAESStream.cs
+++ b/src/ICSharpCode.SharpZipLib/Encryption/ZipAESStream.cs
@@ -40,7 +40,7 @@ public ZipAESStream(Stream stream, ZipAESTransform transform, CryptoStreamMode m
}
// The final n bytes of the AES stream contain the Auth Code.
- private const int AUTH_CODE_LENGTH = 10;
+ public const int AUTH_CODE_LENGTH = 10;
// Blocksize is always 16 here, even for AES-256 which has transform.InputBlockSize of 32.
private const int CRYPTO_BLOCK_SIZE = 16;
diff --git a/src/ICSharpCode.SharpZipLib/Encryption/ZipAESTransform.cs b/src/ICSharpCode.SharpZipLib/Encryption/ZipAESTransform.cs
index 6c84be691..32c7b8156 100644
--- a/src/ICSharpCode.SharpZipLib/Encryption/ZipAESTransform.cs
+++ b/src/ICSharpCode.SharpZipLib/Encryption/ZipAESTransform.cs
@@ -1,6 +1,5 @@
using System;
using System.Security.Cryptography;
-using ICSharpCode.SharpZipLib.Core;
namespace ICSharpCode.SharpZipLib.Encryption
{
@@ -9,31 +8,6 @@ namespace ICSharpCode.SharpZipLib.Encryption
///
internal class ZipAESTransform : ICryptoTransform
{
-#if NET45
- class IncrementalHash : HMACSHA1
- {
- bool _finalised;
- public IncrementalHash(byte[] key) : base(key) { }
- public static IncrementalHash CreateHMAC(string n, byte[] key) => new IncrementalHash(key);
- public void AppendData(byte[] buffer, int offset, int count) => TransformBlock(buffer, offset, count, buffer, offset);
- public byte[] GetHashAndReset()
- {
- if (!_finalised)
- {
- byte[] dummy = new byte[0];
- TransformFinalBlock(dummy, 0, 0);
- _finalised = true;
- }
- return Hash;
- }
- }
-
- static class HashAlgorithmName
- {
- public static string SHA1 = null;
- }
-#endif
-
private const int PWD_VER_LENGTH = 2;
// WinZip use iteration count of 1000 for PBKDF2 key generation
@@ -137,91 +111,67 @@ public int TransformBlock(byte[] inputBuffer, int inputOffset, int inputCount, b
///
/// Returns the 2 byte password verifier
///
- public byte[] PwdVerifier
- {
- get
- {
- return _pwdVerifier;
- }
- }
+ public byte[] PwdVerifier => _pwdVerifier;
///
/// Returns the 10 byte AUTH CODE to be checked or appended immediately following the AES data stream.
///
- public byte[] GetAuthCode()
- {
- if (_authCode == null)
- {
- _authCode = _hmacsha1.GetHashAndReset();
- }
- return _authCode;
- }
+ public byte[] GetAuthCode() => _authCode ?? (_authCode = _hmacsha1.GetHashAndReset());
#region ICryptoTransform Members
///
- /// Not implemented.
+ /// Transform final block and read auth code
///
public byte[] TransformFinalBlock(byte[] inputBuffer, int inputOffset, int inputCount)
{
- if (inputCount > 0)
- {
- throw new NotImplementedException("TransformFinalBlock is not implemented and inputCount is greater than 0");
+ var buffer = Array.Empty();
+
+ // FIXME: When used together with `ZipAESStream`, the final block handling is done inside of it instead
+ // This should not be necessary anymore, and the entire `ZipAESStream` class should be replaced with a plain `CryptoStream`
+ if (inputCount != 0) {
+ if (inputCount > ZipAESStream.AUTH_CODE_LENGTH)
+ {
+ // At least one byte of data is preceeding the auth code
+ int finalBlock = inputCount - ZipAESStream.AUTH_CODE_LENGTH;
+ buffer = new byte[finalBlock];
+ TransformBlock(inputBuffer, inputOffset, finalBlock, buffer, 0);
+ }
+ else if (inputCount < ZipAESStream.AUTH_CODE_LENGTH)
+ throw new Zip.ZipException("Auth code missing from input stream");
+
+ // Read the authcode from the last 10 bytes
+ _authCode = _hmacsha1.GetHashAndReset();
}
- return Empty.Array();
+
+
+ return buffer;
}
///
/// Gets the size of the input data blocks in bytes.
///
- public int InputBlockSize
- {
- get
- {
- return _blockSize;
- }
- }
+ public int InputBlockSize => _blockSize;
///
/// Gets the size of the output data blocks in bytes.
///
- public int OutputBlockSize
- {
- get
- {
- return _blockSize;
- }
- }
+ public int OutputBlockSize => _blockSize;
///
/// Gets a value indicating whether multiple blocks can be transformed.
///
- public bool CanTransformMultipleBlocks
- {
- get
- {
- return true;
- }
- }
+ public bool CanTransformMultipleBlocks => true;
///
/// Gets a value indicating whether the current transform can be reused.
///
- public bool CanReuseTransform
- {
- get
- {
- return true;
- }
- }
+ public bool CanReuseTransform => true;
///
/// Cleanup internal state.
///
- public void Dispose()
- {
- _encryptor.Dispose();
- }
+ public void Dispose() => _encryptor.Dispose();
#endregion ICryptoTransform Members
}
diff --git a/src/ICSharpCode.SharpZipLib/ICSharpCode.SharpZipLib.csproj b/src/ICSharpCode.SharpZipLib/ICSharpCode.SharpZipLib.csproj
index e736ad1cc..0dfc04003 100644
--- a/src/ICSharpCode.SharpZipLib/ICSharpCode.SharpZipLib.csproj
+++ b/src/ICSharpCode.SharpZipLib/ICSharpCode.SharpZipLib.csproj
@@ -1,8 +1,10 @@
- netstandard2.0;netstandard2.1;net45
- True
+ netstandard2.0;netstandard2.1;net6.0
+ true
+ true
+ true
../../assets/ICSharpCode.SharpZipLib.snk
true
true
@@ -11,8 +13,8 @@
- 1.3.3
- $(Version).11
+ 1.4.0
+ $(Version).12
$(FileVersion)
SharpZipLib
ICSharpCode
@@ -22,11 +24,11 @@
http://icsharpcode.github.io/SharpZipLib/
images/sharpziplib-nuget-256x256.png
https://github.com/icsharpcode/SharpZipLib
- Copyright © 2000-2021 SharpZipLib Contributors
+ Copyright © 2000-2022 SharpZipLib Contributors
Compression Library Zip GZip BZip2 LZW Tar
en-US
-Please see https://github.com/icsharpcode/SharpZipLib/wiki/Release-1.3.3 for more information.
+Please see https://github.com/icsharpcode/SharpZipLib/wiki/Release-1.4.0 for more information.
https://github.com/icsharpcode/SharpZipLib
@@ -34,11 +36,6 @@ Please see https://github.com/icsharpcode/SharpZipLib/wiki/Release-1.3.3 for mor
-
-
-
-
-
diff --git a/test/ICSharpCode.SharpZipLib.Tests/ICSharpCode.SharpZipLib.Tests.csproj b/test/ICSharpCode.SharpZipLib.Tests/ICSharpCode.SharpZipLib.Tests.csproj
index 4a46e84f2..73ef2eb0d 100644
--- a/test/ICSharpCode.SharpZipLib.Tests/ICSharpCode.SharpZipLib.Tests.csproj
+++ b/test/ICSharpCode.SharpZipLib.Tests/ICSharpCode.SharpZipLib.Tests.csproj
@@ -2,7 +2,7 @@
Library
- netcoreapp3.1;net46
+ net6.0;net462
true
@@ -13,9 +13,9 @@
-
-
-
+
+
+