How do I read EF.PLMNsel?

52 Views Asked by At

I'm working on a JavaCard Applet and I want to change something in the MF/DF.GSM/DF.PLMNsel file once I get a specific APDU. I am finally able to select it, but now I want to read it. The problem is that I get a UICCException.SECURITY_STATUS_NOT_SATISFIED response.

From GSM 11.11 I understand that I need the CHV1 access condition. My CHV1 is currently disabled, but I also tried it while enabled and verified. I expected that this is all the access conditions I should meet.

My current Applet is found below. The try/catch block in the process(APDU apdu) function catches an UICCException.SECURITY_STATUS_NOT_SATISFIED exception when I read the binary file. From the UICC JavaDoc I understand that it is returned when the access conditions are not met.

Why am I still getting this error? What am I missing? Is this the wrong approach entirely?

package com.abc.def;

import javacard.framework.APDU;
import javacard.framework.Applet;
import javacard.framework.ISO7816;
import javacard.framework.ISOException;
import javacard.framework.JCSystem;
import javacard.framework.SystemException;
import javacard.framework.Util;

import uicc.access.FileView;
import uicc.access.UICCException;
import uicc.access.UICCSystem;
import uicc.toolkit.ToolkitException;
import uicc.toolkit.ToolkitInterface;
import uicc.toolkit.ToolkitRegistry;
import uicc.toolkit.ToolkitRegistrySystem;
import uicc.usim.access.SIMConstants;

public class Main extends Applet implements ToolkitInterface {

    public static void install(byte[] bArray, short bOffset, byte bLength) throws SystemException, ToolkitException {
        new Main();
    }

    public Main() throws SystemException, ToolkitException{
        register();
        ToolkitRegistry registry = ToolkitRegistrySystem.getEntry();
    }

    @Override
    public void process(APDU apdu) throws ISOException {
        final short fbLength = 8;

        if (selectingApplet()) {
            return;
        }

        byte[] apduBuffer = apdu.getBuffer();

        byte[] fileBytes = new byte[fbLength];

        try {
            FileView fileView = UICCSystem.getTheUICCView(JCSystem.NOT_A_TRANSIENT_OBJECT);
            fileView.select(SIMConstants.FID_DF_GSM);
            fileView.select(SIMConstants.FID_EF_PLMNSEL);

//--------------------------------
//| The Line below is the issue  |
//--------------------------------
            fileView.readBinary((short) 0, fileBytes, (short) 0, fbLength);
        } catch (SystemException | UICCException e){
            // I checked, its not a SystemException
            ISOException.throwIt((short)(e.getReason() | ISO7816.SW_UNKNOWN));
        }

        Util.arrayCopyNonAtomic(fileBytes, (short) 0, apduBuffer, (short) 0, fbLength);
    }

    @Override
    public void processToolkit(short i) throws ToolkitException {}
}
0

There are 0 best solutions below