Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jpki/iso7816: explicitly check for PIN length != 0 on VERIFY #2911

Merged
merged 2 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
jpki/iso7816: explicityl check for PIN length != 0 on VERIFY
If we want to verify the PIN, we don't want the status request, which
results in an almost identical APDU (VERIFY APDU with no data). However,
as the request for verifying the PIN results in a CASE 3 APDU,
`sc_check_apdu()` will check for missing data for the verification so
that an error is returned and no PIN bypass is possible.
  • Loading branch information
frankmorgner committed Oct 23, 2023
commit a2e36f7f675fe560f5017a282af02a08ab7ae001
3 changes: 3 additions & 0 deletions src/libopensc/card-jpki.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,9 @@ jpki_pin_cmd(sc_card_t *card, struct sc_pin_cmd_data *data, int *tries_left)

switch (data->cmd) {
case SC_PIN_CMD_VERIFY:
/* detect overloaded APDU with SC_PIN_CMD_GET_INFO */
if (data->pin1.len == 0)
LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_PIN_LENGTH);
sc_format_apdu(card, &apdu, SC_APDU_CASE_3, 0x20, 0x00, 0x80);
apdu.data = data->pin1.data;
apdu.datalen = data->pin1.len;
Expand Down
3 changes: 3 additions & 0 deletions src/libopensc/iso7816.c
Original file line number Diff line number Diff line change
Expand Up @@ -1201,6 +1201,9 @@ iso7816_build_pin_apdu(struct sc_card *card, struct sc_apdu *apdu,
switch (data->cmd) {
case SC_PIN_CMD_VERIFY:
ins = 0x20;
/* detect overloaded APDU with SC_PIN_CMD_GET_INFO */
if (data->pin1.len == 0)
Jakuje marked this conversation as resolved.
Show resolved Hide resolved
return SC_ERROR_INVALID_PIN_LENGTH;
if ((r = sc_build_pin(buf, buf_len, &data->pin1, pad)) < 0)
return r;
len = r;
Expand Down
Loading