Skip to content

Commit c968d0d

Browse files
committed
GIDS No Padding Indication Byte
It appears the PI byte in not needed so don't send it. It may be needed for Secure Messaging but we don't support that. On branch gids-decipher Changes to be committed: modified: src/libopensc/card-gids.c
1 parent 1a4711a commit c968d0d

File tree

1 file changed

+3
-29
lines changed

1 file changed

+3
-29
lines changed

src/libopensc/card-gids.c

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -881,9 +881,9 @@ gids_decipher(struct sc_card *card,
881881

882882
sbuf[0] = 0; /* padding indicator byte, 0x00 = No further indication */
883883
memcpy(sbuf + 1, crgram, crgram_len);
884-
apdu.data = sbuf;
885-
apdu.lc = crgram_len + 1;
886-
apdu.datalen = crgram_len + 1;
884+
apdu.data = sbuf + 1; /* Skip padding indication not needed unless SM */
885+
apdu.lc = crgram_len;
886+
apdu.datalen = crgram_len;
887887

888888
fixup_transceive_length(card, &apdu);
889889
r = sc_transmit_apdu(card, &apdu);
@@ -894,35 +894,9 @@ gids_decipher(struct sc_card *card,
894894
if (apdu.sw1 == 0x90 && apdu.sw2 == 0x00)
895895
LOG_FUNC_RETURN(card->ctx, apdu.resplen);
896896

897-
/*
898-
* The Padding Indicator may be optional and "Virtual Spart Card" using TPM
899-
* does not accept the PI so try again sending just the cryptogram
900-
*/
901-
if (apdu.sw1 == 0x65 && apdu.sw2 == 0x00) {
902-
sc_log(card->ctx, "Gids decipher: Failed with 6D00, retry without Padding indication byte");
903-
904-
/* INS: 0x2A PERFORM SECURITY OPERATION
905-
* P1: 0x80 Resp: Plain value
906-
* P2: 0x86 Cmd: Padding indicator byte followed by cryptogram */
907-
sc_format_apdu(card, &apdu, SC_APDU_CASE_4, 0x2A, 0x80, 0x86);
908-
apdu.resp = out;
909-
apdu.resplen = outlen;
910-
apdu.le = outlen;
911-
apdu.data = crgram;
912-
apdu.lc = crgram_len;
913-
apdu.datalen = crgram_len;
914-
fixup_transceive_length(card, &apdu);
915-
r = sc_transmit_apdu(card, &apdu);
916-
LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
917-
918-
if (apdu.sw1 == 0x90 && apdu.sw2 == 0x00)
919-
LOG_FUNC_RETURN(card->ctx, apdu.resplen);
920-
}
921-
922897
LOG_FUNC_RETURN(card->ctx, sc_check_sw(card, apdu.sw1, apdu.sw2));
923898
}
924899

925-
926900
// deauthenticate all pins
927901
static int gids_logout(sc_card_t *card)
928902
{

0 commit comments

Comments
 (0)