summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--crypto/src/crypto/ISigner.cs61
-rw-r--r--crypto/src/crypto/signers/DsaDigestSigner.cs56
-rw-r--r--crypto/src/crypto/signers/Ed25519Signer.cs7
-rw-r--r--crypto/src/crypto/signers/Ed25519ctxSigner.cs7
-rw-r--r--crypto/src/crypto/signers/Ed25519phSigner.cs7
-rw-r--r--crypto/src/crypto/signers/Ed448Signer.cs7
-rw-r--r--crypto/src/crypto/signers/Ed448phSigner.cs7
-rw-r--r--crypto/src/crypto/signers/GOST3410DigestSigner.cs40
-rw-r--r--crypto/src/crypto/signers/GenericSigner.cs25
-rw-r--r--crypto/src/crypto/signers/Iso9796d2PssSigner.cs37
-rw-r--r--crypto/src/crypto/signers/Iso9796d2Signer.cs46
-rw-r--r--crypto/src/crypto/signers/PssSigner.cs29
-rw-r--r--crypto/src/crypto/signers/RsaDigestSigner.cs34
-rw-r--r--crypto/src/crypto/signers/SM2Signer.cs11
-rw-r--r--crypto/src/crypto/signers/X931Signer.cs28
15 files changed, 201 insertions, 201 deletions
diff --git a/crypto/src/crypto/ISigner.cs b/crypto/src/crypto/ISigner.cs
index e03bbf4d3..668e5e4cd 100644
--- a/crypto/src/crypto/ISigner.cs
+++ b/crypto/src/crypto/ISigner.cs
@@ -1,50 +1,45 @@
-
 using System;
-using System.Text;
 
 namespace Org.BouncyCastle.Crypto
 {
     public interface ISigner
     {
-        /**
-         * Return the name of the algorithm the signer implements.
-         *
-         * @return the name of the algorithm the signer implements.
-         */
+        /// <summary>The algorithm name.</summary>
         string AlgorithmName { get; }
 
-		/**
-         * Initialise the signer for signing or verification.
-         *
-         * @param forSigning true if for signing, false otherwise
-         * @param param necessary parameters.
-         */
-         void Init(bool forSigning, ICipherParameters parameters);
-
-        /**
-         * update the internal digest with the byte b
-         */
+        /// <summary>Initialise the signer for signing or verification.</summary>
+        /// <param name="forSigning">true if for signing, false otherwise.</param>
+        /// <param name="parameters">necessary parameters.</param>
+        void Init(bool forSigning, ICipherParameters parameters);
+
+        /// <summary>Update the signer with a single byte.</summary>
+        /// <param name="input">the input byte to be entered.</param>
         void Update(byte input);
 
-        /**
-         * update the internal digest with the byte array in
-         */
-        void BlockUpdate(byte[] input, int inOff, int length);
+        /// <summary>Update the signer with a block of bytes.</summary>
+        /// <param name="input">the byte array containing the data.</param>
+        /// <param name="inOff">the offset into the byte array where the data starts.</param>
+        /// <param name="inLen">the length of the data.</param>
+        void BlockUpdate(byte[] input, int inOff, int inLen);
 
-        /**
-         * Generate a signature for the message we've been loaded with using
-         * the key we were initialised with.
-         */
+#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
+        /// <summary>Update the signer with a span of bytes.</summary>
+        /// <param name="input">the span containing the data.</param>
+        void BlockUpdate(ReadOnlySpan<byte> input);
+#endif
+
+        /// <summary>Generate a signature for the message we've been loaded with using the key we were initialised with.
+        /// </summary>
+        /// <returns>A byte array containing the signature for the message.</returns>
         byte[] GenerateSignature();
-        /**
-         * return true if the internal state represents the signature described
-         * in the passed in array.
-         */
+
+        /// <summary>Return true if the internal state represents the signature described in the passed in array.
+        /// </summary>
+        /// <param name="signature">an array containing the candidate signature to verify.</param>
+        /// <returns>true if the internal state represents the signature described in the passed in array.</returns>
         bool VerifySignature(byte[] signature);
 
-        /**
-         * reset the internal state
-         */
+        /// <summary>Reset the signer back to its initial state.</summary>
         void Reset();
     }
 }
diff --git a/crypto/src/crypto/signers/DsaDigestSigner.cs b/crypto/src/crypto/signers/DsaDigestSigner.cs
index da8a8c62d..e8c2487ba 100644
--- a/crypto/src/crypto/signers/DsaDigestSigner.cs
+++ b/crypto/src/crypto/signers/DsaDigestSigner.cs
@@ -14,19 +14,12 @@ namespace Org.BouncyCastle.Crypto.Signers
         private readonly IDsaEncoding encoding;
         private bool forSigning;
 
-		public DsaDigestSigner(
-			IDsa	dsa,
-			IDigest	digest)
+		public DsaDigestSigner(IDsa dsa, IDigest digest)
+			: this(dsa, digest, StandardDsaEncoding.Instance)
 		{
-            this.dsa = dsa;
-            this.digest = digest;
-            this.encoding = StandardDsaEncoding.Instance;
 		}
 
-        public DsaDigestSigner(
-            IDsa dsa,
-            IDigest digest,
-            IDsaEncoding encoding)
+        public DsaDigestSigner(IDsa dsa, IDigest digest, IDsaEncoding encoding)
         {
             this.dsa = dsa;
             this.digest = digest;
@@ -38,17 +31,14 @@ namespace Org.BouncyCastle.Crypto.Signers
 			get { return digest.AlgorithmName + "with" + dsa.AlgorithmName; }
 		}
 
-        public virtual void Init(
-			bool forSigning,
-			ICipherParameters parameters)
+        public virtual void Init(bool forSigning, ICipherParameters parameters)
 		{
 			this.forSigning = forSigning;
 
 			AsymmetricKeyParameter k;
-
-			if (parameters is ParametersWithRandom)
+			if (parameters is ParametersWithRandom withRandom)
 			{
-				k = (AsymmetricKeyParameter)((ParametersWithRandom)parameters).Parameters;
+				k = (AsymmetricKeyParameter)withRandom.Parameters;
 			}
 			else
 			{
@@ -66,31 +56,24 @@ namespace Org.BouncyCastle.Crypto.Signers
 			dsa.Init(forSigning, parameters);
 		}
 
-		/**
-		 * update the internal digest with the byte b
-		 */
-        public virtual void Update(
-			byte input)
+        public virtual void Update(byte input)
 		{
 			digest.Update(input);
 		}
 
-		/**
-		 * update the internal digest with the byte array in
-		 */
-        public virtual void BlockUpdate(
-			byte[]	input,
-			int			inOff,
-			int			length)
+        public virtual void BlockUpdate(byte[] input, int inOff, int inLen)
+		{
+			digest.BlockUpdate(input, inOff, inLen);
+		}
+
+#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
+		public virtual void BlockUpdate(ReadOnlySpan<byte> input)
 		{
-			digest.BlockUpdate(input, inOff, length);
+			digest.BlockUpdate(input);
 		}
+#endif
 
-		/**
-		 * Generate a signature for the message we've been loaded with using
-		 * the key we were initialised with.
-     */
-        public virtual byte[] GenerateSignature()
+		public virtual byte[] GenerateSignature()
 		{
 			if (!forSigning)
 				throw new InvalidOperationException("DSADigestSigner not initialised for signature generation.");
@@ -110,9 +93,7 @@ namespace Org.BouncyCastle.Crypto.Signers
             }
 		}
 
-		/// <returns>true if the internal state represents the signature described in the passed in array.</returns>
-        public virtual bool VerifySignature(
-			byte[] signature)
+        public virtual bool VerifySignature(byte[] signature)
 		{
 			if (forSigning)
 				throw new InvalidOperationException("DSADigestSigner not initialised for verification");
@@ -132,7 +113,6 @@ namespace Org.BouncyCastle.Crypto.Signers
             }
 		}
 
-		/// <summary>Reset the internal state</summary>
         public virtual void Reset()
 		{
 			digest.Reset();
diff --git a/crypto/src/crypto/signers/Ed25519Signer.cs b/crypto/src/crypto/signers/Ed25519Signer.cs
index 4646ce1a5..59dc1bec5 100644
--- a/crypto/src/crypto/signers/Ed25519Signer.cs
+++ b/crypto/src/crypto/signers/Ed25519Signer.cs
@@ -52,6 +52,13 @@ namespace Org.BouncyCastle.Crypto.Signers
             buffer.Write(buf, off, len);
         }
 
+#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
+        public virtual void BlockUpdate(ReadOnlySpan<byte> input)
+        {
+            buffer.Write(input);
+        }
+#endif
+
         public virtual byte[] GenerateSignature()
         {
             if (!forSigning || null == privateKey)
diff --git a/crypto/src/crypto/signers/Ed25519ctxSigner.cs b/crypto/src/crypto/signers/Ed25519ctxSigner.cs
index 293afedf5..4ccca8f22 100644
--- a/crypto/src/crypto/signers/Ed25519ctxSigner.cs
+++ b/crypto/src/crypto/signers/Ed25519ctxSigner.cs
@@ -55,6 +55,13 @@ namespace Org.BouncyCastle.Crypto.Signers
             buffer.Write(buf, off, len);
         }
 
+#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
+        public virtual void BlockUpdate(ReadOnlySpan<byte> input)
+        {
+            buffer.Write(input);
+        }
+#endif
+
         public virtual byte[] GenerateSignature()
         {
             if (!forSigning || null == privateKey)
diff --git a/crypto/src/crypto/signers/Ed25519phSigner.cs b/crypto/src/crypto/signers/Ed25519phSigner.cs
index 8f4afab19..800447143 100644
--- a/crypto/src/crypto/signers/Ed25519phSigner.cs
+++ b/crypto/src/crypto/signers/Ed25519phSigner.cs
@@ -55,6 +55,13 @@ namespace Org.BouncyCastle.Crypto.Signers
             prehash.BlockUpdate(buf, off, len);
         }
 
+#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
+        public virtual void BlockUpdate(ReadOnlySpan<byte> input)
+        {
+            prehash.BlockUpdate(input);
+        }
+#endif
+
         public virtual byte[] GenerateSignature()
         {
             if (!forSigning || null == privateKey)
diff --git a/crypto/src/crypto/signers/Ed448Signer.cs b/crypto/src/crypto/signers/Ed448Signer.cs
index 723ee7e33..3a7def690 100644
--- a/crypto/src/crypto/signers/Ed448Signer.cs
+++ b/crypto/src/crypto/signers/Ed448Signer.cs
@@ -55,6 +55,13 @@ namespace Org.BouncyCastle.Crypto.Signers
             buffer.Write(buf, off, len);
         }
 
+#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
+        public virtual void BlockUpdate(ReadOnlySpan<byte> input)
+        {
+            buffer.Write(input);
+        }
+#endif
+
         public virtual byte[] GenerateSignature()
         {
             if (!forSigning || null == privateKey)
diff --git a/crypto/src/crypto/signers/Ed448phSigner.cs b/crypto/src/crypto/signers/Ed448phSigner.cs
index 197c2f706..30d4a0aba 100644
--- a/crypto/src/crypto/signers/Ed448phSigner.cs
+++ b/crypto/src/crypto/signers/Ed448phSigner.cs
@@ -55,6 +55,13 @@ namespace Org.BouncyCastle.Crypto.Signers
             prehash.BlockUpdate(buf, off, len);
         }
 
+#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
+        public virtual void BlockUpdate(ReadOnlySpan<byte> input)
+        {
+            prehash.BlockUpdate(input);
+        }
+#endif
+
         public virtual byte[] GenerateSignature()
         {
             if (!forSigning || null == privateKey)
diff --git a/crypto/src/crypto/signers/GOST3410DigestSigner.cs b/crypto/src/crypto/signers/GOST3410DigestSigner.cs
index 17a7b659b..9564e43d3 100644
--- a/crypto/src/crypto/signers/GOST3410DigestSigner.cs
+++ b/crypto/src/crypto/signers/GOST3410DigestSigner.cs
@@ -15,9 +15,7 @@ namespace Org.BouncyCastle.Crypto.Signers
         private int halfSize;
         private bool forSigning;
 
-        public Gost3410DigestSigner(
-            IDsa signer,
-            IDigest digest)
+        public Gost3410DigestSigner(IDsa signer, IDigest digest)
         {
             this.dsaSigner = signer;
             this.digest = digest;
@@ -32,9 +30,7 @@ namespace Org.BouncyCastle.Crypto.Signers
             get { return digest.AlgorithmName + "with" + dsaSigner.AlgorithmName; }
         }
 
-        public virtual void Init(
-            bool forSigning,
-            ICipherParameters parameters)
+        public virtual void Init(bool forSigning, ICipherParameters parameters)
         {
             this.forSigning = forSigning;
 
@@ -64,30 +60,23 @@ namespace Org.BouncyCastle.Crypto.Signers
             dsaSigner.Init(forSigning, parameters);
         }
 
-        /**
-		 * update the internal digest with the byte b
-		 */
-        public virtual void Update(
-            byte input)
+        public virtual void Update(byte input)
         {
             digest.Update(input);
         }
 
-        /**
-		 * update the internal digest with the byte array in
-		 */
-        public virtual void BlockUpdate(
-            byte[] input,
-            int inOff,
-            int length)
+        public virtual void BlockUpdate(byte[] input, int inOff, int inLen)
         {
-            digest.BlockUpdate(input, inOff, length);
+            digest.BlockUpdate(input, inOff, inLen);
         }
 
-        /**
-		 * Generate a signature for the message we've been loaded with using
-		 * the key we were initialised with.
-		 */
+#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
+        public virtual void BlockUpdate(ReadOnlySpan<byte> input)
+        {
+            digest.BlockUpdate(input);
+        }
+#endif
+
         public virtual byte[] GenerateSignature()
         {
             if (!forSigning)
@@ -114,9 +103,7 @@ namespace Org.BouncyCastle.Crypto.Signers
             }
         }
 
-        /// <returns>true if the internal state represents the signature described in the passed in array.</returns>
-        public virtual bool VerifySignature(
-            byte[] signature)
+        public virtual bool VerifySignature(byte[] signature)
         {
             if (forSigning)
                 throw new InvalidOperationException("DSADigestSigner not initialised for verification");
@@ -138,7 +125,6 @@ namespace Org.BouncyCastle.Crypto.Signers
             return dsaSigner.VerifySignature(hash, R, S);
         }
 
-        /// <summary>Reset the internal state</summary>
         public virtual void Reset()
         {
             digest.Reset();
diff --git a/crypto/src/crypto/signers/GenericSigner.cs b/crypto/src/crypto/signers/GenericSigner.cs
index a5512176f..e0ff685ae 100644
--- a/crypto/src/crypto/signers/GenericSigner.cs
+++ b/crypto/src/crypto/signers/GenericSigner.cs
@@ -59,26 +59,23 @@ namespace Org.BouncyCastle.Crypto.Signers
             engine.Init(forSigning, parameters);
         }
 
-        /**
-        * update the internal digest with the byte b
-        */
         public virtual void Update(byte input)
         {
             digest.Update(input);
         }
 
-        /**
-        * update the internal digest with the byte array in
-        */
-        public virtual void BlockUpdate(byte[] input, int inOff, int length)
+        public virtual void BlockUpdate(byte[] input, int inOff, int inLen)
         {
-            digest.BlockUpdate(input, inOff, length);
+            digest.BlockUpdate(input, inOff, inLen);
         }
 
-        /**
-        * Generate a signature for the message we've been loaded with using the key
-        * we were initialised with.
-        */
+#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
+        public virtual void BlockUpdate(ReadOnlySpan<byte> input)
+        {
+            digest.BlockUpdate(input);
+        }
+#endif
+
         public virtual byte[] GenerateSignature()
         {
             if (!forSigning)
@@ -90,10 +87,6 @@ namespace Org.BouncyCastle.Crypto.Signers
             return engine.ProcessBlock(hash, 0, hash.Length);
         }
 
-        /**
-        * return true if the internal state represents the signature described in
-        * the passed in array.
-        */
         public virtual bool VerifySignature(byte[] signature)
         {
             if (forSigning)
diff --git a/crypto/src/crypto/signers/Iso9796d2PssSigner.cs b/crypto/src/crypto/signers/Iso9796d2PssSigner.cs
index ad2718280..573765c1a 100644
--- a/crypto/src/crypto/signers/Iso9796d2PssSigner.cs
+++ b/crypto/src/crypto/signers/Iso9796d2PssSigner.cs
@@ -290,27 +290,46 @@ namespace Org.BouncyCastle.Crypto.Signers
             }
         }
 
-        /// <summary> update the internal digest with the byte array in</summary>
-        public virtual void BlockUpdate(
-            byte[]	input,
-            int		inOff,
-            int		length)
+        public virtual void BlockUpdate(byte[] input, int inOff, int inLen)
         {
+#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
+            BlockUpdate(input.AsSpan(inOff, inLen));
+#else
             if (preSig == null)
             {
-                while (length > 0 && messageLength < mBuf.Length)
+                while (inLen > 0 && messageLength < mBuf.Length)
                 {
                     this.Update(input[inOff]);
                     inOff++;
-                    length--;
+                    inLen--;
+                }
+            }
+
+            if (inLen > 0)
+            {
+                digest.BlockUpdate(input, inOff, inLen);
+            }
+#endif
+        }
+
+#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
+        public virtual void BlockUpdate(ReadOnlySpan<byte> input)
+        {
+            if (preSig == null)
+            {
+                while (!input.IsEmpty && messageLength < mBuf.Length)
+                {
+                    this.Update(input[0]);
+                    input = input[1..];
                 }
             }
 
-            if (length > 0)
+            if (!input.IsEmpty)
             {
-                digest.BlockUpdate(input, inOff, length);
+                digest.BlockUpdate(input);
             }
         }
+#endif
 
         /// <summary> reset the internal state</summary>
         public virtual void Reset()
diff --git a/crypto/src/crypto/signers/Iso9796d2Signer.cs b/crypto/src/crypto/signers/Iso9796d2Signer.cs
index f28c4ac71..ea1dc3f18 100644
--- a/crypto/src/crypto/signers/Iso9796d2Signer.cs
+++ b/crypto/src/crypto/signers/Iso9796d2Signer.cs
@@ -218,9 +218,7 @@ namespace Org.BouncyCastle.Crypto.Signers
             recoveredMessage.CopyTo(mBuf, 0);
         }
 
-        /// <summary> update the internal digest with the byte b</summary>
-        public virtual void Update(
-            byte input)
+        public virtual void Update(byte input)
         {
             digest.Update(input);
 
@@ -232,26 +230,42 @@ namespace Org.BouncyCastle.Crypto.Signers
             messageLength++;
         }
 
-        /// <summary> update the internal digest with the byte array in</summary>
-        public virtual void BlockUpdate(
-            byte[]	input,
-            int		inOff,
-            int		length)
+        public virtual void BlockUpdate(byte[] input, int inOff, int inLen)
         {
-            while (length > 0 && messageLength < mBuf.Length)
+#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
+            BlockUpdate(input.AsSpan(inOff, inLen));
+#else
+            while (inLen > 0 && messageLength < mBuf.Length)
             {
-                //for (int i = 0; i < length && (i + messageLength) < mBuf.Length; i++)
-                //{
-                //    mBuf[messageLength + i] = input[inOff + i];
-                //}
                 this.Update(input[inOff]);
                 inOff++;
-                length--;
+                inLen--;
             }
 
-            digest.BlockUpdate(input, inOff, length);
-            messageLength += length;
+            if (inLen > 0)
+            {
+                digest.BlockUpdate(input, inOff, inLen);
+                messageLength += inLen;
+            }
+#endif
+        }
+
+#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
+        public virtual void BlockUpdate(ReadOnlySpan<byte> input)
+        {
+            while (!input.IsEmpty && messageLength < mBuf.Length)
+            {
+                this.Update(input[0]);
+                input = input[1..];
+            }
+
+            if (!input.IsEmpty)
+            {
+                digest.BlockUpdate(input);
+                messageLength += input.Length;
+            }
         }
+#endif
 
         /// <summary> reset the internal state</summary>
         public virtual void Reset()
diff --git a/crypto/src/crypto/signers/PssSigner.cs b/crypto/src/crypto/signers/PssSigner.cs
index 2a941df47..b033bb251 100644
--- a/crypto/src/crypto/signers/PssSigner.cs
+++ b/crypto/src/crypto/signers/PssSigner.cs
@@ -198,31 +198,28 @@ namespace Org.BouncyCastle.Crypto.Signers
 			Array.Clear(block, 0, block.Length);
 		}
 
-		/// <summary> update the internal digest with the byte b</summary>
-		public virtual void Update(
-			byte input)
+		public virtual void Update(byte input)
 		{
 			contentDigest1.Update(input);
 		}
 
-		/// <summary> update the internal digest with the byte array in</summary>
-		public virtual void BlockUpdate(
-			byte[]	input,
-			int		inOff,
-			int		length)
+		public virtual void BlockUpdate(byte[] input, int inOff, int inLen)
+		{
+			contentDigest1.BlockUpdate(input, inOff, inLen);
+		}
+
+#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
+		public virtual void BlockUpdate(ReadOnlySpan<byte> input)
 		{
-			contentDigest1.BlockUpdate(input, inOff, length);
+			contentDigest1.BlockUpdate(input);
 		}
+#endif
 
-		/// <summary> reset the internal state</summary>
 		public virtual void Reset()
 		{
 			contentDigest1.Reset();
 		}
 
-		/// <summary> Generate a signature for the message we've been loaded with using
-		/// the key we were initialised with.
-		/// </summary>
 		public virtual byte[] GenerateSignature()
 		{
 			if (contentDigest1.GetDigestSize() != hLen)
@@ -268,11 +265,7 @@ namespace Org.BouncyCastle.Crypto.Signers
 			return b;
 		}
 
-		/// <summary> return true if the internal state represents the signature described
-		/// in the passed in array.
-		/// </summary>
-		public virtual bool VerifySignature(
-			byte[] signature)
+		public virtual bool VerifySignature(byte[] signature)
 		{
 			if (contentDigest1.GetDigestSize() != hLen)
 				throw new InvalidOperationException();
diff --git a/crypto/src/crypto/signers/RsaDigestSigner.cs b/crypto/src/crypto/signers/RsaDigestSigner.cs
index 25bd4af4e..75b3a24b9 100644
--- a/crypto/src/crypto/signers/RsaDigestSigner.cs
+++ b/crypto/src/crypto/signers/RsaDigestSigner.cs
@@ -122,30 +122,23 @@ namespace Org.BouncyCastle.Crypto.Signers
             rsaEngine.Init(forSigning, parameters);
         }
 
-        /**
-         * update the internal digest with the byte b
-         */
-        public virtual void Update(
-            byte input)
+        public virtual void Update(byte input)
         {
             digest.Update(input);
         }
 
-        /**
-         * update the internal digest with the byte array in
-         */
-        public virtual void BlockUpdate(
-            byte[]	input,
-            int		inOff,
-            int		length)
+        public virtual void BlockUpdate(byte[] input, int inOff, int inLen)
         {
-            digest.BlockUpdate(input, inOff, length);
+            digest.BlockUpdate(input, inOff, inLen);
         }
 
-        /**
-         * Generate a signature for the message we've been loaded with using
-         * the key we were initialised with.
-         */
+#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
+        public virtual void BlockUpdate(ReadOnlySpan<byte> input)
+        {
+            digest.BlockUpdate(input);
+        }
+#endif
+
         public virtual byte[] GenerateSignature()
         {
             if (!forSigning)
@@ -158,12 +151,7 @@ namespace Org.BouncyCastle.Crypto.Signers
             return rsaEngine.ProcessBlock(data, 0, data.Length);
         }
 
-        /**
-         * return true if the internal state represents the signature described
-         * in the passed in array.
-         */
-        public virtual bool VerifySignature(
-            byte[] signature)
+        public virtual bool VerifySignature(byte[] signature)
         {
             if (forSigning)
                 throw new InvalidOperationException("RsaDigestSigner not initialised for verification");
diff --git a/crypto/src/crypto/signers/SM2Signer.cs b/crypto/src/crypto/signers/SM2Signer.cs
index c344a220a..24aedd970 100644
--- a/crypto/src/crypto/signers/SM2Signer.cs
+++ b/crypto/src/crypto/signers/SM2Signer.cs
@@ -106,11 +106,18 @@ namespace Org.BouncyCastle.Crypto.Signers
             digest.Update(b);
         }
 
-        public virtual void BlockUpdate(byte[] buf, int off, int len)
+        public virtual void BlockUpdate(byte[] input, int inOff, int inLen)
         {
-            digest.BlockUpdate(buf, off, len);
+            digest.BlockUpdate(input, inOff, inLen);
         }
 
+#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
+        public virtual void BlockUpdate(ReadOnlySpan<byte> input)
+        {
+            digest.BlockUpdate(input);
+        }
+#endif
+
         public virtual bool VerifySignature(byte[] signature)
         {
             try
diff --git a/crypto/src/crypto/signers/X931Signer.cs b/crypto/src/crypto/signers/X931Signer.cs
index 0907403a8..6c0aa9427 100644
--- a/crypto/src/crypto/signers/X931Signer.cs
+++ b/crypto/src/crypto/signers/X931Signer.cs
@@ -88,34 +88,28 @@ namespace Org.BouncyCastle.Crypto.Signers
             Array.Clear(block, 0, block.Length);
         }
 
-        /**
-         * update the internal digest with the byte b
-         */
         public virtual void Update(byte b)
         {
             digest.Update(b);
         }
 
-        /**
-         * update the internal digest with the byte array in
-         */
-        public virtual void BlockUpdate(byte[] input, int off, int len)
+        public virtual void BlockUpdate(byte[] input, int inOff, int inLen)
         {
-            digest.BlockUpdate(input, off, len);
+            digest.BlockUpdate(input, inOff, inLen);
         }
 
-        /**
-         * reset the internal state
-         */
+#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
+        public virtual void BlockUpdate(ReadOnlySpan<byte> input)
+        {
+            digest.BlockUpdate(input);
+        }
+#endif
+
         public virtual void Reset()
         {
             digest.Reset();
         }
 
-        /**
-         * generate a signature for the loaded message using the key we were
-         * initialised with.
-         */
         public virtual byte[] GenerateSignature()
         {
             CreateSignatureBlock();
@@ -156,10 +150,6 @@ namespace Org.BouncyCastle.Crypto.Signers
             block[delta - 1] = (byte)0xba;
         }
 
-        /**
-         * return true if the signature represents a ISO9796-2 signature
-         * for the passed in message.
-         */
         public virtual bool VerifySignature(byte[] signature)
         {
             try