|
Packit |
cfa437 |
/*
|
|
Packit |
cfa437 |
* defines the entry point for the Global Plarform Applet emulation. Only used
|
|
Packit |
cfa437 |
* by vcard_emul_type.c
|
|
Packit |
cfa437 |
*
|
|
Packit |
cfa437 |
* Copyright 2018 Red Hat, Inc.
|
|
Packit |
cfa437 |
*
|
|
Packit |
cfa437 |
* Author: Jakub Jelen <jjelen@redhat.com>
|
|
Packit |
cfa437 |
*
|
|
Packit |
cfa437 |
* This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
|
|
Packit |
cfa437 |
* See the COPYING file in the top-level directory.
|
|
Packit |
cfa437 |
*/
|
|
Packit |
cfa437 |
|
|
Packit |
cfa437 |
#include "glib-compat.h"
|
|
Packit |
cfa437 |
|
|
Packit |
cfa437 |
#include <string.h>
|
|
Packit |
cfa437 |
#include <stdio.h>
|
|
Packit |
cfa437 |
#include <stdbool.h>
|
|
Packit |
cfa437 |
|
|
Packit |
cfa437 |
#include "gp.h"
|
|
Packit |
cfa437 |
#include "vcard.h"
|
|
Packit |
cfa437 |
#include "vcard_emul.h"
|
|
Packit |
cfa437 |
#include "card_7816.h"
|
|
Packit |
cfa437 |
|
|
Packit |
cfa437 |
static unsigned char gp_container_aid[] = {
|
|
Packit |
cfa437 |
0xa0, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00 };
|
|
Packit |
cfa437 |
|
|
Packit |
cfa437 |
/* Data returned for Get Data Instruction */
|
|
Packit |
cfa437 |
static unsigned char gp_get_data[] = {
|
|
Packit |
cfa437 |
0x9F, 0x7F, 0x2A, 0x40, 0x70, 0x50, 0x72, 0x12,
|
|
Packit |
cfa437 |
0x91, 0x51, 0x81, 0x01, 0x00, 0x70, 0x70, 0x00,
|
|
Packit |
cfa437 |
0x00, 0x58, 0xBD, 0x36, 0x0E, 0x40, 0x82, 0x70,
|
|
Packit |
cfa437 |
0x90, 0x12, 0x93, 0x70, 0x90, 0x04, 0x44, 0x72,
|
|
Packit |
cfa437 |
0x00, 0x00, 0x01, 0x00, 0x40, 0x04, 0x45, 0x84,
|
|
Packit |
cfa437 |
0x00, 0x00, 0x2C, 0x19, 0xB5
|
|
Packit |
cfa437 |
};
|
|
Packit |
cfa437 |
|
|
Packit |
cfa437 |
static VCardStatus
|
|
Packit |
cfa437 |
gp_applet_container_process_apdu(VCard *card, VCardAPDU *apdu,
|
|
Packit |
cfa437 |
VCardResponse **response)
|
|
Packit |
cfa437 |
{
|
|
Packit |
cfa437 |
VCardStatus ret = VCARD_FAIL;
|
|
Packit |
cfa437 |
unsigned int tag;
|
|
Packit |
cfa437 |
|
|
Packit |
cfa437 |
switch (apdu->a_ins) {
|
|
Packit |
cfa437 |
case GP_GET_DATA:
|
|
Packit |
cfa437 |
/* GET DATA isntruction for tags:
|
|
Packit |
cfa437 |
* 00 66 (not found):
|
|
Packit |
cfa437 |
* 9F 7F (len = 2D):
|
|
Packit |
cfa437 |
* 9F 7F 2A 40 70 50 72 12 91 51 81 01 00 70 70 00
|
|
Packit |
cfa437 |
* 00 58 BD 36 0E 40 82 70 90 12 93 70 90 04 44 72
|
|
Packit |
cfa437 |
* 00 00 01 00 40 04 45 84 00 00 2C 19 B5
|
|
Packit |
cfa437 |
*/
|
|
Packit |
cfa437 |
tag = (apdu->a_p1 & 0xff) << 8 | (apdu->a_p2 & 0xff);
|
|
Packit |
cfa437 |
if (tag == 0x9f7f) {
|
|
Packit |
cfa437 |
*response = vcard_response_new(card, gp_get_data,
|
|
Packit |
cfa437 |
sizeof(gp_get_data), apdu->a_Le, VCARD7816_STATUS_SUCCESS);
|
|
Packit |
cfa437 |
ret = VCARD_DONE;
|
|
Packit |
cfa437 |
break;
|
|
Packit |
cfa437 |
}
|
|
Packit |
cfa437 |
*response = vcard_make_response(VCARD7816_STATUS_ERROR_DATA_NOT_FOUND);
|
|
Packit |
cfa437 |
ret = VCARD_DONE;
|
|
Packit |
cfa437 |
break;
|
|
Packit |
cfa437 |
|
|
Packit |
cfa437 |
default:
|
|
Packit |
cfa437 |
/* Let the ISO 7816 code to handle other APDUs */
|
|
Packit |
cfa437 |
ret = VCARD_NEXT;
|
|
Packit |
cfa437 |
break;
|
|
Packit |
cfa437 |
}
|
|
Packit |
cfa437 |
return ret;
|
|
Packit |
cfa437 |
}
|
|
Packit |
cfa437 |
|
|
Packit |
cfa437 |
|
|
Packit |
cfa437 |
/*
|
|
Packit |
cfa437 |
* Initialize the cac card. This is the only public function in this file. All
|
|
Packit |
cfa437 |
* the rest are connected through function pointers.
|
|
Packit |
cfa437 |
*/
|
|
Packit |
cfa437 |
VCardStatus
|
|
Packit |
cfa437 |
gp_card_init(VReader *reader, VCard *card,
|
|
Packit |
cfa437 |
const char *params,
|
|
Packit |
cfa437 |
unsigned char * const *cert,
|
|
Packit |
cfa437 |
int cert_len[],
|
|
Packit |
cfa437 |
VCardKey *key[] /* adopt the keys*/,
|
|
Packit |
cfa437 |
int cert_count)
|
|
Packit |
cfa437 |
{
|
|
Packit |
cfa437 |
VCardApplet *applet;
|
|
Packit |
cfa437 |
|
|
Packit |
cfa437 |
/* create Card Manager container */
|
|
Packit |
cfa437 |
applet = vcard_new_applet(gp_applet_container_process_apdu,
|
|
Packit |
cfa437 |
NULL, gp_container_aid,
|
|
Packit |
cfa437 |
sizeof(gp_container_aid));
|
|
Packit |
cfa437 |
if (applet == NULL) {
|
|
Packit |
cfa437 |
goto failure;
|
|
Packit |
cfa437 |
}
|
|
Packit |
cfa437 |
vcard_add_applet(card, applet);
|
|
Packit |
cfa437 |
|
|
Packit |
cfa437 |
return VCARD_DONE;
|
|
Packit |
cfa437 |
|
|
Packit |
cfa437 |
failure:
|
|
Packit |
cfa437 |
return VCARD_FAIL;
|
|
Packit |
cfa437 |
}
|
|
Packit |
cfa437 |
|
|
Packit |
cfa437 |
/* vim: set ts=4 sw=4 tw=0 noet expandtab: */
|