- fixed compiling errors

- adjusted secure messaging to support extended length apdus
- card has to support extended length, this is hardcoded at the moment, but should better be done in the appropriate card driver


git-svn-id: https://vsmartcard.svn.sourceforge.net/svnroot/vsmartcard@274 96b47cad-a561-4643-ad3b-153ac7d7599c
This commit is contained in:
frankmorgner
2010-09-23 12:56:34 +00:00
parent 6bfdafde8a
commit f6d92dfece
4 changed files with 13 additions and 9 deletions

View File

@@ -1125,7 +1125,7 @@ perform_PC_to_RDR_Secure(const __u8 *in, size_t inlen, __u8** out, size_t *outle
sc_result = build_apdu(ctx, abPINApdu, apdulen, &apdu); sc_result = build_apdu(ctx, abPINApdu, apdulen, &apdu);
if (sc_result < 0) { if (sc_result < 0) {
bin_log(ctx, "Invalid APDU", abDataIn, request->dwLength); bin_log(ctx, "Invalid APDU", abPINApdu, apdulen);
goto err; goto err;
} }
apdu.sensitive = 1; apdu.sensitive = 1;

View File

@@ -110,7 +110,7 @@ static const char *option_help[] = {
int pace_translate_apdus(struct sm_ctx *sctx, sc_card_t *card) int pace_translate_apdus(struct sm_ctx *sctx, sc_card_t *card)
{ {
u8 buf[0xff + 5]; u8 buf[4 + 3 + 0xffff + 3];
char *read = NULL; char *read = NULL;
size_t readlen = 0, apdulen; size_t readlen = 0, apdulen;
sc_apdu_t apdu; sc_apdu_t apdu;
@@ -143,7 +143,7 @@ int pace_translate_apdus(struct sm_ctx *sctx, sc_card_t *card)
r = build_apdu(card->ctx, buf, apdulen, &apdu); r = build_apdu(card->ctx, buf, apdulen, &apdu);
if (r < 0) { if (r < 0) {
bin_log(ctx, "Invalid APDU", abDataIn, request->dwLength); bin_log(ctx, "Invalid APDU", buf, apdulen);
continue; continue;
} }
@@ -316,7 +316,7 @@ main (int argc, char **argv)
pace_input.pin_id = PACE_PIN; pace_input.pin_id = PACE_PIN;
if (pin) { if (pin) {
if (sscanf(pin, "%u", &can_nb) != 1) { if (sscanf(pin, "%u", &can_nb) != 1) {
fprintf(stderr, "PIN is not an unsigned integer."); fprintf(stderr, "PIN is not an unsigned integer.\n");
exit(2); exit(2);
} }
} }
@@ -324,7 +324,7 @@ main (int argc, char **argv)
pace_input.pin_id = PACE_CAN; pace_input.pin_id = PACE_CAN;
if (can) { if (can) {
if (sscanf(can, "%u", &can_nb) != 1) { if (sscanf(can, "%u", &can_nb) != 1) {
fprintf(stderr, "CAN is not an unsigned integer."); fprintf(stderr, "CAN is not an unsigned integer.\n");
exit(2); exit(2);
} }
} }
@@ -332,13 +332,13 @@ main (int argc, char **argv)
pace_input.pin_id = PACE_PUK; pace_input.pin_id = PACE_PUK;
if (puk) { if (puk) {
if (sscanf(puk, "%u", &can_nb) != 1) { if (sscanf(puk, "%u", &can_nb) != 1) {
fprintf(stderr, "PUK is not an unsigned integer."); fprintf(stderr, "PUK is not an unsigned integer.\n");
exit(2); exit(2);
} }
} }
} else { } else {
fprintf(stderr, "Please specify whether to do PACE with " fprintf(stderr, "Please specify whether to do PACE with "
"PIN, CAN or PUK."); "PIN, CAN or PUK.\n");
exit(1); exit(1);
} }
@@ -481,7 +481,7 @@ main (int argc, char **argv)
} }
} else { } else {
fprintf(stderr, "Please specify whether to do PACE with " fprintf(stderr, "Please specify whether to do PACE with "
"PIN, CAN, MRZ or PUK."); "PIN, CAN, MRZ or PUK.\n");
exit(1); exit(1);
} }

View File

@@ -1161,6 +1161,10 @@ int EstablishPACEChannel(const struct sm_ctx *oldpacectx, sc_card_t *card,
sctx->block_length = EVP_CIPHER_block_size(pctx->cipher); sctx->block_length = EVP_CIPHER_block_size(pctx->cipher);
sctx->active = 1; sctx->active = 1;
/* All cards with PACE support extended length
* XXX this should better be done by the card driver */
card->caps |= SC_CARD_CAP_APDU_EXT;
err: err:
if (info) if (info)
PACEInfo_free(info); PACEInfo_free(info);

View File

@@ -578,7 +578,7 @@ int sm_transmit_apdu(const struct sm_ctx *sctx, sc_card_t *card,
sc_apdu_t *apdu) sc_apdu_t *apdu)
{ {
sc_apdu_t sm_apdu; sc_apdu_t sm_apdu;
u8 rbuf[SC_MAX_APDU_BUFFER_SIZE - 2], sbuf[SC_MAX_APDU_BUFFER_SIZE - 4]; u8 rbuf[0xffff], sbuf[0xffff];
sm_apdu.data = sbuf; sm_apdu.data = sbuf;
sm_apdu.datalen = sizeof sbuf; sm_apdu.datalen = sizeof sbuf;