fix BigInteger overflow

This commit is contained in:
CaiHQ 2021-11-02 17:45:08 +08:00
parent 4d670653b2
commit 8f8c0f27df

View File

@ -379,8 +379,8 @@ public class SM2Util extends GMBaseUtil {
}
ASN1Encodable[] arr = new ASN1Encodable[4];
arr[0] = new ASN1Integer(c1x);
arr[1] = new ASN1Integer(c1y);
arr[0] = new ASN1Integer(new BigInteger(1,c1x));
arr[1] = new ASN1Integer(new BigInteger(1,c1y));
if (mode == Mode.C1C2C3) {
arr[2] = new DEROctetString(c2);
arr[3] = new DEROctetString(c3);
@ -414,6 +414,8 @@ public class SM2Util extends GMBaseUtil {
byte[] c1y = ((ASN1Integer) as.getObjectAt(1)).getValue().toByteArray();
byte[] c3;
byte[] c2;
c1x = fixToCurveLengthBytes(c1x);
c1y = fixToCurveLengthBytes(c1y);
if (mode == Mode.C1C2C3) {
c2 = ((DEROctetString) as.getObjectAt(2)).getOctets();
c3 = ((DEROctetString) as.getObjectAt(3)).getOctets();