<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; ">Ron,<DIV><BR class="khtml-block-placeholder"></DIV><DIV>This is all very complicated and some careful thought needs to be given on how to proceed.  The good news is that by turning off the decoding of CertificateExtensions, everything works as it stands.  To take the next steps and really implement ASN.1, we need to handle Explicit and Implicit tagging of user defined Types.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>I was glad you picked a point and restarted the conversation.  What follows is more of the mess...</DIV><DIV><BR><DIV><DIV>On Mar 21, 2007, at 5:04 PM, Ron Teitelbaum wrote:</DIV><BLOCKQUOTE type="cite"><DIV class="Section1"><P class="MsoNormal"><FONT size="2" color="navy" face="Arial"><SPAN style="font-size: 10.0pt;font-family:Arial;color:navy">I need to digest all this and read up some more.  I’m still suck on the bit 6.  Doesn’t the 1 in bit 6 mean that we have a constructed value?  Which I translate to mean an object with ivars.  </SPAN></FONT></P></DIV></BLOCKQUOTE>Bit 6 being constructed does not mean that it is an object with ivars.  BER encoding allows primitive types to be constructed.  DER encoding prevents this, but there are other Explicit types which can be constructed that are not objects with ivars.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>I played around with VW this afternoon an the way they model a user defined type is shown as an example which defines the Type #TBSCertificate:</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>( x509Module SEQUENCE: #TBSCertificate )</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>addElement: #version type: #Version tag: 0 tagging: #explicit default: 0;</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>addElement: #serialNumber type: #CertificateSerialNumber;</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>addElement: #signature type: #AlgorithmIdentifier;</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>addElement: #issuer type: #Name;</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>addElement: #validity type: #Validity;</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>addElement: #subject type: #Name;</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>addElement: #subjectPublicKeyInfo type: #SubjectPublicKeyInfo;</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>addOptionalElement: #issuerUniqueID type: #UniqueIdentifier tag: 1 tagging: #implicit;</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>addOptionalElement: #subjectUniqueID type: #UniqueIdentifier tag: 2 tagging: #implicit;</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>addOptionalElement: #extensions type: #Extensions tag: 3 tagging: #explicit;</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>mapping: TBSCertificate;</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>retainEncoding: true.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>The DERStream then uses this type to unpack the values and map them to TBSCertificate.  Notice the 3 OptionaElements.  2 are Implicit and 1 is Explicit.  This has to do with how the tagging shakes out.  </DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>The first Implicit type hides the type tag of the underlying UniqueIdentifier with the Implicit [1], so there is no tag explicitly for the UniqueIdentifier.  The Type definition knows this, which we re missing in our implementation.</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>{10000001} [length octet] [UniqueIdentifier value]</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>The Explicit type does not hide the underlying type tag, and it doesn't have to be sequence.</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>{10100011} [length octet] [{00110000} [length octet] [Extension values]]</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>In the original case I brought up, there is an Implicit constructed Sequence, which was tagged:</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>{10100000} [length octet] [Sequence values] </DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BLOCKQUOTE type="cite"><DIV class="Section1"><P class="MsoNormal"><FONT class="Apple-style-span" color="#000080" face="Arial" size="4"><SPAN class="Apple-style-span" style="font-size: 13.3333px;"><BR class="khtml-block-placeholder"></SPAN></FONT></P><P class="MsoNormal"><FONT size="2" color="navy" face="Arial"><SPAN style="font-size: 10.0pt;font-family:Arial;color:navy">Primitive means single data element  (i.e. String) <O:P></O:P></SPAN></FONT></P><P class="MsoNormal"><FONT size="2" color="navy" face="Arial"><SPAN style="font-size: 10.0pt;font-family:Arial;color:navy">Constructed means multiples (i.e. SomeObject).</SPAN></FONT></P></DIV></BLOCKQUOTE>This is not necessarily true.  Your original posting pointed it out:</DIV><BLOCKQUOTE type="cite"><BLOCKQUOTE type="cite"><DIV class="Section1"><FONT class="Apple-style-span" color="#000080" face="Arial" size="4"><SPAN class="Apple-style-span" style="font-size: 13.3333px;"> </SPAN></FONT><FONT class="Apple-style-span" face="Verdana" size="4"><SPAN class="Apple-style-span" style="font-size: 13.3333px;">3</SPAN></FONT><SPAN style=""><FONT class="Apple-style-span" size="4"><SPAN class="Apple-style-span" style="font-size: 13.3333px;"><FONT class="Apple-style-span" face="Verdana">.2 Constructed, definite-length method</FONT></SPAN></FONT></SPAN><DIV style="margin-top: 0in; margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; "><SPAN style=""><FONT class="Apple-style-span" face="Verdana" size="4"><SPAN class="Apple-style-span" style="font-size: 13.3333px;">This method applies to simple string types, structured types, types derived</SPAN></FONT><FONT class="Apple-style-span" size="4"><SPAN class="Apple-style-span" style="font-size: 16px;"><O:P style=""></O:P></SPAN></FONT></SPAN></DIV><DIV style="margin-top: 0in; margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; "><SPAN style=""><FONT class="Apple-style-span" face="Verdana" size="4"><SPAN class="Apple-style-span" style="font-size: 13.3333px;">simple string types and structured types by implicit tagging, and types derived</SPAN></FONT><FONT class="Apple-style-span" size="4"><SPAN class="Apple-style-span" style="font-size: 16px;"><O:P style=""></O:P></SPAN></FONT></SPAN></DIV><DIV style="margin-top: 0in; margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; "><SPAN style=""><FONT class="Apple-style-span" face="Verdana" size="4"><SPAN class="Apple-style-span" style="font-size: 13.3333px;">from anything by explicit tagging. It requires that the length of the value be</SPAN></FONT><FONT class="Apple-style-span" size="4"><SPAN class="Apple-style-span" style="font-size: 16px;"><O:P style=""></O:P></SPAN></FONT></SPAN></DIV><DIV style="margin-top: 0in; margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; "><SPAN style=""><FONT class="Apple-style-span" face="Verdana" size="4"><SPAN class="Apple-style-span" style="font-size: 13.3333px;">known in advance. The parts of the BER encoding are as follows:</SPAN></FONT><FONT class="Apple-style-span" size="4"><SPAN class="Apple-style-span" style="font-size: 16px;"><O:P style=""></O:P></SPAN></FONT></SPAN></DIV><DIV style="margin-top: 0in; margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; "><SPAN style=""><FONT class="Apple-style-span" face="Verdana" size="4"><SPAN class="Apple-style-span" style="font-size: 13.3333px;">Identifier octets. As described in Section 3.1, except that bit 6 has value "1,"</SPAN></FONT><FONT class="Apple-style-span" size="4"><SPAN class="Apple-style-span" style="font-size: 16px;"><O:P style=""></O:P></SPAN></FONT></SPAN></DIV><DIV style="margin-top: 0in; margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; "><SPAN style=""><FONT class="Apple-style-span" face="Verdana" size="4"><SPAN class="Apple-style-span" style="font-size: 13.3333px;">indicating that the encoding is constructed.</SPAN></FONT></SPAN></DIV></DIV></BLOCKQUOTE></BLOCKQUOTE><DIV><BR class="khtml-block-placeholder"></DIV><DIV>It can be "<SPAN style=""><FONT class="Apple-style-span" face="Verdana" size="4"><SPAN class="Apple-style-span" style="font-size: 13.3333px;">simple string types, ..., <FONT class="Apple-style-span" face="Times New Roman" size="4"><SPAN class="Apple-style-span" style="font-size: 16px;">types derived<FONT class="Apple-style-span" face="Verdana" size="4"><SPAN class="Apple-style-span" style="font-size: 13.3333px;"> </SPAN></FONT><SPAN style=""><FONT class="Apple-style-span" size="5"><SPAN class="Apple-style-span" style="font-size: 18px;"><FONT class="Apple-style-span" face="Verdana" size="4"><SPAN class="Apple-style-span" style="font-size: 13.3333px;">from anything by explicit tagging</SPAN></FONT>".  In BER encoding, you can encode an IA5String with the constructed type:</SPAN></FONT></SPAN></SPAN></FONT></SPAN></FONT></SPAN></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;"><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>36 13</SPAN></FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;"><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>   </SPAN></FONT><FONT class="Apple-style-span" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">16 05 74 65 73 74 31</SPAN></FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;"><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>   </SPAN></FONT><FONT class="Apple-style-span" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">16 01 40</SPAN></FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;"><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>   </SPAN></FONT><FONT class="Apple-style-span" face="Courier" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;">16 07 72 73 61 2e 63 6f 6d</SPAN></FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Times" size="4"><SPAN class="Apple-style-span" style="font-size: 16px;"><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>constructed encoding: "test1" + "@" + "rsa.com"</SPAN></FONT></DIV><DIV>In DER encoding it has to be primitive, however.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><SPAN style="; color: rgb(0, 99, 18); "></SPAN></DIV><DIV><BLOCKQUOTE type="cite"><DIV class="Section1"><P class="MsoNormal"><FONT size="2" color="navy" face="Arial"><SPAN style="font-size: 10.0pt;font-family:Arial;color:navy"><O:P></O:P></SPAN></FONT></P><P class="MsoNormal"><FONT size="2" color="navy" face="Arial"><SPAN style="font-size: 10.0pt;font-family:Arial;color:navy"><O:P> <SPAN style="">Explicit means field name comes from ANS definition.</SPAN></O:P></SPAN></FONT></P><P class="MsoNormal"><FONT size="2" color="navy" face="Arial"><SPAN style="font-size: 10.0pt;font-family:Arial;color:navy">Implicit means field name comes from data?</SPAN></FONT></P></DIV></BLOCKQUOTE>Explicit means it wraps a full Triplet [Explicit tag] [length1] [Underlying tag] [length2] [value].  Implicit retags the underlying Triplet [Implicit tag] [length] [value]</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Both come from the type definition and that is what is needed to know how to decode/encode these structures.<BR><BLOCKQUOTE type="cite"><DIV class="Section1"><P class="MsoNormal"><FONT size="2" color="navy" face="Arial"><SPAN style="font-size: 10.0pt;font-family:Arial;color:navy"><O:P></O:P></SPAN></FONT></P><P class="MsoNormal"><FONT size="2" color="navy" face="Arial"><SPAN style="font-size: 10.0pt;font-family:Arial;color:navy"><O:P> <SPAN style="">Although I’m not sure.  Like I said I need to read up some more.</SPAN></O:P></SPAN></FONT></P></DIV></BLOCKQUOTE>I got a lot of this from the doc you are using "A Layman's Guide to a Subset of ASN.1,. BER, and DER"<BR><BLOCKQUOTE type="cite"><DIV class="Section1"><P class="MsoNormal"><FONT size="2" color="navy" face="Arial"><SPAN style="font-size: 10.0pt;font-family:Arial;color:navy"><O:P> <SPAN style="">The definition parser is really not that complicated.  It is almost done, I was hoping to add pragmas onto objects to allow reading and writing to asn from the metadata on the ivars.  This would tie the definition to the object model.  Problem is having enough time to finish it. </SPAN></O:P></SPAN></FONT></P></DIV></BLOCKQUOTE>I personally don't like pragmas.  I prefer to use a Type-MetaType pattern and have the Type instance separate from the associated class.  Whether this Type (the MetaType) comes from a Smalltalk construction, like the VW example, or comes out of an ASN.1 Definition Parser is a wash.  The goal is the execution environment of the decoding will be a stream with a Type to interpret the tags and values.  Unless I am missing something.  In honesty, I don't know what you have done.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Lot's to chew on,</DIV><DIV>Robert<BR><BLOCKQUOTE type="cite"><DIV class="Section1"></DIV></BLOCKQUOTE></DIV><BR></DIV></BODY></HTML>