added ef.cardaccess and statusbytes to response of establishpacechannel
git-svn-id: https://vsmartcard.svn.sourceforge.net/svnroot/vsmartcard@191 96b47cad-a561-4643-ad3b-153ac7d7599c
This commit is contained in:
@@ -700,7 +700,7 @@ int EstablishPACEChannel(const struct sm_ctx *oldpacectx, sc_card_t *card,
|
|||||||
*token = NULL, *pub = NULL, *pub_opp = NULL, *key = NULL;
|
*token = NULL, *pub = NULL, *pub_opp = NULL, *key = NULL;
|
||||||
PACE_SEC *sec = NULL;
|
PACE_SEC *sec = NULL;
|
||||||
PACE_CTX *pctx = NULL;
|
PACE_CTX *pctx = NULL;
|
||||||
int r, second_execution;
|
int r;
|
||||||
|
|
||||||
if (!card)
|
if (!card)
|
||||||
return SC_ERROR_CARD_NOT_PRESENT;
|
return SC_ERROR_CARD_NOT_PRESENT;
|
||||||
@@ -762,14 +762,15 @@ int EstablishPACEChannel(const struct sm_ctx *oldpacectx, sc_card_t *card,
|
|||||||
certificate_description, length_cert_desc);
|
certificate_description, length_cert_desc);
|
||||||
|
|
||||||
|
|
||||||
if (!*out) {
|
if (!oldpacectx) {
|
||||||
second_execution = 0;
|
/* PACE is executed the first time */
|
||||||
r = get_ef_card_access(card, &ef_cardaccess, &length_ef_cardaccess);
|
r = get_ef_card_access(card, &ef_cardaccess, &length_ef_cardaccess);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
sc_error(card->ctx, "Could not get EF.CardAccess.");
|
sc_error(card->ctx, "Could not get EF.CardAccess.");
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
*out = malloc(6 + length_ef_cardaccess);
|
/* get enough memory for status bytes and EF.CardAccess */
|
||||||
|
*out = realloc(4 + length_ef_cardaccess);
|
||||||
if (!*out) {
|
if (!*out) {
|
||||||
r = SC_ERROR_OUT_OF_MEMORY;
|
r = SC_ERROR_OUT_OF_MEMORY;
|
||||||
goto err;
|
goto err;
|
||||||
@@ -778,11 +779,13 @@ int EstablishPACEChannel(const struct sm_ctx *oldpacectx, sc_card_t *card,
|
|||||||
memcpy(*out + 2, &word, sizeof word);
|
memcpy(*out + 2, &word, sizeof word);
|
||||||
memcpy(*out + 4, ef_cardaccess, length_ef_cardaccess);
|
memcpy(*out + 4, ef_cardaccess, length_ef_cardaccess);
|
||||||
} else {
|
} else {
|
||||||
second_execution = 1;
|
/* PACE is executed the second time. EF.CardAccess should already be
|
||||||
|
* present */
|
||||||
memcpy(&word, *out + 2, sizeof word);
|
memcpy(&word, *out + 2, sizeof word);
|
||||||
length_ef_cardaccess = __le16_to_cpu(word);
|
length_ef_cardaccess = __le16_to_cpu(word);
|
||||||
ef_cardaccess = *out + 4;
|
ef_cardaccess = *out + 4;
|
||||||
}
|
}
|
||||||
|
*outlen = 4+length_ef_cardaccess;
|
||||||
bin_log(card->ctx, "EF.CardAccess", ef_cardaccess, length_ef_cardaccess);
|
bin_log(card->ctx, "EF.CardAccess", ef_cardaccess, length_ef_cardaccess);
|
||||||
|
|
||||||
if (!parse_ef_card_access(ef_cardaccess, length_ef_cardaccess,
|
if (!parse_ef_card_access(ef_cardaccess, length_ef_cardaccess,
|
||||||
@@ -929,7 +932,7 @@ int EstablishPACEChannel(const struct sm_ctx *oldpacectx, sc_card_t *card,
|
|||||||
sctx->active = 1;
|
sctx->active = 1;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
if (ef_cardaccess && !second_execution)
|
if (ef_cardaccess && !oldpacectx)
|
||||||
free(ef_cardaccess);
|
free(ef_cardaccess);
|
||||||
if (info)
|
if (info)
|
||||||
PACEInfo_free(info);
|
PACEInfo_free(info);
|
||||||
|
|||||||
Reference in New Issue
Block a user