Search in sources :

Example 11 with EncryptedPIN

use of org.jpos.security.EncryptedPIN in project jPOS by jpos.

the class JCESecurityModuleTest method testTranslatePINGenerateSM_MACImpl1.

@Test
public void testTranslatePINGenerateSM_MACImpl1() 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("F473D25D9B478970", SMAdapter.FORMAT34, accountNo);
    Pair<EncryptedPIN, byte[]> result = jcesecmod.translatePINGenerateSM_MAC(MKDMethod.OPTION_A, SKDMethod.MCHIP, null, imksmi, accountNo, accntSeqNo, atc, arqc, apdu, null, pin, zpk, imksmc, null, SMAdapter.FORMAT34);
    assertArrayEquals(expectdPIN.getPINBlock(), result.getValue0().getPINBlock());
    assertArrayEquals(ISOUtil.hex2byte("831B043B4A314FD2"), result.getValue1());
}
Also used : EncryptedPIN(org.jpos.security.EncryptedPIN) Test(org.junit.Test)

Example 12 with EncryptedPIN

use of org.jpos.security.EncryptedPIN in project jPOS by jpos.

the class JCESecurityModuleTest method testTranslatePINGenerateSM_MACImpl6.

@Test
public void testTranslatePINGenerateSM_MACImpl6() throws Throwable {
    String accountNo = accountNoA;
    String accntSeqNo = accountNoA_CSN;
    byte[] apdu = apdu01;
    byte[] atc = atc01;
    byte[] arqc = arqc01;
    EncryptedPIN oldpin = new EncryptedPIN("33BADC0F07C6FB29", SMAdapter.FORMAT01, accountNo);
    EncryptedPIN pin = pinUnderZPK;
    apdu = ISOUtil.concat(apdu, atc);
    apdu = ISOUtil.concat(apdu, arqc);
    EncryptedPIN expectdPIN = new EncryptedPIN("74253653C81CE99140C47C0F7C572473", SMAdapter.FORMAT42, accountNo);
    Pair<EncryptedPIN, byte[]> result = jcesecmod.translatePINGenerateSM_MAC(MKDMethod.OPTION_A, SKDMethod.VSDC, null, imksmi, accountNo, accntSeqNo, atc, arqc, apdu, oldpin, pin, zpk, imksmc, imkac, SMAdapter.FORMAT42);
    assertArrayEquals(expectdPIN.getPINBlock(), result.getValue0().getPINBlock());
    assertArrayEquals(ISOUtil.hex2byte("6F403E51DCE1E4A6"), result.getValue1());
}
Also used : EncryptedPIN(org.jpos.security.EncryptedPIN) Test(org.junit.Test)

Example 13 with EncryptedPIN

use of org.jpos.security.EncryptedPIN in project jPOS by jpos.

the class JCESecurityModuleTest method testImportPINImplThrowsNullPointerException.

@Test
public void testImportPINImplThrowsNullPointerException() throws Throwable {
    try {
        new JCESecurityModule().importPINImpl(new EncryptedPIN("testJCESecurityModulePinBlockHexString", (byte) 0, "testJCESecurityModuleAccountNumber"), null);
        fail("Expected NullPointerException to be thrown");
    } catch (NullPointerException ex) {
        assertNull("ex.getMessage()", ex.getMessage());
    }
}
Also used : EncryptedPIN(org.jpos.security.EncryptedPIN) Test(org.junit.Test)

Example 14 with EncryptedPIN

use of org.jpos.security.EncryptedPIN in project jPOS by jpos.

the class JCESecurityModuleTest method testTranslatePINGenerateSM_MACImpl3.

@Test
public void testTranslatePINGenerateSM_MACImpl3() 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("158C4C2E67041975DEB907E2E57EC85D", SMAdapter.FORMAT41, accountNo);
    Pair<EncryptedPIN, byte[]> result = jcesecmod.translatePINGenerateSM_MAC(MKDMethod.OPTION_A, SKDMethod.EMV_CSKD, PaddingMethod.VSDC, imksmi, accountNo, accntSeqNo, atc, arqc, apdu, null, pin, zpk, imksmc, imkac, SMAdapter.FORMAT41);
    assertArrayEquals(expectdPIN.getPINBlock(), result.getValue0().getPINBlock());
    assertArrayEquals(ISOUtil.hex2byte("7DE6117DEB56D37F"), result.getValue1());
}
Also used : EncryptedPIN(org.jpos.security.EncryptedPIN) Test(org.junit.Test)

Example 15 with EncryptedPIN

use of org.jpos.security.EncryptedPIN in project jPOS by jpos.

the class JCESecurityModuleTest method setUpClass.

@BeforeClass
public static void setUpClass() throws Exception {
    jcesecmod = new JCESecurityModule(PREFIX + "secret.lmk");
    pinUnderLMK = jcesecmod.encryptPIN("1234", "1234567890123");
    pinUnderTPK = jcesecmod.exportPINImpl(pinUnderLMK, tpk, SMAdapter.FORMAT01);
    pinUnderZPK = new EncryptedPIN("ABE38E29B58EA392", SMAdapter.FORMAT01, accountNoA);
    etd = new EMVTxnData();
}
Also used : EncryptedPIN(org.jpos.security.EncryptedPIN) BeforeClass(org.junit.BeforeClass)

Aggregations

EncryptedPIN (org.jpos.security.EncryptedPIN)20 Test (org.junit.Test)18 SecureDESKey (org.jpos.security.SecureDESKey)4 LogEvent (org.jpos.util.LogEvent)1 BeforeClass (org.junit.BeforeClass)1