- added new cardctl SC_CARDCTL_GET_DEFAULT_KEY to get default transport keys
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@741 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
parent
6df8dbbed3
commit
3168c8ea26
|
@ -73,7 +73,8 @@ struct gpk_private_data {
|
||||||
* should really query for this during gpk_init */
|
* should really query for this during gpk_init */
|
||||||
unsigned int offset_shift;
|
unsigned int offset_shift;
|
||||||
unsigned int offset_mask;
|
unsigned int offset_mask;
|
||||||
unsigned int locked : 1;
|
unsigned int locked : 1,
|
||||||
|
sample_card : 1;
|
||||||
|
|
||||||
/* access control bits of file most recently selected */
|
/* access control bits of file most recently selected */
|
||||||
unsigned short int ac[3];
|
unsigned short int ac[3];
|
||||||
|
@ -222,6 +223,10 @@ gpk_init(struct sc_card *card)
|
||||||
if (info[12] & 0x08) {
|
if (info[12] & 0x08) {
|
||||||
priv->locked = 1;
|
priv->locked = 1;
|
||||||
}
|
}
|
||||||
|
/* Sample cards use a transport key of "TEST KEYTEST KEY" */
|
||||||
|
if (!memcmp(info+5, "\x00\xff\x00", 3)) {
|
||||||
|
priv->sample_card = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1725,6 +1730,22 @@ gpk_pkfile_load(struct sc_card *card, struct sc_cardctl_gpk_pkload *args)
|
||||||
SC_FUNC_RETURN(card->ctx, 1, r);
|
SC_FUNC_RETURN(card->ctx, 1, r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This function lets pkcs15init query for the transport key
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
gpk_get_default_key(struct sc_card *card, struct sc_cardctl_default_key *data)
|
||||||
|
{
|
||||||
|
if (data->method == SC_AC_PRO && data->key_ref == 1) {
|
||||||
|
if (data->len < 16)
|
||||||
|
return SC_ERROR_BUFFER_TOO_SMALL;
|
||||||
|
memcpy(data->key_data, "TEST KEYTEST KEY", 16);
|
||||||
|
data->len = 16;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return SC_ERROR_NO_DEFAULT_KEY;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get the maximum size of a session key the card is
|
* Get the maximum size of a session key the card is
|
||||||
* willing to decrypt
|
* willing to decrypt
|
||||||
|
@ -1788,6 +1809,9 @@ gpk_card_ctl(struct sc_card *card, unsigned long cmd, void *ptr)
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case SC_CARDCTL_ERASE_CARD:
|
case SC_CARDCTL_ERASE_CARD:
|
||||||
return gpk_erase_card(card);
|
return gpk_erase_card(card);
|
||||||
|
case SC_CARDCTL_GET_DEFAULT_KEY:
|
||||||
|
return gpk_get_default_key(card,
|
||||||
|
(struct sc_cardctl_default_key *) ptr);
|
||||||
case SC_CARDCTL_GPK_VARIANT:
|
case SC_CARDCTL_GPK_VARIANT:
|
||||||
*(int *) ptr = DRVDATA(card)->variant;
|
*(int *) ptr = DRVDATA(card)->variant;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -27,6 +27,7 @@ enum {
|
||||||
*/
|
*/
|
||||||
SC_CARDCTL_GENERIC_BASE = 0x00000000,
|
SC_CARDCTL_GENERIC_BASE = 0x00000000,
|
||||||
SC_CARDCTL_ERASE_CARD,
|
SC_CARDCTL_ERASE_CARD,
|
||||||
|
SC_CARDCTL_GET_DEFAULT_KEY,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GPK specific calls
|
* GPK specific calls
|
||||||
|
@ -65,6 +66,18 @@ enum {
|
||||||
SC_CARDCTL_ETOKEN_GENERATE_KEY
|
SC_CARDCTL_ETOKEN_GENERATE_KEY
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Generic cardctl - check if the required key is a default
|
||||||
|
* key (such as the GPK "TEST KEYTEST KEY" key, or the Cryptoflex AAK)
|
||||||
|
*/
|
||||||
|
struct sc_cardctl_default_key {
|
||||||
|
int method; /* SC_AC_XXX */
|
||||||
|
int key_ref; /* key reference */
|
||||||
|
|
||||||
|
size_t len; /* in: max size, out: actual size */
|
||||||
|
u8 * key_data; /* out: key data */
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GPK lock file.
|
* GPK lock file.
|
||||||
* Parent DF of file must be selected.
|
* Parent DF of file must be selected.
|
||||||
|
|
|
@ -82,6 +82,7 @@ extern "C" {
|
||||||
#define SC_ERROR_SYNTAX_ERROR -1501
|
#define SC_ERROR_SYNTAX_ERROR -1501
|
||||||
#define SC_ERROR_INCONSISTENT_PROFILE -1502
|
#define SC_ERROR_INCONSISTENT_PROFILE -1502
|
||||||
#define SC_ERROR_INCOMPATIBLE_KEY -1503
|
#define SC_ERROR_INCOMPATIBLE_KEY -1503
|
||||||
|
#define SC_ERROR_NO_DEFAULT_KEY -1504
|
||||||
|
|
||||||
/* Errors that do not fit the categories above */
|
/* Errors that do not fit the categories above */
|
||||||
#define SC_ERROR_UNKNOWN -1900
|
#define SC_ERROR_UNKNOWN -1900
|
||||||
|
|
Loading…
Reference in New Issue