sdf api
This commit is contained in:
@@ -72,12 +72,12 @@ public class LoadBalancedSdfApiService implements SdfApiService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EccSignature externalSign(byte[] privateKey, byte[] pucData) {
|
||||
return externalSignWithId(privateKey, pucData, new byte[0]);
|
||||
public EccSignature externalSignECC(byte[] privateKey, byte[] pucData) {
|
||||
return externalSignWithIdECC(privateKey, pucData, new byte[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EccSignature externalSignWithId(byte[] privateKey, byte[] pucData, byte[] userId) {
|
||||
public EccSignature externalSignWithIdECC(byte[] privateKey, byte[] pucData, byte[] userId) {
|
||||
EccPriKey sdfEccPrivateKey = EccPriKey.fromBytes(privateKey);
|
||||
SM2PreprocessSigner signer = new SM2PreprocessSigner();
|
||||
CipherParameters keyParameters = BCECUtils.createECPrivateKeyParameters(sdfEccPrivateKey.getD());
|
||||
@@ -91,7 +91,7 @@ public class LoadBalancedSdfApiService implements SdfApiService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean externalVerifyWithId(byte[] publicKey, byte[] pubData, byte[] signData, byte[] userId) {
|
||||
public boolean externalVerifyWithIdECC(byte[] publicKey, byte[] pubData, byte[] signData, byte[] userId) {
|
||||
EccPubKey eccPublicKey = EccPubKey.fromBytes(publicKey);
|
||||
CipherParameters parameters = BCECUtils.createECPublicKeyParameters(eccPublicKey.getX(), eccPublicKey.getY());
|
||||
if (userId != null && userId.length > 0) {
|
||||
@@ -107,18 +107,18 @@ public class LoadBalancedSdfApiService implements SdfApiService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean externalVerify(byte[] publicKey, byte[] pubData, byte[] signData) {
|
||||
return externalVerifyWithId(publicKey, pubData, signData, new byte[0]);
|
||||
public boolean externalVerifyECC(byte[] publicKey, byte[] pubData, byte[] signData) {
|
||||
return externalVerifyWithIdECC(publicKey, pubData, signData, new byte[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EccCipher externalEncrypt(byte[] publicKey, byte[] pucData) {
|
||||
public EccCipher externalEncryptECC(byte[] publicKey, byte[] pucData) {
|
||||
EccPubKey eccPublicKey = EccPubKey.fromBytes(publicKey);
|
||||
return apply(s -> s.getSdfApiAdapter().externalEncryptECC(s.getSessionHandle(), eccPublicKey, pucData));
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] externalDecrypt(byte[] privateKey, byte[] encData) {
|
||||
public byte[] externalDecryptECC(byte[] privateKey, byte[] encData) {
|
||||
EccPriKey sdfEccPrivateKey = EccPriKey.fromBytes(privateKey);
|
||||
EccCipher eccCipher = EccCipher.fromBytes(encData);
|
||||
return apply(s -> s.getSdfApiAdapter().externalDecryptECC(s.getSessionHandle(), sdfEccPrivateKey, eccCipher));
|
||||
@@ -128,7 +128,7 @@ public class LoadBalancedSdfApiService implements SdfApiService {
|
||||
public byte[] calculateMAC(byte[] symKey, byte[] pucIv, byte[] pucData) {
|
||||
return apply(s -> {
|
||||
String keyHandle = s.getSdfApiAdapter().importKey(s.getSessionHandle(), symKey);
|
||||
byte[] mac = s.getSdfApiAdapter().calculateMAC(s.getSessionHandle(), keyHandle, AlgId.SGD_SM4_MAC, pucIv, pucData);
|
||||
byte[] mac = s.getSdfApiAdapter().calculateMAC(s.getSessionHandle(), keyHandle, AlgId.SGD_SM4_MAC, pucIv, PaddingUtil.PKCS7Padding(pucData));
|
||||
s.getSdfApiAdapter().destroyKey(s.getSessionHandle(), keyHandle);
|
||||
return mac;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user