uncrypt / unpack PinBlock

266 views
Skip to first unread message

João Luiz

unread,
Oct 14, 2022, 2:38:46 PM10/14/22
to jPOS Users
Hi People!!! :-)

I have hard task do decript a pinblock, but not understand how to make using jpos!!

Succes using this site: https://emvlab.org/pinblock/


PINblock  1781F8275BDDA0D3
PAN 0000375602171111
Key with Hex / ZPK  5AFFEB76124DD79C2AF54B09D8F70561

decripted 045755FFFFFFFFFF

my pass = 5755 ....


But no way to descrypt with JPOS ... 

    public static String test_dataDecrypt(String cryptogram,String key) throws Exception {
        JCESecurityModule sm = new JCESecurityModule();
        SecureDESKey bdk = new SecureDESKey(SMAdapter.LENGTH_DES3_2KEY,SMAdapter.TYPE_PVK+":0X",key,"6FB1C8");
        byte[] cleartext = sm.dataDecrypt(bdk, cryptogram.getBytes());
        return cleartext.toString();
    }

TKS !!!! :-) 

Andrés Alcarraz

unread,
Oct 14, 2022, 3:06:55 PM10/14/22
to jpos-...@googlegroups.com

Hi Joao.

The method you are using is for decrypting data (not necessarily a PIN Block) using a BDK, not a ZPK. And also, that BDK should be encrypted with the LMK of the Security module, which I don't see you are setting when instantiating.

Also, the idea is that you don't decrypt a PIN Block, but just translate to another key or validate it using the PVV or the PIN offset.

If you want to do that anyway using that approach, you'll have to import your ZPK under the LMK, then create a BDK, translate the pin block to that BDK and then perform the data decrypt.


Best regards


Andrés Alcarraz


El 14/10/22 a las 12:18, João Luiz escribió:
--
--
jPOS is licensed under AGPL - free for community usage for your open-source project. Licenses are also available for commercial usage. Please support jPOS, contact: sa...@jpos.org
---
You received this message because you are subscribed to the Google Groups "jPOS Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jpos-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jpos-users/4c8fe27c-925b-4a21-9e26-47eb7e6e8541n%40googlegroups.com.

João Luiz

unread,
Oct 14, 2022, 4:02:46 PM10/14/22
to jPOS Users
Tks Andrés!! :-D

Have examples from this?  "Also, the idea is that you don't decrypt a PIN Block, but just translate to another key or validate it using the PVV or the PIN offset."

but..... And if I created a pinblock to compare with what arrived, would that work????

like this (extracted from examples, but not accept zpmKey  :-(        org.jpos.security.SMException: Invalid key code: LMK0x0004      )

public static String CreatePinBlock() throws Exception {        
    JCESecurityModule jcesecmod = new JCESecurityModule();
    String pin = "5755";
    String pan = "900320007371";
    String zpkKey = "5AFFEB76124DD79C2AF54B09D8F70561";
    SecureDESKey sdk = new SecureDESKey(SMAdapter.LENGTH_DES3_2KEY, SMAdapter.TYPE_ZPK, zpkKey, "026268");
    EncryptedPIN pinUnderLMK = jcesecmod.encryptPINImpl(pin, pan);
    System.out.println("pinUnderLMK =" + ISOUtil.hexString(pinUnderLMK.getPINBlock()));
    EncryptedPIN pinUnderZPK = jcesecmod.exportPINImpl(pinUnderLMK, sdk, SMAdapter.FORMAT00);
    System.out.println("pinUnderZPK =" + ISOUtil.hexString(pinUnderZPK.getPINBlock()));
    return "";
}  
 
Produced PINBlock to compare with received PinBlock

tks :-)

João Luiz

unread,
Oct 17, 2022, 4:39:49 PM10/17/22
to jPOS Users
Hi !!!


If any testing PinBlock decode, this code have the solution

Thanks very mutch :-D

Reply all
Reply to author
Forward
0 new messages