Permalink
Browse files

Fix offset computation when a buffer limit exists. Patch contributed …

…by brad@symform.com
  • Loading branch information...
1 parent e6b6f79 commit 3a6e861fe514c3792a6a2c109448567e9c644b6c @spouliot spouliot committed Jul 17, 2012
Showing with 4 additions and 2 deletions.
  1. +4 −2 class/Crimson.CryptoDev/Crimson.CryptoDev/CryptoDevTransform.cs
@@ -151,8 +151,10 @@ void Transform (byte[] input, int inputOffset, byte[] output, int outputOffset,
fixed (byte *i = &iv [0])
context.iv = (IntPtr) i;
- if (!encrypt)
- Buffer.BlockCopy (input, length - BlockSizeByte, save_iv, 0, BlockSizeByte);
+ if (!encrypt) {
+ int ivOffset = inputOffset + size - BlockSizeByte;
+ Buffer.BlockCopy (input, ivOffset, save_iv, 0, BlockSizeByte);
+ }
}
fixed (byte *i = &input [inputOffset])

0 comments on commit 3a6e861

Please sign in to comment.