fetch CAR for TA from MSE:Set AT

This commit is contained in:
Frank Morgner
2012-09-18 01:06:28 +02:00
parent 70a108dfe3
commit 00f262ad68

View File

@@ -1255,15 +1255,6 @@ int EstablishPACEChannel(struct sm_ctx *oldnpactx, sc_card_t *card,
bin_log(card->ctx, SC_LOG_DEBUG_NORMAL, "ID PCD", pace_output->id_pcd, bin_log(card->ctx, SC_LOG_DEBUG_NORMAL, "ID PCD", pace_output->id_pcd,
pace_output->id_pcd_length); pace_output->id_pcd_length);
if(pace_output->recent_car && pace_output->recent_car_length
&& !EAC_CTX_init_ta(eac_ctx, NULL, 0, NULL, 0,
pace_output->recent_car, pace_output->recent_car_length)) {
sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "Could not initialize TA.\n");
ssl_error(card->ctx);
r = SC_ERROR_INTERNAL;
goto err;
}
sctx->priv_data = npa_sm_ctx_create(eac_ctx, sctx->priv_data = npa_sm_ctx_create(eac_ctx,
pace_input.certificate_description, pace_input.certificate_description,
pace_input.certificate_description_length, pace_input.certificate_description_length,
@@ -1680,10 +1671,8 @@ npa_sm_pre_transmit(sc_card_t *card, const struct sm_ctx *ctx,
goto err; goto err;
} }
} else if (apdu->ins == 0x22 && apdu->p1 == 0x81 && apdu->p2 == 0xa4) { } else if (apdu->ins == 0x22 && apdu->p2 == 0xa4) {
/* MSE:Set AT /* MSE:Set AT */
* fetch auxiliary data and terminal's compressed ephemeral public key
* for CA */
len = add_tag(&sequence, 1, V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL, apdu->data, apdu->datalen); len = add_tag(&sequence, 1, V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL, apdu->data, apdu->datalen);
p = sequence; p = sequence;
@@ -1693,6 +1682,11 @@ npa_sm_pre_transmit(sc_card_t *card, const struct sm_ctx *ctx,
r = SC_ERROR_INTERNAL; r = SC_ERROR_INTERNAL;
goto err; goto err;
} }
if (apdu->p1 == 0x81) {
/* CA: fetch auxiliary data and terminal's compressed ephemeral
* public key */
if (msesetat->auxiliary_data) { if (msesetat->auxiliary_data) {
sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "Saving terminal's auxiliary data"); sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "Saving terminal's auxiliary data");
if (eacsmctx->auxiliary_data) if (eacsmctx->auxiliary_data)
@@ -1741,7 +1735,21 @@ npa_sm_pre_transmit(sc_card_t *card, const struct sm_ctx *ctx,
goto err; goto err;
} }
} }
} else if (apdu->p1 == 0x41) {
/* TA: Set CAR */
if (msesetat->key_reference1 && msesetat->key_reference1->data &&
msesetat->key_reference1->length) {
if (!EAC_CTX_init_ta(eacsmctx->ctx, NULL, 0, NULL, 0,
msesetat->key_reference1->data,
msesetat->key_reference1->length)) {
sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "Could not initialize TA.\n");
ssl_error(card->ctx);
r = SC_ERROR_INTERNAL;
goto err;
}
}
}
} else if (apdu->ins == 0x82 && apdu->p1 == 0x00 && apdu->p2 == 0x00) { } else if (apdu->ins == 0x82 && apdu->p1 == 0x00 && apdu->p2 == 0x00) {
/* External Authenticate /* External Authenticate
* check terminal's signature */ * check terminal's signature */