/** * @param pinBlockHexString the PIN Block represented as a HexString instead of a byte[] * @param pinBlockFormat * @param accountNumber account number, including BIN and the check digit */ public EncryptedPIN (String pinBlockHexString, byte pinBlockFormat, String accountNumber) { this(ISOUtil.hex2byte(pinBlockHexString), pinBlockFormat, accountNumber); } /**
/** * Bitwise XOR between corresponding byte arrays represented in hex * @param op1 hexstring 1 * @param op2 hexstring 2 * @return an array of length = the smallest between op1 and op2 */ public static String hexor (String op1, String op2) { byte[] xor = xor (hex2byte (op1), hex2byte (op2)); return hexString (xor); }
/** * @param header Hex representation of header */ public void setHeader (String header) { super.setHeader ( ISOUtil.hex2byte (header.getBytes(), 0, header.length() / 2) ); } }
/** * @param header Hex representation of header */ public void setHeader (String header) { setHeader ( ISOUtil.hex2byte (header.getBytes(), 0, header.getBytes().length / 2) ); } public byte[] getHeader () {
/** * * @param header Hex representation of header */ public void setHeader (String header) { super.setHeader ( ISOUtil.hex2byte (header.getBytes(), 0, header.length() / 2) ); } }
@Test public void testVerifyCVC3Impl1() throws Throwable { String accountNo = "1234567890123456"; String accntSeqNo = "00"; byte[] data = ISOUtil.hex2byte("1234567890123456D12012061000110000000F"); String cvc3 = "464"; byte[] atc = ISOUtil.hex2byte("2710"); byte[] upn = ISOUtil.hex2byte("00002710"); boolean result = jcesecmod.verifyCVC3(imkcvc3, accountNo, accntSeqNo, atc ,upn, data, MKDMethod.OPTION_A, cvc3); assertTrue(result); }
@Test public void testGenerateARPCImpl_VSDC_M1() throws Throwable { byte[] arqc = ISOUtil.hex2byte("26C8A1042D1CAF3E"); byte[] arc = ISOUtil.hex2byte("3030"); byte[] arpc = ISOUtil.hex2byte("98DE7C7B3D80A831"); byte[] result = jcesecmod.generateARPC(MKDMethod.OPTION_A, SKDMethod.VSDC ,imkac, accountNoA, accountNoA_CSN, arqc ,etd.getATC(), null ,ARPCMethod.METHOD_1, arc, null); assertArrayEquals(arpc, result); }
@Before public void setUp() { oneByte = new IFB_BITMAP(1,"1 byte bitmap"); eightBytes = new IFB_BITMAP(8,"8 byte bitmap"); sixteenBytes = new IFB_BITMAP(16,"16 byte bitmap"); twentyfourBytes = new IFB_BITMAP(24,"24 byte bitmap"); // Next Bitmap? Next Bitmap? // V V inBytes = ISOUtil.hex2byte("8181421FF12418F1"+"8F81421FF12418F1"+"8F81421FF12418F1"); eightByteBitMapIn24Bytes = ISOUtil.hex2byte("7181421FF12418F1"+"1881421FF12418F1"+"8F81421FF12418F1"); sixteenByteBitMapIn24Bytes = ISOUtil.hex2byte("8181421FF12418F1"+"1881421FF12418F1"+"8F81421FF12418F1"); }
@Test //OK public void testVerifyARQCGenerateARPCImpl_VSDC_P00_M1() throws Throwable { byte[] arqc = ISOUtil.hex2byte("26C8A1042D1CAF3E"); byte[] arc = ISOUtil.hex2byte("3030"); byte[] arpc = ISOUtil.hex2byte("98DE7C7B3D80A831"); byte[] result = jcesecmod.verifyARQCGenerateARPC(MKDMethod.OPTION_A, SKDMethod.VSDC ,imkac, accountNoA, accountNoA_CSN, arqc ,etd.getATC(), null, etd.getDataNoPad() ,ARPCMethod.METHOD_1, arc, null); assertArrayEquals(arpc, result); }
@Test //OK public void testVerifyARQCGenerateARPCImpl_CSKD_P00_M1_OA_P19() throws Throwable { byte[] arqc = ISOUtil.hex2byte("36DBEE15F36B1E7F"); byte[] arc = ISOUtil.hex2byte("0012"); byte[] arpc = ISOUtil.hex2byte("0E56BBA476EB5588"); byte[] result = jcesecmod.verifyARQCGenerateARPC(MKDMethod.OPTION_A, SKDMethod.EMV_CSKD ,imkac, accountNoB, accountNoA_CSN, arqc ,etd.getATC(), null, etd.getDataNoPad() ,ARPCMethod.METHOD_1, arc, null); assertArrayEquals(arpc, result); }
@Test //OK public void testVerifyARQCGenerateARPCImpl_CSKD_P00_M2() throws Throwable { byte[] arqc = ISOUtil.hex2byte("36DBEE15F36B1E7F"); byte[] csu = ISOUtil.hex2byte("00120000"); byte[] arpc = ISOUtil.hex2byte("332CD266"); byte[] result = jcesecmod.verifyARQCGenerateARPC(MKDMethod.OPTION_A, SKDMethod.EMV_CSKD ,imkac, accountNoA, accountNoA_CSN, arqc ,etd.getATC(), null, etd.getDataNoPad() ,ARPCMethod.METHOD_2, csu, null); assertArrayEquals(arpc, result); }
@Test //OK public void testVerifyARQCGenerateARPCImpl_CSKD_P80_M2() throws Throwable { byte[] arqc = ISOUtil.hex2byte("55BE45DD2C9E0CBF"); byte[] csu = ISOUtil.hex2byte("00120000"); byte[] arpc = ISOUtil.hex2byte("B4C698B6"); byte[] result = jcesecmod.verifyARQCGenerateARPC(MKDMethod.OPTION_A, SKDMethod.EMV_CSKD ,imkac, accountNoA, accountNoA_CSN, arqc ,etd.getATC(), null, etd.getDataPad80() ,ARPCMethod.METHOD_2, csu, null); assertArrayEquals(arpc, result); }
@Test (expected = SMException.class) public void testVerifyARQCGenerateARPCImpl_MCHIP_P00_M2() throws Throwable { byte[] arqc = ISOUtil.hex2byte("9FFD1D52AE0EC0F3"); byte[] csu = ISOUtil.hex2byte("00120000"); byte[] arpc = ISOUtil.hex2byte("24E13D5D"); byte[] result = jcesecmod.verifyARQCGenerateARPC(MKDMethod.OPTION_A, SKDMethod.MCHIP ,imkac, accountNoA, accountNoA_CSN, arqc ,etd.getATC(), etd.getUPN(), etd.getDataNoPad() ,ARPCMethod.METHOD_2, csu, null); assertArrayEquals(arpc, result); }
@Test public void testEncryptDataImplCBC_16Bytes() throws Throwable { byte[] b = testData02; byte[] iv = new byte[8]; b = jcesecmod.encryptDataImpl(CipherMode.CBC, dek, b, iv); assertArrayEquals(ISOUtil.hex2byte("ABFA6F3C28A8CB0C99C22188F56DAE9F"), b); assertArrayEquals(ISOUtil.hex2byte("99C22188F56DAE9F"), iv); }
@Test public void testUnpackWith0x00Padding() throws Throwable { byte[] buf = ISOUtil.hex2byte("fe0000"); tLVList.unpack(buf, 0); assertTrue("tLVList.elements().hasMoreElements()", tLVList.elements().hasMoreElements()); }
@Test public void testDumpContentByteArr() throws Throwable { byte[] b = ISOUtil.hex2byte("3AF1"); new SimpleMsg("tag", "Some Name", b).dump(p, "--||--"); assertEquals( "--||--<tag name=\"Some Name\">" + NL + "--||-- 3AF1" + NL + "--||--</tag>" + NL ,os.toString()); }
@Test public void testDecryptDataImplCFB8_16Bytes() throws Throwable { byte[] b = ISOUtil.hex2byte("6F5DF407E1691DB1B049507DB318D6E2"); byte[] iv = new byte[8]; b = jcesecmod.decryptDataImpl(CipherMode.CFB8, dek, b, iv); assertArrayEquals(testData02, b); assertArrayEquals(testData01, iv); }
@Test public void testDecryptDataImplCFB64_8Bytes() throws Throwable { byte[] b = ISOUtil.hex2byte("6FA0EA8C194EDCFC"); byte[] iv = new byte[8]; b = jcesecmod.decryptDataImpl(CipherMode.CFB64, dek, b, iv); assertArrayEquals(testData01, b); assertArrayEquals(testData01, iv); }
@Test public void testThirdBitmapPack() throws Exception { byte[] b = ISOUtil.hex2byte("F23C04800AE00000"+"8000000000000108"+"63BC780000000010"); BitSet bs1 = ISOUtil.byte2BitSet(b, 0, 192); ISOBitMap bmap = new ISOBitMap(-1); bmap.setValue(bs1); IFA_BITMAP ifa = new IFA_BITMAP(24, "BITMAP"); byte[] b1 = ifa.pack(bmap); assertEquals ("Pack should be equal to unpack", ISOUtil.hexString(b), new String(b1)); } }
@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()); }