fix:jna
This commit is contained in:
-27
@@ -8,9 +8,6 @@ public class EccAgreementSessionKeyRequest {
|
|||||||
private byte[] responseId;
|
private byte[] responseId;
|
||||||
private byte[] responsePublicKeyBlob;
|
private byte[] responsePublicKeyBlob;
|
||||||
private byte[] responseTmpPublicKeyBlob;
|
private byte[] responseTmpPublicKeyBlob;
|
||||||
private int sponsorPublicKeyBufferSize;
|
|
||||||
private int sponsorTmpPublicKeyBufferSize;
|
|
||||||
private int sessionKeyBufferSize;
|
|
||||||
|
|
||||||
public int getIskIndex() {
|
public int getIskIndex() {
|
||||||
return iskIndex;
|
return iskIndex;
|
||||||
@@ -59,28 +56,4 @@ public class EccAgreementSessionKeyRequest {
|
|||||||
public void setResponseTmpPublicKeyBlob(byte[] responseTmpPublicKeyBlob) {
|
public void setResponseTmpPublicKeyBlob(byte[] responseTmpPublicKeyBlob) {
|
||||||
this.responseTmpPublicKeyBlob = responseTmpPublicKeyBlob;
|
this.responseTmpPublicKeyBlob = responseTmpPublicKeyBlob;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSponsorPublicKeyBufferSize() {
|
|
||||||
return sponsorPublicKeyBufferSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSponsorPublicKeyBufferSize(int sponsorPublicKeyBufferSize) {
|
|
||||||
this.sponsorPublicKeyBufferSize = sponsorPublicKeyBufferSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getSponsorTmpPublicKeyBufferSize() {
|
|
||||||
return sponsorTmpPublicKeyBufferSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSponsorTmpPublicKeyBufferSize(int sponsorTmpPublicKeyBufferSize) {
|
|
||||||
this.sponsorTmpPublicKeyBufferSize = sponsorTmpPublicKeyBufferSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getSessionKeyBufferSize() {
|
|
||||||
return sessionKeyBufferSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSessionKeyBufferSize(int sessionKeyBufferSize) {
|
|
||||||
this.sessionKeyBufferSize = sessionKeyBufferSize;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
-9
@@ -5,7 +5,6 @@ public class EccExternalEncryptRequest {
|
|||||||
private int algId;
|
private int algId;
|
||||||
private byte[] publicKeyBlob;
|
private byte[] publicKeyBlob;
|
||||||
private byte[] data;
|
private byte[] data;
|
||||||
private int outBufferSize;
|
|
||||||
|
|
||||||
public int getAlgId() {
|
public int getAlgId() {
|
||||||
return algId;
|
return algId;
|
||||||
@@ -30,12 +29,4 @@ public class EccExternalEncryptRequest {
|
|||||||
public void setData(byte[] data) {
|
public void setData(byte[] data) {
|
||||||
this.data = data;
|
this.data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getOutBufferSize() {
|
|
||||||
return outBufferSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOutBufferSize(int outBufferSize) {
|
|
||||||
this.outBufferSize = outBufferSize;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ public class EccExternalSignRequest {
|
|||||||
private int algId;
|
private int algId;
|
||||||
private byte[] privateKeyBlob;
|
private byte[] privateKeyBlob;
|
||||||
private byte[] data;
|
private byte[] data;
|
||||||
private int signatureBufferSize;
|
|
||||||
|
|
||||||
public int getAlgId() {
|
public int getAlgId() {
|
||||||
return algId;
|
return algId;
|
||||||
@@ -30,12 +29,4 @@ public class EccExternalSignRequest {
|
|||||||
public void setData(byte[] data) {
|
public void setData(byte[] data) {
|
||||||
this.data = data;
|
this.data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSignatureBufferSize() {
|
|
||||||
return signatureBufferSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSignatureBufferSize(int signatureBufferSize) {
|
|
||||||
this.signatureBufferSize = signatureBufferSize;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
-9
@@ -4,7 +4,6 @@ public class EccInternalEncryptRequest {
|
|||||||
|
|
||||||
private int keyIndex;
|
private int keyIndex;
|
||||||
private byte[] data;
|
private byte[] data;
|
||||||
private int outBufferSize;
|
|
||||||
|
|
||||||
public int getKeyIndex() {
|
public int getKeyIndex() {
|
||||||
return keyIndex;
|
return keyIndex;
|
||||||
@@ -21,12 +20,4 @@ public class EccInternalEncryptRequest {
|
|||||||
public void setData(byte[] data) {
|
public void setData(byte[] data) {
|
||||||
this.data = data;
|
this.data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getOutBufferSize() {
|
|
||||||
return outBufferSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOutBufferSize(int outBufferSize) {
|
|
||||||
this.outBufferSize = outBufferSize;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ public class EccInternalSignRequest {
|
|||||||
|
|
||||||
private int keyIndex;
|
private int keyIndex;
|
||||||
private byte[] data;
|
private byte[] data;
|
||||||
private int signatureBufferSize;
|
|
||||||
|
|
||||||
public int getKeyIndex() {
|
public int getKeyIndex() {
|
||||||
return keyIndex;
|
return keyIndex;
|
||||||
@@ -21,12 +20,4 @@ public class EccInternalSignRequest {
|
|||||||
public void setData(byte[] data) {
|
public void setData(byte[] data) {
|
||||||
this.data = data;
|
this.data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSignatureBufferSize() {
|
|
||||||
return signatureBufferSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSignatureBufferSize(int signatureBufferSize) {
|
|
||||||
this.signatureBufferSize = signatureBufferSize;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
-9
@@ -6,7 +6,6 @@ public class ExchangeDigitEnvelopeEccRequest {
|
|||||||
private int algId;
|
private int algId;
|
||||||
private byte[] publicKeyBlob;
|
private byte[] publicKeyBlob;
|
||||||
private byte[] inputEnvelopeBlob;
|
private byte[] inputEnvelopeBlob;
|
||||||
private int outBufferSize;
|
|
||||||
|
|
||||||
public int getKeyIndex() {
|
public int getKeyIndex() {
|
||||||
return keyIndex;
|
return keyIndex;
|
||||||
@@ -39,12 +38,4 @@ public class ExchangeDigitEnvelopeEccRequest {
|
|||||||
public void setInputEnvelopeBlob(byte[] inputEnvelopeBlob) {
|
public void setInputEnvelopeBlob(byte[] inputEnvelopeBlob) {
|
||||||
this.inputEnvelopeBlob = inputEnvelopeBlob;
|
this.inputEnvelopeBlob = inputEnvelopeBlob;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getOutBufferSize() {
|
|
||||||
return outBufferSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOutBufferSize(int outBufferSize) {
|
|
||||||
this.outBufferSize = outBufferSize;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
-18
@@ -8,8 +8,6 @@ public class GenerateAgreementDataAndKeyEccRequest {
|
|||||||
private byte[] sponsorId;
|
private byte[] sponsorId;
|
||||||
private byte[] sponsorPublicKeyBlob;
|
private byte[] sponsorPublicKeyBlob;
|
||||||
private byte[] sponsorTmpPublicKeyBlob;
|
private byte[] sponsorTmpPublicKeyBlob;
|
||||||
private int responsePublicKeyBufferSize;
|
|
||||||
private int responseTmpPublicKeyBufferSize;
|
|
||||||
|
|
||||||
public int getIskIndex() {
|
public int getIskIndex() {
|
||||||
return iskIndex;
|
return iskIndex;
|
||||||
@@ -58,20 +56,4 @@ public class GenerateAgreementDataAndKeyEccRequest {
|
|||||||
public void setSponsorTmpPublicKeyBlob(byte[] sponsorTmpPublicKeyBlob) {
|
public void setSponsorTmpPublicKeyBlob(byte[] sponsorTmpPublicKeyBlob) {
|
||||||
this.sponsorTmpPublicKeyBlob = sponsorTmpPublicKeyBlob;
|
this.sponsorTmpPublicKeyBlob = sponsorTmpPublicKeyBlob;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getResponsePublicKeyBufferSize() {
|
|
||||||
return responsePublicKeyBufferSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setResponsePublicKeyBufferSize(int responsePublicKeyBufferSize) {
|
|
||||||
this.responsePublicKeyBufferSize = responsePublicKeyBufferSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getResponseTmpPublicKeyBufferSize() {
|
|
||||||
return responseTmpPublicKeyBufferSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setResponseTmpPublicKeyBufferSize(int responseTmpPublicKeyBufferSize) {
|
|
||||||
this.responseTmpPublicKeyBufferSize = responseTmpPublicKeyBufferSize;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
-9
@@ -5,7 +5,6 @@ public class GenerateKeyWithEpkEccRequest {
|
|||||||
private int keyBits;
|
private int keyBits;
|
||||||
private int algId;
|
private int algId;
|
||||||
private byte[] publicKeyBlob;
|
private byte[] publicKeyBlob;
|
||||||
private int outBufferSize;
|
|
||||||
|
|
||||||
public int getKeyBits() {
|
public int getKeyBits() {
|
||||||
return keyBits;
|
return keyBits;
|
||||||
@@ -30,12 +29,4 @@ public class GenerateKeyWithEpkEccRequest {
|
|||||||
public void setPublicKeyBlob(byte[] publicKeyBlob) {
|
public void setPublicKeyBlob(byte[] publicKeyBlob) {
|
||||||
this.publicKeyBlob = publicKeyBlob;
|
this.publicKeyBlob = publicKeyBlob;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getOutBufferSize() {
|
|
||||||
return outBufferSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOutBufferSize(int outBufferSize) {
|
|
||||||
this.outBufferSize = outBufferSize;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
-9
@@ -4,7 +4,6 @@ public class GenerateKeyWithIpkEccRequest {
|
|||||||
|
|
||||||
private int ipkIndex;
|
private int ipkIndex;
|
||||||
private int keyBits;
|
private int keyBits;
|
||||||
private int outBufferSize;
|
|
||||||
|
|
||||||
public int getIpkIndex() {
|
public int getIpkIndex() {
|
||||||
return ipkIndex;
|
return ipkIndex;
|
||||||
@@ -21,12 +20,4 @@ public class GenerateKeyWithIpkEccRequest {
|
|||||||
public void setKeyBits(int keyBits) {
|
public void setKeyBits(int keyBits) {
|
||||||
this.keyBits = keyBits;
|
this.keyBits = keyBits;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getOutBufferSize() {
|
|
||||||
return outBufferSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOutBufferSize(int outBufferSize) {
|
|
||||||
this.outBufferSize = outBufferSize;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
-18
@@ -4,8 +4,6 @@ public class GenerateStandardEccKeyPairRequest {
|
|||||||
|
|
||||||
private int algId;
|
private int algId;
|
||||||
private int keyBits;
|
private int keyBits;
|
||||||
private int publicKeyBufferSize;
|
|
||||||
private int privateKeyBufferSize;
|
|
||||||
|
|
||||||
public int getAlgId() {
|
public int getAlgId() {
|
||||||
return algId;
|
return algId;
|
||||||
@@ -22,20 +20,4 @@ public class GenerateStandardEccKeyPairRequest {
|
|||||||
public void setKeyBits(int keyBits) {
|
public void setKeyBits(int keyBits) {
|
||||||
this.keyBits = keyBits;
|
this.keyBits = keyBits;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPublicKeyBufferSize() {
|
|
||||||
return publicKeyBufferSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPublicKeyBufferSize(int publicKeyBufferSize) {
|
|
||||||
this.publicKeyBufferSize = publicKeyBufferSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPrivateKeyBufferSize() {
|
|
||||||
return privateKeyBufferSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPrivateKeyBufferSize(int privateKeyBufferSize) {
|
|
||||||
this.privateKeyBufferSize = privateKeyBufferSize;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
-18
@@ -3,8 +3,6 @@ package com.cisd.tms.integration.crypto.pcie.model;
|
|||||||
public class GenerateStandardRsaKeyPairRequest {
|
public class GenerateStandardRsaKeyPairRequest {
|
||||||
|
|
||||||
private int keyBits;
|
private int keyBits;
|
||||||
private int publicKeyBufferSize;
|
|
||||||
private int privateKeyBufferSize;
|
|
||||||
|
|
||||||
public int getKeyBits() {
|
public int getKeyBits() {
|
||||||
return keyBits;
|
return keyBits;
|
||||||
@@ -13,20 +11,4 @@ public class GenerateStandardRsaKeyPairRequest {
|
|||||||
public void setKeyBits(int keyBits) {
|
public void setKeyBits(int keyBits) {
|
||||||
this.keyBits = keyBits;
|
this.keyBits = keyBits;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPublicKeyBufferSize() {
|
|
||||||
return publicKeyBufferSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPublicKeyBufferSize(int publicKeyBufferSize) {
|
|
||||||
this.publicKeyBufferSize = publicKeyBufferSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPrivateKeyBufferSize() {
|
|
||||||
return privateKeyBufferSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPrivateKeyBufferSize(int privateKeyBufferSize) {
|
|
||||||
this.privateKeyBufferSize = privateKeyBufferSize;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ public class IkSignRequest {
|
|||||||
|
|
||||||
private int keyType;
|
private int keyType;
|
||||||
private byte[] data;
|
private byte[] data;
|
||||||
private int signatureBufferSize;
|
|
||||||
|
|
||||||
public int getKeyType() {
|
public int getKeyType() {
|
||||||
return keyType;
|
return keyType;
|
||||||
@@ -21,12 +20,4 @@ public class IkSignRequest {
|
|||||||
public void setData(byte[] data) {
|
public void setData(byte[] data) {
|
||||||
this.data = data;
|
this.data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSignatureBufferSize() {
|
|
||||||
return signatureBufferSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSignatureBufferSize(int signatureBufferSize) {
|
|
||||||
this.signatureBufferSize = signatureBufferSize;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-263
@@ -68,7 +68,6 @@ import com.cisd.tms.integration.crypto.pcie.model.IkSignRequest;
|
|||||||
import com.cisd.tms.integration.crypto.pcie.model.IkVerifyRequest;
|
import com.cisd.tms.integration.crypto.pcie.model.IkVerifyRequest;
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.KekComponentRequest;
|
import com.cisd.tms.integration.crypto.pcie.model.KekComponentRequest;
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.KeyStatusResult;
|
import com.cisd.tms.integration.crypto.pcie.model.KeyStatusResult;
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.LoginStatusResult;
|
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.MacCalcRequest;
|
import com.cisd.tms.integration.crypto.pcie.model.MacCalcRequest;
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.PrivateKeyAccessRequest;
|
import com.cisd.tms.integration.crypto.pcie.model.PrivateKeyAccessRequest;
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.RecoverKekRequest;
|
import com.cisd.tms.integration.crypto.pcie.model.RecoverKekRequest;
|
||||||
@@ -79,10 +78,6 @@ import com.cisd.tms.integration.crypto.pcie.model.RsaInternalKeyOpRequest;
|
|||||||
import com.cisd.tms.integration.crypto.pcie.model.SymmetricCryptoRequest;
|
import com.cisd.tms.integration.crypto.pcie.model.SymmetricCryptoRequest;
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.SymmetricKekCryptoRequest;
|
import com.cisd.tms.integration.crypto.pcie.model.SymmetricKekCryptoRequest;
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.StandardKeyPairResult;
|
import com.cisd.tms.integration.crypto.pcie.model.StandardKeyPairResult;
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.UkeyGenerateRequest;
|
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.UkeyLoginRequest;
|
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.UkeyPinChangeRequest;
|
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.UkeyUnlockRequest;
|
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.UpdateBackedKeyRequest;
|
import com.cisd.tms.integration.crypto.pcie.model.UpdateBackedKeyRequest;
|
||||||
import com.sun.jna.Memory;
|
import com.sun.jna.Memory;
|
||||||
import com.sun.jna.Pointer;
|
import com.sun.jna.Pointer;
|
||||||
@@ -99,8 +94,6 @@ public class JnaPcieCryptoService implements PcieCryptoService {
|
|||||||
private static final int SDFE_INIT_STATUS_LOW_BYTE = 0x25;
|
private static final int SDFE_INIT_STATUS_LOW_BYTE = 0x25;
|
||||||
private static final int IK_KEY_TYPE_DEVICE = 1;
|
private static final int IK_KEY_TYPE_DEVICE = 1;
|
||||||
private static final int IK_KEY_TYPE_AUTH = 2;
|
private static final int IK_KEY_TYPE_AUTH = 2;
|
||||||
private static final int ADMIN_INDEX_MIN = 1;
|
|
||||||
private static final int ADMIN_INDEX_MAX = 3;
|
|
||||||
private static final int HMAC_MAX_LENGTH = 64;
|
private static final int HMAC_MAX_LENGTH = 64;
|
||||||
private static final int ECC_CIPHER_PREFIX_LENGTH = (EccRefPublicKey.MAX_LEN * 2) + 32 + Integer.BYTES;
|
private static final int ECC_CIPHER_PREFIX_LENGTH = (EccRefPublicKey.MAX_LEN * 2) + 32 + Integer.BYTES;
|
||||||
|
|
||||||
@@ -678,15 +671,11 @@ public class JnaPcieCryptoService implements PcieCryptoService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BackupDataResult exportSignPublicKeyRsa(int keyIndex, int outBufferSize) {
|
public BackupDataResult exportSignPublicKeyRsa(int keyIndex) {
|
||||||
int safeKeyIndex = requireNonNegative("keyIndex", keyIndex);
|
int safeKeyIndex = requireNonNegative("keyIndex", keyIndex);
|
||||||
int size = requirePositive("outBufferSize", outBufferSize);
|
|
||||||
|
|
||||||
return sessionTemplate.withSession("SDF_ExportSignPublicKey_RSA", (lib, deviceHandle, sessionHandle) -> {
|
return sessionTemplate.withSession("SDF_ExportSignPublicKey_RSA", (lib, deviceHandle, sessionHandle) -> {
|
||||||
RsaRefPublicKey out = new RsaRefPublicKey();
|
RsaRefPublicKey out = new RsaRefPublicKey();
|
||||||
if (size < out.size()) {
|
|
||||||
throw new IllegalArgumentException("outBufferSize must be >= " + out.size());
|
|
||||||
}
|
|
||||||
sessionTemplate.ensureSuccess(
|
sessionTemplate.ensureSuccess(
|
||||||
"SDF_ExportSignPublicKey_RSA",
|
"SDF_ExportSignPublicKey_RSA",
|
||||||
lib.SDF_ExportSignPublicKey_RSA(sessionHandle, safeKeyIndex, out)
|
lib.SDF_ExportSignPublicKey_RSA(sessionHandle, safeKeyIndex, out)
|
||||||
@@ -697,15 +686,11 @@ public class JnaPcieCryptoService implements PcieCryptoService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BackupDataResult exportEncPublicKeyRsa(int keyIndex, int outBufferSize) {
|
public BackupDataResult exportEncPublicKeyRsa(int keyIndex) {
|
||||||
int safeKeyIndex = requireNonNegative("keyIndex", keyIndex);
|
int safeKeyIndex = requireNonNegative("keyIndex", keyIndex);
|
||||||
int size = requirePositive("outBufferSize", outBufferSize);
|
|
||||||
|
|
||||||
return sessionTemplate.withSession("SDF_ExportEncPublicKey_RSA", (lib, deviceHandle, sessionHandle) -> {
|
return sessionTemplate.withSession("SDF_ExportEncPublicKey_RSA", (lib, deviceHandle, sessionHandle) -> {
|
||||||
RsaRefPublicKey out = new RsaRefPublicKey();
|
RsaRefPublicKey out = new RsaRefPublicKey();
|
||||||
if (size < out.size()) {
|
|
||||||
throw new IllegalArgumentException("outBufferSize must be >= " + out.size());
|
|
||||||
}
|
|
||||||
sessionTemplate.ensureSuccess(
|
sessionTemplate.ensureSuccess(
|
||||||
"SDF_ExportEncPublicKey_RSA",
|
"SDF_ExportEncPublicKey_RSA",
|
||||||
lib.SDF_ExportEncPublicKey_RSA(sessionHandle, safeKeyIndex, out)
|
lib.SDF_ExportEncPublicKey_RSA(sessionHandle, safeKeyIndex, out)
|
||||||
@@ -716,15 +701,11 @@ public class JnaPcieCryptoService implements PcieCryptoService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BackupDataResult exportSignPublicKeyEcc(int keyIndex, int outBufferSize) {
|
public BackupDataResult exportSignPublicKeyEcc(int keyIndex) {
|
||||||
int safeKeyIndex = requireNonNegative("keyIndex", keyIndex);
|
int safeKeyIndex = requireNonNegative("keyIndex", keyIndex);
|
||||||
int size = requirePositive("outBufferSize", outBufferSize);
|
|
||||||
|
|
||||||
return sessionTemplate.withSession("SDF_ExportSignPublicKey_ECC", (lib, deviceHandle, sessionHandle) -> {
|
return sessionTemplate.withSession("SDF_ExportSignPublicKey_ECC", (lib, deviceHandle, sessionHandle) -> {
|
||||||
EccRefPublicKey out = new EccRefPublicKey();
|
EccRefPublicKey out = new EccRefPublicKey();
|
||||||
if (size < out.size()) {
|
|
||||||
throw new IllegalArgumentException("outBufferSize must be >= " + out.size());
|
|
||||||
}
|
|
||||||
sessionTemplate.ensureSuccess(
|
sessionTemplate.ensureSuccess(
|
||||||
"SDF_ExportSignPublicKey_ECC",
|
"SDF_ExportSignPublicKey_ECC",
|
||||||
lib.SDF_ExportSignPublicKey_ECC(sessionHandle, safeKeyIndex, out)
|
lib.SDF_ExportSignPublicKey_ECC(sessionHandle, safeKeyIndex, out)
|
||||||
@@ -735,15 +716,11 @@ public class JnaPcieCryptoService implements PcieCryptoService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BackupDataResult exportEncPublicKeyEcc(int keyIndex, int outBufferSize) {
|
public BackupDataResult exportEncPublicKeyEcc(int keyIndex) {
|
||||||
int safeKeyIndex = requireNonNegative("keyIndex", keyIndex);
|
int safeKeyIndex = requireNonNegative("keyIndex", keyIndex);
|
||||||
int size = requirePositive("outBufferSize", outBufferSize);
|
|
||||||
|
|
||||||
return sessionTemplate.withSession("SDF_ExportEncPublicKey_ECC", (lib, deviceHandle, sessionHandle) -> {
|
return sessionTemplate.withSession("SDF_ExportEncPublicKey_ECC", (lib, deviceHandle, sessionHandle) -> {
|
||||||
EccRefPublicKey out = new EccRefPublicKey();
|
EccRefPublicKey out = new EccRefPublicKey();
|
||||||
if (size < out.size()) {
|
|
||||||
throw new IllegalArgumentException("outBufferSize must be >= " + out.size());
|
|
||||||
}
|
|
||||||
sessionTemplate.ensureSuccess(
|
sessionTemplate.ensureSuccess(
|
||||||
"SDF_ExportEncPublicKey_ECC",
|
"SDF_ExportEncPublicKey_ECC",
|
||||||
lib.SDF_ExportEncPublicKey_ECC(sessionHandle, safeKeyIndex, out)
|
lib.SDF_ExportEncPublicKey_ECC(sessionHandle, safeKeyIndex, out)
|
||||||
@@ -754,15 +731,11 @@ public class JnaPcieCryptoService implements PcieCryptoService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BackupDataResult exportIkPublicKey(int keyType, int outBufferSize) {
|
public BackupDataResult exportIkPublicKey(int keyType) {
|
||||||
int safeKeyType = requireNonNegative("keyType", keyType);
|
int safeKeyType = requireNonNegative("keyType", keyType);
|
||||||
int size = requirePositive("outBufferSize", outBufferSize);
|
|
||||||
|
|
||||||
return sessionTemplate.withSession("SDFE_ExportIKPublicKey", (lib, deviceHandle, sessionHandle) -> {
|
return sessionTemplate.withSession("SDFE_ExportIKPublicKey", (lib, deviceHandle, sessionHandle) -> {
|
||||||
EccRefPublicKey out = new EccRefPublicKey();
|
EccRefPublicKey out = new EccRefPublicKey();
|
||||||
if (size < out.size()) {
|
|
||||||
throw new IllegalArgumentException("outBufferSize must be >= " + out.size());
|
|
||||||
}
|
|
||||||
sessionTemplate.ensureSuccess(
|
sessionTemplate.ensureSuccess(
|
||||||
"SDFE_ExportIKPublicKey",
|
"SDFE_ExportIKPublicKey",
|
||||||
lib.SDFE_ExportIKPublicKey(sessionHandle, safeKeyType, out)
|
lib.SDFE_ExportIKPublicKey(sessionHandle, safeKeyType, out)
|
||||||
@@ -790,18 +763,10 @@ public class JnaPcieCryptoService implements PcieCryptoService {
|
|||||||
public StandardKeyPairResult generateStandardRsaKeyPair(GenerateStandardRsaKeyPairRequest request) {
|
public StandardKeyPairResult generateStandardRsaKeyPair(GenerateStandardRsaKeyPairRequest request) {
|
||||||
GenerateStandardRsaKeyPairRequest req = requireRequest("request", request);
|
GenerateStandardRsaKeyPairRequest req = requireRequest("request", request);
|
||||||
int keyBits = requirePositive("keyBits", req.getKeyBits());
|
int keyBits = requirePositive("keyBits", req.getKeyBits());
|
||||||
int publicKeySize = requirePositive("publicKeyBufferSize", req.getPublicKeyBufferSize());
|
|
||||||
int privateKeySize = requirePositive("privateKeyBufferSize", req.getPrivateKeyBufferSize());
|
|
||||||
|
|
||||||
return sessionTemplate.withSession("SDF_GenerateKeyPair_RSA", (lib, deviceHandle, sessionHandle) -> {
|
return sessionTemplate.withSession("SDF_GenerateKeyPair_RSA", (lib, deviceHandle, sessionHandle) -> {
|
||||||
RsaRefPublicKey publicKey = new RsaRefPublicKey();
|
RsaRefPublicKey publicKey = new RsaRefPublicKey();
|
||||||
RsaRefPrivateKey privateKey = new RsaRefPrivateKey();
|
RsaRefPrivateKey privateKey = new RsaRefPrivateKey();
|
||||||
if (publicKeySize < publicKey.size()) {
|
|
||||||
throw new IllegalArgumentException("publicKeyBufferSize must be >= " + publicKey.size());
|
|
||||||
}
|
|
||||||
if (privateKeySize < privateKey.size()) {
|
|
||||||
throw new IllegalArgumentException("privateKeyBufferSize must be >= " + privateKey.size());
|
|
||||||
}
|
|
||||||
sessionTemplate.ensureSuccess(
|
sessionTemplate.ensureSuccess(
|
||||||
"SDF_GenerateKeyPair_RSA",
|
"SDF_GenerateKeyPair_RSA",
|
||||||
lib.SDF_GenerateKeyPair_RSA(sessionHandle, keyBits, publicKey, privateKey)
|
lib.SDF_GenerateKeyPair_RSA(sessionHandle, keyBits, publicKey, privateKey)
|
||||||
@@ -815,18 +780,10 @@ public class JnaPcieCryptoService implements PcieCryptoService {
|
|||||||
GenerateStandardEccKeyPairRequest req = requireRequest("request", request);
|
GenerateStandardEccKeyPairRequest req = requireRequest("request", request);
|
||||||
int algId = requireValidAlgId("algId", req.getAlgId());
|
int algId = requireValidAlgId("algId", req.getAlgId());
|
||||||
int keyBits = requirePositive("keyBits", req.getKeyBits());
|
int keyBits = requirePositive("keyBits", req.getKeyBits());
|
||||||
int publicKeySize = requirePositive("publicKeyBufferSize", req.getPublicKeyBufferSize());
|
|
||||||
int privateKeySize = requirePositive("privateKeyBufferSize", req.getPrivateKeyBufferSize());
|
|
||||||
|
|
||||||
return sessionTemplate.withSession("SDF_GenerateKeyPair_ECC", (lib, deviceHandle, sessionHandle) -> {
|
return sessionTemplate.withSession("SDF_GenerateKeyPair_ECC", (lib, deviceHandle, sessionHandle) -> {
|
||||||
EccRefPublicKey publicKey = new EccRefPublicKey();
|
EccRefPublicKey publicKey = new EccRefPublicKey();
|
||||||
EccRefPrivateKey privateKey = new EccRefPrivateKey();
|
EccRefPrivateKey privateKey = new EccRefPrivateKey();
|
||||||
if (publicKeySize < publicKey.size()) {
|
|
||||||
throw new IllegalArgumentException("publicKeyBufferSize must be >= " + publicKey.size());
|
|
||||||
}
|
|
||||||
if (privateKeySize < privateKey.size()) {
|
|
||||||
throw new IllegalArgumentException("privateKeyBufferSize must be >= " + privateKey.size());
|
|
||||||
}
|
|
||||||
sessionTemplate.ensureSuccess(
|
sessionTemplate.ensureSuccess(
|
||||||
"SDF_GenerateKeyPair_ECC",
|
"SDF_GenerateKeyPair_ECC",
|
||||||
lib.SDF_GenerateKeyPair_ECC(sessionHandle, algId, keyBits, publicKey, privateKey)
|
lib.SDF_GenerateKeyPair_ECC(sessionHandle, algId, keyBits, publicKey, privateKey)
|
||||||
@@ -1055,13 +1012,9 @@ public class JnaPcieCryptoService implements PcieCryptoService {
|
|||||||
GenerateKeyWithIpkEccRequest req = requireRequest("request", request);
|
GenerateKeyWithIpkEccRequest req = requireRequest("request", request);
|
||||||
int ipkIndex = requireNonNegative("ipkIndex", req.getIpkIndex());
|
int ipkIndex = requireNonNegative("ipkIndex", req.getIpkIndex());
|
||||||
int keyBits = requirePositive("keyBits", req.getKeyBits());
|
int keyBits = requirePositive("keyBits", req.getKeyBits());
|
||||||
int outBufferSize = requirePositive("outBufferSize", req.getOutBufferSize());
|
|
||||||
|
|
||||||
return sessionTemplate.withSession("SDF_GenerateKeyWithIPK_ECC", (lib, deviceHandle, sessionHandle) -> {
|
return sessionTemplate.withSession("SDF_GenerateKeyWithIPK_ECC", (lib, deviceHandle, sessionHandle) -> {
|
||||||
EccCipher encryptedKey = new EccCipher();
|
EccCipher encryptedKey = new EccCipher();
|
||||||
if (outBufferSize < encryptedKey.size()) {
|
|
||||||
throw new IllegalArgumentException("outBufferSize must be >= " + encryptedKey.size());
|
|
||||||
}
|
|
||||||
PointerByReference keyHandleRef = new PointerByReference();
|
PointerByReference keyHandleRef = new PointerByReference();
|
||||||
sessionTemplate.ensureSuccess(
|
sessionTemplate.ensureSuccess(
|
||||||
"SDF_GenerateKeyWithIPK_ECC",
|
"SDF_GenerateKeyWithIPK_ECC",
|
||||||
@@ -1088,13 +1041,9 @@ public class JnaPcieCryptoService implements PcieCryptoService {
|
|||||||
int keyBits = requirePositive("keyBits", req.getKeyBits());
|
int keyBits = requirePositive("keyBits", req.getKeyBits());
|
||||||
int algId = requireValidAlgId("algId", req.getAlgId());
|
int algId = requireValidAlgId("algId", req.getAlgId());
|
||||||
EccRefPublicKey publicKeyBlob = toEccRefPublicKey("publicKeyBlob", req.getPublicKeyBlob());
|
EccRefPublicKey publicKeyBlob = toEccRefPublicKey("publicKeyBlob", req.getPublicKeyBlob());
|
||||||
int outBufferSize = requirePositive("outBufferSize", req.getOutBufferSize());
|
|
||||||
|
|
||||||
return sessionTemplate.withSession("SDF_GenerateKeyWithEPK_ECC", (lib, deviceHandle, sessionHandle) -> {
|
return sessionTemplate.withSession("SDF_GenerateKeyWithEPK_ECC", (lib, deviceHandle, sessionHandle) -> {
|
||||||
EccCipher encryptedKey = new EccCipher();
|
EccCipher encryptedKey = new EccCipher();
|
||||||
if (outBufferSize < encryptedKey.size()) {
|
|
||||||
throw new IllegalArgumentException("outBufferSize must be >= " + encryptedKey.size());
|
|
||||||
}
|
|
||||||
PointerByReference keyHandleRef = new PointerByReference();
|
PointerByReference keyHandleRef = new PointerByReference();
|
||||||
sessionTemplate.ensureSuccess(
|
sessionTemplate.ensureSuccess(
|
||||||
"SDF_GenerateKeyWithEPK_ECC",
|
"SDF_GenerateKeyWithEPK_ECC",
|
||||||
@@ -1167,13 +1116,9 @@ public class JnaPcieCryptoService implements PcieCryptoService {
|
|||||||
int algId = requireValidAlgId("algId", req.getAlgId());
|
int algId = requireValidAlgId("algId", req.getAlgId());
|
||||||
EccRefPublicKey publicKeyBlob = toEccRefPublicKey("publicKeyBlob", req.getPublicKeyBlob());
|
EccRefPublicKey publicKeyBlob = toEccRefPublicKey("publicKeyBlob", req.getPublicKeyBlob());
|
||||||
EccCipher inputEnvelopeBlob = toEccCipher("inputEnvelopeBlob", req.getInputEnvelopeBlob());
|
EccCipher inputEnvelopeBlob = toEccCipher("inputEnvelopeBlob", req.getInputEnvelopeBlob());
|
||||||
int outBufferSize = requirePositive("outBufferSize", req.getOutBufferSize());
|
|
||||||
|
|
||||||
return sessionTemplate.withSession("SDF_ExchangeDigitEnvelopeBaseOnECC", (lib, deviceHandle, sessionHandle) -> {
|
return sessionTemplate.withSession("SDF_ExchangeDigitEnvelopeBaseOnECC", (lib, deviceHandle, sessionHandle) -> {
|
||||||
EccCipher outputEnvelopeBlob = new EccCipher();
|
EccCipher outputEnvelopeBlob = new EccCipher();
|
||||||
if (outBufferSize < outputEnvelopeBlob.size()) {
|
|
||||||
throw new IllegalArgumentException("outBufferSize must be >= " + outputEnvelopeBlob.size());
|
|
||||||
}
|
|
||||||
sessionTemplate.ensureSuccess(
|
sessionTemplate.ensureSuccess(
|
||||||
"SDF_ExchangeDigitEnvelopeBaseOnECC",
|
"SDF_ExchangeDigitEnvelopeBaseOnECC",
|
||||||
lib.SDF_ExchangeDigitEnvelopeBaseOnECC(
|
lib.SDF_ExchangeDigitEnvelopeBaseOnECC(
|
||||||
@@ -1199,18 +1144,10 @@ public class JnaPcieCryptoService implements PcieCryptoService {
|
|||||||
byte[] sponsorId = requireNonEmptyBytes("sponsorId", req.getSponsorId());
|
byte[] sponsorId = requireNonEmptyBytes("sponsorId", req.getSponsorId());
|
||||||
EccRefPublicKey sponsorPublicKey = toEccRefPublicKey("sponsorPublicKeyBlob", req.getSponsorPublicKeyBlob());
|
EccRefPublicKey sponsorPublicKey = toEccRefPublicKey("sponsorPublicKeyBlob", req.getSponsorPublicKeyBlob());
|
||||||
EccRefPublicKey sponsorTmpPublicKey = toEccRefPublicKey("sponsorTmpPublicKeyBlob", req.getSponsorTmpPublicKeyBlob());
|
EccRefPublicKey sponsorTmpPublicKey = toEccRefPublicKey("sponsorTmpPublicKeyBlob", req.getSponsorTmpPublicKeyBlob());
|
||||||
int responsePublicKeySize = requirePositive("responsePublicKeyBufferSize", req.getResponsePublicKeyBufferSize());
|
|
||||||
int responseTmpPublicKeySize = requirePositive("responseTmpPublicKeyBufferSize", req.getResponseTmpPublicKeyBufferSize());
|
|
||||||
|
|
||||||
return sessionTemplate.withSession("SDF_GenerateAgreementDataAndKeyWithECC", (lib, deviceHandle, sessionHandle) -> {
|
return sessionTemplate.withSession("SDF_GenerateAgreementDataAndKeyWithECC", (lib, deviceHandle, sessionHandle) -> {
|
||||||
EccRefPublicKey responsePublicKey = new EccRefPublicKey();
|
EccRefPublicKey responsePublicKey = new EccRefPublicKey();
|
||||||
EccRefPublicKey responseTmpPublicKey = new EccRefPublicKey();
|
EccRefPublicKey responseTmpPublicKey = new EccRefPublicKey();
|
||||||
if (responsePublicKeySize < responsePublicKey.size()) {
|
|
||||||
throw new IllegalArgumentException("responsePublicKeyBufferSize must be >= " + responsePublicKey.size());
|
|
||||||
}
|
|
||||||
if (responseTmpPublicKeySize < responseTmpPublicKey.size()) {
|
|
||||||
throw new IllegalArgumentException("responseTmpPublicKeyBufferSize must be >= " + responseTmpPublicKey.size());
|
|
||||||
}
|
|
||||||
PointerByReference keyHandleRef = new PointerByReference();
|
PointerByReference keyHandleRef = new PointerByReference();
|
||||||
sessionTemplate.ensureSuccess(
|
sessionTemplate.ensureSuccess(
|
||||||
"SDF_GenerateAgreementDataAndKeyWithECC",
|
"SDF_GenerateAgreementDataAndKeyWithECC",
|
||||||
@@ -1254,19 +1191,10 @@ public class JnaPcieCryptoService implements PcieCryptoService {
|
|||||||
byte[] responseId = requireNonEmptyBytes("responseId", req.getResponseId());
|
byte[] responseId = requireNonEmptyBytes("responseId", req.getResponseId());
|
||||||
EccRefPublicKey responsePublicKey = toEccRefPublicKey("responsePublicKeyBlob", req.getResponsePublicKeyBlob());
|
EccRefPublicKey responsePublicKey = toEccRefPublicKey("responsePublicKeyBlob", req.getResponsePublicKeyBlob());
|
||||||
EccRefPublicKey responseTmpPublicKey = toEccRefPublicKey("responseTmpPublicKeyBlob", req.getResponseTmpPublicKeyBlob());
|
EccRefPublicKey responseTmpPublicKey = toEccRefPublicKey("responseTmpPublicKeyBlob", req.getResponseTmpPublicKeyBlob());
|
||||||
int sponsorPublicKeySize = requirePositive("sponsorPublicKeyBufferSize", req.getSponsorPublicKeyBufferSize());
|
|
||||||
int sponsorTmpPublicKeySize = requirePositive("sponsorTmpPublicKeyBufferSize", req.getSponsorTmpPublicKeyBufferSize());
|
|
||||||
requirePositive("sessionKeyBufferSize", req.getSessionKeyBufferSize());
|
|
||||||
|
|
||||||
return sessionTemplate.withSession("SDF_GenerateAgreementDataWithECC+SDF_GenerateKeyWithECC", (lib, deviceHandle, sessionHandle) -> {
|
return sessionTemplate.withSession("SDF_GenerateAgreementDataWithECC+SDF_GenerateKeyWithECC", (lib, deviceHandle, sessionHandle) -> {
|
||||||
EccRefPublicKey sponsorPublicKey = new EccRefPublicKey();
|
EccRefPublicKey sponsorPublicKey = new EccRefPublicKey();
|
||||||
EccRefPublicKey sponsorTmpPublicKey = new EccRefPublicKey();
|
EccRefPublicKey sponsorTmpPublicKey = new EccRefPublicKey();
|
||||||
if (sponsorPublicKeySize < sponsorPublicKey.size()) {
|
|
||||||
throw new IllegalArgumentException("sponsorPublicKeyBufferSize must be >= " + sponsorPublicKey.size());
|
|
||||||
}
|
|
||||||
if (sponsorTmpPublicKeySize < sponsorTmpPublicKey.size()) {
|
|
||||||
throw new IllegalArgumentException("sponsorTmpPublicKeyBufferSize must be >= " + sponsorTmpPublicKey.size());
|
|
||||||
}
|
|
||||||
PointerByReference agreementHandleRef = new PointerByReference();
|
PointerByReference agreementHandleRef = new PointerByReference();
|
||||||
sessionTemplate.ensureSuccess(
|
sessionTemplate.ensureSuccess(
|
||||||
"SDF_GenerateAgreementDataWithECC",
|
"SDF_GenerateAgreementDataWithECC",
|
||||||
@@ -1326,13 +1254,9 @@ public class JnaPcieCryptoService implements PcieCryptoService {
|
|||||||
EccInternalSignRequest req = requireRequest("request", request);
|
EccInternalSignRequest req = requireRequest("request", request);
|
||||||
int keyIndex = requireNonNegative("keyIndex", req.getKeyIndex());
|
int keyIndex = requireNonNegative("keyIndex", req.getKeyIndex());
|
||||||
byte[] data = requireBytes("data", req.getData());
|
byte[] data = requireBytes("data", req.getData());
|
||||||
int signatureBufferSize = requirePositive("signatureBufferSize", req.getSignatureBufferSize());
|
|
||||||
|
|
||||||
return sessionTemplate.withSession("SDF_InternalSign_ECC", (lib, deviceHandle, sessionHandle) -> {
|
return sessionTemplate.withSession("SDF_InternalSign_ECC", (lib, deviceHandle, sessionHandle) -> {
|
||||||
EccSignature signature = new EccSignature();
|
EccSignature signature = new EccSignature();
|
||||||
if (signatureBufferSize < signature.size()) {
|
|
||||||
throw new IllegalArgumentException("signatureBufferSize must be >= " + signature.size());
|
|
||||||
}
|
|
||||||
sessionTemplate.ensureSuccess(
|
sessionTemplate.ensureSuccess(
|
||||||
"SDF_InternalSign_ECC",
|
"SDF_InternalSign_ECC",
|
||||||
lib.SDF_InternalSign_ECC(sessionHandle, keyIndex, data, data.length, signature)
|
lib.SDF_InternalSign_ECC(sessionHandle, keyIndex, data, data.length, signature)
|
||||||
@@ -1347,13 +1271,9 @@ public class JnaPcieCryptoService implements PcieCryptoService {
|
|||||||
IkSignRequest req = requireRequest("request", request);
|
IkSignRequest req = requireRequest("request", request);
|
||||||
int keyType = requireNonNegative("keyType", req.getKeyType());
|
int keyType = requireNonNegative("keyType", req.getKeyType());
|
||||||
byte[] data = requireBytes("data", req.getData());
|
byte[] data = requireBytes("data", req.getData());
|
||||||
int signatureBufferSize = requirePositive("signatureBufferSize", req.getSignatureBufferSize());
|
|
||||||
|
|
||||||
return sessionTemplate.withSession("SDFE_SignIK", (lib, deviceHandle, sessionHandle) -> {
|
return sessionTemplate.withSession("SDFE_SignIK", (lib, deviceHandle, sessionHandle) -> {
|
||||||
EccSignature signature = new EccSignature();
|
EccSignature signature = new EccSignature();
|
||||||
if (signatureBufferSize < signature.size()) {
|
|
||||||
throw new IllegalArgumentException("signatureBufferSize must be >= " + signature.size());
|
|
||||||
}
|
|
||||||
sessionTemplate.ensureSuccess(
|
sessionTemplate.ensureSuccess(
|
||||||
"SDFE_SignIK",
|
"SDFE_SignIK",
|
||||||
lib.SDFE_SignIK(sessionHandle, keyType, data, data.length, signature)
|
lib.SDFE_SignIK(sessionHandle, keyType, data, data.length, signature)
|
||||||
@@ -1369,13 +1289,9 @@ public class JnaPcieCryptoService implements PcieCryptoService {
|
|||||||
int algId = requireValidAlgId("algId", req.getAlgId());
|
int algId = requireValidAlgId("algId", req.getAlgId());
|
||||||
EccRefPrivateKey privateKeyBlob = toEccRefPrivateKey("privateKeyBlob", req.getPrivateKeyBlob());
|
EccRefPrivateKey privateKeyBlob = toEccRefPrivateKey("privateKeyBlob", req.getPrivateKeyBlob());
|
||||||
byte[] data = requireBytes("data", req.getData());
|
byte[] data = requireBytes("data", req.getData());
|
||||||
int signatureBufferSize = requirePositive("signatureBufferSize", req.getSignatureBufferSize());
|
|
||||||
|
|
||||||
return sessionTemplate.withSession("SDF_ExternalSign_ECC", (lib, deviceHandle, sessionHandle) -> {
|
return sessionTemplate.withSession("SDF_ExternalSign_ECC", (lib, deviceHandle, sessionHandle) -> {
|
||||||
EccSignature signature = new EccSignature();
|
EccSignature signature = new EccSignature();
|
||||||
if (signatureBufferSize < signature.size()) {
|
|
||||||
throw new IllegalArgumentException("signatureBufferSize must be >= " + signature.size());
|
|
||||||
}
|
|
||||||
sessionTemplate.ensureSuccess(
|
sessionTemplate.ensureSuccess(
|
||||||
"SDF_ExternalSign_ECC",
|
"SDF_ExternalSign_ECC",
|
||||||
lib.SDF_ExternalSign_ECC(sessionHandle, algId, privateKeyBlob, data, data.length, signature)
|
lib.SDF_ExternalSign_ECC(sessionHandle, algId, privateKeyBlob, data, data.length, signature)
|
||||||
@@ -1440,13 +1356,9 @@ public class JnaPcieCryptoService implements PcieCryptoService {
|
|||||||
int algId = requireValidAlgId("algId", req.getAlgId());
|
int algId = requireValidAlgId("algId", req.getAlgId());
|
||||||
EccRefPublicKey publicKeyBlob = toEccRefPublicKey("publicKeyBlob", req.getPublicKeyBlob());
|
EccRefPublicKey publicKeyBlob = toEccRefPublicKey("publicKeyBlob", req.getPublicKeyBlob());
|
||||||
byte[] data = requireBytes("data", req.getData());
|
byte[] data = requireBytes("data", req.getData());
|
||||||
int outBufferSize = requirePositive("outBufferSize", req.getOutBufferSize());
|
|
||||||
|
|
||||||
return sessionTemplate.withSession("SDF_ExternalEncrypt_ECC", (lib, deviceHandle, sessionHandle) -> {
|
return sessionTemplate.withSession("SDF_ExternalEncrypt_ECC", (lib, deviceHandle, sessionHandle) -> {
|
||||||
EccCipher encrypted = new EccCipher();
|
EccCipher encrypted = new EccCipher();
|
||||||
if (outBufferSize < encrypted.size()) {
|
|
||||||
throw new IllegalArgumentException("outBufferSize must be >= " + encrypted.size());
|
|
||||||
}
|
|
||||||
sessionTemplate.ensureSuccess(
|
sessionTemplate.ensureSuccess(
|
||||||
"SDF_ExternalEncrypt_ECC",
|
"SDF_ExternalEncrypt_ECC",
|
||||||
lib.SDF_ExternalEncrypt_ECC(sessionHandle, algId, publicKeyBlob, data, data.length, encrypted)
|
lib.SDF_ExternalEncrypt_ECC(sessionHandle, algId, publicKeyBlob, data, data.length, encrypted)
|
||||||
@@ -1700,13 +1612,9 @@ public class JnaPcieCryptoService implements PcieCryptoService {
|
|||||||
EccInternalEncryptRequest req = requireRequest("request", request);
|
EccInternalEncryptRequest req = requireRequest("request", request);
|
||||||
int keyIndex = requireNonNegative("keyIndex", req.getKeyIndex());
|
int keyIndex = requireNonNegative("keyIndex", req.getKeyIndex());
|
||||||
byte[] data = requireBytes("data", req.getData());
|
byte[] data = requireBytes("data", req.getData());
|
||||||
int outBufferSize = requirePositive("outBufferSize", req.getOutBufferSize());
|
|
||||||
|
|
||||||
return sessionTemplate.withSession("SDFE_InternalEncrypt_ECC", (lib, deviceHandle, sessionHandle) -> {
|
return sessionTemplate.withSession("SDFE_InternalEncrypt_ECC", (lib, deviceHandle, sessionHandle) -> {
|
||||||
EccCipher cipher = new EccCipher();
|
EccCipher cipher = new EccCipher();
|
||||||
if (outBufferSize < cipher.size()) {
|
|
||||||
throw new IllegalArgumentException("outBufferSize must be >= " + cipher.size());
|
|
||||||
}
|
|
||||||
sessionTemplate.ensureSuccess(
|
sessionTemplate.ensureSuccess(
|
||||||
"SDFE_InternalEncrypt_ECC",
|
"SDFE_InternalEncrypt_ECC",
|
||||||
lib.SDFE_InternalEncrypt_ECC(sessionHandle, keyIndex, data, data.length, cipher)
|
lib.SDFE_InternalEncrypt_ECC(sessionHandle, keyIndex, data, data.length, cipher)
|
||||||
@@ -1928,172 +1836,6 @@ public class JnaPcieCryptoService implements PcieCryptoService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void generateUkey(UkeyGenerateRequest request) {
|
|
||||||
UkeyGenerateRequest req = requireRequest("request", request);
|
|
||||||
int adminIndex = requireByteRange("adminIndex", req.getAdminIndex());
|
|
||||||
byte[] ukeyPin = requireNonEmptyBytes("ukeyPin", req.getUkeyPin());
|
|
||||||
byte[] loginPin = requireNonEmptyBytes("loginPin", req.getLoginPin());
|
|
||||||
|
|
||||||
try {
|
|
||||||
sessionTemplate.withSession("SDFE_GenerateUkey", (lib, deviceHandle, sessionHandle) -> {
|
|
||||||
sessionTemplate.ensureSuccess(
|
|
||||||
"SDFE_GenerateUkey",
|
|
||||||
lib.SDFE_GenerateUkey(
|
|
||||||
sessionHandle,
|
|
||||||
(byte) adminIndex,
|
|
||||||
ukeyPin,
|
|
||||||
ukeyPin.length,
|
|
||||||
loginPin,
|
|
||||||
loginPin.length
|
|
||||||
)
|
|
||||||
);
|
|
||||||
return null;
|
|
||||||
});
|
|
||||||
} finally {
|
|
||||||
wipe(ukeyPin);
|
|
||||||
wipe(loginPin);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void loginUkey(UkeyLoginRequest request) {
|
|
||||||
UkeyLoginRequest req = requireRequest("request", request);
|
|
||||||
byte[] ukeyPin = requireNonEmptyBytes("ukeyPin", req.getUkeyPin());
|
|
||||||
byte[] loginPin = requireNonEmptyBytes("loginPin", req.getLoginPin());
|
|
||||||
|
|
||||||
try {
|
|
||||||
sessionTemplate.withSession("SDFE_LoginUkey", (lib, deviceHandle, sessionHandle) -> {
|
|
||||||
sessionTemplate.ensureSuccess(
|
|
||||||
"SDFE_LoginUkey",
|
|
||||||
lib.SDFE_LoginUkey(sessionHandle, ukeyPin, ukeyPin.length, loginPin, loginPin.length)
|
|
||||||
);
|
|
||||||
return null;
|
|
||||||
});
|
|
||||||
} finally {
|
|
||||||
wipe(ukeyPin);
|
|
||||||
wipe(loginPin);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void changeUkeyPin(UkeyPinChangeRequest request) {
|
|
||||||
UkeyPinChangeRequest req = requireRequest("request", request);
|
|
||||||
int pinType = requireNonNegative("pinType", req.getPinType());
|
|
||||||
byte[] oldPin = requireNonEmptyBytes("oldPin", req.getOldPin());
|
|
||||||
byte[] newPin = requireNonEmptyBytes("newPin", req.getNewPin());
|
|
||||||
|
|
||||||
try {
|
|
||||||
sessionTemplate.withSession("SDFE_ChangeUkeyPin", (lib, deviceHandle, sessionHandle) -> {
|
|
||||||
sessionTemplate.ensureSuccess(
|
|
||||||
"SDFE_ChangeUkeyPin",
|
|
||||||
lib.SDFE_ChangeUkeyPin(sessionHandle, pinType, oldPin, oldPin.length, newPin, newPin.length)
|
|
||||||
);
|
|
||||||
return null;
|
|
||||||
});
|
|
||||||
} finally {
|
|
||||||
wipe(oldPin);
|
|
||||||
wipe(newPin);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void unlockUkey(UkeyUnlockRequest request) {
|
|
||||||
UkeyUnlockRequest req = requireRequest("request", request);
|
|
||||||
byte[] adminPin = requireNonEmptyBytes("adminPin", req.getAdminPin());
|
|
||||||
byte[] userPin = requireNonEmptyBytes("userPin", req.getUserPin());
|
|
||||||
|
|
||||||
try {
|
|
||||||
sessionTemplate.withSession("SDFE_UnlockUkey", (lib, deviceHandle, sessionHandle) -> {
|
|
||||||
sessionTemplate.ensureSuccess(
|
|
||||||
"SDFE_UnlockUkey",
|
|
||||||
lib.SDFE_UnlockUkey(sessionHandle, adminPin, adminPin.length, userPin, userPin.length)
|
|
||||||
);
|
|
||||||
return null;
|
|
||||||
});
|
|
||||||
} finally {
|
|
||||||
wipe(adminPin);
|
|
||||||
wipe(userPin);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void readLmkComponent(byte[] ukeyPin) {
|
|
||||||
byte[] pin = requireNonEmptyBytes("ukeyPin", ukeyPin);
|
|
||||||
|
|
||||||
try {
|
|
||||||
sessionTemplate.withSession("SDFE_ReadUkeyLMKComponent", (lib, deviceHandle, sessionHandle) -> {
|
|
||||||
sessionTemplate.ensureSuccess(
|
|
||||||
"SDFE_ReadUkeyLMKComponent",
|
|
||||||
lib.SDFE_ReadUkeyLMKComponent(sessionHandle, pin, pin.length)
|
|
||||||
);
|
|
||||||
return null;
|
|
||||||
});
|
|
||||||
} finally {
|
|
||||||
wipe(pin);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void readUkeyIkComponent(int keyType, byte[] ukeyPin) {
|
|
||||||
int safeKeyType = requireNonNegative("keyType", keyType);
|
|
||||||
byte[] pin = requireNonEmptyBytes("ukeyPin", ukeyPin);
|
|
||||||
|
|
||||||
try {
|
|
||||||
sessionTemplate.withSession("SDFE_ReadUkeyIKComponent", (lib, deviceHandle, sessionHandle) -> {
|
|
||||||
sessionTemplate.ensureSuccess(
|
|
||||||
"SDFE_ReadUkeyIKComponent",
|
|
||||||
lib.SDFE_ReadUkeyIKComponent(sessionHandle, safeKeyType, pin, pin.length)
|
|
||||||
);
|
|
||||||
return null;
|
|
||||||
});
|
|
||||||
} finally {
|
|
||||||
wipe(pin);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void generateCertificate(byte[] ukeyPin) {
|
|
||||||
byte[] pin = requireNonEmptyBytes("ukeyPin", ukeyPin);
|
|
||||||
|
|
||||||
try {
|
|
||||||
sessionTemplate.withSession("SDFE_GenerateUkeyCertificate", (lib, deviceHandle, sessionHandle) -> {
|
|
||||||
sessionTemplate.ensureSuccess(
|
|
||||||
"SDFE_GenerateUkeyCertificate",
|
|
||||||
lib.SDFE_GenerateUkeyCertificate(sessionHandle, pin, pin.length)
|
|
||||||
);
|
|
||||||
return null;
|
|
||||||
});
|
|
||||||
} finally {
|
|
||||||
wipe(pin);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void logoutAdmin(int adminIndex) {
|
|
||||||
int safeAdminIndex = requireByteRange("adminIndex", adminIndex);
|
|
||||||
|
|
||||||
sessionTemplate.withSession("SDFE_LoginoutUkey", (lib, deviceHandle, sessionHandle) -> {
|
|
||||||
sessionTemplate.ensureSuccess("SDFE_LoginoutUkey", lib.SDFE_LoginoutUkey(sessionHandle, (byte) safeAdminIndex));
|
|
||||||
return null;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public LoginStatusResult loginStatus() {
|
|
||||||
return sessionTemplate.withSession("SDFE_UkeyLoginStatus", (lib, deviceHandle, sessionHandle) -> {
|
|
||||||
SdfeLoginState state = new SdfeLoginState();
|
|
||||||
sessionTemplate.ensureSuccess("SDFE_UkeyLoginStatus", lib.SDFE_UkeyLoginStatus(sessionHandle, state));
|
|
||||||
state.read();
|
|
||||||
|
|
||||||
LoginStatusResult result = new LoginStatusResult();
|
|
||||||
result.setAdmin1(state.admin1);
|
|
||||||
result.setAdmin2(state.admin2);
|
|
||||||
result.setAdmin3(state.admin3);
|
|
||||||
return result;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createFile(FileCreateRequest request) {
|
public void createFile(FileCreateRequest request) {
|
||||||
FileCreateRequest req = requireRequest("request", request);
|
FileCreateRequest req = requireRequest("request", request);
|
||||||
|
|||||||
+33
-111
@@ -2,6 +2,12 @@ package com.cisd.tms.integration.crypto.pcie.service;
|
|||||||
|
|
||||||
import com.cisd.tms.integration.crypto.pcie.PcieKeyState;
|
import com.cisd.tms.integration.crypto.pcie.PcieKeyState;
|
||||||
import com.cisd.tms.integration.crypto.pcie.PcieUserKeyType;
|
import com.cisd.tms.integration.crypto.pcie.PcieUserKeyType;
|
||||||
|
import com.cisd.tms.integration.crypto.pcie.jna.EccCipher;
|
||||||
|
import com.cisd.tms.integration.crypto.pcie.jna.EccRefPrivateKey;
|
||||||
|
import com.cisd.tms.integration.crypto.pcie.jna.EccRefPublicKey;
|
||||||
|
import com.cisd.tms.integration.crypto.pcie.jna.EccSignature;
|
||||||
|
import com.cisd.tms.integration.crypto.pcie.jna.RsaRefPrivateKey;
|
||||||
|
import com.cisd.tms.integration.crypto.pcie.jna.RsaRefPublicKey;
|
||||||
import com.cisd.tms.integration.crypto.pcie.jna.SdfeDeviceStatus;
|
import com.cisd.tms.integration.crypto.pcie.jna.SdfeDeviceStatus;
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.AgreementDataAndKeyEccResult;
|
import com.cisd.tms.integration.crypto.pcie.model.AgreementDataAndKeyEccResult;
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.BackupDataResult;
|
import com.cisd.tms.integration.crypto.pcie.model.BackupDataResult;
|
||||||
@@ -49,7 +55,6 @@ import com.cisd.tms.integration.crypto.pcie.model.IkSignRequest;
|
|||||||
import com.cisd.tms.integration.crypto.pcie.model.IkVerifyRequest;
|
import com.cisd.tms.integration.crypto.pcie.model.IkVerifyRequest;
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.KekComponentRequest;
|
import com.cisd.tms.integration.crypto.pcie.model.KekComponentRequest;
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.KeyStatusResult;
|
import com.cisd.tms.integration.crypto.pcie.model.KeyStatusResult;
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.LoginStatusResult;
|
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.MacCalcRequest;
|
import com.cisd.tms.integration.crypto.pcie.model.MacCalcRequest;
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.PrivateKeyAccessRequest;
|
import com.cisd.tms.integration.crypto.pcie.model.PrivateKeyAccessRequest;
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.RecoverKekRequest;
|
import com.cisd.tms.integration.crypto.pcie.model.RecoverKekRequest;
|
||||||
@@ -60,10 +65,6 @@ import com.cisd.tms.integration.crypto.pcie.model.RsaInternalKeyOpRequest;
|
|||||||
import com.cisd.tms.integration.crypto.pcie.model.SymmetricCryptoRequest;
|
import com.cisd.tms.integration.crypto.pcie.model.SymmetricCryptoRequest;
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.SymmetricKekCryptoRequest;
|
import com.cisd.tms.integration.crypto.pcie.model.SymmetricKekCryptoRequest;
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.StandardKeyPairResult;
|
import com.cisd.tms.integration.crypto.pcie.model.StandardKeyPairResult;
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.UkeyGenerateRequest;
|
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.UkeyLoginRequest;
|
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.UkeyPinChangeRequest;
|
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.UkeyUnlockRequest;
|
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.UpdateBackedKeyRequest;
|
import com.cisd.tms.integration.crypto.pcie.model.UpdateBackedKeyRequest;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import javax.crypto.Mac;
|
import javax.crypto.Mac;
|
||||||
@@ -310,38 +311,33 @@ public class MockPcieCryptoService implements PcieCryptoService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BackupDataResult exportSignPublicKeyRsa(int keyIndex, int outBufferSize) {
|
public BackupDataResult exportSignPublicKeyRsa(int keyIndex) {
|
||||||
requireNonNegative("keyIndex", keyIndex);
|
requireNonNegative("keyIndex", keyIndex);
|
||||||
int size = requirePositive("outBufferSize", outBufferSize);
|
return mockBackup(new RsaRefPublicKey().size(), 0x41);
|
||||||
return mockBackup(size, 0x41);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BackupDataResult exportEncPublicKeyRsa(int keyIndex, int outBufferSize) {
|
public BackupDataResult exportEncPublicKeyRsa(int keyIndex) {
|
||||||
requireNonNegative("keyIndex", keyIndex);
|
requireNonNegative("keyIndex", keyIndex);
|
||||||
int size = requirePositive("outBufferSize", outBufferSize);
|
return mockBackup(new RsaRefPublicKey().size(), 0x42);
|
||||||
return mockBackup(size, 0x42);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BackupDataResult exportSignPublicKeyEcc(int keyIndex, int outBufferSize) {
|
public BackupDataResult exportSignPublicKeyEcc(int keyIndex) {
|
||||||
requireNonNegative("keyIndex", keyIndex);
|
requireNonNegative("keyIndex", keyIndex);
|
||||||
int size = requirePositive("outBufferSize", outBufferSize);
|
return mockBackup(new EccRefPublicKey().size(), 0x43);
|
||||||
return mockBackup(size, 0x43);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BackupDataResult exportEncPublicKeyEcc(int keyIndex, int outBufferSize) {
|
public BackupDataResult exportEncPublicKeyEcc(int keyIndex) {
|
||||||
requireNonNegative("keyIndex", keyIndex);
|
requireNonNegative("keyIndex", keyIndex);
|
||||||
int size = requirePositive("outBufferSize", outBufferSize);
|
return mockBackup(new EccRefPublicKey().size(), 0x44);
|
||||||
return mockBackup(size, 0x44);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BackupDataResult exportIkPublicKey(int keyType, int outBufferSize) {
|
public BackupDataResult exportIkPublicKey(int keyType) {
|
||||||
requireNonNegative("keyType", keyType);
|
requireNonNegative("keyType", keyType);
|
||||||
int size = requirePositive("outBufferSize", outBufferSize);
|
return mockBackup(new EccRefPublicKey().size(), 0x45);
|
||||||
return mockBackup(size, 0x45);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -354,9 +350,7 @@ public class MockPcieCryptoService implements PcieCryptoService {
|
|||||||
public StandardKeyPairResult generateStandardRsaKeyPair(GenerateStandardRsaKeyPairRequest request) {
|
public StandardKeyPairResult generateStandardRsaKeyPair(GenerateStandardRsaKeyPairRequest request) {
|
||||||
GenerateStandardRsaKeyPairRequest req = requireRequest("request", request);
|
GenerateStandardRsaKeyPairRequest req = requireRequest("request", request);
|
||||||
requirePositive("keyBits", req.getKeyBits());
|
requirePositive("keyBits", req.getKeyBits());
|
||||||
int pubSize = requirePositive("publicKeyBufferSize", req.getPublicKeyBufferSize());
|
return mockStandardKeyPair(new RsaRefPublicKey().size(), new RsaRefPrivateKey().size(), 0x53, 0x54);
|
||||||
int priSize = requirePositive("privateKeyBufferSize", req.getPrivateKeyBufferSize());
|
|
||||||
return mockStandardKeyPair(pubSize, priSize, 0x53, 0x54);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -364,9 +358,7 @@ public class MockPcieCryptoService implements PcieCryptoService {
|
|||||||
GenerateStandardEccKeyPairRequest req = requireRequest("request", request);
|
GenerateStandardEccKeyPairRequest req = requireRequest("request", request);
|
||||||
requirePositive("algId", req.getAlgId());
|
requirePositive("algId", req.getAlgId());
|
||||||
requirePositive("keyBits", req.getKeyBits());
|
requirePositive("keyBits", req.getKeyBits());
|
||||||
int pubSize = requirePositive("publicKeyBufferSize", req.getPublicKeyBufferSize());
|
return mockStandardKeyPair(new EccRefPublicKey().size(), new EccRefPrivateKey().size(), 0x55, 0x56);
|
||||||
int priSize = requirePositive("privateKeyBufferSize", req.getPrivateKeyBufferSize());
|
|
||||||
return mockStandardKeyPair(pubSize, priSize, 0x55, 0x56);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -445,8 +437,7 @@ public class MockPcieCryptoService implements PcieCryptoService {
|
|||||||
GenerateKeyWithIpkEccRequest req = requireRequest("request", request);
|
GenerateKeyWithIpkEccRequest req = requireRequest("request", request);
|
||||||
requireNonNegative("ipkIndex", req.getIpkIndex());
|
requireNonNegative("ipkIndex", req.getIpkIndex());
|
||||||
requirePositive("keyBits", req.getKeyBits());
|
requirePositive("keyBits", req.getKeyBits());
|
||||||
int size = requirePositive("outBufferSize", req.getOutBufferSize());
|
return mockBackup(new EccCipher().size(), 0x50);
|
||||||
return mockBackup(size, 0x50);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -455,8 +446,7 @@ public class MockPcieCryptoService implements PcieCryptoService {
|
|||||||
requirePositive("keyBits", req.getKeyBits());
|
requirePositive("keyBits", req.getKeyBits());
|
||||||
requirePositive("algId", req.getAlgId());
|
requirePositive("algId", req.getAlgId());
|
||||||
requireNonEmptyBytes("publicKeyBlob", req.getPublicKeyBlob());
|
requireNonEmptyBytes("publicKeyBlob", req.getPublicKeyBlob());
|
||||||
int size = requirePositive("outBufferSize", req.getOutBufferSize());
|
return mockBackup(new EccCipher().size(), 0x51);
|
||||||
return mockBackup(size, 0x51);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -483,8 +473,7 @@ public class MockPcieCryptoService implements PcieCryptoService {
|
|||||||
requirePositive("algId", req.getAlgId());
|
requirePositive("algId", req.getAlgId());
|
||||||
requireNonEmptyBytes("publicKeyBlob", req.getPublicKeyBlob());
|
requireNonEmptyBytes("publicKeyBlob", req.getPublicKeyBlob());
|
||||||
requireNonEmptyBytes("inputEnvelopeBlob", req.getInputEnvelopeBlob());
|
requireNonEmptyBytes("inputEnvelopeBlob", req.getInputEnvelopeBlob());
|
||||||
int size = requirePositive("outBufferSize", req.getOutBufferSize());
|
return mockBackup(new EccCipher().size(), 0x57);
|
||||||
return mockBackup(size, 0x57);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -496,11 +485,9 @@ public class MockPcieCryptoService implements PcieCryptoService {
|
|||||||
requireNonEmptyBytes("sponsorId", req.getSponsorId());
|
requireNonEmptyBytes("sponsorId", req.getSponsorId());
|
||||||
requireNonEmptyBytes("sponsorPublicKeyBlob", req.getSponsorPublicKeyBlob());
|
requireNonEmptyBytes("sponsorPublicKeyBlob", req.getSponsorPublicKeyBlob());
|
||||||
requireNonEmptyBytes("sponsorTmpPublicKeyBlob", req.getSponsorTmpPublicKeyBlob());
|
requireNonEmptyBytes("sponsorTmpPublicKeyBlob", req.getSponsorTmpPublicKeyBlob());
|
||||||
int responsePublicKeySize = requirePositive("responsePublicKeyBufferSize", req.getResponsePublicKeyBufferSize());
|
|
||||||
int responseTmpPublicKeySize = requirePositive("responseTmpPublicKeyBufferSize", req.getResponseTmpPublicKeyBufferSize());
|
|
||||||
|
|
||||||
BackupDataResult responsePublicKey = mockBackup(responsePublicKeySize, 0x58);
|
BackupDataResult responsePublicKey = mockBackup(new EccRefPublicKey().size(), 0x58);
|
||||||
BackupDataResult responseTmpPublicKey = mockBackup(responseTmpPublicKeySize, 0x59);
|
BackupDataResult responseTmpPublicKey = mockBackup(new EccRefPublicKey().size(), 0x59);
|
||||||
|
|
||||||
AgreementDataAndKeyEccResult result = new AgreementDataAndKeyEccResult();
|
AgreementDataAndKeyEccResult result = new AgreementDataAndKeyEccResult();
|
||||||
result.setResponsePublicKey(responsePublicKey.getData());
|
result.setResponsePublicKey(responsePublicKey.getData());
|
||||||
@@ -520,21 +507,17 @@ public class MockPcieCryptoService implements PcieCryptoService {
|
|||||||
requireNonEmptyBytes("responseId", req.getResponseId());
|
requireNonEmptyBytes("responseId", req.getResponseId());
|
||||||
requireNonEmptyBytes("responsePublicKeyBlob", req.getResponsePublicKeyBlob());
|
requireNonEmptyBytes("responsePublicKeyBlob", req.getResponsePublicKeyBlob());
|
||||||
requireNonEmptyBytes("responseTmpPublicKeyBlob", req.getResponseTmpPublicKeyBlob());
|
requireNonEmptyBytes("responseTmpPublicKeyBlob", req.getResponseTmpPublicKeyBlob());
|
||||||
int sponsorPublicKeySize = requirePositive("sponsorPublicKeyBufferSize", req.getSponsorPublicKeyBufferSize());
|
|
||||||
int sponsorTmpPublicKeySize = requirePositive("sponsorTmpPublicKeyBufferSize", req.getSponsorTmpPublicKeyBufferSize());
|
|
||||||
int sessionKeySize = requirePositive("sessionKeyBufferSize", req.getSessionKeyBufferSize());
|
|
||||||
|
|
||||||
BackupDataResult sponsorPublicKey = mockBackup(sponsorPublicKeySize, 0x5A);
|
BackupDataResult sponsorPublicKey = mockBackup(new EccRefPublicKey().size(), 0x5A);
|
||||||
BackupDataResult sponsorTmpPublicKey = mockBackup(sponsorTmpPublicKeySize, 0x5B);
|
BackupDataResult sponsorTmpPublicKey = mockBackup(new EccRefPublicKey().size(), 0x5B);
|
||||||
BackupDataResult sessionKey = mockBackup(sessionKeySize, 0x5C);
|
|
||||||
|
|
||||||
EccAgreementSessionKeyResult result = new EccAgreementSessionKeyResult();
|
EccAgreementSessionKeyResult result = new EccAgreementSessionKeyResult();
|
||||||
result.setSponsorPublicKey(sponsorPublicKey.getData());
|
result.setSponsorPublicKey(sponsorPublicKey.getData());
|
||||||
result.setSponsorPublicKeyLength(sponsorPublicKey.getLength());
|
result.setSponsorPublicKeyLength(sponsorPublicKey.getLength());
|
||||||
result.setSponsorTmpPublicKey(sponsorTmpPublicKey.getData());
|
result.setSponsorTmpPublicKey(sponsorTmpPublicKey.getData());
|
||||||
result.setSponsorTmpPublicKeyLength(sponsorTmpPublicKey.getLength());
|
result.setSponsorTmpPublicKeyLength(sponsorTmpPublicKey.getLength());
|
||||||
result.setSessionKey(sessionKey.getData());
|
result.setSessionKey(new byte[0]);
|
||||||
result.setSessionKeyLength(sessionKey.getLength());
|
result.setSessionKeyLength(0);
|
||||||
result.setSessionKeyGenerated(true);
|
result.setSessionKeyGenerated(true);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -544,8 +527,7 @@ public class MockPcieCryptoService implements PcieCryptoService {
|
|||||||
EccInternalSignRequest req = requireRequest("request", request);
|
EccInternalSignRequest req = requireRequest("request", request);
|
||||||
requireNonNegative("keyIndex", req.getKeyIndex());
|
requireNonNegative("keyIndex", req.getKeyIndex());
|
||||||
requireBytes("data", req.getData());
|
requireBytes("data", req.getData());
|
||||||
int size = requirePositive("signatureBufferSize", req.getSignatureBufferSize());
|
return mockBackup(new EccSignature().size(), 0x49);
|
||||||
return mockBackup(size, 0x49);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -553,8 +535,7 @@ public class MockPcieCryptoService implements PcieCryptoService {
|
|||||||
IkSignRequest req = requireRequest("request", request);
|
IkSignRequest req = requireRequest("request", request);
|
||||||
requireNonNegative("keyType", req.getKeyType());
|
requireNonNegative("keyType", req.getKeyType());
|
||||||
requireBytes("data", req.getData());
|
requireBytes("data", req.getData());
|
||||||
int size = requirePositive("signatureBufferSize", req.getSignatureBufferSize());
|
return mockBackup(new EccSignature().size(), 0x5A);
|
||||||
return mockBackup(size, 0x5A);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -563,8 +544,7 @@ public class MockPcieCryptoService implements PcieCryptoService {
|
|||||||
requirePositive("algId", req.getAlgId());
|
requirePositive("algId", req.getAlgId());
|
||||||
requireNonEmptyBytes("privateKeyBlob", req.getPrivateKeyBlob());
|
requireNonEmptyBytes("privateKeyBlob", req.getPrivateKeyBlob());
|
||||||
requireBytes("data", req.getData());
|
requireBytes("data", req.getData());
|
||||||
int size = requirePositive("signatureBufferSize", req.getSignatureBufferSize());
|
return mockBackup(new EccSignature().size(), 0x4F);
|
||||||
return mockBackup(size, 0x4F);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -598,8 +578,7 @@ public class MockPcieCryptoService implements PcieCryptoService {
|
|||||||
requirePositive("algId", req.getAlgId());
|
requirePositive("algId", req.getAlgId());
|
||||||
requireNonEmptyBytes("publicKeyBlob", req.getPublicKeyBlob());
|
requireNonEmptyBytes("publicKeyBlob", req.getPublicKeyBlob());
|
||||||
requireBytes("data", req.getData());
|
requireBytes("data", req.getData());
|
||||||
int size = requirePositive("outBufferSize", req.getOutBufferSize());
|
return mockBackup(new EccCipher().size(), 0x4A);
|
||||||
return mockBackup(size, 0x4A);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -710,8 +689,7 @@ public class MockPcieCryptoService implements PcieCryptoService {
|
|||||||
EccInternalEncryptRequest req = requireRequest("request", request);
|
EccInternalEncryptRequest req = requireRequest("request", request);
|
||||||
requireNonNegative("keyIndex", req.getKeyIndex());
|
requireNonNegative("keyIndex", req.getKeyIndex());
|
||||||
requireBytes("data", req.getData());
|
requireBytes("data", req.getData());
|
||||||
int size = requirePositive("outBufferSize", req.getOutBufferSize());
|
return mockBackup(new EccCipher().size(), 0x75);
|
||||||
return mockBackup(size, 0x75);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -826,62 +804,6 @@ public class MockPcieCryptoService implements PcieCryptoService {
|
|||||||
return keyStatus(PcieKeyState.RIGHT);
|
return keyStatus(PcieKeyState.RIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void generateUkey(UkeyGenerateRequest request) {
|
|
||||||
UkeyGenerateRequest req = requireRequest("request", request);
|
|
||||||
requireByteRange("adminIndex", req.getAdminIndex());
|
|
||||||
requireNonEmptyBytes("ukeyPin", req.getUkeyPin());
|
|
||||||
requireNonEmptyBytes("loginPin", req.getLoginPin());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void loginUkey(UkeyLoginRequest request) {
|
|
||||||
UkeyLoginRequest req = requireRequest("request", request);
|
|
||||||
requireNonEmptyBytes("ukeyPin", req.getUkeyPin());
|
|
||||||
requireNonEmptyBytes("loginPin", req.getLoginPin());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void changeUkeyPin(UkeyPinChangeRequest request) {
|
|
||||||
UkeyPinChangeRequest req = requireRequest("request", request);
|
|
||||||
requireNonNegative("pinType", req.getPinType());
|
|
||||||
requireNonEmptyBytes("oldPin", req.getOldPin());
|
|
||||||
requireNonEmptyBytes("newPin", req.getNewPin());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void unlockUkey(UkeyUnlockRequest request) {
|
|
||||||
UkeyUnlockRequest req = requireRequest("request", request);
|
|
||||||
requireNonEmptyBytes("adminPin", req.getAdminPin());
|
|
||||||
requireNonEmptyBytes("userPin", req.getUserPin());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void readLmkComponent(byte[] ukeyPin) {
|
|
||||||
requireNonEmptyBytes("ukeyPin", ukeyPin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void readUkeyIkComponent(int keyType, byte[] ukeyPin) {
|
|
||||||
requireNonNegative("keyType", keyType);
|
|
||||||
requireNonEmptyBytes("ukeyPin", ukeyPin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void generateCertificate(byte[] ukeyPin) {
|
|
||||||
requireNonEmptyBytes("ukeyPin", ukeyPin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void logoutAdmin(int adminIndex) {
|
|
||||||
requireByteRange("adminIndex", adminIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public LoginStatusResult loginStatus() {
|
|
||||||
return new LoginStatusResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createFile(FileCreateRequest request) {
|
public void createFile(FileCreateRequest request) {
|
||||||
FileCreateRequest req = requireRequest("request", request);
|
FileCreateRequest req = requireRequest("request", request);
|
||||||
@@ -939,7 +861,7 @@ public class MockPcieCryptoService implements PcieCryptoService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static BackupDataResult mockBackup(int outBufferSize, int seed) {
|
private static BackupDataResult mockBackup(int outBufferSize, int seed) {
|
||||||
int length = Math.min(outBufferSize, 32);
|
int length = requirePositive("outBufferSize", outBufferSize);
|
||||||
byte[] data = new byte[length];
|
byte[] data = new byte[length];
|
||||||
Arrays.fill(data, (byte) (seed & 0xFF));
|
Arrays.fill(data, (byte) (seed & 0xFF));
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,6 @@ import com.cisd.tms.integration.crypto.pcie.model.IkSignRequest;
|
|||||||
import com.cisd.tms.integration.crypto.pcie.model.IkVerifyRequest;
|
import com.cisd.tms.integration.crypto.pcie.model.IkVerifyRequest;
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.KekComponentRequest;
|
import com.cisd.tms.integration.crypto.pcie.model.KekComponentRequest;
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.KeyStatusResult;
|
import com.cisd.tms.integration.crypto.pcie.model.KeyStatusResult;
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.LoginStatusResult;
|
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.MacCalcRequest;
|
import com.cisd.tms.integration.crypto.pcie.model.MacCalcRequest;
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.PrivateKeyAccessRequest;
|
import com.cisd.tms.integration.crypto.pcie.model.PrivateKeyAccessRequest;
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.RecoverKekRequest;
|
import com.cisd.tms.integration.crypto.pcie.model.RecoverKekRequest;
|
||||||
@@ -57,10 +56,6 @@ import com.cisd.tms.integration.crypto.pcie.model.RsaInternalKeyOpRequest;
|
|||||||
import com.cisd.tms.integration.crypto.pcie.model.SymmetricCryptoRequest;
|
import com.cisd.tms.integration.crypto.pcie.model.SymmetricCryptoRequest;
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.SymmetricKekCryptoRequest;
|
import com.cisd.tms.integration.crypto.pcie.model.SymmetricKekCryptoRequest;
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.StandardKeyPairResult;
|
import com.cisd.tms.integration.crypto.pcie.model.StandardKeyPairResult;
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.UkeyGenerateRequest;
|
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.UkeyLoginRequest;
|
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.UkeyPinChangeRequest;
|
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.UkeyUnlockRequest;
|
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.UpdateBackedKeyRequest;
|
import com.cisd.tms.integration.crypto.pcie.model.UpdateBackedKeyRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -256,22 +251,22 @@ public interface PcieCryptoService {
|
|||||||
/**
|
/**
|
||||||
* 导出 RSA 签名公钥。
|
* 导出 RSA 签名公钥。
|
||||||
*/
|
*/
|
||||||
BackupDataResult exportSignPublicKeyRsa(int keyIndex, int outBufferSize);
|
BackupDataResult exportSignPublicKeyRsa(int keyIndex);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出 RSA 加密公钥。
|
* 导出 RSA 加密公钥。
|
||||||
*/
|
*/
|
||||||
BackupDataResult exportEncPublicKeyRsa(int keyIndex, int outBufferSize);
|
BackupDataResult exportEncPublicKeyRsa(int keyIndex);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出 ECC 签名公钥。
|
* 导出 ECC 签名公钥。
|
||||||
*/
|
*/
|
||||||
BackupDataResult exportSignPublicKeyEcc(int keyIndex, int outBufferSize);
|
BackupDataResult exportSignPublicKeyEcc(int keyIndex);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出 ECC 加密公钥。
|
* 导出 ECC 加密公钥。
|
||||||
*/
|
*/
|
||||||
BackupDataResult exportEncPublicKeyEcc(int keyIndex, int outBufferSize);
|
BackupDataResult exportEncPublicKeyEcc(int keyIndex);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成标准 RSA 密钥对并导出结果。
|
* 生成标准 RSA 密钥对并导出结果。
|
||||||
@@ -522,7 +517,7 @@ public interface PcieCryptoService {
|
|||||||
/**
|
/**
|
||||||
* 导出 IK 公钥。
|
* 导出 IK 公钥。
|
||||||
*/
|
*/
|
||||||
BackupDataResult exportIkPublicKey(int keyType, int outBufferSize);
|
BackupDataResult exportIkPublicKey(int keyType);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出 IK 校验值。
|
* 导出 IK 校验值。
|
||||||
@@ -570,56 +565,7 @@ public interface PcieCryptoService {
|
|||||||
KeyStatusResult statusIk(int keyType);
|
KeyStatusResult statusIk(int keyType);
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------UKey 管理类接口-------------------------------------------
|
//----------------------------------------设备文件系统类接口-------------------------------------------
|
||||||
|
|
||||||
/**
|
|
||||||
* 生成 UKey 管理员。
|
|
||||||
*/
|
|
||||||
void generateUkey(UkeyGenerateRequest request);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 登录 UKey。
|
|
||||||
*/
|
|
||||||
void loginUkey(UkeyLoginRequest request);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改 UKey PIN。
|
|
||||||
*/
|
|
||||||
void changeUkeyPin(UkeyPinChangeRequest request);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 解锁 UKey。
|
|
||||||
*/
|
|
||||||
void unlockUkey(UkeyUnlockRequest request);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 从 UKey 读取 LMK 分量到设备运行态。
|
|
||||||
*/
|
|
||||||
void readLmkComponent(byte[] ukeyPin);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 从 UKey 读取 IK 分量到设备运行态。
|
|
||||||
*/
|
|
||||||
void readUkeyIkComponent(int keyType, byte[] ukeyPin);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 为 UKey 生成证书。
|
|
||||||
*/
|
|
||||||
void generateCertificate(byte[] ukeyPin);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 注销指定管理员索引的 UKey 登录态。
|
|
||||||
*/
|
|
||||||
void logoutAdmin(int adminIndex);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询 UKey 登录状态。
|
|
||||||
*/
|
|
||||||
LoginStatusResult loginStatus();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设备文件系统类接口。
|
|
||||||
*/
|
|
||||||
/**
|
/**
|
||||||
* 在设备文件系统中创建文件。
|
* 在设备文件系统中创建文件。
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ import com.cisd.tms.integration.crypto.pcie.model.GenerateStandardRsaKeyPairRequ
|
|||||||
import com.cisd.tms.integration.crypto.pcie.model.HmacRequest;
|
import com.cisd.tms.integration.crypto.pcie.model.HmacRequest;
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.HmacResult;
|
import com.cisd.tms.integration.crypto.pcie.model.HmacResult;
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.KeyStatusResult;
|
import com.cisd.tms.integration.crypto.pcie.model.KeyStatusResult;
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.LoginStatusResult;
|
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.MacCalcRequest;
|
import com.cisd.tms.integration.crypto.pcie.model.MacCalcRequest;
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.RecoverUserKeyRequest;
|
import com.cisd.tms.integration.crypto.pcie.model.RecoverUserKeyRequest;
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.SymmetricCryptoRequest;
|
import com.cisd.tms.integration.crypto.pcie.model.SymmetricCryptoRequest;
|
||||||
@@ -279,8 +278,6 @@ public class CryptoCardController {
|
|||||||
) {
|
) {
|
||||||
GenerateStandardRsaKeyPairRequest req = new GenerateStandardRsaKeyPairRequest();
|
GenerateStandardRsaKeyPairRequest req = new GenerateStandardRsaKeyPairRequest();
|
||||||
req.setKeyBits(request.getKeyBits());
|
req.setKeyBits(request.getKeyBits());
|
||||||
req.setPublicKeyBufferSize(request.getPublicKeyBufferSize());
|
|
||||||
req.setPrivateKeyBufferSize(request.getPrivateKeyBufferSize());
|
|
||||||
StandardKeyPairResult result = pcieCryptoService.generateStandardRsaKeyPair(req);
|
StandardKeyPairResult result = pcieCryptoService.generateStandardRsaKeyPair(req);
|
||||||
return ApiResponse.success(Map.of(
|
return ApiResponse.success(Map.of(
|
||||||
"publicKeyLength", result.getPublicKeyLength(),
|
"publicKeyLength", result.getPublicKeyLength(),
|
||||||
@@ -298,8 +295,6 @@ public class CryptoCardController {
|
|||||||
GenerateStandardEccKeyPairRequest req = new GenerateStandardEccKeyPairRequest();
|
GenerateStandardEccKeyPairRequest req = new GenerateStandardEccKeyPairRequest();
|
||||||
req.setAlgId(request.getAlgId());
|
req.setAlgId(request.getAlgId());
|
||||||
req.setKeyBits(request.getKeyBits());
|
req.setKeyBits(request.getKeyBits());
|
||||||
req.setPublicKeyBufferSize(request.getPublicKeyBufferSize());
|
|
||||||
req.setPrivateKeyBufferSize(request.getPrivateKeyBufferSize());
|
|
||||||
StandardKeyPairResult result = pcieCryptoService.generateStandardEccKeyPair(req);
|
StandardKeyPairResult result = pcieCryptoService.generateStandardEccKeyPair(req);
|
||||||
return ApiResponse.success(Map.of(
|
return ApiResponse.success(Map.of(
|
||||||
"publicKeyLength", result.getPublicKeyLength(),
|
"publicKeyLength", result.getPublicKeyLength(),
|
||||||
@@ -336,7 +331,6 @@ public class CryptoCardController {
|
|||||||
req.setAlgId(request.getAlgId());
|
req.setAlgId(request.getAlgId());
|
||||||
req.setPublicKeyBlob(Base64.getDecoder().decode(request.getPublicKeyBase64()));
|
req.setPublicKeyBlob(Base64.getDecoder().decode(request.getPublicKeyBase64()));
|
||||||
req.setInputEnvelopeBlob(Base64.getDecoder().decode(request.getInputEnvelopeBase64()));
|
req.setInputEnvelopeBlob(Base64.getDecoder().decode(request.getInputEnvelopeBase64()));
|
||||||
req.setOutBufferSize(request.getOutBufferSize());
|
|
||||||
byte[] data = pcieCryptoService.exchangeDigitEnvelopeBaseOnEcc(req).getData();
|
byte[] data = pcieCryptoService.exchangeDigitEnvelopeBaseOnEcc(req).getData();
|
||||||
return ApiResponse.success(Map.of(
|
return ApiResponse.success(Map.of(
|
||||||
"length", data.length,
|
"length", data.length,
|
||||||
@@ -356,8 +350,6 @@ public class CryptoCardController {
|
|||||||
req.setSponsorId(Base64.getDecoder().decode(request.getSponsorIdBase64()));
|
req.setSponsorId(Base64.getDecoder().decode(request.getSponsorIdBase64()));
|
||||||
req.setSponsorPublicKeyBlob(Base64.getDecoder().decode(request.getSponsorPublicKeyBase64()));
|
req.setSponsorPublicKeyBlob(Base64.getDecoder().decode(request.getSponsorPublicKeyBase64()));
|
||||||
req.setSponsorTmpPublicKeyBlob(Base64.getDecoder().decode(request.getSponsorTmpPublicKeyBase64()));
|
req.setSponsorTmpPublicKeyBlob(Base64.getDecoder().decode(request.getSponsorTmpPublicKeyBase64()));
|
||||||
req.setResponsePublicKeyBufferSize(request.getResponsePublicKeyBufferSize());
|
|
||||||
req.setResponseTmpPublicKeyBufferSize(request.getResponseTmpPublicKeyBufferSize());
|
|
||||||
AgreementDataAndKeyEccResult result = pcieCryptoService.generateAgreementDataAndKeyWithEcc(req);
|
AgreementDataAndKeyEccResult result = pcieCryptoService.generateAgreementDataAndKeyWithEcc(req);
|
||||||
return ApiResponse.success(Map.of(
|
return ApiResponse.success(Map.of(
|
||||||
"responsePublicKeyLength", result.getResponsePublicKeyLength(),
|
"responsePublicKeyLength", result.getResponsePublicKeyLength(),
|
||||||
@@ -380,9 +372,6 @@ public class CryptoCardController {
|
|||||||
req.setResponseId(Base64.getDecoder().decode(request.getResponseIdBase64()));
|
req.setResponseId(Base64.getDecoder().decode(request.getResponseIdBase64()));
|
||||||
req.setResponsePublicKeyBlob(Base64.getDecoder().decode(request.getResponsePublicKeyBase64()));
|
req.setResponsePublicKeyBlob(Base64.getDecoder().decode(request.getResponsePublicKeyBase64()));
|
||||||
req.setResponseTmpPublicKeyBlob(Base64.getDecoder().decode(request.getResponseTmpPublicKeyBase64()));
|
req.setResponseTmpPublicKeyBlob(Base64.getDecoder().decode(request.getResponseTmpPublicKeyBase64()));
|
||||||
req.setSponsorPublicKeyBufferSize(request.getSponsorPublicKeyBufferSize());
|
|
||||||
req.setSponsorTmpPublicKeyBufferSize(request.getSponsorTmpPublicKeyBufferSize());
|
|
||||||
req.setSessionKeyBufferSize(request.getSessionKeyBufferSize());
|
|
||||||
EccAgreementSessionKeyResult result = pcieCryptoService.generateSessionKeyWithEccAgreement(req);
|
EccAgreementSessionKeyResult result = pcieCryptoService.generateSessionKeyWithEccAgreement(req);
|
||||||
return ApiResponse.success(Map.of(
|
return ApiResponse.success(Map.of(
|
||||||
"sponsorPublicKeyLength", result.getSponsorPublicKeyLength(),
|
"sponsorPublicKeyLength", result.getSponsorPublicKeyLength(),
|
||||||
@@ -740,71 +729,4 @@ public class CryptoCardController {
|
|||||||
public ApiResponse<KeyStatusResult> statusIk(@RequestParam @Min(0) int keyType) {
|
public ApiResponse<KeyStatusResult> statusIk(@RequestParam @Min(0) int keyType) {
|
||||||
return ApiResponse.success(pcieCryptoService.statusIk(keyType));
|
return ApiResponse.success(pcieCryptoService.statusIk(keyType));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/ukey/generate")
|
|
||||||
@Operation(summary = "生成 UKey", description = "生成 UKey 并初始化管理员与登录 PIN。")
|
|
||||||
public ApiResponse<Void> generateUkey(@Valid @RequestBody CryptoUkeyGenerateInternalRequest request) {
|
|
||||||
pcieCryptoService.generateUkey(toUkeyGenerateRequest(request));
|
|
||||||
return ApiResponse.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/ukey/login")
|
|
||||||
@Operation(summary = "UKey 登录", description = "使用 UKey PIN 和登录 PIN 完成 UKey 登录。")
|
|
||||||
public ApiResponse<Void> loginUkey(@Valid @RequestBody CryptoUkeyLoginInternalRequest request) {
|
|
||||||
pcieCryptoService.loginUkey(toUkeyLoginRequest(request));
|
|
||||||
return ApiResponse.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/ukey/pin/change")
|
|
||||||
@Operation(summary = "修改 UKey PIN", description = "修改 UKey 用户或管理员 PIN。")
|
|
||||||
public ApiResponse<Void> changeUkeyPin(@Valid @RequestBody CryptoUkeyPinChangeInternalRequest request) {
|
|
||||||
pcieCryptoService.changeUkeyPin(toUkeyPinChangeRequest(request));
|
|
||||||
return ApiResponse.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/ukey/unlock")
|
|
||||||
@Operation(summary = "解锁 UKey", description = "使用管理员 PIN 和用户 PIN 解锁 UKey。")
|
|
||||||
public ApiResponse<Void> unlockUkey(@Valid @RequestBody CryptoUkeyUnlockInternalRequest request) {
|
|
||||||
pcieCryptoService.unlockUkey(toUkeyUnlockRequest(request));
|
|
||||||
return ApiResponse.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/ukey/lmk-component/read")
|
|
||||||
@Operation(summary = "读取 UKey LMK 分量", description = "读取并处理 UKey LMK 分量。")
|
|
||||||
public ApiResponse<Void> readLmkComponent(@Valid @RequestBody CryptoUkeyPinInternalRequest request) {
|
|
||||||
pcieCryptoService.readLmkComponent(decodeBase64(request.getUkeyPinBase64()));
|
|
||||||
return ApiResponse.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/ukey/ik-component/read")
|
|
||||||
@Operation(summary = "读取 UKey IK 分量", description = "按 keyType 读取并处理 UKey IK 分量。")
|
|
||||||
public ApiResponse<Void> readUkeyIkComponent(
|
|
||||||
@Valid @RequestBody CryptoReadUkeyIkComponentInternalRequest request
|
|
||||||
) {
|
|
||||||
pcieCryptoService.readUkeyIkComponent(
|
|
||||||
request.getKeyType(),
|
|
||||||
decodeBase64(request.getUkeyPinBase64())
|
|
||||||
);
|
|
||||||
return ApiResponse.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/ukey/certificate/generate")
|
|
||||||
@Operation(summary = "生成 UKey 证书", description = "使用 UKey PIN 生成 UKey 证书。")
|
|
||||||
public ApiResponse<Void> generateCertificate(@Valid @RequestBody CryptoUkeyPinInternalRequest request) {
|
|
||||||
pcieCryptoService.generateCertificate(decodeBase64(request.getUkeyPinBase64()));
|
|
||||||
return ApiResponse.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/ukey/logout-admin")
|
|
||||||
@Operation(summary = "管理员退出 UKey", description = "指定管理员索引执行 UKey 退出。")
|
|
||||||
public ApiResponse<Void> logoutAdmin(@RequestParam @Min(0) int adminIndex) {
|
|
||||||
pcieCryptoService.logoutAdmin(adminIndex);
|
|
||||||
return ApiResponse.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/ukey/login-status")
|
|
||||||
@Operation(summary = "查询 UKey 登录状态", description = "返回三个管理员槽位的 UKey 登录状态。")
|
|
||||||
public ApiResponse<LoginStatusResult> loginStatus() {
|
|
||||||
return ApiResponse.success(pcieCryptoService.loginStatus());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
-11
@@ -17,9 +17,6 @@ public class CryptoExchangeEnvelopeEccInternalRequest {
|
|||||||
@NotBlank
|
@NotBlank
|
||||||
private String inputEnvelopeBase64;
|
private String inputEnvelopeBase64;
|
||||||
|
|
||||||
@Min(1)
|
|
||||||
private int outBufferSize;
|
|
||||||
|
|
||||||
public int getKeyIndex() {
|
public int getKeyIndex() {
|
||||||
return keyIndex;
|
return keyIndex;
|
||||||
}
|
}
|
||||||
@@ -51,12 +48,4 @@ public class CryptoExchangeEnvelopeEccInternalRequest {
|
|||||||
public void setInputEnvelopeBase64(String inputEnvelopeBase64) {
|
public void setInputEnvelopeBase64(String inputEnvelopeBase64) {
|
||||||
this.inputEnvelopeBase64 = inputEnvelopeBase64;
|
this.inputEnvelopeBase64 = inputEnvelopeBase64;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getOutBufferSize() {
|
|
||||||
return outBufferSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOutBufferSize(int outBufferSize) {
|
|
||||||
this.outBufferSize = outBufferSize;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
-22
@@ -23,12 +23,6 @@ public class CryptoGenerateAgreementDataAndKeyEccInternalRequest {
|
|||||||
@NotBlank
|
@NotBlank
|
||||||
private String sponsorTmpPublicKeyBase64;
|
private String sponsorTmpPublicKeyBase64;
|
||||||
|
|
||||||
@Min(1)
|
|
||||||
private int responsePublicKeyBufferSize;
|
|
||||||
|
|
||||||
@Min(1)
|
|
||||||
private int responseTmpPublicKeyBufferSize;
|
|
||||||
|
|
||||||
public int getIskIndex() {
|
public int getIskIndex() {
|
||||||
return iskIndex;
|
return iskIndex;
|
||||||
}
|
}
|
||||||
@@ -76,20 +70,4 @@ public class CryptoGenerateAgreementDataAndKeyEccInternalRequest {
|
|||||||
public void setSponsorTmpPublicKeyBase64(String sponsorTmpPublicKeyBase64) {
|
public void setSponsorTmpPublicKeyBase64(String sponsorTmpPublicKeyBase64) {
|
||||||
this.sponsorTmpPublicKeyBase64 = sponsorTmpPublicKeyBase64;
|
this.sponsorTmpPublicKeyBase64 = sponsorTmpPublicKeyBase64;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getResponsePublicKeyBufferSize() {
|
|
||||||
return responsePublicKeyBufferSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setResponsePublicKeyBufferSize(int responsePublicKeyBufferSize) {
|
|
||||||
this.responsePublicKeyBufferSize = responsePublicKeyBufferSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getResponseTmpPublicKeyBufferSize() {
|
|
||||||
return responseTmpPublicKeyBufferSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setResponseTmpPublicKeyBufferSize(int responseTmpPublicKeyBufferSize) {
|
|
||||||
this.responseTmpPublicKeyBufferSize = responseTmpPublicKeyBufferSize;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
-33
@@ -23,15 +23,6 @@ public class CryptoGenerateSessionKeyEccInternalRequest {
|
|||||||
@NotBlank
|
@NotBlank
|
||||||
private String responseTmpPublicKeyBase64;
|
private String responseTmpPublicKeyBase64;
|
||||||
|
|
||||||
@Min(1)
|
|
||||||
private int sponsorPublicKeyBufferSize;
|
|
||||||
|
|
||||||
@Min(1)
|
|
||||||
private int sponsorTmpPublicKeyBufferSize;
|
|
||||||
|
|
||||||
@Min(1)
|
|
||||||
private int sessionKeyBufferSize;
|
|
||||||
|
|
||||||
public int getIskIndex() {
|
public int getIskIndex() {
|
||||||
return iskIndex;
|
return iskIndex;
|
||||||
}
|
}
|
||||||
@@ -79,28 +70,4 @@ public class CryptoGenerateSessionKeyEccInternalRequest {
|
|||||||
public void setResponseTmpPublicKeyBase64(String responseTmpPublicKeyBase64) {
|
public void setResponseTmpPublicKeyBase64(String responseTmpPublicKeyBase64) {
|
||||||
this.responseTmpPublicKeyBase64 = responseTmpPublicKeyBase64;
|
this.responseTmpPublicKeyBase64 = responseTmpPublicKeyBase64;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSponsorPublicKeyBufferSize() {
|
|
||||||
return sponsorPublicKeyBufferSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSponsorPublicKeyBufferSize(int sponsorPublicKeyBufferSize) {
|
|
||||||
this.sponsorPublicKeyBufferSize = sponsorPublicKeyBufferSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getSponsorTmpPublicKeyBufferSize() {
|
|
||||||
return sponsorTmpPublicKeyBufferSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSponsorTmpPublicKeyBufferSize(int sponsorTmpPublicKeyBufferSize) {
|
|
||||||
this.sponsorTmpPublicKeyBufferSize = sponsorTmpPublicKeyBufferSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getSessionKeyBufferSize() {
|
|
||||||
return sessionKeyBufferSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSessionKeyBufferSize(int sessionKeyBufferSize) {
|
|
||||||
this.sessionKeyBufferSize = sessionKeyBufferSize;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
-22
@@ -10,12 +10,6 @@ public class CryptoGenerateStandardEccKeyPairInternalRequest {
|
|||||||
@Min(1)
|
@Min(1)
|
||||||
private int keyBits;
|
private int keyBits;
|
||||||
|
|
||||||
@Min(1)
|
|
||||||
private int publicKeyBufferSize;
|
|
||||||
|
|
||||||
@Min(1)
|
|
||||||
private int privateKeyBufferSize;
|
|
||||||
|
|
||||||
public int getAlgId() {
|
public int getAlgId() {
|
||||||
return algId;
|
return algId;
|
||||||
}
|
}
|
||||||
@@ -31,20 +25,4 @@ public class CryptoGenerateStandardEccKeyPairInternalRequest {
|
|||||||
public void setKeyBits(int keyBits) {
|
public void setKeyBits(int keyBits) {
|
||||||
this.keyBits = keyBits;
|
this.keyBits = keyBits;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPublicKeyBufferSize() {
|
|
||||||
return publicKeyBufferSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPublicKeyBufferSize(int publicKeyBufferSize) {
|
|
||||||
this.publicKeyBufferSize = publicKeyBufferSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPrivateKeyBufferSize() {
|
|
||||||
return privateKeyBufferSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPrivateKeyBufferSize(int privateKeyBufferSize) {
|
|
||||||
this.privateKeyBufferSize = privateKeyBufferSize;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
-22
@@ -7,12 +7,6 @@ public class CryptoGenerateStandardRsaKeyPairInternalRequest {
|
|||||||
@Min(1)
|
@Min(1)
|
||||||
private int keyBits;
|
private int keyBits;
|
||||||
|
|
||||||
@Min(1)
|
|
||||||
private int publicKeyBufferSize;
|
|
||||||
|
|
||||||
@Min(1)
|
|
||||||
private int privateKeyBufferSize;
|
|
||||||
|
|
||||||
public int getKeyBits() {
|
public int getKeyBits() {
|
||||||
return keyBits;
|
return keyBits;
|
||||||
}
|
}
|
||||||
@@ -20,20 +14,4 @@ public class CryptoGenerateStandardRsaKeyPairInternalRequest {
|
|||||||
public void setKeyBits(int keyBits) {
|
public void setKeyBits(int keyBits) {
|
||||||
this.keyBits = keyBits;
|
this.keyBits = keyBits;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPublicKeyBufferSize() {
|
|
||||||
return publicKeyBufferSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPublicKeyBufferSize(int publicKeyBufferSize) {
|
|
||||||
this.publicKeyBufferSize = publicKeyBufferSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPrivateKeyBufferSize() {
|
|
||||||
return privateKeyBufferSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPrivateKeyBufferSize(int privateKeyBufferSize) {
|
|
||||||
this.privateKeyBufferSize = privateKeyBufferSize;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,10 +11,6 @@ import com.cisd.tms.integration.crypto.pcie.model.RecoverKekRequest;
|
|||||||
import com.cisd.tms.integration.crypto.pcie.model.RecoverUserKeyRequest;
|
import com.cisd.tms.integration.crypto.pcie.model.RecoverUserKeyRequest;
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.SymmetricCryptoRequest;
|
import com.cisd.tms.integration.crypto.pcie.model.SymmetricCryptoRequest;
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.SymmetricKekCryptoRequest;
|
import com.cisd.tms.integration.crypto.pcie.model.SymmetricKekCryptoRequest;
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.UkeyGenerateRequest;
|
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.UkeyLoginRequest;
|
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.UkeyPinChangeRequest;
|
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.UkeyUnlockRequest;
|
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.UpdateBackedKeyRequest;
|
import com.cisd.tms.integration.crypto.pcie.model.UpdateBackedKeyRequest;
|
||||||
import com.cisd.tms.modules.device.dto.crypto.request.CryptoChangePrivateKeyPasswordInternalRequest;
|
import com.cisd.tms.modules.device.dto.crypto.request.CryptoChangePrivateKeyPasswordInternalRequest;
|
||||||
import com.cisd.tms.modules.device.dto.crypto.request.CryptoGenerateKeyPairInternalRequest;
|
import com.cisd.tms.modules.device.dto.crypto.request.CryptoGenerateKeyPairInternalRequest;
|
||||||
@@ -27,10 +23,6 @@ import com.cisd.tms.modules.device.dto.crypto.request.CryptoRecoverKekInternalRe
|
|||||||
import com.cisd.tms.modules.device.dto.crypto.request.CryptoRecoverUserKeyInternalRequest;
|
import com.cisd.tms.modules.device.dto.crypto.request.CryptoRecoverUserKeyInternalRequest;
|
||||||
import com.cisd.tms.modules.device.dto.crypto.request.CryptoSymmetricInternalRequest;
|
import com.cisd.tms.modules.device.dto.crypto.request.CryptoSymmetricInternalRequest;
|
||||||
import com.cisd.tms.modules.device.dto.crypto.request.CryptoSymmetricKekInternalRequest;
|
import com.cisd.tms.modules.device.dto.crypto.request.CryptoSymmetricKekInternalRequest;
|
||||||
import com.cisd.tms.modules.device.dto.crypto.request.CryptoUkeyGenerateInternalRequest;
|
|
||||||
import com.cisd.tms.modules.device.dto.crypto.request.CryptoUkeyLoginInternalRequest;
|
|
||||||
import com.cisd.tms.modules.device.dto.crypto.request.CryptoUkeyPinChangeInternalRequest;
|
|
||||||
import com.cisd.tms.modules.device.dto.crypto.request.CryptoUkeyUnlockInternalRequest;
|
|
||||||
import com.cisd.tms.modules.device.dto.crypto.request.CryptoUpdateBackedKeyInternalRequest;
|
import com.cisd.tms.modules.device.dto.crypto.request.CryptoUpdateBackedKeyInternalRequest;
|
||||||
|
|
||||||
public final class CryptoRequestMapper {
|
public final class CryptoRequestMapper {
|
||||||
@@ -136,33 +128,4 @@ public final class CryptoRequestMapper {
|
|||||||
return req;
|
return req;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static UkeyGenerateRequest toUkeyGenerateRequest(CryptoUkeyGenerateInternalRequest request) {
|
|
||||||
UkeyGenerateRequest req = new UkeyGenerateRequest();
|
|
||||||
req.setAdminIndex(request.getAdminIndex());
|
|
||||||
req.setUkeyPin(CryptoPayloadCodec.decodeBase64(request.getUkeyPinBase64()));
|
|
||||||
req.setLoginPin(CryptoPayloadCodec.decodeBase64(request.getLoginPinBase64()));
|
|
||||||
return req;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static UkeyLoginRequest toUkeyLoginRequest(CryptoUkeyLoginInternalRequest request) {
|
|
||||||
UkeyLoginRequest req = new UkeyLoginRequest();
|
|
||||||
req.setUkeyPin(CryptoPayloadCodec.decodeBase64(request.getUkeyPinBase64()));
|
|
||||||
req.setLoginPin(CryptoPayloadCodec.decodeBase64(request.getLoginPinBase64()));
|
|
||||||
return req;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static UkeyPinChangeRequest toUkeyPinChangeRequest(CryptoUkeyPinChangeInternalRequest request) {
|
|
||||||
UkeyPinChangeRequest req = new UkeyPinChangeRequest();
|
|
||||||
req.setPinType(request.getPinType());
|
|
||||||
req.setOldPin(CryptoPayloadCodec.decodeBase64(request.getOldPinBase64()));
|
|
||||||
req.setNewPin(CryptoPayloadCodec.decodeBase64(request.getNewPinBase64()));
|
|
||||||
return req;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static UkeyUnlockRequest toUkeyUnlockRequest(CryptoUkeyUnlockInternalRequest request) {
|
|
||||||
UkeyUnlockRequest req = new UkeyUnlockRequest();
|
|
||||||
req.setAdminPin(CryptoPayloadCodec.decodeBase64(request.getAdminPinBase64()));
|
|
||||||
req.setUserPin(CryptoPayloadCodec.decodeBase64(request.getUserPinBase64()));
|
|
||||||
return req;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,8 +95,7 @@ public class LmkServiceImpl implements LmkService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String exportIkPublicKeyHex() {
|
public String exportIkPublicKeyHex() {
|
||||||
int outBufferSize = new EccRefPublicKey().size();
|
BackupDataResult result = pcieCryptoService.exportIkPublicKey(AUTH_SIGN_KEY_INDEX);
|
||||||
BackupDataResult result = pcieCryptoService.exportIkPublicKey(AUTH_SIGN_KEY_INDEX, outBufferSize);
|
|
||||||
return Hex.toHexString(result.getData());
|
return Hex.toHexString(result.getData());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,7 +105,6 @@ public class LmkServiceImpl implements LmkService {
|
|||||||
IkSignRequest request = new IkSignRequest();
|
IkSignRequest request = new IkSignRequest();
|
||||||
request.setKeyType(AUTH_SIGN_KEY_INDEX);
|
request.setKeyType(AUTH_SIGN_KEY_INDEX);
|
||||||
request.setData(digest);
|
request.setData(digest);
|
||||||
request.setSignatureBufferSize(new EccSignature().size());
|
|
||||||
BackupDataResult result = pcieCryptoService.signIk(request);
|
BackupDataResult result = pcieCryptoService.signIk(request);
|
||||||
return Hex.toHexString(result.getData());
|
return Hex.toHexString(result.getData());
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-5
@@ -141,7 +141,7 @@ class JnaPcieCryptoServiceTest {
|
|||||||
return callback.apply(lib, Pointer.createConstant(1), Pointer.createConstant(2));
|
return callback.apply(lib, Pointer.createConstant(1), Pointer.createConstant(2));
|
||||||
});
|
});
|
||||||
|
|
||||||
byte[] data = service.exportIkPublicKey(2, new EccRefPublicKey().size()).getData();
|
byte[] data = service.exportIkPublicKey(2).getData();
|
||||||
|
|
||||||
Assertions.assertEquals(new EccRefPublicKey().size(), data.length);
|
Assertions.assertEquals(new EccRefPublicKey().size(), data.length);
|
||||||
Mockito.verify(sessionTemplate).withSession(Mockito.eq("SDFE_ExportIKPublicKey"), Mockito.any());
|
Mockito.verify(sessionTemplate).withSession(Mockito.eq("SDFE_ExportIKPublicKey"), Mockito.any());
|
||||||
@@ -182,8 +182,6 @@ class JnaPcieCryptoServiceTest {
|
|||||||
IkSignRequest request = new IkSignRequest();
|
IkSignRequest request = new IkSignRequest();
|
||||||
request.setKeyType(2);
|
request.setKeyType(2);
|
||||||
request.setData(new byte[] {0x01, 0x02});
|
request.setData(new byte[] {0x01, 0x02});
|
||||||
request.setSignatureBufferSize(new EccSignature().size());
|
|
||||||
|
|
||||||
Mockito.when(sessionTemplate.withSession(Mockito.eq("SDFE_SignIK"), Mockito.any()))
|
Mockito.when(sessionTemplate.withSession(Mockito.eq("SDFE_SignIK"), Mockito.any()))
|
||||||
.thenAnswer(invocation -> {
|
.thenAnswer(invocation -> {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@@ -398,8 +396,6 @@ class JnaPcieCryptoServiceTest {
|
|||||||
EccInternalEncryptRequest request = new EccInternalEncryptRequest();
|
EccInternalEncryptRequest request = new EccInternalEncryptRequest();
|
||||||
request.setKeyIndex(1);
|
request.setKeyIndex(1);
|
||||||
request.setData(new byte[] {0x01, 0x02});
|
request.setData(new byte[] {0x01, 0x02});
|
||||||
request.setOutBufferSize(new EccCipher().size());
|
|
||||||
|
|
||||||
Mockito.when(sessionTemplate.withSession(Mockito.eq("SDFE_InternalEncrypt_ECC"), Mockito.any()))
|
Mockito.when(sessionTemplate.withSession(Mockito.eq("SDFE_InternalEncrypt_ECC"), Mockito.any()))
|
||||||
.thenAnswer(invocation -> {
|
.thenAnswer(invocation -> {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
|||||||
+19
-26
@@ -1,5 +1,11 @@
|
|||||||
package com.cisd.tms.integration.crypto.pcie.service;
|
package com.cisd.tms.integration.crypto.pcie.service;
|
||||||
|
|
||||||
|
import com.cisd.tms.integration.crypto.pcie.jna.EccCipher;
|
||||||
|
import com.cisd.tms.integration.crypto.pcie.jna.EccRefPrivateKey;
|
||||||
|
import com.cisd.tms.integration.crypto.pcie.jna.EccRefPublicKey;
|
||||||
|
import com.cisd.tms.integration.crypto.pcie.jna.EccSignature;
|
||||||
|
import com.cisd.tms.integration.crypto.pcie.jna.RsaRefPrivateKey;
|
||||||
|
import com.cisd.tms.integration.crypto.pcie.jna.RsaRefPublicKey;
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.BackupDataResult;
|
import com.cisd.tms.integration.crypto.pcie.model.BackupDataResult;
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.EccExternalSignRequest;
|
import com.cisd.tms.integration.crypto.pcie.model.EccExternalSignRequest;
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.ExchangeDigitEnvelopeEccRequest;
|
import com.cisd.tms.integration.crypto.pcie.model.ExchangeDigitEnvelopeEccRequest;
|
||||||
@@ -74,10 +80,9 @@ class MockPcieCryptoServiceExtendedTest {
|
|||||||
request.setAlgId(1);
|
request.setAlgId(1);
|
||||||
request.setPrivateKeyBlob(new byte[] {1, 2, 3});
|
request.setPrivateKeyBlob(new byte[] {1, 2, 3});
|
||||||
request.setData(new byte[] {4, 5});
|
request.setData(new byte[] {4, 5});
|
||||||
request.setSignatureBufferSize(64);
|
|
||||||
|
|
||||||
BackupDataResult result = service.eccExternalSign(request);
|
BackupDataResult result = service.eccExternalSign(request);
|
||||||
Assertions.assertTrue(result.getLength() > 0 && result.getLength() <= 64);
|
Assertions.assertEquals(new EccSignature().size(), result.getLength());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -85,10 +90,9 @@ class MockPcieCryptoServiceExtendedTest {
|
|||||||
GenerateKeyWithIpkEccRequest request = new GenerateKeyWithIpkEccRequest();
|
GenerateKeyWithIpkEccRequest request = new GenerateKeyWithIpkEccRequest();
|
||||||
request.setIpkIndex(1);
|
request.setIpkIndex(1);
|
||||||
request.setKeyBits(128);
|
request.setKeyBits(128);
|
||||||
request.setOutBufferSize(96);
|
|
||||||
|
|
||||||
BackupDataResult result = service.generateKeyWithIpkEcc(request);
|
BackupDataResult result = service.generateKeyWithIpkEcc(request);
|
||||||
Assertions.assertTrue(result.getLength() > 0 && result.getLength() <= 96);
|
Assertions.assertEquals(new EccCipher().size(), result.getLength());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -97,10 +101,9 @@ class MockPcieCryptoServiceExtendedTest {
|
|||||||
request.setKeyBits(128);
|
request.setKeyBits(128);
|
||||||
request.setAlgId(1);
|
request.setAlgId(1);
|
||||||
request.setPublicKeyBlob(new byte[] {1, 2, 3});
|
request.setPublicKeyBlob(new byte[] {1, 2, 3});
|
||||||
request.setOutBufferSize(96);
|
|
||||||
|
|
||||||
BackupDataResult result = service.generateKeyWithEpkEcc(request);
|
BackupDataResult result = service.generateKeyWithEpkEcc(request);
|
||||||
Assertions.assertTrue(result.getLength() > 0 && result.getLength() <= 96);
|
Assertions.assertEquals(new EccCipher().size(), result.getLength());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -128,12 +131,10 @@ class MockPcieCryptoServiceExtendedTest {
|
|||||||
void shouldGenerateStandardRsaKeyPair() {
|
void shouldGenerateStandardRsaKeyPair() {
|
||||||
GenerateStandardRsaKeyPairRequest request = new GenerateStandardRsaKeyPairRequest();
|
GenerateStandardRsaKeyPairRequest request = new GenerateStandardRsaKeyPairRequest();
|
||||||
request.setKeyBits(2048);
|
request.setKeyBits(2048);
|
||||||
request.setPublicKeyBufferSize(512);
|
|
||||||
request.setPrivateKeyBufferSize(2048);
|
|
||||||
|
|
||||||
StandardKeyPairResult result = service.generateStandardRsaKeyPair(request);
|
StandardKeyPairResult result = service.generateStandardRsaKeyPair(request);
|
||||||
Assertions.assertTrue(result.getPublicKeyLength() > 0 && result.getPublicKeyLength() <= 512);
|
Assertions.assertEquals(new RsaRefPublicKey().size(), result.getPublicKeyLength());
|
||||||
Assertions.assertTrue(result.getPrivateKeyLength() > 0 && result.getPrivateKeyLength() <= 2048);
|
Assertions.assertEquals(new RsaRefPrivateKey().size(), result.getPrivateKeyLength());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -141,12 +142,10 @@ class MockPcieCryptoServiceExtendedTest {
|
|||||||
GenerateStandardEccKeyPairRequest request = new GenerateStandardEccKeyPairRequest();
|
GenerateStandardEccKeyPairRequest request = new GenerateStandardEccKeyPairRequest();
|
||||||
request.setAlgId(1);
|
request.setAlgId(1);
|
||||||
request.setKeyBits(256);
|
request.setKeyBits(256);
|
||||||
request.setPublicKeyBufferSize(256);
|
|
||||||
request.setPrivateKeyBufferSize(256);
|
|
||||||
|
|
||||||
StandardKeyPairResult result = service.generateStandardEccKeyPair(request);
|
StandardKeyPairResult result = service.generateStandardEccKeyPair(request);
|
||||||
Assertions.assertTrue(result.getPublicKeyLength() > 0 && result.getPublicKeyLength() <= 256);
|
Assertions.assertEquals(new EccRefPublicKey().size(), result.getPublicKeyLength());
|
||||||
Assertions.assertTrue(result.getPrivateKeyLength() > 0 && result.getPrivateKeyLength() <= 256);
|
Assertions.assertEquals(new EccRefPrivateKey().size(), result.getPrivateKeyLength());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -156,10 +155,9 @@ class MockPcieCryptoServiceExtendedTest {
|
|||||||
request.setAlgId(1);
|
request.setAlgId(1);
|
||||||
request.setPublicKeyBlob(new byte[] {1, 2, 3});
|
request.setPublicKeyBlob(new byte[] {1, 2, 3});
|
||||||
request.setInputEnvelopeBlob(new byte[] {4, 5, 6});
|
request.setInputEnvelopeBlob(new byte[] {4, 5, 6});
|
||||||
request.setOutBufferSize(256);
|
|
||||||
|
|
||||||
BackupDataResult result = service.exchangeDigitEnvelopeBaseOnEcc(request);
|
BackupDataResult result = service.exchangeDigitEnvelopeBaseOnEcc(request);
|
||||||
Assertions.assertTrue(result.getLength() > 0 && result.getLength() <= 256);
|
Assertions.assertEquals(new EccCipher().size(), result.getLength());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -171,12 +169,10 @@ class MockPcieCryptoServiceExtendedTest {
|
|||||||
request.setSponsorId(new byte[] {2, 2, 2});
|
request.setSponsorId(new byte[] {2, 2, 2});
|
||||||
request.setSponsorPublicKeyBlob(new byte[] {3, 3, 3});
|
request.setSponsorPublicKeyBlob(new byte[] {3, 3, 3});
|
||||||
request.setSponsorTmpPublicKeyBlob(new byte[] {4, 4, 4});
|
request.setSponsorTmpPublicKeyBlob(new byte[] {4, 4, 4});
|
||||||
request.setResponsePublicKeyBufferSize(128);
|
|
||||||
request.setResponseTmpPublicKeyBufferSize(128);
|
|
||||||
|
|
||||||
AgreementDataAndKeyEccResult result = service.generateAgreementDataAndKeyWithEcc(request);
|
AgreementDataAndKeyEccResult result = service.generateAgreementDataAndKeyWithEcc(request);
|
||||||
Assertions.assertTrue(result.getResponsePublicKeyLength() > 0 && result.getResponsePublicKeyLength() <= 128);
|
Assertions.assertEquals(new EccRefPublicKey().size(), result.getResponsePublicKeyLength());
|
||||||
Assertions.assertTrue(result.getResponseTmpPublicKeyLength() > 0 && result.getResponseTmpPublicKeyLength() <= 128);
|
Assertions.assertEquals(new EccRefPublicKey().size(), result.getResponseTmpPublicKeyLength());
|
||||||
Assertions.assertTrue(result.isSessionKeyGenerated());
|
Assertions.assertTrue(result.isSessionKeyGenerated());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,14 +185,11 @@ class MockPcieCryptoServiceExtendedTest {
|
|||||||
request.setResponseId(new byte[] {4, 5, 6});
|
request.setResponseId(new byte[] {4, 5, 6});
|
||||||
request.setResponsePublicKeyBlob(new byte[] {7, 8, 9});
|
request.setResponsePublicKeyBlob(new byte[] {7, 8, 9});
|
||||||
request.setResponseTmpPublicKeyBlob(new byte[] {10, 11, 12});
|
request.setResponseTmpPublicKeyBlob(new byte[] {10, 11, 12});
|
||||||
request.setSponsorPublicKeyBufferSize(128);
|
|
||||||
request.setSponsorTmpPublicKeyBufferSize(128);
|
|
||||||
request.setSessionKeyBufferSize(64);
|
|
||||||
|
|
||||||
EccAgreementSessionKeyResult result = service.generateSessionKeyWithEccAgreement(request);
|
EccAgreementSessionKeyResult result = service.generateSessionKeyWithEccAgreement(request);
|
||||||
Assertions.assertTrue(result.getSponsorPublicKeyLength() > 0 && result.getSponsorPublicKeyLength() <= 128);
|
Assertions.assertEquals(new EccRefPublicKey().size(), result.getSponsorPublicKeyLength());
|
||||||
Assertions.assertTrue(result.getSponsorTmpPublicKeyLength() > 0 && result.getSponsorTmpPublicKeyLength() <= 128);
|
Assertions.assertEquals(new EccRefPublicKey().size(), result.getSponsorTmpPublicKeyLength());
|
||||||
Assertions.assertTrue(result.getSessionKeyLength() > 0 && result.getSessionKeyLength() <= 64);
|
Assertions.assertEquals(0, result.getSessionKeyLength());
|
||||||
Assertions.assertTrue(result.isSessionKeyGenerated());
|
Assertions.assertTrue(result.isSessionKeyGenerated());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+13
-17
@@ -5,7 +5,6 @@ import com.cisd.tms.integration.crypto.pcie.model.BackupDataResult;
|
|||||||
import com.cisd.tms.integration.crypto.pcie.model.DeviceStatusResult;
|
import com.cisd.tms.integration.crypto.pcie.model.DeviceStatusResult;
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.GenerateKeyPairRequest;
|
import com.cisd.tms.integration.crypto.pcie.model.GenerateKeyPairRequest;
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.KeyStatusResult;
|
import com.cisd.tms.integration.crypto.pcie.model.KeyStatusResult;
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.LoginStatusResult;
|
|
||||||
import com.cisd.tms.integration.crypto.pcie.model.RecoverUserKeyRequest;
|
import com.cisd.tms.integration.crypto.pcie.model.RecoverUserKeyRequest;
|
||||||
import com.cisd.tms.integration.crypto.pcie.service.PcieCryptoService;
|
import com.cisd.tms.integration.crypto.pcie.service.PcieCryptoService;
|
||||||
import org.mockito.ArgumentCaptor;
|
import org.mockito.ArgumentCaptor;
|
||||||
@@ -193,23 +192,20 @@ class CryptoCardControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldReturnUkeyLoginStatus() throws Exception {
|
void shouldRemoveUkeyManagementEndpoints() {
|
||||||
PcieCryptoService pcieCryptoService = Mockito.mock(PcieCryptoService.class);
|
java.util.Set<String> controllerMethods = java.util.Arrays.stream(CryptoCardController.class.getDeclaredMethods())
|
||||||
LoginStatusResult result = new LoginStatusResult();
|
.map(java.lang.reflect.Method::getName)
|
||||||
result.setAdmin1(1);
|
.collect(java.util.stream.Collectors.toSet());
|
||||||
result.setAdmin2(0);
|
|
||||||
result.setAdmin3(1);
|
|
||||||
Mockito.when(pcieCryptoService.loginStatus()).thenReturn(result);
|
|
||||||
|
|
||||||
MockMvc mockMvc = MockMvcBuilders.standaloneSetup(new CryptoCardController(pcieCryptoService))
|
assertFalse(controllerMethods.contains("generateUkey"));
|
||||||
.setControllerAdvice(new GlobalExceptionHandler())
|
assertFalse(controllerMethods.contains("loginUkey"));
|
||||||
.build();
|
assertFalse(controllerMethods.contains("changeUkeyPin"));
|
||||||
|
assertFalse(controllerMethods.contains("unlockUkey"));
|
||||||
mockMvc.perform(get("/api/v1/device/crypto/ukey/login-status"))
|
assertFalse(controllerMethods.contains("readLmkComponent"));
|
||||||
.andExpect(status().isOk())
|
assertFalse(controllerMethods.contains("readUkeyIkComponent"));
|
||||||
.andExpect(content().string(containsString("\"admin1\":1")))
|
assertFalse(controllerMethods.contains("generateCertificate"));
|
||||||
.andExpect(content().string(containsString("\"admin2\":0")))
|
assertFalse(controllerMethods.contains("logoutAdmin"));
|
||||||
.andExpect(content().string(containsString("\"admin3\":1")));
|
assertFalse(controllerMethods.contains("loginStatus"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -115,15 +115,15 @@ class LmkServiceTest {
|
|||||||
BackupDataResult publicKey = new BackupDataResult();
|
BackupDataResult publicKey = new BackupDataResult();
|
||||||
publicKey.setLength(new EccRefPublicKey().size());
|
publicKey.setLength(new EccRefPublicKey().size());
|
||||||
publicKey.setData(sequentialBytes(new EccRefPublicKey().size(), 0x31));
|
publicKey.setData(sequentialBytes(new EccRefPublicKey().size(), 0x31));
|
||||||
Mockito.when(pcieCryptoService.exportIkPublicKey(2, new EccRefPublicKey().size())).thenReturn(publicKey);
|
Mockito.when(pcieCryptoService.exportIkPublicKey(2)).thenReturn(publicKey);
|
||||||
|
|
||||||
LmkService service = new LmkServiceImpl(pcieCryptoService, properties);
|
LmkService service = new LmkServiceImpl(pcieCryptoService, properties);
|
||||||
|
|
||||||
String result = service.exportIkPublicKeyHex();
|
String result = service.exportIkPublicKeyHex();
|
||||||
|
|
||||||
Assertions.assertEquals(org.bouncycastle.util.encoders.Hex.toHexString(publicKey.getData()), result);
|
Assertions.assertEquals(org.bouncycastle.util.encoders.Hex.toHexString(publicKey.getData()), result);
|
||||||
Mockito.verify(pcieCryptoService).exportIkPublicKey(2, new EccRefPublicKey().size());
|
Mockito.verify(pcieCryptoService).exportIkPublicKey(2);
|
||||||
Mockito.verify(pcieCryptoService, Mockito.never()).exportSignPublicKeyEcc(Mockito.anyInt(), Mockito.anyInt());
|
Mockito.verify(pcieCryptoService, Mockito.never()).exportSignPublicKeyEcc(Mockito.anyInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user