2001-12-22 20:43:09 +00:00
|
|
|
|
/*
|
2002-01-08 13:56:50 +00:00
|
|
|
|
* iso7816.c: Functions specified by the ISO 7816 standard
|
2001-12-22 20:43:09 +00:00
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2001 Juha Yrj<EFBFBD>l<EFBFBD> <juha.yrjola@iki.fi>
|
|
|
|
|
*
|
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
*/
|
|
|
|
|
|
2001-12-25 20:45:48 +00:00
|
|
|
|
#include "sc-internal.h"
|
2001-12-22 20:43:09 +00:00
|
|
|
|
#include "sc-asn1.h"
|
|
|
|
|
#include "sc-log.h"
|
|
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
#include <ctype.h>
|
|
|
|
|
|
|
|
|
|
static int iso7816_read_binary(struct sc_card *card,
|
2001-12-29 02:07:32 +00:00
|
|
|
|
unsigned int idx, u8 *buf, size_t count,
|
|
|
|
|
unsigned long flags)
|
2001-12-22 20:43:09 +00:00
|
|
|
|
{
|
|
|
|
|
struct sc_apdu apdu;
|
|
|
|
|
u8 recvbuf[SC_MAX_APDU_BUFFER_SIZE];
|
|
|
|
|
int r;
|
|
|
|
|
|
|
|
|
|
sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xB0,
|
|
|
|
|
(idx >> 8) & 0x7F, idx & 0xFF);
|
|
|
|
|
apdu.le = count;
|
|
|
|
|
apdu.resplen = count;
|
|
|
|
|
apdu.resp = recvbuf;
|
|
|
|
|
|
|
|
|
|
r = sc_transmit_apdu(card, &apdu);
|
|
|
|
|
SC_TEST_RET(card->ctx, r, "APDU transmit failed");
|
|
|
|
|
if (apdu.resplen == 0)
|
|
|
|
|
SC_FUNC_RETURN(card->ctx, 2, sc_sw_to_errorcode(card, apdu.sw1, apdu.sw2));
|
|
|
|
|
memcpy(buf, recvbuf, apdu.resplen);
|
|
|
|
|
|
2002-01-08 13:56:50 +00:00
|
|
|
|
SC_FUNC_RETURN(card->ctx, 3, apdu.resplen);
|
2001-12-22 20:43:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-12-29 02:07:32 +00:00
|
|
|
|
static int iso7816_read_record(struct sc_card *card,
|
|
|
|
|
unsigned int rec_nr, u8 *buf, size_t count,
|
|
|
|
|
unsigned long flags)
|
|
|
|
|
{
|
|
|
|
|
struct sc_apdu apdu;
|
|
|
|
|
u8 recvbuf[SC_MAX_APDU_BUFFER_SIZE];
|
|
|
|
|
int r;
|
|
|
|
|
|
|
|
|
|
sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xB2, rec_nr, 0);
|
2002-02-10 18:04:03 +00:00
|
|
|
|
apdu.p2 = (flags & SC_READ_RECORD_EF_ID_MASK) << 3;
|
2001-12-29 02:07:32 +00:00
|
|
|
|
if (flags & SC_READ_RECORD_BY_REC_NR)
|
|
|
|
|
apdu.p2 |= 0x04;
|
|
|
|
|
|
|
|
|
|
apdu.le = count;
|
|
|
|
|
apdu.resplen = count;
|
|
|
|
|
apdu.resp = recvbuf;
|
|
|
|
|
|
|
|
|
|
r = sc_transmit_apdu(card, &apdu);
|
|
|
|
|
SC_TEST_RET(card->ctx, r, "APDU transmit failed");
|
|
|
|
|
if (apdu.resplen == 0)
|
|
|
|
|
SC_FUNC_RETURN(card->ctx, 2, sc_sw_to_errorcode(card, apdu.sw1, apdu.sw2));
|
|
|
|
|
memcpy(buf, recvbuf, apdu.resplen);
|
|
|
|
|
|
2002-01-08 13:56:50 +00:00
|
|
|
|
SC_FUNC_RETURN(card->ctx, 3, apdu.resplen);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int iso7816_write_binary(struct sc_card *card,
|
|
|
|
|
unsigned int idx, const u8 *buf,
|
|
|
|
|
size_t count, unsigned long flags)
|
|
|
|
|
{
|
|
|
|
|
struct sc_apdu apdu;
|
|
|
|
|
int r;
|
|
|
|
|
|
|
|
|
|
if (count > SC_APDU_CHOP_SIZE) {
|
|
|
|
|
error(card->ctx, "Too large buffer supplied\n");
|
|
|
|
|
return SC_ERROR_CMD_TOO_LONG;
|
|
|
|
|
}
|
|
|
|
|
sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xD0,
|
|
|
|
|
(idx >> 8) & 0x7F, idx & 0xFF);
|
|
|
|
|
apdu.lc = count;
|
|
|
|
|
apdu.datalen = count;
|
|
|
|
|
apdu.data = buf;
|
|
|
|
|
|
|
|
|
|
r = sc_transmit_apdu(card, &apdu);
|
|
|
|
|
SC_TEST_RET(card->ctx, r, "APDU transmit failed");
|
|
|
|
|
SC_TEST_RET(card->ctx, sc_sw_to_errorcode(card, apdu.sw1, apdu.sw2),
|
|
|
|
|
"Card returned error");
|
|
|
|
|
SC_FUNC_RETURN(card->ctx, 3, count);
|
2001-12-29 02:07:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-01-13 23:56:13 +00:00
|
|
|
|
static int iso7816_update_binary(struct sc_card *card,
|
|
|
|
|
unsigned int idx, const u8 *buf,
|
|
|
|
|
size_t count, unsigned long flags)
|
|
|
|
|
{
|
|
|
|
|
struct sc_apdu apdu;
|
|
|
|
|
int r;
|
|
|
|
|
|
|
|
|
|
if (count > SC_APDU_CHOP_SIZE) {
|
|
|
|
|
error(card->ctx, "Too large buffer supplied\n");
|
|
|
|
|
return SC_ERROR_CMD_TOO_LONG;
|
|
|
|
|
}
|
|
|
|
|
sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xD6,
|
|
|
|
|
(idx >> 8) & 0x7F, idx & 0xFF);
|
|
|
|
|
apdu.lc = count;
|
|
|
|
|
apdu.datalen = count;
|
|
|
|
|
apdu.data = buf;
|
|
|
|
|
|
|
|
|
|
r = sc_transmit_apdu(card, &apdu);
|
|
|
|
|
SC_TEST_RET(card->ctx, r, "APDU transmit failed");
|
|
|
|
|
SC_TEST_RET(card->ctx, sc_sw_to_errorcode(card, apdu.sw1, apdu.sw2),
|
|
|
|
|
"Card returned error");
|
|
|
|
|
SC_FUNC_RETURN(card->ctx, 3, count);
|
|
|
|
|
}
|
|
|
|
|
|
2001-12-22 20:43:09 +00:00
|
|
|
|
static void process_fci(struct sc_context *ctx, struct sc_file *file,
|
2002-01-08 13:56:50 +00:00
|
|
|
|
const u8 *buf, size_t buflen)
|
2001-12-22 20:43:09 +00:00
|
|
|
|
{
|
2001-12-29 19:03:46 +00:00
|
|
|
|
size_t taglen, len = buflen;
|
2001-12-22 20:43:09 +00:00
|
|
|
|
const u8 *tag = NULL, *p = buf;
|
|
|
|
|
|
|
|
|
|
if (ctx->debug >= 3)
|
|
|
|
|
debug(ctx, "processing FCI bytes\n");
|
2001-12-29 19:03:46 +00:00
|
|
|
|
tag = sc_asn1_find_tag(ctx, p, len, 0x83, &taglen);
|
2001-12-22 20:43:09 +00:00
|
|
|
|
if (tag != NULL && taglen == 2) {
|
|
|
|
|
file->id = (tag[0] << 8) | tag[1];
|
|
|
|
|
if (ctx->debug >= 3)
|
|
|
|
|
debug(ctx, " file identifier: 0x%02X%02X\n", tag[0],
|
|
|
|
|
tag[1]);
|
|
|
|
|
}
|
2001-12-29 19:03:46 +00:00
|
|
|
|
tag = sc_asn1_find_tag(ctx, p, len, 0x81, &taglen);
|
2001-12-22 20:43:09 +00:00
|
|
|
|
if (tag != NULL && taglen >= 2) {
|
|
|
|
|
int bytes = (tag[0] << 8) + tag[1];
|
|
|
|
|
if (ctx->debug >= 3)
|
|
|
|
|
debug(ctx, " bytes in file: %d\n", bytes);
|
|
|
|
|
file->size = bytes;
|
|
|
|
|
}
|
2001-12-29 19:03:46 +00:00
|
|
|
|
tag = sc_asn1_find_tag(ctx, p, len, 0x82, &taglen);
|
2001-12-22 20:43:09 +00:00
|
|
|
|
if (tag != NULL) {
|
|
|
|
|
if (taglen > 0) {
|
|
|
|
|
unsigned char byte = tag[0];
|
|
|
|
|
const char *type;
|
|
|
|
|
|
|
|
|
|
file->shareable = byte & 0x40 ? 1 : 0;
|
|
|
|
|
if (ctx->debug >= 3)
|
|
|
|
|
debug(ctx, " shareable: %s\n",
|
|
|
|
|
(byte & 0x40) ? "yes" : "no");
|
|
|
|
|
file->ef_structure = byte & 0x07;
|
2001-12-29 02:07:32 +00:00
|
|
|
|
switch ((byte >> 3) & 7) {
|
|
|
|
|
case 0:
|
|
|
|
|
type = "working EF";
|
|
|
|
|
file->type = SC_FILE_TYPE_WORKING_EF;
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
type = "internal EF";
|
|
|
|
|
file->type = SC_FILE_TYPE_INTERNAL_EF;
|
|
|
|
|
break;
|
|
|
|
|
case 7:
|
|
|
|
|
type = "DF";
|
|
|
|
|
file->type = SC_FILE_TYPE_DF;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
type = "unknown";
|
|
|
|
|
break;
|
|
|
|
|
}
|
2001-12-22 20:43:09 +00:00
|
|
|
|
if (ctx->debug >= 3) {
|
|
|
|
|
debug(ctx, " type: %s\n", type);
|
|
|
|
|
debug(ctx, " EF structure: %d\n",
|
|
|
|
|
byte & 0x07);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2001-12-29 19:03:46 +00:00
|
|
|
|
tag = sc_asn1_find_tag(ctx, p, len, 0x84, &taglen);
|
2001-12-22 20:43:09 +00:00
|
|
|
|
if (tag != NULL && taglen > 0 && taglen <= 16) {
|
|
|
|
|
char name[17];
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
memcpy(file->name, tag, taglen);
|
|
|
|
|
file->namelen = taglen;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < taglen; i++) {
|
|
|
|
|
if (isalnum(tag[i]) || ispunct(tag[i])
|
|
|
|
|
|| isspace(tag[i]))
|
|
|
|
|
name[i] = tag[i];
|
|
|
|
|
else
|
|
|
|
|
name[i] = '?';
|
|
|
|
|
}
|
|
|
|
|
name[taglen] = 0;
|
|
|
|
|
if (ctx->debug >= 3)
|
|
|
|
|
debug(ctx, "File name: %s\n", name);
|
|
|
|
|
}
|
2001-12-29 19:03:46 +00:00
|
|
|
|
tag = sc_asn1_find_tag(ctx, p, len, 0x85, &taglen);
|
2001-12-22 20:43:09 +00:00
|
|
|
|
if (tag != NULL && taglen && taglen <= SC_MAX_PROP_ATTR_SIZE) {
|
|
|
|
|
memcpy(file->prop_attr, tag, taglen);
|
|
|
|
|
file->prop_attr_len = taglen;
|
|
|
|
|
} else
|
|
|
|
|
file->prop_attr_len = 0;
|
2001-12-29 19:03:46 +00:00
|
|
|
|
tag = sc_asn1_find_tag(ctx, p, len, 0xA5, &taglen);
|
2001-12-29 12:39:41 +00:00
|
|
|
|
if (tag != NULL && taglen && taglen <= SC_MAX_PROP_ATTR_SIZE) {
|
|
|
|
|
memcpy(file->prop_attr, tag, taglen);
|
|
|
|
|
file->prop_attr_len = taglen;
|
|
|
|
|
}
|
2001-12-29 19:03:46 +00:00
|
|
|
|
tag = sc_asn1_find_tag(ctx, p, len, 0x86, &taglen);
|
2002-02-11 15:55:34 +00:00
|
|
|
|
if (tag != NULL && taglen && taglen <= SC_MAX_SEC_ATTR_SIZE) {
|
|
|
|
|
memcpy(file->sec_attr, tag, taglen);
|
|
|
|
|
file->sec_attr_len = taglen;
|
|
|
|
|
}
|
2001-12-22 20:43:09 +00:00
|
|
|
|
file->magic = SC_FILE_MAGIC;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int iso7816_select_file(struct sc_card *card,
|
2001-12-22 23:51:12 +00:00
|
|
|
|
const struct sc_path *in_path,
|
|
|
|
|
struct sc_file *file)
|
2001-12-22 20:43:09 +00:00
|
|
|
|
{
|
|
|
|
|
struct sc_context *ctx;
|
|
|
|
|
struct sc_apdu apdu;
|
2001-12-30 21:17:34 +00:00
|
|
|
|
u8 buf[SC_MAX_APDU_BUFFER_SIZE];
|
2001-12-22 20:43:09 +00:00
|
|
|
|
u8 pathbuf[SC_MAX_PATH_SIZE], *path = pathbuf;
|
|
|
|
|
int r, pathlen;
|
|
|
|
|
|
|
|
|
|
assert(card != NULL && in_path != NULL);
|
|
|
|
|
ctx = card->ctx;
|
|
|
|
|
memcpy(path, in_path->value, in_path->len);
|
|
|
|
|
pathlen = in_path->len;
|
|
|
|
|
|
2002-02-11 15:55:34 +00:00
|
|
|
|
sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0xA4, 0, 0);
|
2001-12-22 20:43:09 +00:00
|
|
|
|
|
|
|
|
|
switch (in_path->type) {
|
|
|
|
|
case SC_PATH_TYPE_FILE_ID:
|
|
|
|
|
apdu.p1 = 0;
|
|
|
|
|
if (pathlen != 2)
|
|
|
|
|
return SC_ERROR_INVALID_ARGUMENTS;
|
|
|
|
|
break;
|
|
|
|
|
case SC_PATH_TYPE_DF_NAME:
|
|
|
|
|
apdu.p1 = 4;
|
|
|
|
|
break;
|
|
|
|
|
case SC_PATH_TYPE_PATH:
|
|
|
|
|
apdu.p1 = 8;
|
|
|
|
|
if (pathlen >= 2 && memcmp(path, "\x3F\x00", 2) == 0) {
|
|
|
|
|
if (pathlen == 2) { /* only 3F00 supplied */
|
|
|
|
|
apdu.p1 = 0;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
path += 2;
|
|
|
|
|
pathlen -= 2;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
SC_FUNC_RETURN(card->ctx, 2, SC_ERROR_INVALID_ARGUMENTS);
|
|
|
|
|
}
|
2002-02-11 15:55:34 +00:00
|
|
|
|
apdu.p2 = 0; /* first record, return FCI */
|
2001-12-22 20:43:09 +00:00
|
|
|
|
apdu.lc = pathlen;
|
|
|
|
|
apdu.data = path;
|
|
|
|
|
apdu.datalen = pathlen;
|
|
|
|
|
|
|
|
|
|
if (file != NULL) {
|
2001-12-29 02:07:32 +00:00
|
|
|
|
int i;
|
|
|
|
|
/* initialize file to default values */
|
|
|
|
|
memset(file, 0, sizeof(struct sc_file));
|
|
|
|
|
for (i = 0; i < SC_MAX_AC_OPS; i++)
|
|
|
|
|
file->acl[i] = SC_AC_UNKNOWN;
|
2002-01-24 16:02:54 +00:00
|
|
|
|
file->path = *in_path;
|
2002-02-11 15:55:34 +00:00
|
|
|
|
|
|
|
|
|
apdu.resp = buf;
|
|
|
|
|
apdu.resplen = sizeof(buf);
|
|
|
|
|
apdu.le = 256;
|
|
|
|
|
} else {
|
2001-12-29 02:07:32 +00:00
|
|
|
|
apdu.resplen = 0;
|
2002-02-11 15:55:34 +00:00
|
|
|
|
apdu.le = 0;
|
|
|
|
|
apdu.cse = SC_APDU_CASE_3_SHORT;
|
|
|
|
|
apdu.p2 = 0x0c;
|
|
|
|
|
}
|
2001-12-22 20:43:09 +00:00
|
|
|
|
r = sc_transmit_apdu(card, &apdu);
|
|
|
|
|
SC_TEST_RET(card->ctx, r, "APDU transmit failed");
|
2002-01-09 01:03:10 +00:00
|
|
|
|
if (file == NULL) {
|
2001-12-22 20:43:09 +00:00
|
|
|
|
if (apdu.sw1 == 0x61)
|
|
|
|
|
SC_FUNC_RETURN(card->ctx, 2, 0);
|
|
|
|
|
SC_FUNC_RETURN(card->ctx, 2, sc_sw_to_errorcode(card, apdu.sw1, apdu.sw2));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
r = sc_sw_to_errorcode(card, apdu.sw1, apdu.sw2);
|
|
|
|
|
if (r)
|
|
|
|
|
SC_FUNC_RETURN(card->ctx, 2, r);
|
|
|
|
|
|
|
|
|
|
switch (apdu.resp[0]) {
|
|
|
|
|
case 0x6F:
|
|
|
|
|
if (file != NULL && apdu.resp[1] <= apdu.resplen)
|
|
|
|
|
process_fci(card->ctx, file, apdu.resp+2, apdu.resp[1]);
|
|
|
|
|
break;
|
|
|
|
|
case 0x00: /* proprietary coding */
|
|
|
|
|
SC_FUNC_RETURN(card->ctx, 2, SC_ERROR_UNKNOWN_REPLY);
|
|
|
|
|
default:
|
|
|
|
|
SC_FUNC_RETURN(card->ctx, 2, SC_ERROR_UNKNOWN_REPLY);
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int iso7816_get_challenge(struct sc_card *card, u8 *rnd, size_t len)
|
|
|
|
|
{
|
|
|
|
|
int r;
|
|
|
|
|
struct sc_apdu apdu;
|
|
|
|
|
u8 buf[10];
|
|
|
|
|
|
|
|
|
|
sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT,
|
|
|
|
|
0x84, 0x00, 0x00);
|
|
|
|
|
apdu.le = 8;
|
|
|
|
|
apdu.resp = buf;
|
|
|
|
|
apdu.resplen = 8; /* include SW's */
|
|
|
|
|
|
|
|
|
|
while (len > 0) {
|
|
|
|
|
int n = len > 8 ? 8 : len;
|
|
|
|
|
|
|
|
|
|
r = sc_transmit_apdu(card, &apdu);
|
|
|
|
|
SC_TEST_RET(card->ctx, r, "APDU transmit failed");
|
|
|
|
|
if (apdu.resplen != 8)
|
|
|
|
|
return sc_sw_to_errorcode(card, apdu.sw1, apdu.sw2);
|
|
|
|
|
memcpy(rnd, apdu.resp, n);
|
|
|
|
|
len -= n;
|
|
|
|
|
rnd += n;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2002-01-10 23:02:48 +00:00
|
|
|
|
static u8 acl_to_byte(unsigned int acl)
|
|
|
|
|
{
|
|
|
|
|
switch (acl) {
|
|
|
|
|
case SC_AC_NONE:
|
|
|
|
|
return 0x00;
|
|
|
|
|
case SC_AC_CHV1:
|
|
|
|
|
return 0x01;
|
|
|
|
|
case SC_AC_CHV2:
|
|
|
|
|
return 0x02;
|
|
|
|
|
case SC_AC_TERM:
|
|
|
|
|
return 0x04;
|
|
|
|
|
case SC_AC_NEVER:
|
|
|
|
|
return 0x0F;
|
|
|
|
|
}
|
|
|
|
|
return 0x00;
|
|
|
|
|
}
|
|
|
|
|
|
2002-01-08 13:56:50 +00:00
|
|
|
|
static int construct_fci(const struct sc_file *file, u8 *out, size_t *outlen)
|
|
|
|
|
{
|
|
|
|
|
u8 *p = out;
|
2002-01-10 23:02:48 +00:00
|
|
|
|
u8 buf[64];
|
|
|
|
|
int i;
|
2002-01-08 13:56:50 +00:00
|
|
|
|
|
|
|
|
|
*p++ = 0x6F;
|
|
|
|
|
p++;
|
|
|
|
|
|
|
|
|
|
buf[0] = (file->size >> 8) & 0xFF;
|
|
|
|
|
buf[1] = file->size & 0xFF;
|
|
|
|
|
sc_asn1_put_tag(0x81, buf, 2, p, 16, &p);
|
|
|
|
|
buf[0] = file->shareable ? 0x40 : 0;
|
|
|
|
|
switch (file->type) {
|
|
|
|
|
case SC_FILE_TYPE_WORKING_EF:
|
|
|
|
|
break;
|
|
|
|
|
case SC_FILE_TYPE_INTERNAL_EF:
|
|
|
|
|
buf[0] |= 0x08;
|
|
|
|
|
break;
|
|
|
|
|
case SC_FILE_TYPE_DF:
|
|
|
|
|
buf[0] |= 0x38;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
return SC_ERROR_NOT_SUPPORTED;
|
|
|
|
|
}
|
|
|
|
|
buf[0] |= file->ef_structure & 7;
|
|
|
|
|
sc_asn1_put_tag(0x82, buf, 1, p, 16, &p);
|
|
|
|
|
buf[0] = (file->id >> 8) & 0xFF;
|
|
|
|
|
buf[1] = file->id & 0xFF;
|
|
|
|
|
sc_asn1_put_tag(0x83, buf, 2, p, 16, &p);
|
|
|
|
|
/* 0x84 = DF name */
|
|
|
|
|
if (file->prop_attr_len) {
|
|
|
|
|
memcpy(buf, file->prop_attr, file->prop_attr_len);
|
|
|
|
|
sc_asn1_put_tag(0x85, buf, file->prop_attr_len, p, 18, &p);
|
|
|
|
|
}
|
|
|
|
|
if (file->sec_attr_len) {
|
|
|
|
|
memcpy(buf, file->sec_attr, file->sec_attr_len);
|
|
|
|
|
sc_asn1_put_tag(0x86, buf, file->sec_attr_len, p, 18, &p);
|
2002-01-10 23:02:48 +00:00
|
|
|
|
} else {
|
|
|
|
|
int idx[6];
|
|
|
|
|
if (file->type == SC_FILE_TYPE_DF) {
|
|
|
|
|
const int df_idx[6] = {
|
|
|
|
|
SC_AC_OP_SELECT, SC_AC_OP_LOCK, SC_AC_OP_DELETE,
|
|
|
|
|
SC_AC_OP_CREATE, SC_AC_OP_REHABILITATE,
|
|
|
|
|
SC_AC_OP_INVALIDATE
|
|
|
|
|
};
|
|
|
|
|
for (i = 0; i < 6; i++)
|
|
|
|
|
idx[i] = df_idx[i];
|
|
|
|
|
} else {
|
|
|
|
|
const int ef_idx[6] = {
|
|
|
|
|
SC_AC_OP_READ, SC_AC_OP_UPDATE, SC_AC_OP_WRITE,
|
|
|
|
|
SC_AC_OP_ERASE, SC_AC_OP_REHABILITATE,
|
|
|
|
|
SC_AC_OP_INVALIDATE
|
|
|
|
|
};
|
|
|
|
|
for (i = 0; i < 6; i++)
|
|
|
|
|
idx[i] = ef_idx[i];
|
|
|
|
|
}
|
|
|
|
|
for (i = 0; i < 6; i++)
|
|
|
|
|
buf[i] = acl_to_byte(file->acl[idx[i]]);
|
|
|
|
|
sc_asn1_put_tag(0x86, buf, 6, p, 18, &p);
|
2002-01-08 13:56:50 +00:00
|
|
|
|
}
|
|
|
|
|
out[1] = p - out - 2;
|
|
|
|
|
|
|
|
|
|
*outlen = p - out;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2002-01-17 11:44:27 +00:00
|
|
|
|
static int iso7816_create_file(struct sc_card *card, struct sc_file *file)
|
2002-01-08 13:56:50 +00:00
|
|
|
|
{
|
2002-01-10 13:49:54 +00:00
|
|
|
|
int r;
|
|
|
|
|
size_t len;
|
2002-01-08 13:56:50 +00:00
|
|
|
|
u8 sbuf[SC_MAX_APDU_BUFFER_SIZE];
|
|
|
|
|
struct sc_apdu apdu;
|
|
|
|
|
|
|
|
|
|
len = SC_MAX_APDU_BUFFER_SIZE;
|
|
|
|
|
r = construct_fci(file, sbuf, &len);
|
|
|
|
|
SC_TEST_RET(card->ctx, r, "construct_fci() failed");
|
|
|
|
|
|
|
|
|
|
sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xE0, 0x00, 0x00);
|
|
|
|
|
apdu.lc = len;
|
|
|
|
|
apdu.datalen = len;
|
|
|
|
|
apdu.data = sbuf;
|
|
|
|
|
|
|
|
|
|
r = sc_transmit_apdu(card, &apdu);
|
|
|
|
|
SC_TEST_RET(card->ctx, r, "APDU transmit failed");
|
|
|
|
|
return sc_sw_to_errorcode(card, apdu.sw1, apdu.sw2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int iso7816_delete_file(struct sc_card *card, const struct sc_path *path)
|
|
|
|
|
{
|
|
|
|
|
int r;
|
|
|
|
|
u8 sbuf[2];
|
|
|
|
|
struct sc_apdu apdu;
|
|
|
|
|
|
|
|
|
|
SC_FUNC_CALLED(card->ctx, 1);
|
|
|
|
|
if (path->type != SC_PATH_TYPE_FILE_ID && path->len != 2) {
|
|
|
|
|
error(card->ctx, "File type has to be SC_PATH_TYPE_FILE_ID\n");
|
|
|
|
|
SC_FUNC_RETURN(card->ctx, 1, SC_ERROR_INVALID_ARGUMENTS);
|
|
|
|
|
}
|
|
|
|
|
sbuf[0] = path->value[0];
|
|
|
|
|
sbuf[1] = path->value[1];
|
|
|
|
|
sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xE4, 0x00, 0x00);
|
|
|
|
|
apdu.lc = 2;
|
|
|
|
|
apdu.datalen = 2;
|
|
|
|
|
apdu.data = sbuf;
|
|
|
|
|
|
|
|
|
|
r = sc_transmit_apdu(card, &apdu);
|
|
|
|
|
SC_TEST_RET(card->ctx, r, "APDU transmit failed");
|
|
|
|
|
return sc_sw_to_errorcode(card, apdu.sw1, apdu.sw2);
|
|
|
|
|
}
|
|
|
|
|
|
2002-01-09 01:03:10 +00:00
|
|
|
|
static int iso7816_list_files(struct sc_card *card, u8 *buf, size_t buflen)
|
|
|
|
|
{
|
|
|
|
|
struct sc_apdu apdu;
|
|
|
|
|
int r;
|
|
|
|
|
|
|
|
|
|
sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xAA, 0, 0);
|
|
|
|
|
apdu.resp = buf;
|
|
|
|
|
apdu.resplen = buflen;
|
2002-02-11 15:55:34 +00:00
|
|
|
|
apdu.le = buflen > 256 ? 256 : buflen;
|
2002-01-09 01:03:10 +00:00
|
|
|
|
r = sc_transmit_apdu(card, &apdu);
|
|
|
|
|
SC_TEST_RET(card->ctx, r, "APDU transmit failed");
|
|
|
|
|
if (apdu.resplen == 0)
|
|
|
|
|
return sc_sw_to_errorcode(card, apdu.sw1, apdu.sw2);
|
|
|
|
|
return apdu.resplen;
|
|
|
|
|
}
|
|
|
|
|
|
2002-01-10 23:02:48 +00:00
|
|
|
|
static int iso7816_verify(struct sc_card *card, unsigned int type, int ref,
|
|
|
|
|
const u8 *pin, size_t pinlen, int *tries_left)
|
|
|
|
|
{
|
|
|
|
|
struct sc_apdu apdu;
|
|
|
|
|
u8 sbuf[SC_MAX_APDU_BUFFER_SIZE];
|
|
|
|
|
int r;
|
|
|
|
|
|
|
|
|
|
if (pinlen >= SC_MAX_APDU_BUFFER_SIZE)
|
|
|
|
|
return SC_ERROR_INVALID_ARGUMENTS;
|
|
|
|
|
switch (type) {
|
|
|
|
|
case SC_AC_CHV1:
|
|
|
|
|
case SC_AC_CHV2:
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
return SC_ERROR_INVALID_ARGUMENTS;
|
|
|
|
|
}
|
|
|
|
|
sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x20, 0, ref);
|
|
|
|
|
memcpy(sbuf, pin, pinlen);
|
|
|
|
|
apdu.lc = pinlen;
|
|
|
|
|
apdu.datalen = pinlen;
|
|
|
|
|
apdu.data = sbuf;
|
|
|
|
|
apdu.resplen = 0;
|
|
|
|
|
|
|
|
|
|
r = sc_transmit_apdu(card, &apdu);
|
|
|
|
|
memset(sbuf, 0, pinlen);
|
|
|
|
|
SC_TEST_RET(card->ctx, r, "APDU transmit failed");
|
|
|
|
|
if (apdu.sw1 == 0x63) {
|
|
|
|
|
if ((apdu.sw2 & 0xF0) == 0xC0 && tries_left != NULL)
|
|
|
|
|
*tries_left = apdu.sw2 & 0x0F;
|
|
|
|
|
return SC_ERROR_PIN_CODE_INCORRECT;
|
|
|
|
|
}
|
|
|
|
|
return sc_sw_to_errorcode(card, apdu.sw1, apdu.sw2);
|
|
|
|
|
}
|
|
|
|
|
|
2002-01-16 23:59:18 +00:00
|
|
|
|
static int iso7816_set_security_env(struct sc_card *card,
|
|
|
|
|
const struct sc_security_env *env,
|
|
|
|
|
int se_num)
|
|
|
|
|
{
|
|
|
|
|
struct sc_apdu apdu;
|
|
|
|
|
u8 sbuf[SC_MAX_APDU_BUFFER_SIZE];
|
|
|
|
|
u8 *p;
|
|
|
|
|
int r, locked = 0;
|
|
|
|
|
|
|
|
|
|
assert(card != NULL && env != NULL);
|
|
|
|
|
sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x22, 0, 0);
|
|
|
|
|
switch (env->operation) {
|
|
|
|
|
case SC_SEC_OPERATION_DECIPHER:
|
|
|
|
|
apdu.p1 = 0x41;
|
|
|
|
|
apdu.p2 = 0xB8;
|
|
|
|
|
break;
|
|
|
|
|
case SC_SEC_OPERATION_SIGN:
|
|
|
|
|
apdu.p1 = 0x81;
|
|
|
|
|
apdu.p2 = 0xB6;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
return SC_ERROR_INVALID_ARGUMENTS;
|
|
|
|
|
}
|
|
|
|
|
apdu.le = 0;
|
|
|
|
|
p = sbuf;
|
|
|
|
|
if (env->flags & SC_SEC_ENV_ALG_REF_PRESENT) {
|
|
|
|
|
*p++ = 0x80; /* algorithm reference */
|
2002-01-20 21:20:09 +00:00
|
|
|
|
*p++ = 0x01;
|
2002-01-16 23:59:18 +00:00
|
|
|
|
*p++ = env->algorithm_ref & 0xFF;
|
|
|
|
|
}
|
|
|
|
|
if (env->flags & SC_SEC_ENV_FILE_REF_PRESENT) {
|
|
|
|
|
*p++ = 0x81;
|
2002-01-20 21:20:09 +00:00
|
|
|
|
*p++ = env->file_ref.len;
|
|
|
|
|
memcpy(p, env->file_ref.value, env->file_ref.len);
|
|
|
|
|
p += env->file_ref.len;
|
2002-01-16 23:59:18 +00:00
|
|
|
|
}
|
|
|
|
|
if (env->flags & SC_SEC_ENV_KEY_REF_PRESENT) {
|
2002-01-20 21:20:09 +00:00
|
|
|
|
if (env->flags & SC_SEC_ENV_KEY_REF_ASYMMETRIC)
|
|
|
|
|
*p++ = 0x83;
|
|
|
|
|
else
|
|
|
|
|
*p++ = 0x84;
|
|
|
|
|
*p++ = env->key_ref_len;
|
|
|
|
|
memcpy(p, env->key_ref, env->key_ref_len);
|
|
|
|
|
p += env->key_ref_len;
|
2002-01-16 23:59:18 +00:00
|
|
|
|
}
|
|
|
|
|
r = p - sbuf;
|
|
|
|
|
apdu.lc = r;
|
|
|
|
|
apdu.datalen = r;
|
|
|
|
|
apdu.data = sbuf;
|
|
|
|
|
apdu.resplen = 0;
|
|
|
|
|
if (se_num > 0) {
|
|
|
|
|
r = sc_lock(card);
|
|
|
|
|
SC_TEST_RET(card->ctx, r, "sc_lock() failed");
|
|
|
|
|
locked = 1;
|
|
|
|
|
}
|
|
|
|
|
if (apdu.datalen != 0) {
|
|
|
|
|
r = sc_transmit_apdu(card, &apdu);
|
|
|
|
|
if (r) {
|
|
|
|
|
sc_perror(card->ctx, r, "APDU transmit failed");
|
|
|
|
|
goto err;
|
|
|
|
|
}
|
|
|
|
|
r = sc_sw_to_errorcode(card, apdu.sw1, apdu.sw2);
|
|
|
|
|
if (r) {
|
|
|
|
|
sc_perror(card->ctx, r, "Card returned error");
|
|
|
|
|
goto err;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (se_num <= 0)
|
|
|
|
|
return 0;
|
|
|
|
|
sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x22, 0xF2, se_num);
|
|
|
|
|
r = sc_transmit_apdu(card, &apdu);
|
|
|
|
|
sc_unlock(card);
|
|
|
|
|
SC_TEST_RET(card->ctx, r, "APDU transmit failed");
|
|
|
|
|
return sc_sw_to_errorcode(card, apdu.sw1, apdu.sw2);
|
|
|
|
|
err:
|
|
|
|
|
if (locked)
|
|
|
|
|
sc_unlock(card);
|
|
|
|
|
return r;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int iso7816_restore_security_env(struct sc_card *card, int se_num)
|
|
|
|
|
{
|
|
|
|
|
struct sc_apdu apdu;
|
|
|
|
|
int r;
|
|
|
|
|
u8 rbuf[MAX_BUFFER_SIZE];
|
|
|
|
|
|
|
|
|
|
assert(card != NULL);
|
|
|
|
|
|
|
|
|
|
sc_format_apdu(card, &apdu, SC_APDU_CASE_1, 0x22, 0xF3, se_num);
|
|
|
|
|
apdu.resplen = sizeof(rbuf) > 250 ? 250 : sizeof(rbuf);
|
|
|
|
|
apdu.resp = rbuf;
|
|
|
|
|
r = sc_transmit_apdu(card, &apdu);
|
|
|
|
|
SC_TEST_RET(card->ctx, r, "APDU transmit failed");
|
|
|
|
|
return sc_sw_to_errorcode(card, apdu.sw1, apdu.sw2);
|
|
|
|
|
}
|
|
|
|
|
|
2002-01-20 21:20:09 +00:00
|
|
|
|
static int iso7816_compute_signature(struct sc_card *card,
|
|
|
|
|
const u8 * data, size_t datalen,
|
|
|
|
|
u8 * out, size_t outlen)
|
|
|
|
|
{
|
|
|
|
|
int r;
|
|
|
|
|
struct sc_apdu apdu;
|
|
|
|
|
u8 rbuf[MAX_BUFFER_SIZE];
|
|
|
|
|
u8 sbuf[MAX_BUFFER_SIZE];
|
|
|
|
|
|
|
|
|
|
assert(card != NULL && data != NULL && out != NULL);
|
|
|
|
|
if (datalen > 255)
|
|
|
|
|
SC_FUNC_RETURN(card->ctx, 4, SC_ERROR_INVALID_ARGUMENTS);
|
|
|
|
|
|
|
|
|
|
/* INS: 0x2A PERFORM SECURITY OPERATION
|
|
|
|
|
* P1: 0x9E Resp: Digital Signature
|
|
|
|
|
* P2: 0x9A Cmd: Input for Digital Signature */
|
|
|
|
|
sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x2A, 0x9E,
|
|
|
|
|
0x9A);
|
|
|
|
|
apdu.resp = rbuf;
|
|
|
|
|
apdu.resplen = sizeof(rbuf); /* FIXME */
|
|
|
|
|
|
|
|
|
|
memcpy(sbuf, data, datalen);
|
|
|
|
|
apdu.data = sbuf;
|
|
|
|
|
apdu.lc = datalen;
|
|
|
|
|
apdu.datalen = datalen;
|
|
|
|
|
r = sc_transmit_apdu(card, &apdu);
|
|
|
|
|
SC_TEST_RET(card->ctx, r, "APDU transmit failed");
|
|
|
|
|
if (apdu.sw1 == 0x90 && apdu.sw2 == 0x00) {
|
|
|
|
|
int len = apdu.resplen > outlen ? outlen : apdu.resplen;
|
|
|
|
|
|
|
|
|
|
memcpy(out, apdu.resp, len);
|
|
|
|
|
SC_FUNC_RETURN(card->ctx, 4, len);
|
|
|
|
|
}
|
|
|
|
|
SC_FUNC_RETURN(card->ctx, 4, sc_sw_to_errorcode(card, apdu.sw1, apdu.sw2));
|
|
|
|
|
}
|
|
|
|
|
|
2002-02-10 18:04:03 +00:00
|
|
|
|
static int iso7816_change_reference_data(struct sc_card *card, unsigned int type,
|
|
|
|
|
int ref, const u8 *old, size_t oldlen,
|
|
|
|
|
const u8 *new, size_t newlen,
|
|
|
|
|
int *tries_left)
|
|
|
|
|
{
|
|
|
|
|
struct sc_apdu apdu;
|
|
|
|
|
u8 sbuf[SC_MAX_APDU_BUFFER_SIZE];
|
|
|
|
|
int r, p1 = 0, len = oldlen + newlen;
|
|
|
|
|
|
|
|
|
|
if (len >= SC_MAX_APDU_BUFFER_SIZE)
|
|
|
|
|
SC_FUNC_RETURN(card->ctx, 1, SC_ERROR_INVALID_ARGUMENTS);
|
|
|
|
|
switch (type) {
|
|
|
|
|
case SC_AC_CHV1:
|
|
|
|
|
case SC_AC_CHV2:
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
return SC_ERROR_INVALID_ARGUMENTS;
|
|
|
|
|
}
|
|
|
|
|
if (oldlen == 0)
|
|
|
|
|
p1 = 1;
|
|
|
|
|
sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x24, p1, ref);
|
|
|
|
|
memcpy(sbuf, old, oldlen);
|
|
|
|
|
memcpy(sbuf + oldlen, new, newlen);
|
|
|
|
|
apdu.lc = len;
|
|
|
|
|
apdu.datalen = len;
|
|
|
|
|
apdu.data = sbuf;
|
|
|
|
|
apdu.resplen = 0;
|
|
|
|
|
|
|
|
|
|
r = sc_transmit_apdu(card, &apdu);
|
|
|
|
|
memset(sbuf, 0, len);
|
|
|
|
|
SC_TEST_RET(card->ctx, r, "APDU transmit failed");
|
|
|
|
|
if (apdu.sw1 == 0x63 && (apdu.sw2 & 0xF0) == 0xC0) {
|
|
|
|
|
if (tries_left != NULL)
|
|
|
|
|
*tries_left = apdu.sw2 & 0x0F;
|
|
|
|
|
SC_FUNC_RETURN(card->ctx, 1, SC_ERROR_PIN_CODE_INCORRECT);
|
|
|
|
|
}
|
|
|
|
|
return sc_sw_to_errorcode(card, apdu.sw1, apdu.sw2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int iso7816_reset_retry_counter(struct sc_card *card, unsigned int type, int ref,
|
|
|
|
|
const u8 *puk, size_t puklen, const u8 *new,
|
|
|
|
|
size_t newlen)
|
|
|
|
|
{
|
|
|
|
|
struct sc_apdu apdu;
|
|
|
|
|
u8 sbuf[MAX_BUFFER_SIZE];
|
|
|
|
|
int r, p1 = 0, len = puklen + newlen;
|
|
|
|
|
|
|
|
|
|
if (len >= MAX_BUFFER_SIZE)
|
|
|
|
|
SC_FUNC_RETURN(card->ctx, 1, SC_ERROR_INVALID_ARGUMENTS);
|
|
|
|
|
switch (type) {
|
|
|
|
|
case SC_AC_CHV1:
|
|
|
|
|
case SC_AC_CHV2:
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
return SC_ERROR_INVALID_ARGUMENTS;
|
|
|
|
|
}
|
|
|
|
|
if (puklen == 0) {
|
|
|
|
|
if (newlen == 0)
|
|
|
|
|
p1 = 3;
|
|
|
|
|
else
|
|
|
|
|
p1 = 2;
|
|
|
|
|
} else {
|
|
|
|
|
if (newlen == 0)
|
|
|
|
|
p1 = 1;
|
|
|
|
|
else
|
|
|
|
|
p1 = 0;
|
|
|
|
|
}
|
|
|
|
|
sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x2C, p1, ref);
|
|
|
|
|
memcpy(sbuf, puk, puklen);
|
|
|
|
|
memcpy(sbuf + puklen, new, newlen);
|
|
|
|
|
apdu.lc = len;
|
|
|
|
|
apdu.datalen = len;
|
|
|
|
|
apdu.data = sbuf;
|
|
|
|
|
apdu.resplen = 0;
|
|
|
|
|
|
|
|
|
|
r = sc_transmit_apdu(card, &apdu);
|
|
|
|
|
memset(sbuf, 0, len);
|
|
|
|
|
SC_TEST_RET(card->ctx, r, "APDU transmit failed");
|
|
|
|
|
return sc_sw_to_errorcode(card, apdu.sw1, apdu.sw2);
|
|
|
|
|
}
|
2002-01-20 21:20:09 +00:00
|
|
|
|
|
2001-12-22 20:43:09 +00:00
|
|
|
|
static struct sc_card_operations iso_ops = {
|
2001-12-29 12:44:11 +00:00
|
|
|
|
NULL,
|
2001-12-22 20:43:09 +00:00
|
|
|
|
};
|
2002-01-08 13:56:50 +00:00
|
|
|
|
|
2001-12-22 20:43:09 +00:00
|
|
|
|
static const struct sc_card_driver iso_driver = {
|
2001-12-29 12:39:41 +00:00
|
|
|
|
NULL,
|
2002-01-08 13:56:50 +00:00
|
|
|
|
"ISO 7816 reference driver",
|
|
|
|
|
"iso7816",
|
2001-12-29 12:39:41 +00:00
|
|
|
|
&iso_ops
|
2001-12-22 20:43:09 +00:00
|
|
|
|
};
|
|
|
|
|
|
2001-12-29 12:44:11 +00:00
|
|
|
|
static int no_match(struct sc_card *card)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2001-12-22 20:43:09 +00:00
|
|
|
|
const struct sc_card_driver * sc_get_iso7816_driver(void)
|
|
|
|
|
{
|
2001-12-29 12:44:11 +00:00
|
|
|
|
if (iso_ops.match_card == NULL) {
|
2001-12-22 20:43:09 +00:00
|
|
|
|
memset(&iso_ops, 0, sizeof(iso_ops));
|
2002-01-08 13:56:50 +00:00
|
|
|
|
iso_ops.match_card = no_match;
|
|
|
|
|
iso_ops.read_binary = iso7816_read_binary;
|
|
|
|
|
iso_ops.read_record = iso7816_read_record;
|
|
|
|
|
iso_ops.write_binary = iso7816_write_binary;
|
2002-01-13 23:56:13 +00:00
|
|
|
|
iso_ops.update_binary = iso7816_update_binary;
|
2002-01-08 13:56:50 +00:00
|
|
|
|
iso_ops.select_file = iso7816_select_file;
|
2001-12-22 20:43:09 +00:00
|
|
|
|
iso_ops.get_challenge = iso7816_get_challenge;
|
2002-01-08 13:56:50 +00:00
|
|
|
|
iso_ops.create_file = iso7816_create_file;
|
2002-01-16 23:59:18 +00:00
|
|
|
|
iso_ops.delete_file = iso7816_delete_file;
|
|
|
|
|
iso_ops.list_files = iso7816_list_files;
|
|
|
|
|
iso_ops.verify = iso7816_verify;
|
|
|
|
|
iso_ops.set_security_env = iso7816_set_security_env;
|
|
|
|
|
iso_ops.restore_security_env = iso7816_restore_security_env;
|
2002-01-20 21:20:09 +00:00
|
|
|
|
iso_ops.compute_signature = iso7816_compute_signature;
|
2002-02-10 18:04:03 +00:00
|
|
|
|
iso_ops.reset_retry_counter = iso7816_reset_retry_counter;
|
|
|
|
|
iso_ops.change_reference_data = iso7816_change_reference_data;
|
2001-12-22 20:43:09 +00:00
|
|
|
|
}
|
|
|
|
|
return &iso_driver;
|
|
|
|
|
}
|