Search in sources :

Example 6 with EncryptedPIN

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

the class JCESecurityModuleTest method testImportPINImplFormat05Other.

@Test
public void testImportPINImplFormat05Other() throws Throwable {
    EncryptedPIN pinUnderZPKfmt05 = new EncryptedPIN("07438C40F225BF7D", SMAdapter.FORMAT05, "0210987654321");
    EncryptedPIN ep = jcesecmod.importPINImpl(pinUnderZPKfmt05, zpk);
    String pin = jcesecmod.decryptPINImpl(ep);
    assertEquals("1234", pin);
}
Also used : EncryptedPIN(org.jpos.security.EncryptedPIN) Test(org.junit.Test)

Example 7 with EncryptedPIN

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

the class JCESecurityModuleTest method testTranslatePINImpl.

@Test
public void testTranslatePINImpl() throws Throwable {
    EncryptedPIN pinUnderZPK = new EncryptedPIN("3C0CA40863092C3A", SMAdapter.FORMAT01, "1234567890120");
    EncryptedPIN pinUnderTPK = jcesecmod.translatePINImpl(pinUnderZPK, zpk, tpk, SMAdapter.FORMAT01);
    // Clear keys are that same so after translation expected result must be unchanged
    byte[] expected = ISOUtil.hex2byte("3C0CA40863092C3A");
    assertArrayEquals(expected, pinUnderTPK.getPINBlock());
    assertEquals(SMAdapter.FORMAT01, pinUnderTPK.getPINBlockFormat());
    assertEquals("123456789012", pinUnderTPK.getAccountNumber());
}
Also used : EncryptedPIN(org.jpos.security.EncryptedPIN) Test(org.junit.Test)

Example 8 with EncryptedPIN

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

the class JCESecurityModuleTest method testImportPINImpl.

@Test
public void testImportPINImpl() throws Throwable {
    EncryptedPIN pinUnderKd1 = new EncryptedPIN("3C0CA40863092C3A", SMAdapter.FORMAT01, "1234567890120");
    EncryptedPIN ep = jcesecmod.importPINImpl(pinUnderKd1, zpk);
    String pin = jcesecmod.decryptPINImpl(ep);
    assertEquals("1234", pin);
}
Also used : EncryptedPIN(org.jpos.security.EncryptedPIN) Test(org.junit.Test)

Example 9 with EncryptedPIN

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

the class JCESecurityModuleTest method testEncryptPINImpl1.

@Test
public void testEncryptPINImpl1() throws Throwable {
    EncryptedPIN ep = jcesecmod.encryptPINImpl("123456789012", "12Characters");
    byte[] expected = ISOUtil.hex2byte("B7D085B0EB9E0956");
    assertArrayEquals(expected, ep.getPINBlock());
    assertEquals(SMAdapter.FORMAT00, ep.getPINBlockFormat());
}
Also used : EncryptedPIN(org.jpos.security.EncryptedPIN) Test(org.junit.Test)

Example 10 with EncryptedPIN

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

the class JCESecurityModuleTest method testTranslatePINImplThrowsNullPointerException.

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

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