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

fix response of constructed DO in OpenPGP #61

Merged
merged 1 commit into from
Oct 25, 2023
Merged
Changes from all commits
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
23 changes: 18 additions & 5 deletions applets/openpgp/openpgp.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,8 @@ static int openpgp_get_data(const CAPDU *capdu, RAPDU *rapdu) {
break;

case TAG_CARDHOLDER_RELATED_DATA:
RDATA[off++] = TAG_CARDHOLDER_RELATED_DATA;
RDATA[off++] = 0; // to be filled later
RDATA[off++] = TAG_NAME;
len = read_attr(DATA_PATH, TAG_NAME, RDATA + off + 1, MAX_NAME_LENGTH);
if (len < 0) return -1;
Expand All @@ -313,10 +315,15 @@ static int openpgp_get_data(const CAPDU *capdu, RAPDU *rapdu) {
if (len < 0) return -1;
RDATA[off++] = len;
off += len;
RDATA[1] = off - 2;
LL = off;
break;

case TAG_APPLICATION_RELATED_DATA:
RDATA[off++] = TAG_APPLICATION_RELATED_DATA;
RDATA[off++] = 0x82; // extended length
RDATA[off++] = 0; // to be filled later
RDATA[off++] = 0; // to be filled later
RDATA[off++] = TAG_AID;
RDATA[off++] = sizeof(aid);
memcpy(RDATA + off, aid, sizeof(aid));
Expand Down Expand Up @@ -344,7 +351,7 @@ static int openpgp_get_data(const CAPDU *capdu, RAPDU *rapdu) {

RDATA[off++] = TAG_DISCRETIONARY_DATA_OBJECTS;
RDATA[off++] = 0x82;
uint8_t length_pos = off;
uint16_t length_pos = off;
RDATA[off++] = 0; // these two bytes are for length
RDATA[off++] = 0;

Expand Down Expand Up @@ -447,15 +454,21 @@ static int openpgp_get_data(const CAPDU *capdu, RAPDU *rapdu) {
uint16_t ddo_length = off - length_pos - 2;
RDATA[length_pos] = HI(ddo_length);
RDATA[length_pos + 1] = LO(ddo_length);

ddo_length = off - 4;
RDATA[2] = HI(ddo_length);
RDATA[3] = LO(ddo_length);
LL = off;
break;

case TAG_SECURITY_SUPPORT_TEMPLATE:
RDATA[0] = TAG_DIGITAL_SIG_COUNTER;
RDATA[1] = DIGITAL_SIG_COUNTER_LENGTH;
len = read_attr(DATA_PATH, TAG_DIGITAL_SIG_COUNTER, RDATA + 2, DIGITAL_SIG_COUNTER_LENGTH);
RDATA[0] = TAG_SECURITY_SUPPORT_TEMPLATE;
RDATA[1] = DIGITAL_SIG_COUNTER_LENGTH + 2;
RDATA[2] = TAG_DIGITAL_SIG_COUNTER;
RDATA[3] = DIGITAL_SIG_COUNTER_LENGTH;
len = read_attr(DATA_PATH, TAG_DIGITAL_SIG_COUNTER, RDATA + 4, DIGITAL_SIG_COUNTER_LENGTH);
if (len < 0) return -1;
LL = 2 + DIGITAL_SIG_COUNTER_LENGTH;
LL = 4 + DIGITAL_SIG_COUNTER_LENGTH;
break;

case TAG_CARDHOLDER_CERTIFICATE:
Expand Down
Loading