From dcd4b91b57931403d696b9430762aaf687b41d33 Mon Sep 17 00:00:00 2001 From: cheney Date: Mon, 7 Jul 2025 17:41:43 +0800 Subject: [PATCH] =?UTF-8?q?batch=20mac=20=E8=BF=94=E5=9B=9E=E5=80=BC?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sge/database/SydApiBaseFunction.java | 38 ++++++++++++++++++- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/sunyard/sge/database/SydApiBaseFunction.java b/src/main/java/com/sunyard/sge/database/SydApiBaseFunction.java index 9a83e26..b822db7 100644 --- a/src/main/java/com/sunyard/sge/database/SydApiBaseFunction.java +++ b/src/main/java/com/sunyard/sge/database/SydApiBaseFunction.java @@ -124,6 +124,14 @@ public class SydApiBaseFunction implements SydApi { if (null == this.hsms || this.hsms.length < 1) { throw new SydApiException(-1); } + + if (null == pcData) { + throw new SydApiException("输入内容为 null",19); + } + if ( pcData.length > 1024 ) { + throw new SydApiException("输入内容为空",19); + } + SydApiException le = new SydApiException(-1); updateLastUseTime(); @@ -248,7 +256,15 @@ public class SydApiBaseFunction implements SydApi { if (null == this.hsms || this.hsms.length < 1) { throw new SydApiException(-1); } - + if (Consts.ECB_ENC == iFlag) { + if ( pcData.length > 1024 ) { + throw new SydApiException("输入内容超长",19); + } + } else { + if ( pcData.length > 1040 ) { + throw new SydApiException("输入内容超长",19); + } + } updateLastUseTime(); String keyIndex = String.format("%08d", iKeyIndex); SydApiException le = new SydApiException(-1); @@ -318,13 +334,21 @@ public class SydApiBaseFunction implements SydApi { if (LogFactory.iLogLevel == 3) { log.debug("SYD_SM4_BatchData方法接收参数:iKeyIndex:{},pcData元素个数为:{},iFlag:{}", iKeyIndex, pcData.size(), iFlag); } + if (iFlag == Consts.ECB_DEC) { for (byte[] pcdata : pcData) { - if (null == pcData || pcdata.length == 0) { + if (null == pcData || pcdata.length == 0 || pcdata.length > 1040) { + throw new SydApiException(19); + } + } + } else { + for (byte[] pcdata : pcData) { + if (null == pcData || pcdata.length > 1024) { throw new SydApiException(19); } } } + if (null == this.hsms || this.hsms.length < 1) { throw new SydApiException(-1); } @@ -722,6 +746,11 @@ public class SydApiBaseFunction implements SydApi { if (LogFactory.iLogLevel == 3) { log.debug("SYD_SM4Mac_ShortData方法接收参数:iKeyIndex:{},pcData:{},iFlag:{}", iKeyIndex, Arrays.toString(pcData)); } + + if ( null == pcData || pcData.length > 1040 ) { + throw new SydApiException("输入内容超长",19); + } + if (null == this.hsms || this.hsms.length < 1) { throw new SydApiException(-1); } @@ -777,6 +806,11 @@ public class SydApiBaseFunction implements SydApi { if (LogFactory.iLogLevel == 3) { log.debug("SYD_SM4Mac_ShortData方法接收参数:{}", iKeyIndex, Arrays.toString(pcData), pcMac); } + + if ( null == pcData || pcData.length > 1040 ) { + throw new SydApiException("输入内容超长",19); + } + if (null == this.hsms || this.hsms.length < 1) { throw new SydApiException(-1); }