summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--crypto/src/crypto/engines/SM2Engine.cs5
1 files changed, 5 insertions, 0 deletions
diff --git a/crypto/src/crypto/engines/SM2Engine.cs b/crypto/src/crypto/engines/SM2Engine.cs
index ab7e9cd17..1a121c192 100644
--- a/crypto/src/crypto/engines/SM2Engine.cs
+++ b/crypto/src/crypto/engines/SM2Engine.cs
@@ -62,6 +62,11 @@ namespace Org.BouncyCastle.Crypto.Engines
 
         public virtual byte[] ProcessBlock(byte[] input, int inOff, int inLen)
         {
+            if ((inOff + inLen) > input.Length || inLen == 0)
+            {
+                throw new DataLengthException("input buffer too short");
+            }
+
             if (mForEncryption)
             {
                 return Encrypt(input, inOff, inLen);