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
public byte[] encryptByMK(byte[] data) {
public byte[] encryptByTMK(byte[] data) {
return data;
}
@Override
public byte[] decryptByMK(byte[] data) {
public byte[] decryptByTMK(byte[] data) {
return data;
}

View File

@ -45,7 +45,7 @@ public interface SdfApiService {
*/
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())) {
byte[] symKey = sdfApiService.generateRandom(16);
byte[] encSymKey = sdfApiService.encryptByMK(symKey);
byte[] encSymKey = sdfApiService.encryptByTMK(symKey);
record.setKeyData(Hex.toHexString(encSymKey));
String checkHash = Hex.toHexString(sdfApiService.hash(symKey));
record.setCheckValue(checkHash);
} else {
EccKey eccKey = sdfApiService.genKeyPairEcc();
byte[] d = eccKey.getPriKey().getD();
byte[] encD = sdfApiService.encryptByMK(d);
byte[] encD = sdfApiService.encryptByTMK(d);
record.setKeyData(Hex.toHexString(encD));
String checkHash = Hex.toHexString(sdfApiService.hash(d));
record.setCheckValue(checkHash);
@ -392,7 +392,7 @@ public class KeyInfoServiceImpl implements KeyInfoService {
byte[] y = Arrays.copyOfRange(xy, 32, 64);
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);
ECPrivateKeyParameters priKeyParam = BCECUtils.createECPrivateKeyParameters(priKeyBytes);
ECDomainParameters domainParams = priKeyParam.getParameters();