view simtool/inval_rehab.c @ 93:6041c601304d

fcsim1-mkprov: revert OTA key addition It appears that GrcardSIM2 cards (which is what we got for FCSIM1) do not support OTA after all, contrary to what we were previously led to believe by some tech support emails from Grcard - apparently those support emails and OTA descriptions referred to some other card model(s).
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 21 Apr 2021 05:38:39 +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();
}