2K TDEA encryption and decryption


I am using NEW 8110 POS terminal. I have to communicate with a terminal communicating host. In my case host need's to do communication's securely. We both end's have same key and we have to do encryption and decryption operations. My problem is, when host sent a message to terminal, then the terminal can do decryption. If terminal sent something to the host, then the host can't do decryption. We are using Triple DES as our cryptography algorithm and CBC mode as the mode. Our host is a java based application and we are using JCE as the cypto API. If anyone done something like this please help me.

Thank you.
This is C++ forums , not Java nor is this related to Windows.

Thanks for your reply. I know this is a C forum. I want to know the POS terminal side implementation. In my case it is C language to develop POS application. Inside the terminal there is a unit call PED. We can do store keys and do encryption and decryption. We using TDEA CBC mode. Terminal can do decryption for the message that sent by host. But host can't do decryption for the messages that sent by terminal. I want to know where is the error point in this specific scenario.

Thank you.
Hi everyone,

Thank you for the help. Finally we found the wrong point. There are to wrong things.

1) In terminal side, encrypt the message and convert that byte array into char array (printable) and send it to host. in that case the host getting invalid length of byte array.

2) In my java code I do input the key as a String and convert it into byte array. But it's not working properly.

private String keyPhrase =  "1A2B1C3D1E4F1A5B1C6D1E7F1A8B1C9D1A2B1C3D1E4F1A5B";

DESedeKeySpec keySpec = new DESedeKeySpec(keyPhrase.getBytes()); 

I fixed it as fallows.

byte[] keyArray = {(byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01,...};

Now it's working. Thank you very much for your help and guidance. Greatly appreciated.
Topic archived. No new replies allowed.