From 009ed41fc30543307c8eec1e3b770ad8f624c53b Mon Sep 17 00:00:00 2001 From: "junj2.liang" Date: Wed, 31 Aug 2022 15:10:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0init/update/digest/finish?= =?UTF-8?q?=E9=95=BF=E6=95=B0=E6=8D=AE=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/sunyard/sge/database/SydApiSM4.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/sunyard/sge/database/SydApiSM4.java b/src/main/java/com/sunyard/sge/database/SydApiSM4.java index 379ecc2..cc1ce8a 100644 --- a/src/main/java/com/sunyard/sge/database/SydApiSM4.java +++ b/src/main/java/com/sunyard/sge/database/SydApiSM4.java @@ -46,7 +46,7 @@ public class SydApiSM4 { //加密 if (plength < 16) { api.SYD_SM4_LongData(iKeyIndex, new byte[0], iPkgNum, iFlag); - if (iFlag == 0 && 1 == iKeyIndex) { + if (iFlag == 0 && 1 == iPkgNum) { throw new SydApiException("解密的首包不能小于 16 字节", 0); } ByteBuffer bufferResult = ByteBuffer.allocate(sourceWrap.array().length + plength); @@ -68,7 +68,7 @@ public class SydApiSM4 { sourceWrap = bufferResult; } byte[] bytes = api.SYD_SM4_LongData(iKeyIndex, pcdataResult, iPkgNum, iFlag); - iKeyIndex = 2; + iPkgNum = 2; } else { if (16 > pcData.length + sourceWrap.array().length) { ByteBuffer bufferResult = ByteBuffer.allocate(sourceWrap.array().length + plength); @@ -83,7 +83,6 @@ public class SydApiSM4 { api.SYD_SM4_LongData(iKeyIndex, bytes, iPkgNum, iFlag); } else { - ByteBuffer bufferResult = ByteBuffer.allocate(sourceWrap.array().length + plength); bufferResult.put(sourceWrap); bufferResult.put(pcData); @@ -117,7 +116,7 @@ public class SydApiSM4 { } byte[] bytes = api.SYD_SM4_LongData(iKeyIndex, pcdataResult, iPkgNum, iFlag); - sourceWrap = null; +// sourceWrap = null; return bytes; } public ByteBuffer bufferResult(int plength,byte[] pcData){