Skip to content

Negative file size in FCI processing (iso) #2505

@wcosnc

Description

@wcosnc

Problem

The function iso7816_process_fci() decodes the file_size tag (0x80) with sc_asn1_decode_integer(), so a msb set results into a negative value. I haven't found any hints in the ISO concerning the DO data field encoding for this tag. Cards I use encode them as 2 bytes hi-lo unsigned, not like ASN.1 integer.

Proposed Resolution

Use something like bebytes2ushort().

Steps to reproduce

In my case: 80 02 9E 98.

P:68283; T:0x139801973610560 14:05:22.810 [pkcs15-tool] reader-pcsc.c:335:pcsc_transmit: 
Incoming APDU (64 bytes):
62 3C 80 02 9E 98 82 05 04 41 61 A8 20 83 02 C0 b<.......Aa. ...
00 88 00 8A 01 05 AB 26 84 01 B2 84 01 B3 84 01 .......&........
A0 84 01 A1 90 00 84 01 DC 84 01 DD A0 10 A4 06 ................
95 01 08 83 01 00 A4 06 95 01 80 83 01 01 90 00 ................

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions