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

FINeID: Initial FINeID v3 support #1608

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/libopensc/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ libopensc_la_SOURCES_BASE = \
card-oberthur.c card-belpic.c card-atrust-acos.c \
card-entersafe.c card-epass2003.c card-coolkey.c card-incrypto34.c \
card-piv.c card-cac-common.c card-cac.c card-cac1.c \
card-muscle.c card-acos5.c \
card-muscle.c card-acos5.c card-fineid.c \
card-asepcos.c card-akis.c card-gemsafeV1.c card-rutoken.c \
card-rtecp.c card-westcos.c card-myeid.c \
card-itacns.c card-authentic.c \
Expand Down
2 changes: 1 addition & 1 deletion src/libopensc/Makefile.mak
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ OBJECTS = \
card-entersafe.obj card-epass2003.obj card-coolkey.obj \
card-incrypto34.obj card-cac.obj card-cac1.obj card-cac-common.obj \
card-piv.obj card-muscle.obj \
card-acos5.obj \
card-acos5.obj card-fineid.obj \
card-asepcos.obj card-akis.obj card-gemsafeV1.obj card-rutoken.obj \
card-rtecp.obj card-westcos.obj card-myeid.obj \
card-itacns.obj card-authentic.obj \
Expand Down
32 changes: 24 additions & 8 deletions src/libopensc/asn1.c
Original file line number Diff line number Diff line change
Expand Up @@ -538,14 +538,17 @@ const u8 *sc_asn1_skip_tag(sc_context_t *ctx, const u8 ** buf, size_t *buflen,
return NULL;
break;
}
if (cla & SC_ASN1_TAG_CONSTRUCTED) {
if ((tag_in & SC_ASN1_CONS) == 0)
return NULL;
} else
if (tag_in & SC_ASN1_CONS)
if(tag_in != SC_ASN1_TAG_SEQUENCE_2) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parser is capable of parsing sequences, why are you modifying the code here?

If you want to parse the tag without being split up into its parts, use SC_ASN1_TAG_SEQUENCE|SC_ASN1_CONS with SC_ASN1_OCTET_STRING, see https://github.com/OpenSC/OpenSC/blob/master/src/tools/goid-tool.c#L87

if (cla & SC_ASN1_TAG_CONSTRUCTED) {
if ((tag_in & SC_ASN1_CONS) == 0)
return NULL;
} else {
if (tag_in & SC_ASN1_CONS)
return NULL;
}
if ((tag_in & SC_ASN1_TAG_MASK) != tag)
return NULL;
if ((tag_in & SC_ASN1_TAG_MASK) != tag)
return NULL;
}
len -= (p - *buf); /* header size */
if (taglen > len) {
sc_debug(ctx, SC_LOG_DEBUG_ASN1,
Expand Down Expand Up @@ -1649,8 +1652,21 @@ static int asn1_decode(sc_context_t *ctx, struct sc_asn1_entry *asn1,
if (choice)
break;
}
if (choice && asn1[idx].name == NULL) /* No match */
if (choice && asn1[idx].name == NULL) { /* No match */
sc_debug(ctx, SC_LOG_DEBUG_ASN1, "Reached the end of possible choices, none chosen\n");
if (left) {
u8 line[128], *linep = line;
size_t i;

line[0] = 0;
for (i = 0; i < 10 && i < left; i++) {
sprintf((char *) linep, "%02X ", p[i]);
linep += 3;
}
sc_debug(ctx, SC_LOG_DEBUG_ASN1, "next tag: %s\n", line);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the return value is expressive enough and the ASN.1 parser already has enough debug output. please remove this debug output.

SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_ASN1, SC_ERROR_ASN1_OBJECT_NOT_FOUND);
}
if (newp != NULL)
*newp = p;
if (len_left != NULL)
Expand Down
2 changes: 2 additions & 0 deletions src/libopensc/asn1.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ int sc_asn1_sig_value_sequence_to_rs(struct sc_context *ctx,
#define SC_ASN1_TAG_BMPSTRING 30
#define SC_ASN1_TAG_ESCAPE_MARKER 31

#define SC_ASN1_TAG_SEQUENCE_2 0x30

#ifdef __cplusplus
}
#endif
Expand Down
Loading