Hello everybody,
I want using secure messaging in my applet by org.globalplatform package. I have a library in C# which implement some of globalplatform commands. I can open secure channel to card in CLR, MAC and ENC mode and i can load and install applet on card in mentioned mode.
Also i open secure channel in my applet succesfuly and external authentication response 9000. like this:
case INS_INIT_UPDATE:
case INS_External_AUTHENTICATION:
SDInstruction(apdu);
break;
private void SDInstruction(APDU apdu)
{
byte[] buf = apdu.getBuffer();
byte cla = buf[ISO7816.OFFSET_CLA];
byte ins = buf[ISO7816.OFFSET_INS];
apdu.setIncomingAndReceive();
if(ins == INS_INIT_UPDATE)
secureChannel = GPSystem.getSecureChannel();
short len = secureChannel.processSecurity(apdu);
apdu.setOutgoing();
apdu.setOutgoingLength(len);
apdu.sendBytes(ISO7816.OFFSET_CDATA, (short) len);
}
but when i want unwrap command apdu "which wraped by global platform c# library" in my applet , cardManager return 6982(Security Status not satisfid).
unwraping code:
if (secureChannel.getSecurityLevel() < (SecureChannel.AUTHENTICATED))
ISOException.throwIt(ISO7816.SW_CONDITIONS_NOT_SATISFIED);
short len = secureChannel.unwrap(buf, (short) 0, (short) buf.length);
apdu trace is:
Command APDU >> class="00" Ins=A4 P1=04 P2=00 P3=09 Data=A00000030800001000
Response APDU << SW=611A
Command APDU >> class="00" Ins=C0 P1=00 P2=00 P3=1A
Response APDU << SW=9000 Data=61174F06000010000100790D4F0BA00000030800001000010009
Command APDU >> class="80" Ins=50 P1=00 P2=00 P3=08 Data=0101010101010101
Response APDU << SW=611C
Command APDU >> class="00" Ins=C0 P1=00 P2=00 P3=1C
Response APDU << SW=9000 Data=4D0022840106A783224FFF01AF258B0267752E248D07854961DA9851
Command APDU >> class="84" Ins=82 P1=01 P2=00 P3=10 Data=F6E5BC84DE83E5242E8B6C9CA0ECB741
Response APDU << SW=9000
Command APDU >> class="04" Ins=20 P1=00 P2=80 P3=0E Data=3131313131315F34DCF6BE7EDD3A
Response APDU << SW=6982
Wrapping apdu command faild.
I must mention that secureChannel.getSecurityLevel() returns 0x81
Anyone can help me?
Thank you very much.