summary refs log tree commit diff
path: root/crypto
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2022-11-19 16:12:13 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2022-11-19 16:12:13 +0700
commitfa4de13f49e716e84e85c10511fdd21150de4ed9 (patch)
tree107b94cfe2d43672459fbe5cda01be671d25d8d2 /crypto
parentTaming the many EdDSAs paper (diff)
downloadBouncyCastle.NET-ed25519-fa4de13f49e716e84e85c10511fdd21150de4ed9.tar.xz
Refactoring
Diffstat (limited to 'crypto')
-rw-r--r--crypto/test/src/math/ec/rfc8032/test/Ed25519Test.cs36
1 files 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