初始化主密钥

This commit is contained in:
liulu
2024-11-11 14:14:32 +08:00
parent 4ae46ed32d
commit c18cfda28b
5 changed files with 55 additions and 55 deletions
@@ -2,8 +2,7 @@ package com.sunyard.chsm.sdf;
import com.sunyard.chsm.sdf.model.EccKey;
import com.sunyard.chsm.sdf.model.EccPriKey;
import com.sunyard.chsm.sdf.model.EccPubKey;
import com.sunyard.chsm.sdf.util.LangUtils;
import com.sunyard.chsm.utils.gm.BCSM2Utils;
import com.sunyard.chsm.utils.gm.BCSM3Utils;
import lombok.SneakyThrows;
@@ -43,8 +42,7 @@ public class BCSdfApiService implements SdfApiService {
byte[] x = pubKey.getQ().getXCoord().getEncoded();
byte[] y = pubKey.getQ().getYCoord().getEncoded();
byte[] d = BigIntegers.asUnsignedByteArray(32, priKey.getD());
return new EccKey(new EccPubKey(256, x, y), new EccPriKey(256, d));
return new EccKey(LangUtils.merge(x, y), d);
}
@@ -31,7 +31,7 @@ public class BcSdfApiAdaptor implements SdfApiAdapter {
deviceInfo = new DeviceInfo();
deviceInfo.setIssuerName("BC");
deviceInfo.setDeviceName("BC-3000");
deviceInfo.setDeviceSerial("BC00202411051037");
deviceInfo.setDeviceSerial("BC202411051037");
deviceInfo.setDeviceVersion(1);
deviceInfo.setStandardVersion(1);
deviceInfo.setAsymAlgAbility(new long[]{7493065891348563935L, 3000543215027029126L});
@@ -116,7 +116,7 @@ public class BcSdfApiAdaptor implements SdfApiAdapter {
byte[] encrypt = BCSM2Utils.encrypt(parameters, pucData);
return Arrays.copyOfRange(encrypt, 1, encrypt.length);
} catch (InvalidCipherTextException e) {
throw new RuntimeException(e);
throw new IllegalArgumentException(e);
}
}