RSAPrivateKeyToXmlDoc (String function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (→‎See also: add method to list)
 
(15 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Template:String:RSAPrivateKeyToXmlDoc subtitle}}
{{Template:String:RSAPrivateKeyToXmlDoc subtitle}}
 
<var>RSAPrivateKeyToXmlDoc</var> converts a string (<var>Longstring</var>) that contains an RSA-generated private key to an <var>[[XmlDoc class|XmlDoc]]</var>.  
X509 is a general authentication framework that establishes standard formats for for public-key certificates, certificate revocation list (CRLs), and more. <var>X509CertificateToXmlDoc</var> converts a string (<var>Longstring</var>) that contains an RSA-generated private key to an <var>[[XmlDoc]]</var>. BER (Basic Encoding Rules) data is base64-encoded binary data.
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.


==Syntax==
==Syntax==
{{Template:String:RSAPrivateKeyToXmlDoc syntax}}
{{Template:String:RSAPrivateKeyToXmlDoc syntax}}
===Syntax terms===
===Syntax terms===
<table class="syntaxTable">
<table>
<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>
<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>
 
<tr><th>string</th>
<tr><th>string</th>
<td>A DER encoded string that contains the contents of a digital certificate. <br>'''Note:''' This method fails if the XML representation of <var class="term">string</var> is longer than 650 characters.</td></tr>
<td>A DER encoded string that contains the contents of a digital certificate. </td></tr>
</table>
</table>
===Exceptions===
<var>RSAPrivateKeyToXmlDoc</var> can throw the following [[Exceptions|exception]]:
<dl>
<dt><var>[[InvalidBerData class|InvalidBerData]]</var>
<dd>If the method encounters non-BER-conforming data, properties of the exception object may indicate the position and description of the error.
</dl>


==Usage notes==
==Usage notes==
<ul>
<ul>
<li>Prior to version 7.7 of Model&nbsp;204, input to this method that created any element in the result <var>XmlDoc</var> with a text child whose length exceeded 650 characters produced an error. An example of such input is a 4096-bit key (which requires 1024 hex characters). As of version 7.7, the lengths of created text nodes are not restricted. </li>
<li><var>RSAPrivateKeyToXmlDoc</var> is very similar to   
<li><var>RSAPrivateKeyToXmlDoc</var> is very similar to   
<var>[[DerToXmlDoc (String function)|DerToXmlDoc]]</var>, except that <var>RSAPrivateKeyToXmlDoc</var> understands the semantics of the private key tags, so it provides more meaningful XML element names.  
<var>[[DerToXmlDoc (String function)|DerToXmlDoc]]</var>, except that <var>RSAPrivateKeyToXmlDoc</var> understands the semantics of the private key tags, so it provides more meaningful XML element names. </li>
<li><var>RSAPrivateKeyToXmlDoc</var> is a complete implementation of the PKCS standards for private key syntax.  
 
<li>Currently, no method is available to produce a DER stream from an <var>XmlDoc</var> nor to validate the signature on a certificate.
<li><var>RSAPrivateKeyToXmlDoc</var> is a complete implementation of the PKCS standards for private key syntax. </li>
<li>This method's limit of an XML representation of 650 characters means that it cannot process a 4096-bit key (which requires 1024 hex characters). Fortunately, 4K keys are still uncommon.
<li>Currently, no method is available to produce a DER stream from an <var>XmlDoc</var> nor to validate the signature on a certificate. </li>
</ul>
</ul>


==Examples==
==Examples==
In the following example, the <var>[[PemToString (Stringlist function)|PemToString]]</var> method loads <var>Longstring</var> <code>%ls</code> with the contents of an RSA private key. <var>RSAPrivateKeyToXmlDoc</var> then converts the <var>Longstring</var> to an <var>XmlDoc</var> whose contents are printed: <p class="code"> ...
In the following example, the <var>[[PemToString (Stringlist function)|PemToString]]</var> method loads <var>Longstring</var> <code>%ls</code> with the contents of an RSA private key. <var>RSAPrivateKeyToXmlDoc</var> then converts the <var>Longstring</var> to an <var>XmlDoc</var> whose contents are printed:  
<p class="code"> ...
text to %sl = new raw
text to %sl = new raw
&#45;----BEGIN RSA PRIVATE KEY-----
&#45;----BEGIN RSA PRIVATE KEY-----
Line 72: Line 72:


==See also==
==See also==
Related methods:
<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>
<ul>
<li><var>String</var> class: <var>[[X509CrlToXmlDoc_(String_function)|X509CrlToXmlDoc]]</var>, <var>[[X509CertificateToXmlDoc_(String_function)|X509CertificateToXmlDoc]]</var>, and <var>[[DerToXmlDoc _(String_function)|DerToXmlDoc]]</var>
<li><var>[[Certificate (Socket function)|Certificate]]</var> </li>
<li><var>System</var> class: <var>[[ClientCertificate (System function)|ClientCertificate]]</var>
<li><var>Socket</var> class: <var>[[Certificate (Socket function)|Certificate]]</var>  
<li><var>HttpRequest</var> class: <var>[[Get (HttpRequest function)|Get]]</var>, <var>[[Post (HttpRequest function)|Post]]</var>, and <var>[[Send (HttpRequest function)|Send]]</var>
<li><var>Stringlist</var> class: <var>[[PemToString_(Stringlist_function)|PemToString]]</var>  
</ul>
</ul>


Background information:
Background information:
<ul>
<ul>
<li>[http://en.wikipedia.org/wiki/Abstract_Syntax_Notation_One|"Abstract Syntax Notation One"]
<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>[http://luca.ntop.org/Teaching/Appunti/asn1.html "A Layman's Guide to a Subset of ASN.1, BER, and DER"] </li>
</ul>
</ul>


{{Template:String:RSAPrivateKeyToXmlDoc footer}}
{{Template:String:RSAPrivateKeyToXmlDoc footer}}

Latest revision as of 15:07, 6 September 2018

Convert BER encoded RSA private key to XML (String class)

[Introduced in Sirius Mods 8.0]

RSAPrivateKeyToXmlDoc converts a string (Longstring) that contains an RSA-generated private key to an XmlDoc. 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.

Syntax

%doc = string:RSAPrivateKeyToXmlDoc Throws InvalidBerData

Syntax terms

%doc An XmlDoc object variable to contain the decoded value of the method object, string.
string A DER encoded string that contains the contents of a digital certificate.

Usage notes

  • Prior to version 7.7 of Model 204, input to this method that created any element in the result XmlDoc with a text child whose length exceeded 650 characters produced an error. An example of such input is a 4096-bit key (which requires 1024 hex characters). As of version 7.7, the lengths of created text nodes are not restricted.
  • RSAPrivateKeyToXmlDoc is very similar to DerToXmlDoc, except that RSAPrivateKeyToXmlDoc understands the semantics of the private key tags, so it provides more meaningful XML element names.
  • RSAPrivateKeyToXmlDoc is a complete implementation of the PKCS standards for private key syntax.
  • Currently, no method is available to produce a DER stream from an XmlDoc nor to validate the signature on a certificate.

Examples

In the following example, the PemToString method loads Longstring %ls with the contents of an RSA private key. RSAPrivateKeyToXmlDoc then converts the Longstring to an XmlDoc whose contents are printed:

... text to %sl = new raw -----BEGIN RSA PRIVATE KEY----- MIIEogIBAAKCAQEAm6TwmSXt4+lyrhwy9SBq2LVjdTeJ5kUbU9jzmBCfw/NuC1tX YAAdc0UG5DDJYPHkWkYa7+z50SYzmoxKI8PfCLyxSOPeVW9CEhRSyiIIlyjQikIK a0YMeOXVetGiutl/y346yQYltkbQXb1SOogTg07fTRs7NWcQ4Rrcd6DEnSkrHxbv T04Z0MwoSojA+NRyBCMpa+w+R0dzrBNZIT11WOccecYjEyuPSS2ydcdgr/Rp4WKC UHmRulXWQjhEjwqFPRG4f8BkYJGr8lN262M4ti4Z11KV/lYA/lEpYUkmCaY936p4 IoVoQy8GFn7mj50sxwSa446bTvKlVPsySMDK2wIBAwKCAQAZ8NLEMPz7UZMdBLMo ... aQmxZUwUo7em8Ci6dX17AoGAcmpQ5AUj5vMdRnOmiIhLM+jgbbQjBD+52hwbkkIn sZ00cQ5asvdrHt3ziIqN7RMu5okuwdFTdk5IGHTA43qykel0e7wxwADI7qybJXWF rsIve5XyKCD55gAM4W8y4+CLkCv6dPwmkTq4vfdaYr0/NPIvigzUq0NEXFVPJfQc GncCgYEAlFIEKq0mVWLBtZRwNjehKOaWGkVVHJnoWqlBngfamQkOiGvWScQ0MVbw K3U00KpuNHRF5RVy035uoU2tnQDLyG+RmUO7j2+t90MOmgXqiZlTz08uf/fQaprd NzpmjANA/9cT3rwHD31LsjaDXASM5IW0q7h+vhvVLtVkDzDnW5w= -----END RSA PRIVATE KEY----- end text %ls = %sl:pemToString('RSA PRIVATE KEY') %ls:RSAPrivateKeyToXmlDoc:print ...

The abridged result is shown below:

<RSAPrivateKey> <version>0</version><modulus>196482721346 ... ...685825059547</modulus> <publicExponent>3</publicExponent> <privateExponent>32747120224474 ... ...832238758867</privateExponent> <prime1>163032211406922467 ... ...063864355897</prime1> <primes>120517730607 ... ...628528150451</primes> <exponent1>108688140937 ... ...709242903931</exponent1> <exponent2>803451537383 ... ...419018766967</exponent2> <coefficient>104154110092 ... ...977615354780</coefficient> </RSAPrivateKey>

See also

String methods:

Stringlist methods:

System methods:

Socket methods:

Background information: