IsoApplet: Obtain applet version and card capabilities *after* match_card()
This commit is contained in:
parent
bba6e17aa9
commit
ab5ca331b2
|
@ -48,6 +48,7 @@ struct isoApplet_drv_data
|
||||||
* have to be modified. */
|
* have to be modified. */
|
||||||
unsigned int sec_env_alg_ref;
|
unsigned int sec_env_alg_ref;
|
||||||
unsigned int sec_env_ec_field_length;
|
unsigned int sec_env_ec_field_length;
|
||||||
|
unsigned int isoapplet_version;
|
||||||
};
|
};
|
||||||
#define DRVDATA(card) ((struct isoApplet_drv_data *) ((card)->drv_data))
|
#define DRVDATA(card) ((struct isoApplet_drv_data *) ((card)->drv_data))
|
||||||
|
|
||||||
|
@ -142,19 +143,12 @@ isoApplet_match_card(sc_card_t *card)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The IsoApplet should return an API version (major and minor) and a feature bitmap.
|
/* The IsoApplet should return an API version (major and minor) and a feature bitmap.
|
||||||
|
* We expect 3 bytes: MAJOR API version - MINOR API version - API feature bitmap.
|
||||||
* If applet does not return API version, versions 0x00 will match */
|
* If applet does not return API version, versions 0x00 will match */
|
||||||
if(rlen == 0)
|
if(rlen < 3)
|
||||||
{
|
{
|
||||||
rbuf[0] = 0x00;
|
assert(sizeof(rbuf) >= 3);
|
||||||
rbuf[1] = 0x00;
|
memset(rbuf, 0x00, 3);
|
||||||
rbuf[2] = 0x00;
|
|
||||||
rlen = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* We expect 3 bytes: MAJOR API version - MINOR API version - API feature bitmap */
|
|
||||||
if(rlen != 3)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(rbuf[0] != ISOAPPLET_API_VERSION_MAJOR)
|
if(rbuf[0] != ISOAPPLET_API_VERSION_MAJOR)
|
||||||
|
@ -173,11 +167,6 @@ isoApplet_match_card(sc_card_t *card)
|
||||||
ISOAPPLET_API_VERSION_MAJOR, ISOAPPLET_API_VERSION_MINOR, rbuf[0], rbuf[1]);
|
ISOAPPLET_API_VERSION_MAJOR, ISOAPPLET_API_VERSION_MINOR, rbuf[0], rbuf[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(rbuf[2] & ISOAPPLET_API_FEATURE_EXT_APDU)
|
|
||||||
{
|
|
||||||
card->caps |= SC_CARD_CAP_APDU_EXT;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,6 +176,8 @@ isoApplet_init(sc_card_t *card)
|
||||||
int r;
|
int r;
|
||||||
unsigned long flags = 0;
|
unsigned long flags = 0;
|
||||||
unsigned long ext_flags = 0;
|
unsigned long ext_flags = 0;
|
||||||
|
size_t rlen = SC_MAX_APDU_BUFFER_SIZE;
|
||||||
|
u8 rbuf[SC_MAX_APDU_BUFFER_SIZE];
|
||||||
struct isoApplet_drv_data *drvdata;
|
struct isoApplet_drv_data *drvdata;
|
||||||
struct sc_object_id curve_oid;
|
struct sc_object_id curve_oid;
|
||||||
|
|
||||||
|
@ -199,6 +190,18 @@ isoApplet_init(sc_card_t *card)
|
||||||
card->drv_data = drvdata;
|
card->drv_data = drvdata;
|
||||||
card->cla = 0x00;
|
card->cla = 0x00;
|
||||||
|
|
||||||
|
/* Obtain applet version and specific features */
|
||||||
|
r = isoApplet_select_applet(card, isoApplet_aid, ISOAPPLET_AID_LEN, rbuf, &rlen);
|
||||||
|
LOG_TEST_RET(card->ctx, r, "Error obtaining applet version.");
|
||||||
|
if(rlen < 3)
|
||||||
|
{
|
||||||
|
assert(sizeof(rbuf) >= 3);
|
||||||
|
memset(rbuf, 0x00, 3);
|
||||||
|
}
|
||||||
|
drvdata->isoapplet_version = ((unsigned int)rbuf[0] << 8) | rbuf[1];
|
||||||
|
if(rbuf[2] & ISOAPPLET_API_FEATURE_EXT_APDU)
|
||||||
|
card->caps |= SC_CARD_CAP_APDU_EXT;
|
||||||
|
|
||||||
/* ECDSA
|
/* ECDSA
|
||||||
* Curves supported by the pkcs15-init driver are indicated per curve. This
|
* Curves supported by the pkcs15-init driver are indicated per curve. This
|
||||||
* should be kept in sync with the explicit parameters in the pkcs15-init
|
* should be kept in sync with the explicit parameters in the pkcs15-init
|
||||||
|
|
Loading…
Reference in New Issue