diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2015-12-25 00:23:52 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2015-12-25 00:23:52 +0700 |
commit | d23f5025d8281432258b906ab07dcf96db37703f (patch) | |
tree | 59606ee37faf854051d13876ef215a92c987a0f9 | |
parent | Merge branch 'master' of git.bouncycastle.org:bc-csharp (diff) | |
download | BouncyCastle.NET-ed25519-d23f5025d8281432258b906ab07dcf96db37703f.tar.xz |
Fix VmpcMac to actually use offset in BlockUpdate()
- https://github.com/bcgit/bc-java/issues/127
-rw-r--r-- | crypto/src/crypto/macs/VMPCMac.cs | 2 | ||||
-rw-r--r-- | crypto/test/src/crypto/test/VMPCMacTest.cs | 11 |
2 files changed, 7 insertions, 6 deletions
diff --git a/crypto/src/crypto/macs/VMPCMac.cs b/crypto/src/crypto/macs/VMPCMac.cs index 89916355c..6f2da075c 100644 --- a/crypto/src/crypto/macs/VMPCMac.cs +++ b/crypto/src/crypto/macs/VMPCMac.cs @@ -166,7 +166,7 @@ namespace Org.BouncyCastle.Crypto.Macs for (int i = 0; i < len; i++) { - Update(input[i]); + Update(input[inOff + i]); } } } diff --git a/crypto/test/src/crypto/test/VMPCMacTest.cs b/crypto/test/src/crypto/test/VMPCMacTest.cs index 0ddb5506f..b9a5e3a93 100644 --- a/crypto/test/src/crypto/test/VMPCMacTest.cs +++ b/crypto/test/src/crypto/test/VMPCMacTest.cs @@ -35,16 +35,17 @@ namespace Org.BouncyCastle.Crypto.Tests ICipherParameters kpwiv = new ParametersWithIV(kp, Hex.Decode("4B5C2F003E67F39557A8D26F3DA2B155")); - byte[] m = new byte[256]; + int offset = 117; + byte[] m = new byte[512]; for (int i = 0; i < 256; i++) { - m[i] = (byte) i; + m[offset + i] = (byte)i; } - VmpcMac mac = new VmpcMac(); + VmpcMac mac = new VmpcMac(); mac.Init(kpwiv); - mac.BlockUpdate(m, 0, m.Length); + mac.BlockUpdate(m, offset, 256); byte[] output = new byte[20]; mac.DoFinal(output, 0); @@ -57,7 +58,7 @@ namespace Org.BouncyCastle.Crypto.Tests } } - [Test] + [Test] public void TestFunction() { string resultText = Perform().ToString(); |