AppendGeneratedPrivateKey (Stringlist subroutine)

From m204wiki
Revision as of 18:54, 14 March 2016 by JAL (talk | contribs) (→‎See also: add links)
Jump to navigation Jump to search

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 2048. The default is 512.
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: