Page 1 of 1

Throw exception :6982 when returning encrypted data

Posted: Mon Nov 30, 2015 3:29 am
by JCaberham
I need to use SecureChannel.encryptData() function to encrypt data. I want Global Platform to encrypt data and later I will decrypt it with the correct session key.

The code below is to encrypt the APDU buffer, which expected a response APDU with encrypted 20.

Code: Select all

byte buffer = apdu.getBuffer();
buffer[0] = 20;
short lc = chan.encryptData(buffer, (short) 0, (short) 1);
apdu.setOutgoingAndSend((short) 0, lc);


But this returns an error SW 6982, which means "security condition not satisfied".

Where did I make mistakes? Any help is thankful.

Re: Throw exception :6982 when returning encrypted data

Posted: Mon Nov 30, 2015 10:56 pm
by UNKNwYSHSA
Did you establish secure channel (INITIALIZE UPDATE and EXTERNAL AUTHENTICATE command are both succeeded) before call the encryptData() method?