iso7816: extend iso7816_process_fci()
* define file type SC_FILE_TYPE_UNKNOWN * explicitly set file->type to SC_FILE_TYPE_UNKNOWN for unkown files * store full-length file type attributes via sc_file_set_type_attr() * parse # of records for record-oriented EFs * parse record length for for EFs with fixed-size records Note: I am not sure, parsing the record length only for EFs with fixed- size records is the correct approach. My interpretation of the norm is slightly different, but it seems to be in-line what's currently in opensc: - there's a comment hinting at that interpretation - otherwise variable size records fail to be read in opensc-explorer So I leave it this way for now.
This commit is contained in:
parent
e0b27af205
commit
cd5c91b8ef
|
@ -387,13 +387,36 @@ iso7816_process_fci(struct sc_card *card, struct sc_file *file,
|
|||
file->type = SC_FILE_TYPE_DF;
|
||||
break;
|
||||
default:
|
||||
file->type = SC_FILE_TYPE_UNKNOWN;
|
||||
type = "unknown";
|
||||
break;
|
||||
}
|
||||
sc_log(ctx, " type: %s", type);
|
||||
sc_log(ctx, " EF structure: %d", byte & 0x07);
|
||||
sc_log(ctx, " tag 0x82: 0x%02x", byte);
|
||||
if (SC_SUCCESS != sc_file_set_type_attr(file, &byte, 1))
|
||||
|
||||
/* if possible, get additional information for non-DFs */
|
||||
if (file->type != SC_FILE_TYPE_DF) {
|
||||
/* record length for fixed size records */
|
||||
if (length > 2 && byte & 0x02) {
|
||||
file->record_length = (length > 3)
|
||||
? bebytes2ushort(p+2)
|
||||
: p[2];
|
||||
sc_log(ctx, " record length: %"SC_FORMAT_LEN_SIZE_T"u",
|
||||
file->record_length);
|
||||
}
|
||||
|
||||
/* number of records */
|
||||
if (length > 4) {
|
||||
file->record_count = (length > 5)
|
||||
? bebytes2ushort(p+4)
|
||||
: p[4];
|
||||
sc_log(ctx, " records: %"SC_FORMAT_LEN_SIZE_T"u",
|
||||
file->record_count);
|
||||
}
|
||||
}
|
||||
|
||||
if (SC_SUCCESS != sc_file_set_type_attr(file, p, length))
|
||||
sc_log(ctx, "Warning: Could not set file attributes");
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -209,6 +209,7 @@ typedef struct sc_acl_entry {
|
|||
} sc_acl_entry_t;
|
||||
|
||||
/* File types */
|
||||
#define SC_FILE_TYPE_UNKNOWN 0x00
|
||||
#define SC_FILE_TYPE_DF 0x04
|
||||
#define SC_FILE_TYPE_INTERNAL_EF 0x03
|
||||
#define SC_FILE_TYPE_WORKING_EF 0x01
|
||||
|
|
Loading…
Reference in New Issue