DerToXmlDoc (String function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (→‎See also: add method to list)
 
(29 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{Template:String:DerToXmlDoc subtitle}}
{{Template:String:DerToXmlDoc subtitle}}
 
DER (Distinguished Encoding Rules), a subset of BER (Basic Encoding Rules, provide a way to uniquely encode an Abstract Syntax Notation One (ASN.1) type value as a string of eight-bit octets.
DER (Distinguished Encoding Rules) provide a way to uniquely encode an ASN.1 type value as a string of eight-bit octets.
<var>DerToXmlDoc</var> converts such a string to a generically-formatted <var>[[XmlDoc class|XmlDoc]]</var>. This generic formatting lets you load and access ASN.1 data from any source, for example, LDAP and SNMP, as well as any X509 certificate-related fields that might not be included in the other more specific [[Release notes for Sirius Mods V8.0#DER2Xml|DER-to-XmlDoc]] methods.
<var>DerToXmlDoc</var> converts such a string to an <var>[[XmlDoc]]</var>.


==Syntax==
==Syntax==
Line 8: Line 7:


===Syntax terms===
===Syntax terms===
<table class="syntaxTable">
<table>
<tr><th>%doc</th>
<tr><th>%doc</th>
<td>An <var>XmlDoc</var> object variable to contain the decoded value of the method object, <var class="term">string</var>. </td></tr>
<td>An <var>XmlDoc</var> object variable to contain the decoded value of the method object, <var class="term">string</var>. </td></tr>
<tr><th>string</th>
<tr><th>string</th>
<td>A DER encoded string.</td></tr>
<td>A DER encoded string. </td></tr>
</table>
</table>


==Usage notes==
==Usage notes==
<ul>
<li><var>DerToXmlDoc</var> does the same work as <var>[[X509CertificateToXmlDoc (String function)|X509CertificateToXmlDoc]]</var>, <var>[[X509CrlToXmlDoc (String function)|X509CrlToXmlDoc]]</var>, and
<var>[[RSAPrivateKeyToXmlDoc (String function)|RSAPrivateKeyToXmlDoc]]</var>, except that those methods understand the semantics of the standard tags for those items, so they provide more meaningful XML element names. Contrast the [[DerToXmlDoc (String function)#Examples|DerToXmlDoc examples]] below with the examples for those more specific methods in their respective "Examples" sections.
<p class="note"><b>Note:</b> Prior to version 7.7 of Model&nbsp;204, input to these four <var class="term">xxx</var><var>ToXmlDoc</var> methods that created any element in the result <var>XmlDoc</var> with a text child whose length exceeded 650 characters produced an error. As of version 7.7, the lengths of the created text nodes are not restricted. </p></li>
<li>Currently, no method is available to produce a DER stream from an <var>XmlDoc</var>. </li>
</ul>


==Examples==
==Examples==
[[PemToString (Stringlist function)#Examples|The PemToString example]] loads a <var>Longstring</var> with the contents of the base64 encoded CRL (Certificate Revocation List). If that <var>Longstring</var> is <code>%ls</code> below, the following statement converts that string to the XmlDoc whose contents are printed thereafter:
<ol>
<p class="code">%ls:derToXmlDoc:print</code> </p>
<li>[[PemToString (Stringlist function)#Examples|The PemToString example]] loads a <var>Longstring</var> with the contents of the base64 encoded CRL (Certificate Revocation List). If that <var>Longstring</var> is <code>%ls</code> below, the following statement converts that string to the XmlDoc whose contents are printed thereafter:
<p class="code">%ls:derToXmlDoc:print </p>


The result is shown in part below:
The result is shown in part below:
Line 50: Line 58:
         ... </p>
         ... </p>
                                                                    
                                                                    
The ellipses indicate snipped content and are not part of the XmlDoc.
The ellipses indicate snipped content and are not part of the XmlDoc.</li>
 
<li>In [[RSAPrivateKeyToXmlDoc (String function)#Examples|the RSAPrivateKeyToXmlDoc example]], the <var>PemToString</var> method loads a <var>Longstring</var> with the contents of an RSA private key. If that <var>Longstring</var> is also <code>%ls</code> below, the following statement converts that string to the <var>XmlDoc</var> whose contents are printed below. Compare the XML tags in these results with the tags produced by <var>RSAPrivateKeyToXmlDoc</var>:
<p class="code">%ls:derToXmlDoc:print </p>
 
The result is shown in part below:
<p class="code"><Sequence>
  <Integer>0</Integer>
  <Integer>196482721346 ...
    ...685825059547</Integer>
  <Integer>3</Integer>
  <Integer>327471202244 ...
    ...832238758867</Integer>
  <Integer>163032211406 ...
    ...063864355897</Integer>
  <Integer>120517730607 ...
    ...628528150451</Integer>
  <Integer>108688140937 ...
    ...709242903931</Integer>
  <Integer>803451537383 ...
    ...419018766967</Integer>
  <Integer>104154110092 ...
    ...977615354780</Integer>                                                         
</Sequence> </p></li>
</ol>
 
==See also==
==See also==
<p>
<var>String</var> methods:</p>
<ul>
<li><var>[[CertificateRequest (String function)|CertificateRequest]]</var> </li>
<li><var>[[ClientCertificateRequest (String function)|ClientCertificateRequest]]</var> </li>
<li><var>[[SignedCertificate (String function)|SignedCertificate]]</var> </li>
<li><var>[[SignedClientCertificate (String function)|SignedClientCertificate]]</var> </li>
<li><var>[[DerToXmlDoc (String function)|DerToXmlDoc]]</var> </li>
<li><var>[[RSAPrivateKeyToXmlDoc (String function)|RSAPrivateKeyToXmlDoc]]</var></li>
<li><var>[[X509CertificateToXmlDoc (String function)|X509CertificateToXmlDoc]]</var> </li>
<li><var>[[X509CrlToXmlDoc (String function)|X509CrlToXmlDoc]]</var> </li>
<li>Multiple cryptographic cipher methods </li>
</ul>
<p>
<var>Stringlist</var> methods: </p>
{{Template:Stringlist crypto methods}}
<p>
<var>System</var> methods: </p>
<ul>
<li><var>[[ClientCertificate (System function)|ClientCertificate]]</var></li>
<li><var>[[GeneratedPrivateKey (System function)|GeneratedPrivateKey]]</var> </li>
</ul>
<p>
<var>Socket</var> methods: </p>
<ul>
<li><var>[[Certificate (Socket function)|Certificate]]</var> </li>
</ul>
Background information:
<ul>
<li>[http://en.wikipedia.org/wiki/Abstract_Syntax_Notation_One "Abstract Syntax Notation One"] </li>
<li>[http://luca.ntop.org/Teaching/Appunti/asn1.html "A Layman's Guide to a Subset of ASN.1, BER, and DER"] </li>
</ul>
{{Template:String:DerToXmlDoc footer}}
{{Template:String:DerToXmlDoc footer}}

Latest revision as of 15:06, 6 September 2018

Convert DER encoded data to XML (String class)

[Introduced in Sirius Mods 8.0]

DER (Distinguished Encoding Rules), a subset of BER (Basic Encoding Rules, provide a way to uniquely encode an Abstract Syntax Notation One (ASN.1) type value as a string of eight-bit octets. DerToXmlDoc converts such a string to a generically-formatted XmlDoc. This generic formatting lets you load and access ASN.1 data from any source, for example, LDAP and SNMP, as well as any X509 certificate-related fields that might not be included in the other more specific DER-to-XmlDoc methods.

Syntax

%doc = string:DerToXmlDoc Throws InvalidBerData

Syntax terms

%doc An XmlDoc object variable to contain the decoded value of the method object, string.
string A DER encoded string.

Usage notes

  • DerToXmlDoc does the same work as X509CertificateToXmlDoc, X509CrlToXmlDoc, and RSAPrivateKeyToXmlDoc, except that those methods understand the semantics of the standard tags for those items, so they provide more meaningful XML element names. Contrast the DerToXmlDoc examples below with the examples for those more specific methods in their respective "Examples" sections.

    Note: Prior to version 7.7 of Model 204, input to these four xxxToXmlDoc methods that created any element in the result XmlDoc with a text child whose length exceeded 650 characters produced an error. As of version 7.7, the lengths of the created text nodes are not restricted.

  • Currently, no method is available to produce a DER stream from an XmlDoc.

Examples

  1. The PemToString example loads a Longstring with the contents of the base64 encoded CRL (Certificate Revocation List). If that Longstring is %ls below, the following statement converts that string to the XmlDoc whose contents are printed thereafter:

    %ls:derToXmlDoc:print

    The result is shown in part below:

    <Sequence> <Sequence> <Sequence> <ObjectIdentifier>1.2.840.113549.1.1.4</ObjectIdentifier> <Null/> </Sequence> <Sequence> ... <Set> <Sequence> <ObjectIdentifier>2.5.4.8</ObjectIdentifier> <PrintableString>QLD</PrintableString> </Sequence> </Set> ... <UTCTime>20010115162657.000Z</UTCTime> <UTCTime>20010214162657.000Z</UTCTime> <Sequence> <Sequence> <Integer>1</Integer> <UTCTime>19951009233205.000Z</UTCTime> </Sequence> <Sequence> <Integer>3</Integer> <UTCTime>19951201010000.000Z</UTCTime> </Sequence> ...

    The ellipses indicate snipped content and are not part of the XmlDoc.
  2. In the RSAPrivateKeyToXmlDoc example, the PemToString method loads a Longstring with the contents of an RSA private key. If that Longstring is also %ls below, the following statement converts that string to the XmlDoc whose contents are printed below. Compare the XML tags in these results with the tags produced by RSAPrivateKeyToXmlDoc:

    %ls:derToXmlDoc:print

    The result is shown in part below:

    <Sequence> <Integer>0</Integer> <Integer>196482721346 ... ...685825059547</Integer> <Integer>3</Integer> <Integer>327471202244 ... ...832238758867</Integer> <Integer>163032211406 ... ...063864355897</Integer> <Integer>120517730607 ... ...628528150451</Integer> <Integer>108688140937 ... ...709242903931</Integer> <Integer>803451537383 ... ...419018766967</Integer> <Integer>104154110092 ... ...977615354780</Integer> </Sequence>

See also

String methods:

Stringlist methods:

System methods:

Socket methods:

Background information: