view simtool/inval_rehab.c @ 99:97ba63d9361a

scripts/fcsim1-sst: turn off STK & OTA services In the initial unprogrammed state of the cards from Grcard, SST has services 25 through 29 set to allocated and activated. However, these cards appear to not actually support OTA, ENVELOPE commands do nothing (just return SW 9000), and they were never observed issuing any proactive SIM commands, even after a feature-generous TERMINAL PROFILE. Therefore, let's list these STK & OTA services as allocated, but not activated in our FCSIM1 SST.
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 05 May 2021 04:26:07 +0000
parents ddd767f6e15b
children
line wrap: on
line source

/*
 * This module implements the rarely-used INVALIDATE and REHABILITATE
 * SIM protocol commands.
 */

#include <sys/types.h>
#include <stdio.h>
#include "simresp.h"
#include "file_id.h"

current_ef_inval()
{
	u_char cmd[5];
	int rc;

	/* INVALIDATE command APDU */
	cmd[0] = 0xA0;
	cmd[1] = 0x04;
	cmd[2] = 0;
	cmd[3] = 0;
	cmd[4] = 0;
	rc = apdu_exchange(cmd, 5);
	if (rc < 0)
		return(rc);
	if (sim_resp_sw != 0x9000) {
		fprintf(stderr, "bad SW response to INVALIDATE: %04X\n",
			sim_resp_sw);
		return(-1);
	}
	return(0);
}

current_ef_rehab()
{
	u_char cmd[5];
	int rc;

	/* REHABILITATE command APDU */
	cmd[0] = 0xA0;
	cmd[1] = 0x44;
	cmd[2] = 0;
	cmd[3] = 0;
	cmd[4] = 0;
	rc = apdu_exchange(cmd, 5);
	if (rc < 0)
		return(rc);
	if (sim_resp_sw != 0x9000) {
		fprintf(stderr, "bad SW response to REHABILITATE: %04X\n",
			sim_resp_sw);
		return(-1);
	}
	return(0);
}

cmd_inval_adn()
{
	int rc;

	rc = select_op(DF_TELECOM);
	if (rc < 0)
		return(rc);
	rc = select_op(EF_ADN);
	if (rc < 0)
		return(rc);
	return current_ef_inval();
}

cmd_rehab_adn()
{
	int rc;

	rc = select_op(DF_TELECOM);
	if (rc < 0)
		return(rc);
	rc = select_op(EF_ADN);
	if (rc < 0)
		return(rc);
	return current_ef_rehab();
}

cmd_rehab_imsi()
{
	int rc;

	rc = select_op(DF_GSM);
	if (rc < 0)
		return(rc);
	rc = select_op(EF_IMSI);
	if (rc < 0)
		return(rc);
	return current_ef_rehab();
}

cmd_rehab_loci()
{
	int rc;

	rc = select_op(DF_GSM);
	if (rc < 0)
		return(rc);
	rc = select_op(EF_LOCI);
	if (rc < 0)
		return(rc);
	return current_ef_rehab();
}