mirror of
https://github.com/UglyToad/PdfPig.git
synced 2026-03-10 00:23:29 +08:00
fix bug with handling of more than 256 bytes
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
namespace UglyToad.PdfPig.Encryption
|
namespace UglyToad.PdfPig.Encryption
|
||||||
{
|
{
|
||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
|
|
||||||
@@ -28,6 +29,11 @@
|
|||||||
|
|
||||||
var buffer = new byte[256];
|
var buffer = new byte[256];
|
||||||
|
|
||||||
|
if (data.Length > 256)
|
||||||
|
{
|
||||||
|
Debugger.Break();
|
||||||
|
}
|
||||||
|
|
||||||
using (var decryptor = rijndael.CreateDecryptor(rijndael.Key, rijndael.IV))
|
using (var decryptor = rijndael.CreateDecryptor(rijndael.Key, rijndael.IV))
|
||||||
using (var input = new MemoryStream(data))
|
using (var input = new MemoryStream(data))
|
||||||
using (var output = new MemoryStream())
|
using (var output = new MemoryStream())
|
||||||
@@ -35,15 +41,15 @@
|
|||||||
input.Seek(iv.Length, SeekOrigin.Begin);
|
input.Seek(iv.Length, SeekOrigin.Begin);
|
||||||
using (var cryptoStream = new CryptoStream(input, decryptor, CryptoStreamMode.Read))
|
using (var cryptoStream = new CryptoStream(input, decryptor, CryptoStreamMode.Read))
|
||||||
{
|
{
|
||||||
var offset = 0;
|
|
||||||
int read;
|
int read;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
read = cryptoStream.Read(buffer, offset, buffer.Length - offset);
|
read = cryptoStream.Read(buffer, 0, buffer.Length);
|
||||||
|
|
||||||
output.Write(buffer, offset, read);
|
if (read > 0)
|
||||||
|
{
|
||||||
offset += read;
|
output.Write(buffer, 0, read);
|
||||||
|
}
|
||||||
} while (read > 0);
|
} while (read > 0);
|
||||||
|
|
||||||
return output.ToArray();
|
return output.ToArray();
|
||||||
|
|||||||
Reference in New Issue
Block a user