RSAPrivateKeyToXmlDoc (String function)

From m204wiki
Revision as of 18:42, 21 April 2012 by JAL2 (talk | contribs)
Jump to navigation Jump to search

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

[Introduced in Sirius Mods 8.0]


X509 is a general authentication framework that establishes standard formats for for public-key certificates, certificate revocation list (CRLs), and more. X509CertificateToXmlDoc converts a string (Longstring) that contains an RSA-generated private key to an XmlDoc.

Syntax

%doc = string:RSAPrivateKeyToXmlDoc Throws InvalidBerData

Syntax terms

%docAn 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

  • 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

Related methods: