tilln / jmeter-iso8583

ISO8583 Plugin for JMeter
MIT License
62 stars 32 forks source link

Fail to calculate zone PIN #13

Closed Nzsquall closed 4 years ago

Nzsquall commented 4 years ago

Hi @tilln ,

I am using release 1.0 of the plug in and having some issue with zone PIN block encryption.

In the crypto pre-processor I have define a clear ZPK of 32 hex digits, and here is my packager details for field 52:

<isofield
            id="52"
            length="8"
            name="PIN DATA"
            class="org.jpos.iso.IFB_BINARY"/>

The description says PIN Field Number (usually 52): A clear PIN Block in this field will be replaced with the encrypted one.

So it my sampler, I put down field 52 with a value of 1234.

Here is the error being shown when I ran the test:

2019-10-08 08:31:47,936 DEBUG n.c.b.j.i.ISO8583Crypto: No KSN defined, doing Zone PIN encryption
2019-10-08 08:31:47,981 ERROR n.c.b.j.i.ISO8583Crypto: PIN Block encryption failed org.jpos.security.jceadapter.JCEHandlerException: javax.crypto.IllegalBlockSizeException: data not block size aligned (javax.crypto.IllegalBlockSizeException: data not block size aligned)
org.jpos.security.jceadapter.JCEHandlerException: javax.crypto.IllegalBlockSizeException: data not block size aligned
    at org.jpos.security.jceadapter.JCEHandler.doCryptStuff(JCEHandler.java:317) ~[jpos-2.1.3.jar:2.1.3]
    at org.jpos.security.jceadapter.JCEHandler.doCryptStuff(JCEHandler.java:286) ~[jpos-2.1.3.jar:2.1.3]
    at org.jpos.security.jceadapter.JCEHandler.encryptData(JCEHandler.java:235) ~[jpos-2.1.3.jar:2.1.3]
    at nz.co.breakpoint.jmeter.iso8583.SecurityModule.encryptPINBlock(SecurityModule.java:52) ~[jmeter-iso8583-1.0.jar:?]
    at nz.co.breakpoint.jmeter.iso8583.ISO8583Crypto.encryptPINBlock(ISO8583Crypto.java:166) [jmeter-iso8583-1.0.jar:?]
    at nz.co.breakpoint.jmeter.iso8583.ISO8583Crypto.process(ISO8583Crypto.java:72) [jmeter-iso8583-1.0.jar:?]
    at org.apache.jmeter.threads.JMeterThread.runPreProcessors(JMeterThread.java:935) [ApacheJMeter_core.jar:5.1.1 r1855137]
    at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:537) [ApacheJMeter_core.jar:5.1.1 r1855137]
    at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:486) [ApacheJMeter_core.jar:5.1.1 r1855137]
    at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:253) [ApacheJMeter_core.jar:5.1.1 r1855137]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_221]

From your unit test, I can see you pass in the clear pin block as below

       String clearPinBlock = "0000000000000000";

How can I represent 1234 (clear PIN) in this format?

Thanks Eric

tilln commented 4 years ago

The PIN Block needs to be derived from PIN and PAN, and is not equal to the PIN. Plugin version 1.1 will provide a JMeter function __calculatepinblock. It's already included in the current snapshot release.

Nzsquall commented 4 years ago

Working nicely, apologize if I open too many issues that are just questions.