summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2018-10-05 16:08:39 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2018-10-05 16:08:39 +0700
commit3fb7da2e8648e54ea5e89062203a51a747d210ea (patch)
tree516aa1cfd21d1272dedd7ab29fe6c0537ef24c7c
parentFix some TODOs for PORTABLE and Streams (diff)
downloadBouncyCastle.NET-ed25519-3fb7da2e8648e54ea5e89062203a51a747d210ea.tar.xz
Fix initialization checks
-rw-r--r--crypto/src/crypto/signers/Ed25519Signer.cs4
-rw-r--r--crypto/src/crypto/signers/Ed25519ctxSigner.cs4
-rw-r--r--crypto/src/crypto/signers/Ed25519phSigner.cs4
-rw-r--r--crypto/src/crypto/signers/Ed448Signer.cs4
-rw-r--r--crypto/src/crypto/signers/Ed448phSigner.cs4
5 files changed, 10 insertions, 10 deletions
diff --git a/crypto/src/crypto/signers/Ed25519Signer.cs b/crypto/src/crypto/signers/Ed25519Signer.cs
index 3776880db..1b3142c7b 100644
--- a/crypto/src/crypto/signers/Ed25519Signer.cs
+++ b/crypto/src/crypto/signers/Ed25519Signer.cs
@@ -59,7 +59,7 @@ namespace Org.BouncyCastle.Crypto.Signers
 
         public virtual byte[] GenerateSignature()
         {
-            if (!forSigning)
+            if (!forSigning || null == privateKey)
                 throw new InvalidOperationException("Ed25519Signer not initialised for signature generation.");
 
             return buffer.GenerateSignature(privateKey, publicKey);
@@ -67,7 +67,7 @@ namespace Org.BouncyCastle.Crypto.Signers
 
         public virtual bool VerifySignature(byte[] signature)
         {
-            if (forSigning)
+            if (forSigning || null == publicKey)
                 throw new InvalidOperationException("Ed25519Signer not initialised for verification");
 
             return buffer.VerifySignature(publicKey, signature);
diff --git a/crypto/src/crypto/signers/Ed25519ctxSigner.cs b/crypto/src/crypto/signers/Ed25519ctxSigner.cs
index 9a7b2b904..965453011 100644
--- a/crypto/src/crypto/signers/Ed25519ctxSigner.cs
+++ b/crypto/src/crypto/signers/Ed25519ctxSigner.cs
@@ -61,7 +61,7 @@ namespace Org.BouncyCastle.Crypto.Signers
 
         public virtual byte[] GenerateSignature()
         {
-            if (!forSigning)
+            if (!forSigning || null == privateKey)
                 throw new InvalidOperationException("Ed25519ctxSigner not initialised for signature generation.");
 
             return buffer.GenerateSignature(privateKey, publicKey, context);
@@ -69,7 +69,7 @@ namespace Org.BouncyCastle.Crypto.Signers
 
         public virtual bool VerifySignature(byte[] signature)
         {
-            if (forSigning)
+            if (forSigning || null == publicKey)
                 throw new InvalidOperationException("Ed25519ctxSigner not initialised for verification");
 
             return buffer.VerifySignature(publicKey, context, signature);
diff --git a/crypto/src/crypto/signers/Ed25519phSigner.cs b/crypto/src/crypto/signers/Ed25519phSigner.cs
index 0d3de96f3..3318f6438 100644
--- a/crypto/src/crypto/signers/Ed25519phSigner.cs
+++ b/crypto/src/crypto/signers/Ed25519phSigner.cs
@@ -60,7 +60,7 @@ namespace Org.BouncyCastle.Crypto.Signers
 
         public virtual byte[] GenerateSignature()
         {
-            if (!forSigning)
+            if (!forSigning || null == privateKey)
                 throw new InvalidOperationException("Ed25519phSigner not initialised for signature generation.");
 
             byte[] msg = new byte[Ed25519.PrehashSize];
@@ -74,7 +74,7 @@ namespace Org.BouncyCastle.Crypto.Signers
 
         public virtual bool VerifySignature(byte[] signature)
         {
-            if (forSigning)
+            if (forSigning || null == publicKey)
                 throw new InvalidOperationException("Ed25519phSigner not initialised for verification");
 
             byte[] pk = publicKey.GetEncoded();
diff --git a/crypto/src/crypto/signers/Ed448Signer.cs b/crypto/src/crypto/signers/Ed448Signer.cs
index 44e26b94f..d18f956a8 100644
--- a/crypto/src/crypto/signers/Ed448Signer.cs
+++ b/crypto/src/crypto/signers/Ed448Signer.cs
@@ -61,7 +61,7 @@ namespace Org.BouncyCastle.Crypto.Signers
 
         public virtual byte[] GenerateSignature()
         {
-            if (!forSigning)
+            if (!forSigning || null == privateKey)
                 throw new InvalidOperationException("Ed448Signer not initialised for signature generation.");
 
             return buffer.GenerateSignature(privateKey, publicKey, context);
@@ -69,7 +69,7 @@ namespace Org.BouncyCastle.Crypto.Signers
 
         public virtual bool VerifySignature(byte[] signature)
         {
-            if (forSigning)
+            if (forSigning || null == publicKey)
                 throw new InvalidOperationException("Ed448Signer not initialised for verification");
 
             return buffer.VerifySignature(publicKey, context, signature);
diff --git a/crypto/src/crypto/signers/Ed448phSigner.cs b/crypto/src/crypto/signers/Ed448phSigner.cs
index 50d0a0154..b86d0855c 100644
--- a/crypto/src/crypto/signers/Ed448phSigner.cs
+++ b/crypto/src/crypto/signers/Ed448phSigner.cs
@@ -60,7 +60,7 @@ namespace Org.BouncyCastle.Crypto.Signers
 
         public virtual byte[] GenerateSignature()
         {
-            if (!forSigning)
+            if (!forSigning || null == privateKey)
                 throw new InvalidOperationException("Ed448phSigner not initialised for signature generation.");
 
             byte[] msg = new byte[Ed448.PrehashSize];
@@ -74,7 +74,7 @@ namespace Org.BouncyCastle.Crypto.Signers
 
         public virtual bool VerifySignature(byte[] signature)
         {
-            if (forSigning)
+            if (forSigning || null == publicKey)
                 throw new InvalidOperationException("Ed448phSigner not initialised for verification");
 
             byte[] pk = publicKey.GetEncoded();