static DataDecoder() { byte[] bKey = System.Text.Encoding.ASCII.GetBytes("Implict error #56"); var tiger = new TigerDigest(); tiger.BlockUpdate(bKey, 0, bKey.Length); var bb = new byte[24]; tiger.DoFinal(bb, 0); Key = new KeyParameter(bb); }
public void Reset(IMemoable other) { TigerDigest tigerDigest = (TigerDigest)other; a = tigerDigest.a; b = tigerDigest.b; c = tigerDigest.c; Array.Copy(tigerDigest.x, 0, x, 0, tigerDigest.x.Length); xOff = tigerDigest.xOff; Array.Copy(tigerDigest.Buffer, 0, Buffer, 0, tigerDigest.Buffer.Length); bOff = tigerDigest.bOff; byteCount = tigerDigest.byteCount; }
public void Reset(IMemoable other) { TigerDigest tigerDigest = (TigerDigest)other; a = tigerDigest.a; b = tigerDigest.b; c = tigerDigest.c; global::System.Array.Copy((global::System.Array)tigerDigest.x, 0, (global::System.Array)x, 0, tigerDigest.x.Length); xOff = tigerDigest.xOff; global::System.Array.Copy((global::System.Array)tigerDigest.Buffer, 0, (global::System.Array)Buffer, 0, tigerDigest.Buffer.Length); bOff = tigerDigest.bOff; byteCount = tigerDigest.byteCount; }
public void Reset(IMemoable other) { TigerDigest digest = (TigerDigest)other; this.a = digest.a; this.b = digest.b; this.c = digest.c; Array.Copy(digest.x, 0, this.x, 0, digest.x.Length); this.xOff = digest.xOff; Array.Copy(digest.Buffer, 0, this.Buffer, 0, digest.Buffer.Length); this.bOff = digest.bOff; this.byteCount = digest.byteCount; }
public static IEnumerable<byte[]> EncodeSettings(ClientSettings settings) { if (settings == null) throw new ArgumentNullException("settings"); var ks = "ReadNewSettings2Connection_Request"; byte[] bKey = System.Text.Encoding.ASCII.GetBytes(ks); var tiger = new TigerDigest(); tiger.BlockUpdate(bKey, 0, bKey.Length); var bb = new byte[24]; tiger.DoFinal(bb, 0); var key = new KeyParameter(bb); foreach (var sett in settings.Settings) { yield return DataEncoder.EncodeString(sett.FieldName, key); yield return DataEncoder.EncodeString(sett.GetStringValue(), key); } }
public ITestResult Perform() { IDigest digest = new TigerDigest(); byte[] resBuf = new byte[digest.GetDigestSize()]; for (int i = 0; i < messages.Length; i++) { byte[] m = Encoding.ASCII.GetBytes(messages[i]); digest.BlockUpdate(m, 0, m.Length); digest.DoFinal(resBuf, 0); if (!Arrays.AreEqual(resBuf, Hex.Decode(digests[i]))) { return new SimpleTestResult(false, Name + ": Vector " + i + " failed got " + Hex.ToHexString(resBuf)); } } // // test 2 // byte[] mm = Encoding.ASCII.GetBytes(messages[messages.Length-1]); digest.BlockUpdate(mm, 0, mm.Length/2); // clone the IDigest IDigest d = new TigerDigest((TigerDigest)digest); digest.BlockUpdate(mm, mm.Length/2, mm.Length - mm.Length/2); digest.DoFinal(resBuf, 0); if (!Arrays.AreEqual(resBuf, Hex.Decode(digests[digests.Length-1]))) { return new SimpleTestResult(false, "Tiger failing clone test" + SimpleTest.NewLine + " expected: " + digests[digests.Length-1] + SimpleTest.NewLine + " got : " + Hex.ToHexString(resBuf)); } d.BlockUpdate(mm, mm.Length/2, mm.Length - mm.Length/2); d.DoFinal(resBuf, 0); if (!Arrays.AreEqual(resBuf, Hex.Decode(digests[digests.Length-1]))) { return new SimpleTestResult(false, "Tiger failing clone test - part 2" + SimpleTest.NewLine + " expected: " + digests[digests.Length-1] + SimpleTest.NewLine + " got : " + Hex.ToHexString(resBuf)); } for (int i = 0; i < 65536; i++) { digest.Update((byte)(i & 0xff)); } digest.DoFinal(resBuf, 0); if (!Arrays.AreEqual(resBuf, Hex.Decode(hash64k))) { return new SimpleTestResult(false, Name + ": Million a's failed"); } return new SimpleTestResult(true, Name + ": Okay"); }
public TigerDigest(TigerDigest t) { Reset(t); }
/** * Copy constructor. This will copy the state of the provided * message digest. */ public TigerDigest(TigerDigest t) { Reset(t); }
/** * Copy constructor. This will copy the state of the provided * message digest. */ public TigerDigest(TigerDigest t) { a = t.a; b = t.b; c = t.c; Array.Copy(t.x, 0, x, 0, t.x.Length); xOff = t.xOff; Array.Copy(t.Buffer, 0, Buffer, 0, t.Buffer.Length); bOff = t.bOff; byteCount = t.byteCount; }
public TigerDigest(TigerDigest t) { this.Buffer = new byte[8]; this.x = new long[8]; this.Reset(t); }
public TigerDigest(TigerDigest t) { this.Reset(t); }
/// <summary> /// Note: Clears pool contents before returning /// </summary> private void CreateNewPRNG(byte[] pool) { if (pool == null) { throw new CryptographicException("Refusing to reseed with null pool"); } try { if (pool.Length != PoolSize) { throw new CryptographicException("Refusing to reseed with invalid pool"); } // Now, pool has been seeded, file operations are all completed, it's time to create my internal PRNG IDigest digest; switch (this.myRNGAlgorithm) { case PrngAlgorithm.MD5_128bit: digest = new MD5Digest(); break; case PrngAlgorithm.RIPEMD128_128bit: digest = new RipeMD128Digest(); break; case PrngAlgorithm.RIPEMD160_160bit: digest = new RipeMD160Digest(); break; case PrngAlgorithm.RIPEMD256_256bit: digest = new RipeMD256Digest(); break; case PrngAlgorithm.RIPEMD320_320bit: digest = new RipeMD320Digest(); break; case PrngAlgorithm.SHA1_160bit: digest = new Sha1Digest(); break; case PrngAlgorithm.SHA256_256bit: digest = new Sha256Digest(); break; case PrngAlgorithm.SHA512_512bit: digest = new Sha512Digest(); break; case PrngAlgorithm.Tiger_192bit: digest = new TigerDigest(); break; case PrngAlgorithm.Whirlpool_512bit: digest = new WhirlpoolDigest(); break; default: throw new CryptographicException("Unknown prngAlgorithm specified: " + this.myRNGAlgorithm.ToString()); } var drng = new DigestRandomGenerator(digest); drng.AddSeedMaterial(pool); this.myRNG = drng; } finally { Array.Clear(pool, 0, pool.Length); } }