From da2a01eac0ee6d6a15c12e5ccfb5b425965d4cb4 Mon Sep 17 00:00:00 2001 From: David Hook Date: Mon, 22 Aug 2022 10:44:10 +1000 Subject: added input check --- crypto/src/crypto/engines/SM2Engine.cs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'crypto/src') 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); -- cgit 1.4.1