Skip to content

Commit

Permalink
FINeID: Initial FINeID v3 support
Browse files Browse the repository at this point in the history
- New driver fineid, signing tested, decipher untested
- Add custom 0x30 asn1 sequence parsing as struct
- Improve asn1 parse logging when choice type not resolved
- ACL parsing not implemented (hardcoded as select/read only)
  • Loading branch information
Juho Tykkälä committed Feb 7, 2019
1 parent 928fbf2 commit fbca962
Show file tree
Hide file tree
Showing 8 changed files with 1,032 additions and 12 deletions.
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) {
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);
}
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

0 comments on commit fbca962

Please sign in to comment.