diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2020-04-05 18:54:21 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2020-04-05 18:54:21 +0700 |
commit | 4f8cc0568c9368c0d2dbe04ef286458221e6db59 (patch) | |
tree | 262b69f1619fbeaac83e3a30cda2e70241b9df26 /crypto/src | |
parent | added argument check for bit block size (diff) | |
download | BouncyCastle.NET-ed25519-4f8cc0568c9368c0d2dbe04ef286458221e6db59.tar.xz |
Reset after wrong-length failure
Diffstat (limited to 'crypto/src')
-rw-r--r-- | crypto/src/crypto/signers/Ed25519Signer.cs | 3 | ||||
-rw-r--r-- | crypto/src/crypto/signers/Ed25519ctxSigner.cs | 3 | ||||
-rw-r--r-- | crypto/src/crypto/signers/Ed25519phSigner.cs | 3 | ||||
-rw-r--r-- | crypto/src/crypto/signers/Ed448Signer.cs | 3 | ||||
-rw-r--r-- | crypto/src/crypto/signers/Ed448phSigner.cs | 3 |
5 files changed, 15 insertions, 0 deletions
diff --git a/crypto/src/crypto/signers/Ed25519Signer.cs b/crypto/src/crypto/signers/Ed25519Signer.cs index e58d14ea4..eb3d25398 100644 --- a/crypto/src/crypto/signers/Ed25519Signer.cs +++ b/crypto/src/crypto/signers/Ed25519Signer.cs @@ -98,7 +98,10 @@ namespace Org.BouncyCastle.Crypto.Signers internal bool VerifySignature(Ed25519PublicKeyParameters publicKey, byte[] signature) { if (Ed25519.SignatureSize != signature.Length) + { + Reset(); return false; + } lock (this) { diff --git a/crypto/src/crypto/signers/Ed25519ctxSigner.cs b/crypto/src/crypto/signers/Ed25519ctxSigner.cs index 2b5296e96..3610e25de 100644 --- a/crypto/src/crypto/signers/Ed25519ctxSigner.cs +++ b/crypto/src/crypto/signers/Ed25519ctxSigner.cs @@ -100,7 +100,10 @@ namespace Org.BouncyCastle.Crypto.Signers internal bool VerifySignature(Ed25519PublicKeyParameters publicKey, byte[] ctx, byte[] signature) { if (Ed25519.SignatureSize != signature.Length) + { + Reset(); return false; + } lock (this) { diff --git a/crypto/src/crypto/signers/Ed25519phSigner.cs b/crypto/src/crypto/signers/Ed25519phSigner.cs index cb3c3080a..8f4afab19 100644 --- a/crypto/src/crypto/signers/Ed25519phSigner.cs +++ b/crypto/src/crypto/signers/Ed25519phSigner.cs @@ -74,7 +74,10 @@ namespace Org.BouncyCastle.Crypto.Signers if (forSigning || null == publicKey) throw new InvalidOperationException("Ed25519phSigner not initialised for verification"); if (Ed25519.SignatureSize != signature.Length) + { + prehash.Reset(); return false; + } byte[] pk = publicKey.GetEncoded(); return Ed25519.VerifyPrehash(signature, 0, pk, 0, context, prehash); diff --git a/crypto/src/crypto/signers/Ed448Signer.cs b/crypto/src/crypto/signers/Ed448Signer.cs index 9d1495f2e..746029834 100644 --- a/crypto/src/crypto/signers/Ed448Signer.cs +++ b/crypto/src/crypto/signers/Ed448Signer.cs @@ -100,7 +100,10 @@ namespace Org.BouncyCastle.Crypto.Signers internal bool VerifySignature(Ed448PublicKeyParameters publicKey, byte[] ctx, byte[] signature) { if (Ed448.SignatureSize != signature.Length) + { + Reset(); return false; + } lock (this) { diff --git a/crypto/src/crypto/signers/Ed448phSigner.cs b/crypto/src/crypto/signers/Ed448phSigner.cs index f01b6bfd4..197c2f706 100644 --- a/crypto/src/crypto/signers/Ed448phSigner.cs +++ b/crypto/src/crypto/signers/Ed448phSigner.cs @@ -74,7 +74,10 @@ namespace Org.BouncyCastle.Crypto.Signers if (forSigning || null == publicKey) throw new InvalidOperationException("Ed448phSigner not initialised for verification"); if (Ed448.SignatureSize != signature.Length) + { + prehash.Reset(); return false; + } byte[] pk = publicKey.GetEncoded(); return Ed448.VerifyPrehash(signature, 0, pk, 0, context, prehash); |