Skip to content

Commit 1964c55

Browse files
author
Remo Gloor
committed
Add missing documentation for DecryptionLimit
1 parent 9245118 commit 1964c55

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/ICSharpCode.SharpZipLib/Zip/Compression/Streams/InflaterInputStream.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,14 @@ public int Available
9595
set { available = value; }
9696
}
9797

98+
/// <summary>
99+
/// A limitation how much data is decrypted. If null all the data in the input buffer will be decrypted.
100+
/// Setting limit is important in case the HMAC has to be calculated for each zip entry. In this case
101+
/// it is not possible to decrypt all available data in the input buffer. In this case only the data
102+
/// belonging to the current zip entry must be decrypted so that the HMAC is correctly calculated.
103+
/// </summary>
104+
internal int? DecryptionLimit { get; set; }
105+
98106
/// <summary>
99107
/// Call <see cref="Inflater.SetInput(byte[], int, int)"/> passing the current clear text buffer contents.
100108
/// </summary>
@@ -303,18 +311,16 @@ public ICryptoTransform CryptoTransform
303311

304312
private int CalculateDecryptionSize(int availableBufferSize)
305313
{
306-
int size = DecryptSize ?? availableBufferSize;
314+
int size = DecryptionLimit ?? availableBufferSize;
307315
size = Math.Min(size, availableBufferSize);
308-
if (DecryptSize.HasValue)
316+
if (DecryptionLimit.HasValue)
309317
{
310-
DecryptSize -= size;
318+
DecryptionLimit -= size;
311319
}
312320

313321
return size;
314322
}
315323

316-
public int? DecryptSize { get; set; }
317-
318324
#region Instance Fields
319325

320326
private int rawLength;

src/ICSharpCode.SharpZipLib/Zip/ZipInputStream.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ private int InitialRead(byte[] destination, int offset, int count)
611611
// The AES data has saltLen+AESPasswordVerifyLength bytes as a header, and AESAuthCodeLength bytes
612612
// as a footer.
613613
csize -= (saltLen + ZipConstants.AESPasswordVerifyLength + ZipConstants.AESAuthCodeLength);
614-
inputBuffer.DecryptSize = (int)csize;
614+
inputBuffer.DecryptionLimit = (int)csize;
615615
inputBuffer.CryptoTransform = decryptor;
616616
this.cryptoTransform = decryptor;
617617
}

0 commit comments

Comments
 (0)