From 2b8b14f994b1e965e8df3e908e6200a9c114179f Mon Sep 17 00:00:00 2001 From: frankmorgner Date: Sat, 19 Jun 2010 18:27:27 +0000 Subject: [PATCH] - pace-tool: fixed length of input buffer for EstablishPACEChannel - added debug messages to pace.c git-svn-id: https://vsmartcard.svn.sourceforge.net/svnroot/vsmartcard@157 96b47cad-a561-4643-ad3b-153ac7d7599c --- ccid/src/pace-tool.c | 2 +- ccid/src/pace.c | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ccid/src/pace-tool.c b/ccid/src/pace-tool.c index ad45583..2fcb7b4 100644 --- a/ccid/src/pace-tool.c +++ b/ccid/src/pace-tool.c @@ -156,7 +156,7 @@ int pace_get_channel(struct sm_ctx *oldpacectx, sc_card_t *card, desc, desclen); return EstablishPACEChannel(oldpacectx, card, buf, - 1+pinlen+1+chatlen+2+desclen, out, outlen, sctx); + 1+1+chatlen+1+pinlen+sizeof(word)+desclen, out, outlen, sctx); } int pace_translate_apdus(struct sm_ctx *sctx, sc_card_t *card) diff --git a/ccid/src/pace.c b/ccid/src/pace.c index 52c89b0..4e1f92f 100644 --- a/ccid/src/pace.c +++ b/ccid/src/pace.c @@ -297,6 +297,7 @@ static int pace_mse_set_at(const struct sm_ctx *oldpacectx, sc_card_t *card, } if (!ASN1_INTEGER_set(data->key_reference1, secret_key)) { + sc_error(card->ctx, "Error setting key reference 1 of MSE:Set AT data"); r = SC_ERROR_INTERNAL; goto err; } @@ -304,6 +305,7 @@ static int pace_mse_set_at(const struct sm_ctx *oldpacectx, sc_card_t *card, if (length_chat) { if (!d2i_PACE_CHAT(&data->cha_template, (const unsigned char **) &chat, length_chat)) { + sc_error(card->ctx, "Error decoding card holder authorization template (CHAT)"); r = SC_ERROR_INTERNAL; goto err; } @@ -312,6 +314,7 @@ static int pace_mse_set_at(const struct sm_ctx *oldpacectx, sc_card_t *card, r = i2d_PACE_MSE_SET_AT_C(data, &d); if (r < 0) { + sc_error(card->ctx, "Error encoding MSE:Set AT APDU data"); r = SC_ERROR_INTERNAL; goto err; } @@ -741,7 +744,7 @@ int EstablishPACEChannel(const struct sm_ctx *oldpacectx, sc_card_t *card, in += length_pin; if (inlen < 1+1+length_chat+1+length_pin+sizeof(word)) { - sc_error(card->ctx, "Buffer too small, could not get lengthCertificateDescription %d %d",1+1+length_chat+1+length_pin+sizeof(word), inlen); + sc_error(card->ctx, "Buffer too small, could not get lengthCertificateDescription"); SC_FUNC_RETURN(card->ctx, SC_LOG_TYPE_DEBUG, SC_ERROR_INVALID_DATA); } memcpy(&word, in, sizeof word);