sdf 接口

This commit is contained in:
liulu 2024-11-05 09:46:57 +08:00
parent 96e5f430fd
commit 666cc96799
3 changed files with 7 additions and 7 deletions

View File

@ -71,12 +71,12 @@ public class BCSdfApiService implements SdfApiService {
} }
@Override @Override
public byte[] encryptByMK(byte[] data) { public byte[] encryptByTMK(byte[] data) {
return data; return data;
} }
@Override @Override
public byte[] decryptByMK(byte[] data) { public byte[] decryptByTMK(byte[] data) {
return data; return data;
} }

View File

@ -45,7 +45,7 @@ public interface SdfApiService {
*/ */
byte[] hash(byte[] pucData); byte[] hash(byte[] pucData);
byte[] encryptByMK(byte[] data); byte[] encryptByTMK(byte[] data);
byte[] decryptByMK(byte[] data); byte[] decryptByTMK(byte[] data);
} }

View File

@ -278,14 +278,14 @@ public class KeyInfoServiceImpl implements KeyInfoService {
if (KeyCategory.SYM_KEY.getCode().equals(info.getKeyType())) { if (KeyCategory.SYM_KEY.getCode().equals(info.getKeyType())) {
byte[] symKey = sdfApiService.generateRandom(16); byte[] symKey = sdfApiService.generateRandom(16);
byte[] encSymKey = sdfApiService.encryptByMK(symKey); byte[] encSymKey = sdfApiService.encryptByTMK(symKey);
record.setKeyData(Hex.toHexString(encSymKey)); record.setKeyData(Hex.toHexString(encSymKey));
String checkHash = Hex.toHexString(sdfApiService.hash(symKey)); String checkHash = Hex.toHexString(sdfApiService.hash(symKey));
record.setCheckValue(checkHash); record.setCheckValue(checkHash);
} else { } else {
EccKey eccKey = sdfApiService.genKeyPairEcc(); EccKey eccKey = sdfApiService.genKeyPairEcc();
byte[] d = eccKey.getPriKey().getD(); byte[] d = eccKey.getPriKey().getD();
byte[] encD = sdfApiService.encryptByMK(d); byte[] encD = sdfApiService.encryptByTMK(d);
record.setKeyData(Hex.toHexString(encD)); record.setKeyData(Hex.toHexString(encD));
String checkHash = Hex.toHexString(sdfApiService.hash(d)); String checkHash = Hex.toHexString(sdfApiService.hash(d));
record.setCheckValue(checkHash); record.setCheckValue(checkHash);
@ -392,7 +392,7 @@ public class KeyInfoServiceImpl implements KeyInfoService {
byte[] y = Arrays.copyOfRange(xy, 32, 64); byte[] y = Arrays.copyOfRange(xy, 32, 64);
ECPublicKeyParameters pubKeyParam = BCECUtils.createECPublicKeyParameters(x, y); ECPublicKeyParameters pubKeyParam = BCECUtils.createECPublicKeyParameters(x, y);
byte[] priKeyBytes = sdfApiService.decryptByMK(Hex.decode(record.getKeyData())); byte[] priKeyBytes = sdfApiService.decryptByTMK(Hex.decode(record.getKeyData()));
// byte[][] pri18 = LangUtils.splitAverage(priKeyBytes); // byte[][] pri18 = LangUtils.splitAverage(priKeyBytes);
ECPrivateKeyParameters priKeyParam = BCECUtils.createECPrivateKeyParameters(priKeyBytes); ECPrivateKeyParameters priKeyParam = BCECUtils.createECPrivateKeyParameters(priKeyBytes);
ECDomainParameters domainParams = priKeyParam.getParameters(); ECDomainParameters domainParams = priKeyParam.getParameters();