Changeset aae5b93 in OpenSC
- Timestamp:
- 12/21/11 09:26:23 (5 months ago)
- Children:
- f0bde7d
- Parents:
- 4251a23
- git-author:
- Xiaoshuo <xiaoshuo@…> (12/21/11 09:26:23)
- git-committer:
- Xiaoshuo <xiaoshuo@…> (12/21/11 09:26:23)
- Location:
- src/libopensc
- Files:
-
- 5 edited
-
apdu.c (modified) (2 diffs)
-
card-entersafe.c (modified) (1 diff)
-
card-epass2003.c (modified) (2 diffs)
-
iso7816.c (modified) (1 diff)
-
opensc.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/libopensc/apdu.c
ra28bacf raae5b93 516 516 } 517 517 518 intsc_transmit_apdu(sc_card_t *card, sc_apdu_t *apdu)518 static int _sc_transmit_apdu(sc_card_t *card, sc_apdu_t *apdu) 519 519 { 520 520 int r = SC_SUCCESS; … … 606 606 sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "sc_unlock failed"); 607 607 608 return r; 609 } 610 611 /* 612 * Wrap/Unwrap APDU when requested before sending to reader driver 613 * Needed (un)wrapping apdu is noticed by a non-null 614 * card->ops->(un)wrap_apdu() function pointer 615 * (eg: for Secure Messaging) 616 * @param card sc_card_t object for the smartcard 617 * @param apdu APDU to be sent 618 * @return SC_SUCCESS on success and an error value otherwise 619 */ 620 int sc_transmit_apdu(sc_card_t *card, sc_apdu_t *apdu) { 621 int r; 622 sc_context_t *ctx = card->ctx; 623 624 if (ctx->use_sm != 0) { 625 //construct new SM apdu from original apdu 626 u8 data[SC_MAX_EXT_APDU_BUFFER_SIZE] = {0}; 627 u8 resp[SC_MAX_EXT_APDU_BUFFER_SIZE] = {0}; 628 sc_apdu_t wrapped_apdu; 629 wrapped_apdu.data = &data[0]; 630 wrapped_apdu.datalen = SC_MAX_EXT_APDU_BUFFER_SIZE; 631 wrapped_apdu.resp = &resp[0]; 632 wrapped_apdu.resplen = SC_MAX_EXT_APDU_BUFFER_SIZE; 633 634 /* wrap apdu */ 635 r = card->ops->sm_wrap_apdu(card, apdu, &wrapped_apdu); 636 SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, r, "sm_wrap_apdu error"); 637 638 /* determine the APDU type if necessary, i.e. to use 639 * short or extended APDUs */ 640 sc_detect_apdu_cse(card, apdu); 641 642 /* check wrapped apdu */ 643 r = sc_check_apdu(card, &wrapped_apdu); 644 SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, r, "wrapped APDU is invalid"); 645 646 r = _sc_transmit_apdu(card, &wrapped_apdu); 647 SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, r, "unable to transmit wrapped APDU"); 648 649 /* unwrap apdu */ 650 r = card->ops->sm_unwrap_apdu(card, &wrapped_apdu, apdu); 651 SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, r, "sm_unwrap_apdu error"); 652 653 } else { 654 /* no wrap needed, just call reader driver */ 655 r = _sc_transmit_apdu(card, apdu); 656 } 608 657 return r; 609 658 } -
src/libopensc/card-entersafe.c
r3efe35d raae5b93 131 131 132 132 card->caps = SC_CARD_CAP_RNG; 133 card->ctx->use_sm = 0; 133 134 134 135 /* we need read_binary&friends with max 224 bytes per read */ -
src/libopensc/card-epass2003.c
r4251a23 raae5b93 857 857 card->cla = 0x00; 858 858 card->drv_data = NULL; 859 860 g_sm = SM_PLAIN; 859 card->ctx->use_sm = 1; 860 861 g_sm = SM_SCP01; 862 /* g_sm = SM_PLAIN; */ 861 863 862 864 /* decide FIPS/Non-FIPS mode */ … … 2217 2219 epass2003_ops.match_card = epass2003_match_card; 2218 2220 epass2003_ops.init = epass2003_init; 2221 epass2003_ops.sm_wrap_apdu = epass2003_sm_wrap_apdu; 2222 epass2003_ops.sm_unwrap_apdu = epass2003_sm_unwrap_apdu; 2219 2223 epass2003_ops.write_binary = NULL; 2220 2224 epass2003_ops.write_record = NULL; -
src/libopensc/iso7816.c
r93baf13 raae5b93 1012 1012 NULL, /* init */ 1013 1013 NULL, /* finish */ 1014 NULL, /* sm_wrap_apdu */ 1015 NULL, /* sm_unwrap_apdu */ 1014 1016 iso7816_read_binary, 1015 1017 iso7816_write_binary, -
src/libopensc/opensc.h
ra28bacf raae5b93 464 464 * the card cannot be handled with this driver. */ 465 465 int (*init)(struct sc_card *card); 466 /* Called before invoke card_driver->ops->transmit. 467 * Performing APDU wrap. If set to NULL, there is no wrapping. 468 * Usefull on Secure Messaging APDU encode 469 * Returns SC_SUCCESS or error code */ 470 int (*sm_wrap_apdu)(struct sc_card *card, 471 struct sc_apdu *plain, struct sc_apdu *sm); 472 /* Same as wrap_apdu, but perform unwrap */ 473 int (*sm_unwrap_apdu)(struct sc_card *card, 474 struct sc_apdu *sm, struct sc_apdu *plain); 466 475 /* Called when the card object is being freed. finish() has to 467 476 * deallocate all possible private data. */ … … 619 628 void *mutex; 620 629 630 int use_sm; 621 631 unsigned int magic; 622 632 } sc_context_t;
Note: See TracChangeset
for help on using the changeset viewer.
