view uicc/hlread.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 97646b363eaa
children
line wrap: on
line source

/*
 * This module implements some high-level or user-friendly read commands.
 */

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

retrieve_iccid(buf)
	char *buf;
{
	int rc;
	unsigned len;
	char *cp;

	rc = select_op(FILEID_MF);
	if (rc < 0)
		return(rc);
	rc = select_op(EF_ICCID);
	if (rc < 0)
		return(rc);
	rc = select_resp_get_transparent(&len);
	if (rc < 0)
		return(rc);
	if (len != 10) {
		fprintf(stderr, "error: expected transparent EF of 10 bytes\n");
		return(-1);
	}
	rc = readbin_op(0, 10);
	if (rc < 0)
		return(rc);
	decode_reversed_nibbles(sim_resp_data, 10, buf);
	for (cp = buf + 20; (cp > buf + 1) && (cp[-1] == 'F'); cp--)
		;
	*cp = '\0';
	return(0);
}

cmd_iccid(argc, argv, outf)
	char **argv;
	FILE *outf;
{
	int rc;
	char buf[21];

	rc = retrieve_iccid(buf);
	if (rc < 0)
		return(rc);
	fprintf(outf, "%s\n", buf);
	return(0);
}