JavacardOS will not accept order any more, please contact our partner Feitian online Store:
https://ftsafe.en.alibaba.com/index.html
https://ftsafe.en.alibaba.com/index.html
NITIALIZE UPDATE and EXTERNAL AUTHENTICATE GlobalPlatform
NITIALIZE UPDATE and EXTERNAL AUTHENTICATE GlobalPlatform
I have trouble when using INITIALIZE UPDATE and EXTERNAL AUTHENTICATE function from Global Platform API library in my JavaCard Applet.
Without using the variable SecureChannel mySecureChannel, the installation of the applet into card is NOT successful, returning SW 6A80. But when I remove this variable, the installation is successful.
The library using is 0rg.globalplatform version 1.6; JCDK is 3.0.5 from Oracle site; Card support SCP02 and GP version is 2.1
Could you please share how to fix this error?.
Here is code:
package AuthenTest;
import javacard.framework.*;
import org.globalplatform.GPSystem;
import org.globalplatform.SecureChannel;
public class AuthenTest extends Applet {
final static byte INIITCLA = (byte) 0x80;
final static byte UPDATECLA = (byte) 0x80;
final static byte INITIALIZE_UPDATE = (byte) 0x50;
final static byte EXTERNAL_AUTHENTICATE = (byte) 0x82;
private SecureChannel mySecureChannel;
public static void install(byte[] bArray, short bOffset, byte bLength) {
new AuthenTest(bArray, bOffset, bLength);
}
private AuthenTest(byte[] bArray, short bOffset, byte bLength) {
register();
}
public void process(APDU apdu) {
byte[] buffer = apdu.getBuffer();
short length;
if (selectingApplet()) {
if((short)(buffer[ISO7816.OFFSET_CLA] & 0xFF) != 0x00)
ISOException.throwIt(ISO7816.SW_CLA_NOT_SUPPORTED);
length = apdu.setIncomingAndReceive();
if((short)(buffer[ISO7816.OFFSET_LC] & 0xFF) != (byte) length)
ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
return;
}
if ((buffer[ISO7816.OFFSET_CLA] != (byte) INIITCLA) && (buffer[ISO7816.OFFSET_CLA] != (byte) UPDATECLA))
ISOException.throwIt(ISO7816.SW_CLA_NOT_SUPPORTED);
switch (buffer[ISO7816.OFFSET_INS]) {
case INITIALIZE_UPDATE:
mySecureChannel = GPSystem.getSecureChannel();
length = mySecureChannel.processSecurity(apdu);
apdu.setOutgoingAndSend(ISO7816.OFFSET_CDATA, length);
return;
case EXTERNAL_AUTHENTICATE:
/* if (mySecureChannel == null) {
ISOException.throwIt(ISO7816.SW_CONDITIONS_NOT_SATISFIED);
}
mySecureChannel.processSecurity(apdu);
return;
*/
default:
ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
}
}
}
Without using the variable SecureChannel mySecureChannel, the installation of the applet into card is NOT successful, returning SW 6A80. But when I remove this variable, the installation is successful.
The library using is 0rg.globalplatform version 1.6; JCDK is 3.0.5 from Oracle site; Card support SCP02 and GP version is 2.1
Could you please share how to fix this error?.
Here is code:
package AuthenTest;
import javacard.framework.*;
import org.globalplatform.GPSystem;
import org.globalplatform.SecureChannel;
public class AuthenTest extends Applet {
final static byte INIITCLA = (byte) 0x80;
final static byte UPDATECLA = (byte) 0x80;
final static byte INITIALIZE_UPDATE = (byte) 0x50;
final static byte EXTERNAL_AUTHENTICATE = (byte) 0x82;
private SecureChannel mySecureChannel;
public static void install(byte[] bArray, short bOffset, byte bLength) {
new AuthenTest(bArray, bOffset, bLength);
}
private AuthenTest(byte[] bArray, short bOffset, byte bLength) {
register();
}
public void process(APDU apdu) {
byte[] buffer = apdu.getBuffer();
short length;
if (selectingApplet()) {
if((short)(buffer[ISO7816.OFFSET_CLA] & 0xFF) != 0x00)
ISOException.throwIt(ISO7816.SW_CLA_NOT_SUPPORTED);
length = apdu.setIncomingAndReceive();
if((short)(buffer[ISO7816.OFFSET_LC] & 0xFF) != (byte) length)
ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
return;
}
if ((buffer[ISO7816.OFFSET_CLA] != (byte) INIITCLA) && (buffer[ISO7816.OFFSET_CLA] != (byte) UPDATECLA))
ISOException.throwIt(ISO7816.SW_CLA_NOT_SUPPORTED);
switch (buffer[ISO7816.OFFSET_INS]) {
case INITIALIZE_UPDATE:
mySecureChannel = GPSystem.getSecureChannel();
length = mySecureChannel.processSecurity(apdu);
apdu.setOutgoingAndSend(ISO7816.OFFSET_CDATA, length);
return;
case EXTERNAL_AUTHENTICATE:
/* if (mySecureChannel == null) {
ISOException.throwIt(ISO7816.SW_CONDITIONS_NOT_SATISFIED);
}
mySecureChannel.processSecurity(apdu);
return;
*/
default:
ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
}
}
}
Who is online
Users browsing this forum: No registered users and 22 guests