From fa4de13f49e716e84e85c10511fdd21150de4ed9 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Sat, 19 Nov 2022 16:12:13 +0700 Subject: Refactoring --- .../test/src/math/ec/rfc8032/test/Ed25519Test.cs | 36 +++++++++++----------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/crypto/test/src/math/ec/rfc8032/test/Ed25519Test.cs b/crypto/test/src/math/ec/rfc8032/test/Ed25519Test.cs index f2573903c..04b9c3cce 100644 --- a/crypto/test/src/math/ec/rfc8032/test/Ed25519Test.cs +++ b/crypto/test/src/math/ec/rfc8032/test/Ed25519Test.cs @@ -609,28 +609,28 @@ namespace Org.BouncyCastle.Math.EC.Rfc8032.Tests private static void ImplTamingVector(int number, bool expected, string msgHex, string pubHex, string sigHex) { - bool actual; - if (sigHex.Length > Ed25519.SignatureSize * 2) + bool actual = ImplTamingVector(msgHex, pubHex, sigHex); + + Assert.AreEqual(expected, actual, "Failed Taming EdDSA Vector #" + number); + } + + private static bool ImplTamingVector(string msgHex, string pubHex, string sigHex) + { + if (sigHex.Length != Ed25519.SignatureSize * 2) + return false; + + byte[] msg = Hex.DecodeStrict(msgHex); + byte[] pub = Hex.DecodeStrict(pubHex); + byte[] sig = Hex.DecodeStrict(sigHex); + + try { - actual = false; + return Ed25519.Verify(sig, 0, pub, 0, msg, 0, msg.Length); } - else + catch (Exception) { - byte[] msg = Hex.DecodeStrict(msgHex); - byte[] pub = Hex.DecodeStrict(pubHex); - byte[] sig = Hex.DecodeStrict(sigHex); - - try - { - actual = Ed25519.Verify(sig, 0, pub, 0, msg, 0, msg.Length); - } - catch (Exception) - { - actual = false; - } + return false; } - - Assert.AreEqual(expected, actual, "Failed Taming EdDSA Vector #" + number); } #endregion -- cgit 1.4.1