AppendGeneratedPrivateKey (Stringlist subroutine): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (→‎See also: add method to list)
 
(24 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{Template:Stringlist:AppendGeneratedPrivateKey subtitle}}
{{Template:Stringlist:AppendGeneratedPrivateKey subtitle}}
This page is [[under construction]].
==Syntax==
==Syntax==
{{Template:Stringlist:AppendGeneratedPrivateKey syntax}}
{{Template:Stringlist:AppendGeneratedPrivateKey syntax}}
===Syntax terms===
===Syntax terms===
<table class="syntaxTable">
<table>
<tr><th>sl</th>
<tr><th>sl</th>
<td>Stringlist object</td></tr>
<td>A <var>Stringlist</var> object to contain the generated private key.</td></tr>
 
<tr><th><var>Length</var></th>
<tr><th><var>Length</var></th>
<td>number</td></tr>
<td>This optional, [[Notation conventions for methods#Named parameters|name allowed]], parameter specifies the number of bits in the private key. The value must be at least 64 and no greater than 4096 (as of version 7.7 of Model 204). The pre-7.7 maximum is 2048. The default is 512.
<p class="note"><b>Note:</b> While AppendGeneratedPrivateKey can generate keys whose length is less than 512, such keys are of purely academic interest. To use a key in a certificate request (see <var>[[AppendCertificateRequest (Stringlist function)|AppendCertificateRequest]]</var>, for example, requires a key whose length is 512 or greater. </p></td></tr>
 
<tr><th><var>Exponent</var></th>
<tr><th><var>Exponent</var></th>
<td>number</td></tr>
<td>This optional, name allowed, parameter specifies the number of bits in the public exponent (E). This must be either 3 or X'10001'. The default is 3. </td></tr>
 
<tr><th><var>Salt</var></th>
<tr><th><var>Salt</var></th>
<td>string</td></tr>
<td>This optional, name allowed, parameter is a string that contains seed data for a random number generator. </td></tr>
</table>
</table>


===Return codes===
==Examples==
<table>
In the following example, a private key is generated into a <var>Stringlist</var> and displayed in base64 format, then the private key is extracted to a binary string, loaded into an <var>XmlDoc</var>, and printed:
<tr><th>0</th><td>All is well.</td></tr>
<p class="code">b
<tr><th>3</th><td>Out of CCATEMP.</td></tr>
 
<tr><th>5</th><td><var>Stringlist</var> identifier missing.</td></tr>
%sl  is object stringlist
<tr><th>6</th><td>Invalid <var>Stringlist</var> identifier.</td></tr>
%ls is longstring
<tr><th>7</th><td>Insufficient storage.</td></tr>
%sl = new
<tr><th>8</th><td>Invalid public exponent.</td></tr>
 
<tr><th>9</th><td>Invalid number of bits.</td></tr>
%sl:appendGeneratedPrivateKey(Length=1024)
</table>
%sl:print
 
%ls = %sl:pemToString('RSA PRIVATE KEY') 
%ls:RSAPRIVATEKEYTOXMLDOC:print         
end
</p>
The result is something like:
<p class="output">&#45;----BEGIN RSA PRIVATE KEY-----
MIICWwIBAAKBgQCPcaITVcyiT2zx4aKymt9u+NEZ4FzbPvlhbBQs+WkYhbErBeOb
FR2e5dmch7h5anX5xG6OneIzJ95ylMMmyWiTAjH5nEH1zI7P3k34/3QjN7YgN+f4
R+z7SHraInHc4QoN6uujWVfCvv1aA6YLjONz72JHrWxLgFZiHHLWSA3Z1wIBAwKB
gBfoRa3johsNPNL68HMZz+fUItmlZM81KZA8rgd+5tlrnYcrpe8uL5p7pETBSWmR
vlRLZ8JvpbMxT73DddvMPBhAdsTRWPg3Ef0vFd/+W2icZ4B1qSlVsy7FIHBzxULX
4DHCgNEPa0YM9vD4pTv7Y4EQSoi1PhQk/8S8O7vDFsFHAkEAxSKHX3wu6EyExpFg
y1MSDyaro9Tm+/Coy72znEsO9IkikE3YsoQeS/ohqMVn1U9o4pp0zktEVh2m5XOn
GcuyhQJBALpG1VSv9ZnWW/05WD38nX4icdIcGUnJOd36g8+HPN0/wMuY5EpQACU5
kocBO9M/BKsInp+sjkw6Hs2YyJu5n6sCQQCDbFo/qB9FiFiEYOsyN2Ffbx0X40Sn
9cXdKSJoMgn4W2xgM+XMWBQypsEbLkU435tBvE3e3Ng5aRnuTRoRMncDAkB8Lzjj
H/kROZKo0OV+qGj+waE2vWYxMNE+pwKKWiiTf9XdEJgxiqrDe7cEq303f1hyBb8V
HbQy0WneZdsSe7/HAkEAj7yu1YIx+78xRa2zI494/QCzTcocC3S1tm1VjI6yLChE
6XRE80rGrU5xtiaqYnABdS1uPQAyyRzcDh1swvnDwQ==                   
&#45;----END RSA PRIVATE KEY-----
<RSAPrivateKey>
  <version>0</version>
  <modulus>100729717618318585848486 ... 070347486493510338730901-
817890230060500171831435 ... 947861190265885563641189-
612871869577433527035045 ... 102393395848393488456151</modulus>
  <publicExponent>3</publicExponent>
  <privateExponent>167882862697197643080811 ... 203586267839124774891838-
978848363631503834341669 ... 3621646783354544762317395-
123358365246652607958565 ... 784368917835086686503239</privateExponent>
  <prime1>103247913368407610232689 ... 170858989455376441749390-
58859505943349295342502743592645253</prime1>
  <primes>975610202008600046064537 ... 272137236445431323153153-
9829343947046884546335129776791467</primes>
  <exponent1>688319422456050734884593 ... 361139059929702509611662-
6039239670628899530228335162395096835</exponent1>
  <exponent2>650406801339066697376358 ... 890181424824296954215435-
4359886229298031256364223419851194311</exponent2>
  <coefficient>7528119772196662607878768 ... 656935021038455079267606-
303026918447360800362338060867429057473</coefficient>
</RSAPrivateKey>
</p>


==Usage notes==
==Examples==
==See also==
==See also==
<p>
<var>Stringlist</var> methods: </p>
{{Template:Stringlist crypto methods}}
<p>
<var>String</var> methods:</p>
<ul>
<li><var>[[CertificateRequest (String function)|CertificateRequest]]</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>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>
{{Template:Stringlist:AppendGeneratedPrivateKey footer}}
{{Template:Stringlist:AppendGeneratedPrivateKey footer}}

Latest revision as of 15:13, 6 September 2018

Add base64 encoded RSA private key to a Stringlist (Stringlist class)

[Requires Janus Network Security]

Syntax

sl:AppendGeneratedPrivateKey[( [[Length=] number], [[Exponent=] number], - [[Salt=] string])]

Syntax terms

sl A Stringlist object to contain the generated private key.
Length This optional, name allowed, parameter specifies the number of bits in the private key. The value must be at least 64 and no greater than 4096 (as of version 7.7 of Model 204). The pre-7.7 maximum is 2048. The default is 512.

Note: While AppendGeneratedPrivateKey can generate keys whose length is less than 512, such keys are of purely academic interest. To use a key in a certificate request (see AppendCertificateRequest, for example, requires a key whose length is 512 or greater.

Exponent This optional, name allowed, parameter specifies the number of bits in the public exponent (E). This must be either 3 or X'10001'. The default is 3.
Salt This optional, name allowed, parameter is a string that contains seed data for a random number generator.

Examples

In the following example, a private key is generated into a Stringlist and displayed in base64 format, then the private key is extracted to a binary string, loaded into an XmlDoc, and printed:

b %sl is object stringlist %ls is longstring %sl = new %sl:appendGeneratedPrivateKey(Length=1024) %sl:print %ls = %sl:pemToString('RSA PRIVATE KEY') %ls:RSAPRIVATEKEYTOXMLDOC:print end

The result is something like:

-----BEGIN RSA PRIVATE KEY----- MIICWwIBAAKBgQCPcaITVcyiT2zx4aKymt9u+NEZ4FzbPvlhbBQs+WkYhbErBeOb FR2e5dmch7h5anX5xG6OneIzJ95ylMMmyWiTAjH5nEH1zI7P3k34/3QjN7YgN+f4 R+z7SHraInHc4QoN6uujWVfCvv1aA6YLjONz72JHrWxLgFZiHHLWSA3Z1wIBAwKB gBfoRa3johsNPNL68HMZz+fUItmlZM81KZA8rgd+5tlrnYcrpe8uL5p7pETBSWmR vlRLZ8JvpbMxT73DddvMPBhAdsTRWPg3Ef0vFd/+W2icZ4B1qSlVsy7FIHBzxULX 4DHCgNEPa0YM9vD4pTv7Y4EQSoi1PhQk/8S8O7vDFsFHAkEAxSKHX3wu6EyExpFg y1MSDyaro9Tm+/Coy72znEsO9IkikE3YsoQeS/ohqMVn1U9o4pp0zktEVh2m5XOn GcuyhQJBALpG1VSv9ZnWW/05WD38nX4icdIcGUnJOd36g8+HPN0/wMuY5EpQACU5 kocBO9M/BKsInp+sjkw6Hs2YyJu5n6sCQQCDbFo/qB9FiFiEYOsyN2Ffbx0X40Sn 9cXdKSJoMgn4W2xgM+XMWBQypsEbLkU435tBvE3e3Ng5aRnuTRoRMncDAkB8Lzjj H/kROZKo0OV+qGj+waE2vWYxMNE+pwKKWiiTf9XdEJgxiqrDe7cEq303f1hyBb8V HbQy0WneZdsSe7/HAkEAj7yu1YIx+78xRa2zI494/QCzTcocC3S1tm1VjI6yLChE 6XRE80rGrU5xtiaqYnABdS1uPQAyyRzcDh1swvnDwQ== -----END RSA PRIVATE KEY----- <RSAPrivateKey> <version>0</version> <modulus>100729717618318585848486 ... 070347486493510338730901- 817890230060500171831435 ... 947861190265885563641189- 612871869577433527035045 ... 102393395848393488456151</modulus> <publicExponent>3</publicExponent> <privateExponent>167882862697197643080811 ... 203586267839124774891838- 978848363631503834341669 ... 3621646783354544762317395- 123358365246652607958565 ... 784368917835086686503239</privateExponent> <prime1>103247913368407610232689 ... 170858989455376441749390- 58859505943349295342502743592645253</prime1> <primes>975610202008600046064537 ... 272137236445431323153153- 9829343947046884546335129776791467</primes> <exponent1>688319422456050734884593 ... 361139059929702509611662- 6039239670628899530228335162395096835</exponent1> <exponent2>650406801339066697376358 ... 890181424824296954215435- 4359886229298031256364223419851194311</exponent2> <coefficient>7528119772196662607878768 ... 656935021038455079267606- 303026918447360800362338060867429057473</coefficient> </RSAPrivateKey>

See also

Stringlist methods:

String methods:

System methods:

Socket methods: