<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../assets/xml/rss.xsl" media="all"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Deep in the weeds (Posts about ASN.1)</title><link>https://blog.mattice.org/</link><description></description><atom:link href="https://blog.mattice.org/categories/asn1.xml" rel="self" type="application/rss+xml"></atom:link><language>en</language><lastBuildDate>Tue, 16 May 2017 01:01:35 GMT</lastBuildDate><generator>Nikola (getnikola.com)</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>EMV should be less confusing for all</title><link>https://blog.mattice.org/posts/emv-should-be-less-confusing-for-all/index.html?utm_source=/categories/asn1.xml&amp;utm_medium=nikola_feed&amp;utm_campaign=rss_feed</link><dc:creator>Mike Mattice</dc:creator><description>&lt;div&gt;&lt;p&gt;Excuse me for a moment while I do a happy dance for effecting change.  It's a small victory, but...&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Mr. Mattice,&lt;/p&gt;
&lt;p&gt;Thank you for your comment.
We acknowledge that the EMVCo tag definition is not fully ISO compliant.  For clarification We will remove the reference to ISO 8825 in the next version of the specifications.&lt;/p&gt;
&lt;p&gt;Sincerely,
The EMVCo Secretariat (on behalf of L2WG)&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I'm glad they've admitted to this.  I hope it makes someone else's job easier someday.&lt;/p&gt;&lt;/div&gt;</description><category>ASN.1</category><category>EMV</category><category>EMVCo</category><category>ISO-8825</category><category>specifications</category><category>tech</category><category>X.690</category><guid>https://blog.mattice.org/posts/emv-should-be-less-confusing-for-all/index.html</guid><pubDate>Wed, 22 Jun 2016 16:38:30 GMT</pubDate></item><item><title>EMVCo's response</title><link>https://blog.mattice.org/posts/emvcos-response/index.html?utm_source=/categories/asn1.xml&amp;utm_medium=nikola_feed&amp;utm_campaign=rss_feed</link><dc:creator>Mike Mattice</dc:creator><description>&lt;div&gt;&lt;p&gt;A little more than a month later, I got a response from EMVCo to &lt;a class="reference external" href="https://blog.mattice.org/posts/emvco-request/index.html"&gt;my request&lt;/a&gt;.  It's about what I expected.  I'm not sure they've read their own specification.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://blog.mattice.org/posts/emvcos-response/index.html?utm_source=/categories/asn1.xml&amp;amp;utm_medium=nikola_feed&amp;amp;utm_campaign=rss_feed"&gt;Read more…&lt;/a&gt; (1 min remaining to read)&lt;/p&gt;&lt;/div&gt;</description><category>ASN.1</category><category>EMV</category><category>EMVCo</category><category>ISO-8825</category><category>specifications</category><category>tech</category><category>X.690</category><guid>https://blog.mattice.org/posts/emvcos-response/index.html</guid><pubDate>Mon, 02 May 2016 15:13:33 GMT</pubDate></item><item><title>EMVCo Request</title><link>https://blog.mattice.org/posts/emvco-request/index.html?utm_source=/categories/asn1.xml&amp;utm_medium=nikola_feed&amp;utm_campaign=rss_feed</link><dc:creator>Mike Mattice</dc:creator><description>&lt;div&gt;&lt;p&gt;I sent the following to EMVCo via &lt;a class="reference external" href="https://www.emvco.com/PublicComments.aspx"&gt;https://www.emvco.com/PublicComments.aspx&lt;/a&gt; on March 28th at about 0200UTC.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Table 35 &amp;amp; 36 refer to ISO/IEC 8825 which is also ITU-T Rec. X.690.  The X.690 spec available at &lt;a class="reference external" href="https://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf"&gt;https://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Specifically, the document states "According to ISO/IEC 8825, Table 36 defines the coding rules of the subsequent bytes of a BER-TLV tag when tag numbers ≥ 31 are used (that is, bits b5 - b1 of the first byte equal '11111')."&lt;/p&gt;
&lt;p&gt;Please explain how 9F02 follows this?  The tag number for 9F02 is 2, which is clearly &amp;lt; 31.&lt;/p&gt;
&lt;dl class="docutils"&gt;
&lt;dt&gt;IEC/ISO 8255 states:&lt;/dt&gt;
&lt;dd&gt;8.1.2.2 For tags with a number ranging from zero to 30 (inclusive), the identifier octets shall comprise a single octet encoded as follows:
a) bits 8 and 7 shall be encoded to represent the class of the tag as specified in Table 1;
b) bit 6 shall be a zero or a one according to the rules of 8.1.2.5;
c) bits 5 to 1 shall encode the number of the tag as a binary integer with bit 5 as the most significant bit.&lt;/dd&gt;
&lt;/dl&gt;
&lt;p&gt;That essentially tells me that every EMV tag that's two bytes with the second byte less than 31 is invalid and not capable of being encoded by BER.&lt;/p&gt;
&lt;p&gt;I look forward to your response.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I figure two weeks is plenty of time for them to respond to this simple inquiry.  Unfortunately, I got the only the following in response:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;*****Please do not reply to this email*****&lt;/p&gt;
&lt;p&gt;Dear Mike Mattice,&lt;/p&gt;
&lt;p&gt;Thank you for submitting your comment to EMVCo. EMVCo has received your comment and will review and respond as deemed necessary.&lt;/p&gt;
&lt;p&gt;Please note that EMVCo does not guarantee a response to public comments. EMVCo has implemented a new subscriber program through its website in order to facilitate dialog and interaction between EMVCo and its subscriber community. For more details, please find the service description in the EMVCo website "Contact Us" section.&lt;/p&gt;
&lt;p&gt;For your reference, a copy of your comment is included below.&lt;/p&gt;
&lt;p&gt;Thank you.&lt;/p&gt;
&lt;p&gt;The EMVCo Communication Secretariat
Message ID:1001&lt;/p&gt;
&lt;p&gt;&lt;cite&gt;-------------------&lt;/cite&gt;&lt;/p&gt;
&lt;p&gt;Comment ID: 12005&lt;/p&gt;
&lt;p&gt;&lt;cite&gt;-------------------&lt;/cite&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Perhaps I should start a gofundme to become an EMVCo subscriber so I can get a guaranteed answer.&lt;/p&gt;
&lt;p&gt;In other news I sent this to &lt;a class="reference external" href="mailto:customerservice@iso.org"&gt;customerservice@iso.org&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Are there repercussions for claiming to follow ISO standards (like 8825) but not actually doing so?&lt;/p&gt;
&lt;p&gt;Thanks,
Mike&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;A couple days later I got:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;ISO standards are voluntary, and as such, ISO does not carry out any assessment of conformity, nor does it monitor the implementation of its standards.&lt;/p&gt;
&lt;p&gt;A number of ISO standards - mainly those concerned with health, safety or the environment - have been adopted in some countries as part of their regulatory framework, or are referred to in legislation for which they serve as the technical basis. However, such adoptions are decisions by the regulatory authorities or governments of the countries concerned. ISO itself does not regulate or legislate.&lt;/p&gt;
&lt;p&gt;Cordially,&lt;/p&gt;
&lt;p&gt;joseph martinez&lt;/p&gt;
&lt;p&gt;Information Expert | marketing and sales services | marketing, communication &amp;amp; information | iso central secretariat | phone: +41 22 749 03 17&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;So, no repercussions for saying you follow ISO-8825, but not actually doing so.&lt;/p&gt;&lt;/div&gt;</description><category>ASN.1</category><category>EMV</category><category>EMVCo</category><category>ISO-8825</category><category>specifications</category><category>tech</category><category>X.690</category><guid>https://blog.mattice.org/posts/emvco-request/index.html</guid><pubDate>Thu, 14 Apr 2016 04:01:08 GMT</pubDate></item><item><title>ASN.1 and EMV</title><link>https://blog.mattice.org/posts/asn1-and-emv/index.html?utm_source=/categories/asn1.xml&amp;utm_medium=nikola_feed&amp;utm_campaign=rss_feed</link><dc:creator>Mike Mattice</dc:creator><description>&lt;div&gt;&lt;p&gt;I've been tasked with making EMV work for the company I work for and more importantly, for our customers.  As I write python most of the time these days, I looked around for a tool to play with &lt;a class="reference external" href="https://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf"&gt;ASN.1&lt;/a&gt;.  A stupidly quick Google landed me on &lt;a class="reference external" href="http://pyasn1.sf.net"&gt;pyasn1&lt;/a&gt;.  I made a run at using it to manipulate the BER-TLV the &lt;a class="reference external" href="https://www.emvco.com/download_agreement.aspx?id=654"&gt;EMV 4.3 Book 3&lt;/a&gt; requires.  This resulted in some difficulties.  I reported a &lt;a class="reference external" href="https://sourceforge.net/p/pyasn1/mailman/message/34776952/"&gt;bug&lt;/a&gt; via the mailing list.&lt;/p&gt;
&lt;p&gt;Thinks have changed in the past two months.&lt;/p&gt;
&lt;p&gt;pyasn1 moved to &lt;a class="reference external" href="https://github.com/etingof/pyasn1"&gt;github&lt;/a&gt;.  I'd built some work arounds and submitted a &lt;a class="reference external" href="https://github.com/etingof/pyasn1/pull/5"&gt;PR&lt;/a&gt;.  I ended up splitting the PR into &lt;a class="reference external" href="https://github.com/etingof/pyasn1/pull/6"&gt;another&lt;/a&gt; because that one could break extended tags everywhere.  The issues I saw with the EMV tags and how they decoded are in that first PR, and also in &lt;a class="reference external" href="https://github.com/mmattice/emv-asn1"&gt;emv-asn1&lt;/a&gt;, which I wrote with my assumptions I'd codified in &lt;a class="reference external" href="https://github.com/mmattice/pyasn1/tree/bugfix/emv"&gt;bugfix/emv&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I did these things because I was sure EMVCo would surely stick to standards and that they had interpreted the ASN.1 spec correctly.  I now know I was wrong.&lt;/p&gt;
&lt;p&gt;I've built, and am using, an internal version of pyasn1 and that allows me to encode/decode this EMV stuff 'properly'.  I've even made a decoder/encoder pair for our pinpad's odd text based format with these assumptions.&lt;/p&gt;
&lt;p&gt;Now, however, I want to burn it all to the ground.&lt;/p&gt;
&lt;p&gt;Today I found &lt;a class="reference external" href="https://github.com/Shopify/grizzly_ber"&gt;grizzly_ber&lt;/a&gt;, which is the same workaround in Ruby.  I realized it wasn't just me that was having trouble with this.&lt;/p&gt;
&lt;p&gt;From &lt;a class="reference external" href="https://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf"&gt;ASN.1&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;dl class="docutils"&gt;
&lt;dt&gt;8.1.2.2 For tags with a number ranging from zero to 30 (inclusive), the identifier octets shall comprise a single octet encoded as follows:&lt;/dt&gt;
&lt;dd&gt;&lt;ol class="first last loweralpha simple"&gt;
&lt;li&gt;bits 8 and 7 shall be encoded to represent the class of the tag as specified in Table 1;&lt;/li&gt;
&lt;li&gt;bit 6 shall be a zero or a one according to the rules of 8.1.2.5;&lt;/li&gt;
&lt;li&gt;bits 5 to 1 shall encode the number of the tag as a binary integer with bit 5 as the most significant bit.&lt;/li&gt;
&lt;/ol&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;p&gt;8.1.2.4 For tags with a number greater than or equal to 31, the identifier shall comprise a leading octet followed by one or more subsequent octets.&lt;/p&gt;
&lt;dl class="docutils"&gt;
&lt;dt&gt;8.1.2.4.1 The leading octet shall be encoded as follows:&lt;/dt&gt;
&lt;dd&gt;&lt;ol class="first last loweralpha simple"&gt;
&lt;li&gt;bits 8 and 7 shall be encoded to represent the class of the tag as listed in Table 1;&lt;/li&gt;
&lt;li&gt;bit 6 shall be a zero or a one according to the rules of 8.1.2.5;&lt;/li&gt;
&lt;li&gt;bits 5 to 1 shall be encoded as 11111.&lt;/li&gt;
&lt;/ol&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;a class="reference external" href="http://www.emvlab.org/emvtags/show/t82/"&gt;82&lt;/a&gt; and &lt;a class="reference external" href="http://www.emvlab.org/emvtags/show/t9f02"&gt;9F02&lt;/a&gt; are an example of how EMVCo failed.  9F02 decodes to (80 + 1F) with a tag number of (02); 82 decodes to (80) tagno (02).  That 1F is only supposed to be there &lt;strong&gt;For tags with a number greater than or equal to 31&lt;/strong&gt;.  The EMV standard even refers to the ASN.1 spec correctly in Book 3 Annex B1.&lt;/p&gt;
&lt;blockquote&gt;
Table 36 defines the coding rules of the subsequent bytes of a BER-TLV tag when tag numbers ≥ 31 are used (that is, bits b5 - b1 of the first byte equal '11111').&lt;/blockquote&gt;
&lt;p&gt;The EMV standard claims to use BER-TLV encoding.  It does not.  How can we fix this?  Is it fixable?  What's the right approach?&lt;/p&gt;
&lt;p&gt;I personally like to do things "The Right Way".  Doing so would require billions of cards to be replaced and many instances of software to be updated.  I just don't see that happening any time soon.&lt;/p&gt;
&lt;p&gt;I've &lt;a class="reference external" href="https://www.emvco.com/PublicComments.aspx"&gt;asked&lt;/a&gt; EMVCo how 9F** tags (and the rest of the extended tags) follow the standard they claim to follow.  I'm not guaranteed a response without &lt;a class="reference external" href="https://www.emvco.com/about_emvco.aspx?id=161"&gt;subscribing for $2500&lt;/a&gt;.  We'll see if I get a response.&lt;/p&gt;&lt;/div&gt;</description><category>ASN.1</category><category>EMV</category><category>specifications</category><category>tech</category><guid>https://blog.mattice.org/posts/asn1-and-emv/index.html</guid><pubDate>Sun, 27 Mar 2016 23:41:16 GMT</pubDate></item></channel></rss>