use of org.jpos.security.EncryptedPIN in project jPOS by jpos.
the class JCESecurityModuleTest method testTranslatePINGenerateSM_MACImpl4.
@Test
public void testTranslatePINGenerateSM_MACImpl4() throws Throwable {
String accountNo = accountNoA;
String accntSeqNo = accountNoA_CSN;
byte[] apdu = apdu01;
byte[] atc = atc01;
byte[] arqc = arqc01;
EncryptedPIN pin = pinUnderZPK;
apdu = ISOUtil.concat(apdu, atc);
apdu = ISOUtil.concat(apdu, arqc);
EncryptedPIN expectdPIN = new EncryptedPIN("F473D25D9B478970E72651C08FE487EF", SMAdapter.FORMAT34, accountNo);
Pair<EncryptedPIN, byte[]> result = jcesecmod.translatePINGenerateSM_MAC(MKDMethod.OPTION_A, SKDMethod.EMV_CSKD, null, imksmi, accountNo, accntSeqNo, atc, arqc, apdu, null, pin, zpk, imksmc, null, SMAdapter.FORMAT34);
assertArrayEquals(expectdPIN.getPINBlock(), result.getValue0().getPINBlock());
assertArrayEquals(ISOUtil.hex2byte("299E98C2B5A38B27"), result.getValue1());
}
use of org.jpos.security.EncryptedPIN in project jPOS by jpos.
the class JCESecurityModuleTest method testTranslatePINGenerateSM_MACImpl2.
@Test
public void testTranslatePINGenerateSM_MACImpl2() throws Throwable {
String accountNo = accountNoA;
String accntSeqNo = accountNoA_CSN;
byte[] apdu = apdu01;
byte[] atc = atc01;
byte[] arqc = arqc01;
EncryptedPIN pin = pinUnderZPK;
apdu = ISOUtil.concat(apdu, atc);
apdu = ISOUtil.concat(apdu, arqc);
EncryptedPIN expectdPIN = new EncryptedPIN("E60663E4B11CDB2DE4667CC9433384B4", SMAdapter.FORMAT41, accountNo);
Pair<EncryptedPIN, byte[]> result = jcesecmod.translatePINGenerateSM_MAC(MKDMethod.OPTION_A, SKDMethod.EMV_CSKD, null, imksmi, accountNo, accntSeqNo, atc, arqc, apdu, null, pin, zpk, imksmc, imkac, SMAdapter.FORMAT41);
assertArrayEquals(expectdPIN.getPINBlock(), result.getValue0().getPINBlock());
assertArrayEquals(ISOUtil.hex2byte("0405DB9BFB25BE6F"), result.getValue1());
}
use of org.jpos.security.EncryptedPIN in project jPOS by jpos.
the class JCESecurityModuleTest method testTranslatePINImplThrowsNullPointerException1.
@Test
public void testTranslatePINImplThrowsNullPointerException1() throws Throwable {
byte[] keyBytes = new byte[0];
try {
new JCESecurityModule().translatePINImpl(new EncryptedPIN(), new SecureDESKey((short) 100, "testJCESecurityModuleKeyType", keyBytes, "testString".getBytes()), new SecureDESKey(), (byte) 0);
fail("Expected NullPointerException to be thrown");
} catch (NullPointerException ex) {
assertNull("ex.getMessage()", ex.getMessage());
}
}
use of org.jpos.security.EncryptedPIN in project jPOS by jpos.
the class JCESecurityModuleTest method testImportPINImplFormat05.
@Test
public void testImportPINImplFormat05() throws Throwable {
EncryptedPIN pinUnderZPKfmt05 = new EncryptedPIN("07438C40F225BF7D", SMAdapter.FORMAT05, "1234567890120");
EncryptedPIN ep = jcesecmod.importPINImpl(pinUnderZPKfmt05, zpk);
String pin = jcesecmod.decryptPINImpl(ep);
assertEquals("1234", pin);
}
use of org.jpos.security.EncryptedPIN in project jPOS by jpos.
the class JCESecurityModuleTest method testExportPINImpl.
@Test
public void testExportPINImpl() throws Throwable {
EncryptedPIN ep = jcesecmod.encryptPINImpl("1234", "123456789012");
EncryptedPIN pinUnderZPK = jcesecmod.exportPINImpl(ep, zpk, SMAdapter.FORMAT01);
byte[] expected = ISOUtil.hex2byte("3C0CA40863092C3A");
assertArrayEquals(expected, pinUnderZPK.getPINBlock());
assertEquals(SMAdapter.FORMAT01, pinUnderZPK.getPINBlockFormat());
assertEquals("123456789012", pinUnderZPK.getAccountNumber());
}
Aggregations