From 4819cab88fdd657bd64c672ff62e255a5cc1fe3e Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Sun, 17 Jan 2016 12:32:24 +0700 Subject: Fix re-init bug in HC128/256 engines - add StreamCipherResetTest from Java API --- crypto/src/crypto/engines/HC128Engine.cs | 4 ++-- crypto/src/crypto/engines/HC256Engine.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'crypto/src') diff --git a/crypto/src/crypto/engines/HC128Engine.cs b/crypto/src/crypto/engines/HC128Engine.cs index 7bd1a48ed..b83eb7083 100644 --- a/crypto/src/crypto/engines/HC128Engine.cs +++ b/crypto/src/crypto/engines/HC128Engine.cs @@ -107,7 +107,8 @@ namespace Org.BouncyCastle.Crypto.Engines if (key.Length != 16) throw new ArgumentException("The key must be 128 bits long"); - cnt = 0; + idx = 0; + cnt = 0; uint[] w = new uint[1280]; @@ -223,7 +224,6 @@ namespace Org.BouncyCastle.Crypto.Engines public virtual void Reset() { - idx = 0; Init(); } diff --git a/crypto/src/crypto/engines/HC256Engine.cs b/crypto/src/crypto/engines/HC256Engine.cs index b72258a19..d8d83a634 100644 --- a/crypto/src/crypto/engines/HC256Engine.cs +++ b/crypto/src/crypto/engines/HC256Engine.cs @@ -92,6 +92,7 @@ namespace Org.BouncyCastle.Crypto.Engines iv = newIV; } + idx = 0; cnt = 0; uint[] w = new uint[2560]; @@ -207,7 +208,6 @@ namespace Org.BouncyCastle.Crypto.Engines public virtual void Reset() { - idx = 0; Init(); } -- cgit 1.5.1