1 files changed, 9 insertions, 12 deletions
diff --git a/crypto/src/crypto/paddings/Pkcs7Padding.cs b/crypto/src/crypto/paddings/Pkcs7Padding.cs
index f3166fd96..11585647a 100644
--- a/crypto/src/crypto/paddings/Pkcs7Padding.cs
+++ b/crypto/src/crypto/paddings/Pkcs7Padding.cs
@@ -9,7 +9,7 @@ namespace Org.BouncyCastle.Crypto.Paddings
* A padder that adds Pkcs7/Pkcs5 padding to a block.
*/
public class Pkcs7Padding
- : IBlockCipherPadding
+ : IBlockCipherPadding
{
/**
* Initialise the padder.
@@ -17,7 +17,7 @@ namespace Org.BouncyCastle.Crypto.Paddings
* @param random - a SecureRandom if available.
*/
public void Init(
- SecureRandom random)
+ SecureRandom random)
{
// nothing to do.
}
@@ -32,7 +32,7 @@ namespace Org.BouncyCastle.Crypto.Paddings
get { return "PKCS7"; }
}
- /**
+ /**
* add the pad bytes to the passed in block, returning the
* number of bytes added.
*/
@@ -55,21 +55,18 @@ namespace Org.BouncyCastle.Crypto.Paddings
* return the number of pad bytes present in the block.
*/
public int PadCount(
- byte[] input)
+ byte[] input)
{
- int count = (int) input[input.Length - 1];
+ byte countAsByte = input[input.Length - 1];
+ int count = countAsByte;
- if (count < 1 || count > input.Length)
- {
+ if (count < 1 || count > input.Length)
throw new InvalidCipherTextException("pad block corrupted");
- }
- for (int i = 1; i <= count; i++)
+ for (int i = 2; i <= count; i++)
{
- if (input[input.Length - i] != count)
- {
+ if (input[input.Length - i] != countAsByte)
throw new InvalidCipherTextException("pad block corrupted");
- }
}
return count;
|