iso7816_process_fci: getting the size of the file

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

iso7816_process_fci: getting the size of the file

Vincent Le Toux
Hi,

I've a question about how the file size is retrieved.
It is implemented in iso7816.c: https://github.com/OpenSC/OpenSC/blob/master/src/libopensc/iso7816.c#L362-373

I'm not a DER expert that's why I'm asking.

Is a size encoded with the attribute 0x80 with 4 bytes valid ?
How can I find the difference between 0x81 & 0x80 ?

I get a card with both 0x80 (4 bytes) and 0x81 (2 bytes) tags.
If a 4 bytes is valid, I'd like to propose a patch to the iso7816.c file to handle it.

regards,
--
--
Vincent Le Toux

My Smart Logon
www.mysmartlogon.com

------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Opensc-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/opensc-devel
Reply | Threaded
Open this post in threaded view
|

Re: iso7816_process_fci: getting the size of the file

Frank Morgner
On Sunday, May 10 at 08:48PM, Vincent Le Toux wrote:

> Hi,
>
> I've a question about how the file size is retrieved.
> It is implemented in iso7816.c:
> https://github.com/OpenSC/OpenSC/blob/master/src/libopensc/iso7816.c#L362-373
>
> I'm not a DER expert that's why I'm asking.
>
> Is a size encoded with the attribute 0x80 with 4 bytes valid ?
> How can I find the difference between 0x81 & 0x80 ?
>
> I get a card with both 0x80 (4 bytes) and 0x81 (2 bytes) tags.
> If a 4 bytes is valid, I'd like to propose a patch to the iso7816.c file to
> handle it.
You most likely are interested in the 0x80 size only. See
http://www.cardwerk.com/smartcards/smartcard_standard_ISO7816-4_5_basic_organizations.aspx#table2

Newer versions of ISO 7816-4 define the length of 0x80 to be variable
and the length of 0x81 to be 2. So your card is conforming to the
standard though there are cases where the ISO's restriction does not
make sense.

--
Frank Morgner

Virtual Smart Card Architecture http://vsmartcard.sourceforge.net
OpenPACE                        http://openpace.sourceforge.net
IFD Handler for libnfc Devices  http://sourceforge.net/projects/ifdnfc

------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Opensc-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/opensc-devel

attachment0 (985 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: iso7816_process_fci: getting the size of the file

Frank Morgner
On Sunday, May 10 at 09:18PM, Frank Morgner wrote:

> On Sunday, May 10 at 08:48PM, Vincent Le Toux wrote:
> > Hi,
> >
> > I've a question about how the file size is retrieved.
> > It is implemented in iso7816.c:
> > https://github.com/OpenSC/OpenSC/blob/master/src/libopensc/iso7816.c#L362-373
> >
> > I'm not a DER expert that's why I'm asking.
> >
> > Is a size encoded with the attribute 0x80 with 4 bytes valid ?
> > How can I find the difference between 0x81 & 0x80 ?
> >
> > I get a card with both 0x80 (4 bytes) and 0x81 (2 bytes) tags.
> > If a 4 bytes is valid, I'd like to propose a patch to the iso7816.c file to
> > handle it.
>
> You most likely are interested in the 0x80 size only. See
> http://www.cardwerk.com/smartcards/smartcard_standard_ISO7816-4_5_basic_organizations.aspx#table2
>
> Newer versions of ISO 7816-4 define the length of 0x80 to be variable
> and the length of 0x81 to be 2. So your card is conforming to the
> standard though there are cases where the ISO's restriction does not
> make sense.
Update: The newest version of the standard should have both length variable.

--
Frank Morgner

Virtual Smart Card Architecture http://vsmartcard.sourceforge.net
OpenPACE                        http://openpace.sourceforge.net
IFD Handler for libnfc Devices  http://sourceforge.net/projects/ifdnfc

------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Opensc-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/opensc-devel

attachment0 (985 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: iso7816_process_fci: getting the size of the file

Vincent Le Toux
In reply to this post by Frank Morgner
Hi Frank

Can you indicate to me in which chapter for iso 7816-4 the variable 0x80 encoding size is defined ?
I have the ISO/IEC 7816-4:2013 version.

Thanks in advance

regards,
Vincent

2015-05-10 21:18 GMT+02:00 Frank Morgner <[hidden email]>:
On Sunday, May 10 at 08:48PM, Vincent Le Toux wrote:
> Hi,
>
> I've a question about how the file size is retrieved.
> It is implemented in iso7816.c:
> https://github.com/OpenSC/OpenSC/blob/master/src/libopensc/iso7816.c#L362-373
>
> I'm not a DER expert that's why I'm asking.
>
> Is a size encoded with the attribute 0x80 with 4 bytes valid ?
> How can I find the difference between 0x81 & 0x80 ?
>
> I get a card with both 0x80 (4 bytes) and 0x81 (2 bytes) tags.
> If a 4 bytes is valid, I'd like to propose a patch to the iso7816.c file to
> handle it.

You most likely are interested in the 0x80 size only. See
http://www.cardwerk.com/smartcards/smartcard_standard_ISO7816-4_5_basic_organizations.aspx#table2

Newer versions of ISO 7816-4 define the length of 0x80 to be variable
and the length of 0x81 to be 2. So your card is conforming to the
standard though there are cases where the ISO's restriction does not
make sense.

--
Frank Morgner

Virtual Smart Card Architecture http://vsmartcard.sourceforge.net
OpenPACE                        http://openpace.sourceforge.net
IFD Handler for libnfc Devices  http://sourceforge.net/projects/ifdnfc

------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Opensc-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/opensc-devel




--
--
Vincent Le Toux

My Smart Logon
www.mysmartlogon.com

------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Opensc-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/opensc-devel
Reply | Threaded
Open this post in threaded view
|

Re: iso7816_process_fci: getting the size of the file

Vincent Le Toux
got the anwser:
in ISO/IEC 7816-4:2013(E), chapter 7.4.3.

Table 10 — Control parameter data objects

Tag | Length | Value | Applies to
'80' Var. Number of data bytes in the file, excluding structural information Any EF*
'81' Var. Number of data bytes in the file or DO, including structural information if any File* or DO*

both tag 0x80 and 0x81 can be 4 bytes in length

vincent

2015-05-10 21:57 GMT+02:00 Vincent Le Toux <[hidden email]>:
Hi Frank

Can you indicate to me in which chapter for iso 7816-4 the variable 0x80 encoding size is defined ?
I have the ISO/IEC 7816-4:2013 version.

Thanks in advance

regards,
Vincent

2015-05-10 21:18 GMT+02:00 Frank Morgner <[hidden email]>:
On Sunday, May 10 at 08:48PM, Vincent Le Toux wrote:
> Hi,
>
> I've a question about how the file size is retrieved.
> It is implemented in iso7816.c:
> https://github.com/OpenSC/OpenSC/blob/master/src/libopensc/iso7816.c#L362-373
>
> I'm not a DER expert that's why I'm asking.
>
> Is a size encoded with the attribute 0x80 with 4 bytes valid ?
> How can I find the difference between 0x81 & 0x80 ?
>
> I get a card with both 0x80 (4 bytes) and 0x81 (2 bytes) tags.
> If a 4 bytes is valid, I'd like to propose a patch to the iso7816.c file to
> handle it.

You most likely are interested in the 0x80 size only. See
http://www.cardwerk.com/smartcards/smartcard_standard_ISO7816-4_5_basic_organizations.aspx#table2

Newer versions of ISO 7816-4 define the length of 0x80 to be variable
and the length of 0x81 to be 2. So your card is conforming to the
standard though there are cases where the ISO's restriction does not
make sense.

--
Frank Morgner

Virtual Smart Card Architecture http://vsmartcard.sourceforge.net
OpenPACE                        http://openpace.sourceforge.net
IFD Handler for libnfc Devices  http://sourceforge.net/projects/ifdnfc

------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Opensc-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/opensc-devel




--
--
Vincent Le Toux

My Smart Logon
www.mysmartlogon.com



--
--
Vincent Le Toux

My Smart Logon
www.mysmartlogon.com

------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Opensc-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/opensc-devel
Reply | Threaded
Open this post in threaded view
|

Re: iso7816_process_fci: getting the size of the file

Douglas E Engert
In reply to this post by Vincent Le Toux


On 5/10/2015 1:48 PM, Vincent Le Toux wrote:
> Hi,
>
> I've a question about how the file size is retrieved.
> It is implemented in iso7816.c: https://github.com/OpenSC/OpenSC/blob/master/src/libopensc/iso7816.c#L362-373
>
> I'm not a DER expert that's why I'm asking.

DER is ASN.1

This has been handy...
"A Layman's Guide to a Subset of ASN.1, BER, and DER"
can be found as html or PDF:

http://luca.ntop.org/Teaching/Appunti/asn1.html

http://homepages.dcc.ufmg.br/~coelho/nm/asn.1.intro.pdf

>
> Is a size encoded with the attribute 0x80 with 4 bytes valid ?
> How can I find the difference between 0x81 & 0x80 ?

http://en.wikipedia.org/wiki/X.690
Sounds like you are referring to "The definite form" vs "The indefinite form"

>
> I get a card with both 0x80 (4 bytes) and 0x81 (2 bytes) tags.
> If a 4 bytes is valid, I'd like to propose a patch to the iso7816.c file to handle it.


ISO7816-4 5.2.1 SIMPLE-TLV, 5.2.2 BER-TLV, and  5.2.2.2 BER-TLV length fields
and the lengths are handled differently. So you need to know which one is being used.

>
> regards,
> --
> --
> Vincent Le Toux
>
> My Smart Logon
> www.mysmartlogon.com <http://www.mysmartlogon.com/>
>
>
> ------------------------------------------------------------------------------
> One dashboard for servers and applications across Physical-Virtual-Cloud
> Widest out-of-the-box monitoring support with 50+ applications
> Performance metrics, stats and reports that give you Actionable Insights
> Deep dive visibility with transaction tracing using APM Insight.
> http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
>
>
>
> _______________________________________________
> Opensc-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/opensc-devel
>

--

  Douglas E. Engert  <[hidden email]>


------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Opensc-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/opensc-devel