From f7766a3b5a0dad83f57777479fc5eae8c9d10a42 Mon Sep 17 00:00:00 2001 From: frankmorgner Date: Wed, 26 Oct 2011 13:50:14 +0000 Subject: [PATCH] minor simplifications git-svn-id: https://vsmartcard.svn.sourceforge.net/svnroot/vsmartcard@576 96b47cad-a561-4643-ad3b-153ac7d7599c --- npa/src/example.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/npa/src/example.c b/npa/src/example.c index 4d66e7a..56aed8f 100644 --- a/npa/src/example.c +++ b/npa/src/example.c @@ -21,7 +21,6 @@ * get a secure channel to the nPA. We use the builtin function npa_change_pin * to modify the PIN using the secure channel. Then we transmit an arbitrary * APDU encrypted and authenticated to the card using sm_transmit_apdu. */ -#include #include #include #include @@ -97,11 +96,9 @@ main (int argc, char **argv) * Here we are parsing the raw apdu buffer apdubuf to be transformed into * an sc_apdu_t. Alternatively you could also set CLA, INS, P1, P2, ... by * hand in the sc_apdu_t object. */ - r = sc_bytes2apdu(card->ctx, apdubuf, sizeof apdubuf, &apdu); - if (r < 0) { - bin_log(ctx, SC_LOG_DEBUG_NORMAL, "Invalid C-APDU", apdubuf, sizeof apdubuf); + r = sc_bytes2apdu(ctx, apdubuf, sizeof apdubuf, &apdu); + if (r < 0) goto err; - } /* write the response data to buf */ apdu.resp = buf; @@ -109,14 +106,11 @@ main (int argc, char **argv) /* Transmit the APDU with SM */ r = sm_transmit_apdu(&sctx, card, &apdu); - if (r < 0) { - sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE_TOOL, - "Could not send C-APDU: %s", sc_strerror(r)); - goto err; - } err: + fprintf(r < 0 ? stderr : stdout, "%s\n", sc_strerror(r)); + /* Free up memory and wipe it if necessary (e.g. for keys stored in sm_ctx) */ sm_ctx_clear_free(&sctx); if (pace_output.ef_cardaccess)