Derin Lois Derin Lois - 2 months ago 24
Java Question

Decrypt a data by 3DES-128 bits CBC Mode (padding zero)) using java

In the process of decrypting an encrypted data, i am having a little challenge with it. I will be so glad if anyone can help putting me through.

Although, i have already studied the algorithm in carrying out this operation, since i am to get my data from a device, which already has its Base Derivation Key(BDK), Initially loaded key serial number and the initially loaded pin entry device key.

In the documentation that was been given, we have the Initially loaded key serial number, data encryption key variant and the track 2 Data (which is in plaintext).

In this example, i was made to know that they actually used a 3DES-128 bits CBC Mode (padding zero) method.

my question now is, how was the plaintext gotten from the encrypted data. I will be so glad, if anyone can put me through (stating the flow or the algorithm to use in decrypting this data).

Will so much appreciate your time.

Answer

Since you want to try to carrying out the 3DES-128 bits CBC Mode (padding zero) method, try out this git https://github.com/meshileya/dukpt to use in getting the plaintext from the ciphertext.

Since you already have your BDK and KSN, just try to run the method below.

 public static void main(String[] args) {
     try {
        String theksn = "This should be your KSN";
        String encrypted = "This should be the encrypted data";
        String BDK = "The BDK you mentioned up there";

            tracking= DukptDecrypt.decrypt(theksn, BDK, encrypted);

            System.out.print("PlainText"+ tracking);
        }catch (Exception e){System.out.print(e);}

    }