C-MAC generation on G&D Expert 3.0 cards

Hello folks,

I manage to perform authentication to G&D expert3.0 cards (Init-update, then Ext-Auth) to start a secure channel.

My problem is for following commands in same session, I get an 0x6982 for commands sent in a secure channel, below is a piece of code :

applet:

publicboolean select()

{

mySecureChannel = GPSystem.getSecureChannel();

returntrue;

}

(...)

publicvoid process(APDU apdu)throws ISOException

{

byte[] buffer = apdu.getBuffer();

(....)

switch (buffer[ISO7816.OFFSET_INS]){

case myFunction:

// Host has to be authenticated:

if(mySecureChannel.getSecurityLevel() == SecureChannel.NO_SECURITY_LEVEL)

ISOException.throwIt(ISO7816.SW_CONDITIONS_NOT_SATISFIED);

else

{

wrappedLength = apdu.setIncomingAndReceive();

mySecureChannel.unwrap(buffer,ISO7816.OFFSET_CLA,(short)(wrappedLength + 5));/*<-- Exception thrown HERE*/

myFunction(apdu);}

(...)

I assume MAC generation on host side is correct as I could reproduce sample sequences and MAC for External Authentication is correct.

Any hints greatly appreciated ! Thanks,

Daniel

[1880 byte] By [dani_studa] at [2007-10-3 8:01:51]
# 1
Hello again,I found out the card recognize the C-MAC/ and ENC of my command as long as the clear text data field is at least 8 bytes long.Is this a requierment of any specs or a bug in my DES functions ? I mean Did anybody hear of that ?ThX,Daniel
dani_studa at 2007-7-15 3:05:17 > top of Java-index,Java Mobility Forums,Consumer and Commerce...
# 2
Do you pad the clear text data before MACing it? Cause as far as I remember (without looking into the docs which I left in the office) this is what the GP requires... /Woj
Woja at 2007-7-15 3:05:17 > top of Java-index,Java Mobility Forums,Consumer and Commerce...