public class JCESecurityModule extends BaseSMAdapter
It doesn't require any hardware device to work.
JCESecurityModule also implements the SMAdapter, so you can view it: either
as a self contained security module adapter that doesn't need a security module
or a security module that plugs directly to jpos, so doesn't need
a separate adapter.
It relies on Java(tm) Cryptography Extension (JCE), hence its name.
JCESecurityModule relies on the JCEHandler class to do the low level JCE work.
WARNING: This version of JCESecurityModule is meant for testing purposes and NOT for life operation, since the Local Master Keys are stored in CLEAR on the system's disk. Comming versions of JCESecurity Module will rely on java.security.KeyStore for a better protection of the Local Master Keys.
cfg, logger, realm
FORMAT00, FORMAT01, FORMAT02, FORMAT03, FORMAT04, FORMAT05, FORMAT34, FORMAT35, FORMAT41, FORMAT42, LENGTH_DES, LENGTH_DES3_2KEY, LENGTH_DES3_3KEY, TYPE_BDK, TYPE_CVK, TYPE_DEK, TYPE_HMAC, TYPE_MK_AC, TYPE_MK_CVC3, TYPE_MK_DAC, TYPE_MK_DN, TYPE_MK_SMC, TYPE_MK_SMI, TYPE_PVK, TYPE_RSA_PK, TYPE_RSA_SK, TYPE_TAK, TYPE_TMK, TYPE_TPK, TYPE_ZAK, TYPE_ZEK, TYPE_ZMK, TYPE_ZPK
Constructor and Description |
---|
JCESecurityModule()
Creates an uninitialized JCE Security Module, you need to setConfiguration to initialize it
|
JCESecurityModule(Configuration cfg,
Logger logger,
java.lang.String realm) |
JCESecurityModule(java.lang.String lmkFile) |
JCESecurityModule(java.lang.String lmkFile,
java.lang.String jceProviderClassName) |
Modifier and Type | Method and Description |
---|---|
protected java.lang.String |
calculateCAVVImpl(java.lang.String accountNo,
SecureDESKey cvk,
java.lang.String upn,
java.lang.String authrc,
java.lang.String sfarc)
Your SMAdapter should override this method if it has this functionality
|
protected java.lang.String |
calculateCVC3(SecureDESKey imkcvc3,
java.lang.String accountNo,
java.lang.String acctSeqNo,
byte[] atc,
byte[] upn,
byte[] data,
MKDMethod mkdm) |
protected java.lang.String |
calculateCVVImpl(java.lang.String accountNo,
SecureDESKey cvkA,
SecureDESKey cvkB,
java.util.Date expDate,
java.lang.String serviceCode)
Your SMAdapter should override this method if it has this functionality
|
protected java.lang.String |
calculatedCVV(java.lang.String accountNo,
SecureDESKey imkac,
java.util.Date expDate,
java.lang.String serviceCode,
byte[] atc,
MKDMethod mkdm) |
protected java.lang.String |
calculatePVVImpl(EncryptedPIN pinUnderLmk,
SecureDESKey pvkA,
SecureDESKey pvkB,
int pvkIdx,
java.util.List<java.lang.String> excludes)
Your SMAdapter should override this method if it has this functionality
|
protected java.lang.String |
calculatePVVImpl(EncryptedPIN pinUnderKd1,
SecureDESKey kd1,
SecureDESKey pvkA,
SecureDESKey pvkB,
int pvkIdx,
java.util.List<java.lang.String> excludes)
Your SMAdapter should override this method if it has this functionality
|
protected void |
checkCAVVArgs(java.lang.String upn,
java.lang.String authrc,
java.lang.String sfarc) |
byte[] |
decryptDataImpl(CipherMode cipherMode,
SecureDESKey kd,
byte[] data,
byte[] iv)
Your SMAdapter should override this method if it has this functionality
|
java.lang.String |
decryptPINImpl(EncryptedPIN pinUnderLmk)
Your SMAdapter should override this method if it has this functionality
|
byte[] |
encryptDataImpl(CipherMode cipherMode,
SecureDESKey kd,
byte[] data,
byte[] iv)
Your SMAdapter should override this method if it has this functionality
|
EncryptedPIN |
encryptPINImpl(java.lang.String pin,
java.lang.String accountNumber)
Your SMAdapter should override this method if it has this functionality
|
byte[] |
exportKeyImpl(SecureDESKey key,
SecureDESKey kek)
Your SMAdapter should override this method if it has this functionality
|
EncryptedPIN |
exportPIN(EncryptedPIN pinUnderLmk,
KeySerialNumber ksn,
SecureDESKey bdk,
boolean tdes,
byte destinationPINBlockFormat)
Exports PIN to DUKPT Encryption.
|
EncryptedPIN |
exportPINImpl(EncryptedPIN pinUnderLmk,
SecureDESKey kd2,
byte destinationPINBlockFormat)
Your SMAdapter should override this method if it has this functionality
|
byte[] |
generateARPCImpl(MKDMethod mkdm,
SKDMethod skdm,
SecureDESKey imkac,
java.lang.String accountNo,
java.lang.String accntSeqNo,
byte[] arqc,
byte[] atc,
byte[] upn,
ARPCMethod arpcMethod,
byte[] arc,
byte[] propAuthData)
Your SMAdapter should override this method if it has this functionality
|
protected byte[] |
generateCBC_MACImpl(byte[] data,
SecureDESKey kd)
Generates CBC-MAC (Cipher Block Chaining Message Authentication Code)
for some data.
|
protected byte[] |
generateEDE_MACImpl(byte[] data,
SecureDESKey kd)
Generates EDE-MAC (Encrypt Decrypt Encrypt Message Authentication Code)
for some data.
|
protected byte[] |
generateKeyCheckValueImpl(SecureDESKey secureDESKey)
Generates key check value.
|
SecureDESKey |
generateKeyImpl(short keyLength,
java.lang.String keyType)
Your SMAdapter should override this method if it has this functionality
|
EncryptedPIN |
generatePINImpl(java.lang.String accountNumber,
int pinLen,
java.util.List<java.lang.String> excludes)
Your SMAdapter should override this method if it has this functionality
|
protected byte[] |
generateSM_MACImpl(MKDMethod mkdm,
SKDMethod skdm,
SecureDESKey imksmi,
java.lang.String accountNo,
java.lang.String accntSeqNo,
byte[] atc,
byte[] arqc,
byte[] data)
Your SMAdapter should override this method if it has this functionality
|
SecureDESKey |
importBDK(java.lang.String clearComponent1HexString,
java.lang.String clearComponent2HexString,
java.lang.String clearComponent3HexString) |
SecureDESKey |
importKeyImpl(short keyLength,
java.lang.String keyType,
byte[] encryptedKey,
SecureDESKey kek,
boolean checkParity)
Your SMAdapter should override this method if it has this functionality
|
protected EncryptedPIN |
importPINImpl(EncryptedPIN pinUnderDuk,
KeySerialNumber ksn,
SecureDESKey bdk,
boolean tdes)
Your SMAdapter should override this method if it has this functionality
|
EncryptedPIN |
importPINImpl(EncryptedPIN pinUnderKd1,
SecureDESKey kd1)
Your SMAdapter should override this method if it has this functionality
|
void |
setConfiguration(Configuration cfg)
Configures a JCESecurityModule
|
SecureDESKey |
translateKeySchemeImpl(SecureDESKey key,
KeyScheme keyScheme)
Your SMAdapter should override this method if it has this functionality
|
protected org.javatuples.Pair<EncryptedPIN,byte[]> |
translatePINGenerateSM_MACImpl(MKDMethod mkdm,
SKDMethod skdm,
PaddingMethod padm,
SecureDESKey imksmi,
java.lang.String accountNo,
java.lang.String accntSeqNo,
byte[] atc,
byte[] arqc,
byte[] data,
EncryptedPIN currentPIN,
EncryptedPIN newPIN,
SecureDESKey kd1,
SecureDESKey imksmc,
SecureDESKey imkac,
byte destinationPINBlockFormat)
Your SMAdapter should override this method if it has this functionality
|
protected EncryptedPIN |
translatePINImpl(EncryptedPIN pinUnderDuk,
KeySerialNumber ksn,
SecureDESKey bdk,
SecureDESKey kd2,
byte destinationPINBlockFormat,
boolean tdes)
Your SMAdapter should override this method if it has this functionality
|
EncryptedPIN |
translatePINImpl(EncryptedPIN pinUnderKd1,
SecureDESKey kd1,
SecureDESKey kd2,
byte destinationPINBlockFormat)
Your SMAdapter should override this method if it has this functionality
|
byte[] |
verifyARQCGenerateARPCImpl(MKDMethod mkdm,
SKDMethod skdm,
SecureDESKey imkac,
java.lang.String accountNo,
java.lang.String accntSeqNo,
byte[] arqc,
byte[] atc,
byte[] upn,
byte[] transData,
ARPCMethod arpcMethod,
byte[] arc,
byte[] propAuthData)
Your SMAdapter should override this method if it has this functionality
|
protected boolean |
verifyARQCImpl(MKDMethod mkdm,
SKDMethod skdm,
SecureDESKey imkac,
java.lang.String accountNo,
java.lang.String accntSeqNo,
byte[] arqc,
byte[] atc,
byte[] upn,
byte[] transData)
Your SMAdapter should override this method if it has this functionality
|
protected boolean |
verifyCAVVImpl(java.lang.String accountNo,
SecureDESKey cvk,
java.lang.String cavv,
java.lang.String upn,
java.lang.String authrc,
java.lang.String sfarc)
Your SMAdapter should override this method if it has this functionality
|
protected boolean |
verifyCVC3Impl(SecureDESKey imkcvc3,
java.lang.String accountNo,
java.lang.String acctSeqNo,
byte[] atc,
byte[] upn,
byte[] data,
MKDMethod mkdm,
java.lang.String cvc3)
Your SMAdapter should override this method if it has this functionality
|
protected boolean |
verifyCVVImpl(java.lang.String accountNo,
SecureDESKey cvkA,
SecureDESKey cvkB,
java.lang.String cvv,
java.util.Date expDate,
java.lang.String serviceCode)
Your SMAdapter should override this method if it has this functionality
|
protected boolean |
verifydCVVImpl(java.lang.String accountNo,
SecureDESKey imkac,
java.lang.String dcvv,
java.util.Date expDate,
java.lang.String serviceCode,
byte[] atc,
MKDMethod mkdm)
Your SMAdapter should override this method if it has this functionality
|
boolean |
verifyPVVImpl(EncryptedPIN pinUnderKd1,
SecureDESKey kd1,
SecureDESKey pvkA,
SecureDESKey pvkB,
int pvki,
java.lang.String pvv)
Your SMAdapter should override this method if it has this functionality
|
calculateCAVV, calculateCVV, calculateIBMPINOffset, calculateIBMPINOffset, calculateIBMPINOffset, calculateIBMPINOffset, calculateIBMPINOffsetImpl, calculateIBMPINOffsetImpl, calculatePVV, calculatePVV, calculatePVV, calculatePVV, calculateSignature, calculateSignatureImpl, decryptData, decryptPIN, deriveIBMPIN, deriveIBMPINImpl, encryptData, encryptPIN, encryptPIN, eraseOldLMK, eraseOldLMKImpl, exportKey, exportPIN, generateARPC, generateCBC_MAC, generateEDE_MAC, generateKey, generateKeyCheckValue, generateKeyPair, generateKeyPairImpl, generatePIN, generatePIN, generateSM_MAC, getLogger, getName, getRealm, getSMAdapter, importKey, importPIN, importPIN, importPIN, importPINImpl, printPIN, printPINImpl, setLogger, setName, translateKeyFromOldLMK, translateKeyFromOldLMKImpl, translateKeyScheme, translatePIN, translatePIN, translatePIN, translatePINGenerateSM_MAC, translatePINImpl, verifyARQC, verifyARQCGenerateARPC, verifyCAVV, verifyCVC3, verifyCVV, verifydCVV, verifyIBMPINOffset, verifyIBMPINOffsetImpl, verifyPVV
public JCESecurityModule()
public JCESecurityModule(java.lang.String lmkFile) throws SMException
lmkFile
- Local Master Keys filename of the JCE Security ModuleSMException
public JCESecurityModule(java.lang.String lmkFile, java.lang.String jceProviderClassName) throws SMException
SMException
public JCESecurityModule(Configuration cfg, Logger logger, java.lang.String realm) throws ConfigurationException
ConfigurationException
public void setConfiguration(Configuration cfg) throws ConfigurationException
setConfiguration
in interface Configurable
setConfiguration
in class BaseSMAdapter
cfg
- The following properties are read:ConfigurationException
public SecureDESKey generateKeyImpl(short keyLength, java.lang.String keyType) throws SMException
BaseSMAdapter
generateKeyImpl
in class BaseSMAdapter
SMException
public SecureDESKey importKeyImpl(short keyLength, java.lang.String keyType, byte[] encryptedKey, SecureDESKey kek, boolean checkParity) throws SMException
BaseSMAdapter
importKeyImpl
in class BaseSMAdapter
SMException
public byte[] exportKeyImpl(SecureDESKey key, SecureDESKey kek) throws SMException
BaseSMAdapter
exportKeyImpl
in class BaseSMAdapter
SMException
public EncryptedPIN encryptPINImpl(java.lang.String pin, java.lang.String accountNumber) throws SMException
BaseSMAdapter
encryptPINImpl
in class BaseSMAdapter
SMException
public java.lang.String decryptPINImpl(EncryptedPIN pinUnderLmk) throws SMException
BaseSMAdapter
decryptPINImpl
in class BaseSMAdapter
SMException
public EncryptedPIN importPINImpl(EncryptedPIN pinUnderKd1, SecureDESKey kd1) throws SMException
BaseSMAdapter
importPINImpl
in class BaseSMAdapter
SMException
public EncryptedPIN exportPINImpl(EncryptedPIN pinUnderLmk, SecureDESKey kd2, byte destinationPINBlockFormat) throws SMException
BaseSMAdapter
exportPINImpl
in class BaseSMAdapter
SMException
public EncryptedPIN generatePINImpl(java.lang.String accountNumber, int pinLen, java.util.List<java.lang.String> excludes) throws SMException
BaseSMAdapter
generatePINImpl
in class BaseSMAdapter
SMException
protected java.lang.String calculateCVVImpl(java.lang.String accountNo, SecureDESKey cvkA, SecureDESKey cvkB, java.util.Date expDate, java.lang.String serviceCode) throws SMException
BaseSMAdapter
calculateCVVImpl
in class BaseSMAdapter
SMException
protected void checkCAVVArgs(java.lang.String upn, java.lang.String authrc, java.lang.String sfarc) throws SMException
SMException
protected java.lang.String calculateCAVVImpl(java.lang.String accountNo, SecureDESKey cvk, java.lang.String upn, java.lang.String authrc, java.lang.String sfarc) throws SMException
BaseSMAdapter
calculateCAVVImpl
in class BaseSMAdapter
SMException
protected boolean verifyCVVImpl(java.lang.String accountNo, SecureDESKey cvkA, SecureDESKey cvkB, java.lang.String cvv, java.util.Date expDate, java.lang.String serviceCode) throws SMException
BaseSMAdapter
verifyCVVImpl
in class BaseSMAdapter
SMException
protected boolean verifyCAVVImpl(java.lang.String accountNo, SecureDESKey cvk, java.lang.String cavv, java.lang.String upn, java.lang.String authrc, java.lang.String sfarc) throws SMException
BaseSMAdapter
verifyCAVVImpl
in class BaseSMAdapter
SMException
protected java.lang.String calculatedCVV(java.lang.String accountNo, SecureDESKey imkac, java.util.Date expDate, java.lang.String serviceCode, byte[] atc, MKDMethod mkdm) throws SMException
SMException
protected boolean verifydCVVImpl(java.lang.String accountNo, SecureDESKey imkac, java.lang.String dcvv, java.util.Date expDate, java.lang.String serviceCode, byte[] atc, MKDMethod mkdm) throws SMException
BaseSMAdapter
verifydCVVImpl
in class BaseSMAdapter
SMException
protected java.lang.String calculateCVC3(SecureDESKey imkcvc3, java.lang.String accountNo, java.lang.String acctSeqNo, byte[] atc, byte[] upn, byte[] data, MKDMethod mkdm) throws SMException
SMException
protected boolean verifyCVC3Impl(SecureDESKey imkcvc3, java.lang.String accountNo, java.lang.String acctSeqNo, byte[] atc, byte[] upn, byte[] data, MKDMethod mkdm, java.lang.String cvc3) throws SMException
BaseSMAdapter
verifyCVC3Impl
in class BaseSMAdapter
SMException
protected java.lang.String calculatePVVImpl(EncryptedPIN pinUnderLmk, SecureDESKey pvkA, SecureDESKey pvkB, int pvkIdx, java.util.List<java.lang.String> excludes) throws SMException
BaseSMAdapter
calculatePVVImpl
in class BaseSMAdapter
SMException
protected java.lang.String calculatePVVImpl(EncryptedPIN pinUnderKd1, SecureDESKey kd1, SecureDESKey pvkA, SecureDESKey pvkB, int pvkIdx, java.util.List<java.lang.String> excludes) throws SMException
BaseSMAdapter
calculatePVVImpl
in class BaseSMAdapter
SMException
public boolean verifyPVVImpl(EncryptedPIN pinUnderKd1, SecureDESKey kd1, SecureDESKey pvkA, SecureDESKey pvkB, int pvki, java.lang.String pvv) throws SMException
BaseSMAdapter
verifyPVVImpl
in class BaseSMAdapter
SMException
public EncryptedPIN translatePINImpl(EncryptedPIN pinUnderKd1, SecureDESKey kd1, SecureDESKey kd2, byte destinationPINBlockFormat) throws SMException
BaseSMAdapter
translatePINImpl
in class BaseSMAdapter
SMException
protected boolean verifyARQCImpl(MKDMethod mkdm, SKDMethod skdm, SecureDESKey imkac, java.lang.String accountNo, java.lang.String accntSeqNo, byte[] arqc, byte[] atc, byte[] upn, byte[] transData) throws SMException
BaseSMAdapter
verifyARQCImpl
in class BaseSMAdapter
SMException
public byte[] generateARPCImpl(MKDMethod mkdm, SKDMethod skdm, SecureDESKey imkac, java.lang.String accountNo, java.lang.String accntSeqNo, byte[] arqc, byte[] atc, byte[] upn, ARPCMethod arpcMethod, byte[] arc, byte[] propAuthData) throws SMException
BaseSMAdapter
generateARPCImpl
in class BaseSMAdapter
SMException
public byte[] verifyARQCGenerateARPCImpl(MKDMethod mkdm, SKDMethod skdm, SecureDESKey imkac, java.lang.String accountNo, java.lang.String accntSeqNo, byte[] arqc, byte[] atc, byte[] upn, byte[] transData, ARPCMethod arpcMethod, byte[] arc, byte[] propAuthData) throws SMException
BaseSMAdapter
verifyARQCGenerateARPCImpl
in class BaseSMAdapter
SMException
protected byte[] generateSM_MACImpl(MKDMethod mkdm, SKDMethod skdm, SecureDESKey imksmi, java.lang.String accountNo, java.lang.String accntSeqNo, byte[] atc, byte[] arqc, byte[] data) throws SMException
BaseSMAdapter
generateSM_MACImpl
in class BaseSMAdapter
SMException
protected org.javatuples.Pair<EncryptedPIN,byte[]> translatePINGenerateSM_MACImpl(MKDMethod mkdm, SKDMethod skdm, PaddingMethod padm, SecureDESKey imksmi, java.lang.String accountNo, java.lang.String accntSeqNo, byte[] atc, byte[] arqc, byte[] data, EncryptedPIN currentPIN, EncryptedPIN newPIN, SecureDESKey kd1, SecureDESKey imksmc, SecureDESKey imkac, byte destinationPINBlockFormat) throws SMException
BaseSMAdapter
translatePINGenerateSM_MACImpl
in class BaseSMAdapter
SMException
public byte[] encryptDataImpl(CipherMode cipherMode, SecureDESKey kd, byte[] data, byte[] iv) throws SMException
BaseSMAdapter
encryptDataImpl
in class BaseSMAdapter
SMException
public byte[] decryptDataImpl(CipherMode cipherMode, SecureDESKey kd, byte[] data, byte[] iv) throws SMException
BaseSMAdapter
decryptDataImpl
in class BaseSMAdapter
SMException
protected byte[] generateCBC_MACImpl(byte[] data, SecureDESKey kd) throws SMException
generateCBC_MACImpl
in class BaseSMAdapter
data
- the data to be MACedkd
- the key used for MACingSMException
protected byte[] generateEDE_MACImpl(byte[] data, SecureDESKey kd) throws SMException
generateEDE_MACImpl
in class BaseSMAdapter
data
- the data to be MACedkd
- the key used for MACingSMException
protected byte[] generateKeyCheckValueImpl(SecureDESKey secureDESKey) throws SMException
generateKeyCheckValueImpl
in class BaseSMAdapter
secureDESKey
- SecureDESKey with untrusted or fake Key Check ValueSMException
public SecureDESKey translateKeySchemeImpl(SecureDESKey key, KeyScheme keyScheme) throws SMException
BaseSMAdapter
translateKeySchemeImpl
in class BaseSMAdapter
destKeyScheme
schemeSMException
public SecureDESKey importBDK(java.lang.String clearComponent1HexString, java.lang.String clearComponent2HexString, java.lang.String clearComponent3HexString) throws SMException
SMException
protected EncryptedPIN translatePINImpl(EncryptedPIN pinUnderDuk, KeySerialNumber ksn, SecureDESKey bdk, SecureDESKey kd2, byte destinationPINBlockFormat, boolean tdes) throws SMException
BaseSMAdapter
translatePINImpl
in class BaseSMAdapter
SMException
protected EncryptedPIN importPINImpl(EncryptedPIN pinUnderDuk, KeySerialNumber ksn, SecureDESKey bdk, boolean tdes) throws SMException
BaseSMAdapter
importPINImpl
in class BaseSMAdapter
SMException
public EncryptedPIN exportPIN(EncryptedPIN pinUnderLmk, KeySerialNumber ksn, SecureDESKey bdk, boolean tdes, byte destinationPINBlockFormat) throws SMException
pinUnderLmk
- ksn
- bdk
- tdes
- destinationPINBlockFormat
- SMException