Skip to content

Commit 3fb7da2

Browse files
committed
Fix initialization checks
1 parent 28d7001 commit 3fb7da2

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

crypto/src/crypto/signers/Ed25519Signer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,15 @@ public virtual void BlockUpdate(byte[] buf, int off, int len)
5959

6060
public virtual byte[] GenerateSignature()
6161
{
62-
if (!forSigning)
62+
if (!forSigning || null == privateKey)
6363
throw new InvalidOperationException("Ed25519Signer not initialised for signature generation.");
6464

6565
return buffer.GenerateSignature(privateKey, publicKey);
6666
}
6767

6868
public virtual bool VerifySignature(byte[] signature)
6969
{
70-
if (forSigning)
70+
if (forSigning || null == publicKey)
7171
throw new InvalidOperationException("Ed25519Signer not initialised for verification");
7272

7373
return buffer.VerifySignature(publicKey, signature);

crypto/src/crypto/signers/Ed25519ctxSigner.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ public virtual void BlockUpdate(byte[] buf, int off, int len)
6161

6262
public virtual byte[] GenerateSignature()
6363
{
64-
if (!forSigning)
64+
if (!forSigning || null == privateKey)
6565
throw new InvalidOperationException("Ed25519ctxSigner not initialised for signature generation.");
6666

6767
return buffer.GenerateSignature(privateKey, publicKey, context);
6868
}
6969

7070
public virtual bool VerifySignature(byte[] signature)
7171
{
72-
if (forSigning)
72+
if (forSigning || null == publicKey)
7373
throw new InvalidOperationException("Ed25519ctxSigner not initialised for verification");
7474

7575
return buffer.VerifySignature(publicKey, context, signature);

crypto/src/crypto/signers/Ed25519phSigner.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public virtual void BlockUpdate(byte[] buf, int off, int len)
6060

6161
public virtual byte[] GenerateSignature()
6262
{
63-
if (!forSigning)
63+
if (!forSigning || null == privateKey)
6464
throw new InvalidOperationException("Ed25519phSigner not initialised for signature generation.");
6565

6666
byte[] msg = new byte[Ed25519.PrehashSize];
@@ -74,7 +74,7 @@ public virtual byte[] GenerateSignature()
7474

7575
public virtual bool VerifySignature(byte[] signature)
7676
{
77-
if (forSigning)
77+
if (forSigning || null == publicKey)
7878
throw new InvalidOperationException("Ed25519phSigner not initialised for verification");
7979

8080
byte[] pk = publicKey.GetEncoded();

crypto/src/crypto/signers/Ed448Signer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ public virtual void BlockUpdate(byte[] buf, int off, int len)
6161

6262
public virtual byte[] GenerateSignature()
6363
{
64-
if (!forSigning)
64+
if (!forSigning || null == privateKey)
6565
throw new InvalidOperationException("Ed448Signer not initialised for signature generation.");
6666

6767
return buffer.GenerateSignature(privateKey, publicKey, context);
6868
}
6969

7070
public virtual bool VerifySignature(byte[] signature)
7171
{
72-
if (forSigning)
72+
if (forSigning || null == publicKey)
7373
throw new InvalidOperationException("Ed448Signer not initialised for verification");
7474

7575
return buffer.VerifySignature(publicKey, context, signature);

crypto/src/crypto/signers/Ed448phSigner.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public virtual void BlockUpdate(byte[] buf, int off, int len)
6060

6161
public virtual byte[] GenerateSignature()
6262
{
63-
if (!forSigning)
63+
if (!forSigning || null == privateKey)
6464
throw new InvalidOperationException("Ed448phSigner not initialised for signature generation.");
6565

6666
byte[] msg = new byte[Ed448.PrehashSize];
@@ -74,7 +74,7 @@ public virtual byte[] GenerateSignature()
7474

7575
public virtual bool VerifySignature(byte[] signature)
7676
{
77-
if (forSigning)
77+
if (forSigning || null == publicKey)
7878
throw new InvalidOperationException("Ed448phSigner not initialised for verification");
7979

8080
byte[] pk = publicKey.GetEncoded();

0 commit comments

Comments
 (0)