AppendPrivateKeyInfo (Stringlist function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (→‎See also: add method to list)
 
(25 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{Template:Stringlist:AppendPrivateKeyInfo subtitle}}
{{Template:Stringlist:AppendPrivateKeyInfo subtitle}}
This [[Notation conventions for methods#Callable functions|callable]] method adds lines from the information section of an SSL private key to the end of a <var>Stringlist</var>.
This [[Notation conventions for methods#Callable functions|callable]] method adds lines from the information section of an SSL private key to the end of a <var>Stringlist</var>.


Line 7: Line 6:


===Syntax terms===
===Syntax terms===
<table class="syntaxTable">
<table>
<tr><th>%number</th><td>An, optional, numeric variable that is set to zero if the function is a success. The possible return codes are described below in [[#Return codes|"Return codes"]]. </td></tr>
<tr><th>%number</th><td>An, optional, numeric variable that is set to zero if the function is a success. The possible return codes are described below in [[#Return codes|Return codes]]. </td></tr>
 
<tr><th>sl</th>
<tr><th>sl</th>
<td>A <var>Stringlist</var> object to receive the private key information.</td></tr>
<td>A <var>Stringlist</var> object to receive the private key information.</td></tr>
<tr><th>sl</th>
<tr><th>sl</th>
<td>A <var>Stringlist</var> object that contains the base-64 encoded text of an RSA private key.</td></tr>
<td>A <var>Stringlist</var> object that contains the base64 encoded text of an RSA private key.</td></tr>
 
<tr><th><var>Password</var></th>
<tr><th><var>Password</var></th>
<td>This optional, [[Notation conventions for methods#Named parameters|name allowed]], parameter is a string that contains a password to decrypt the private key, if necessary.</td></tr>
<td>This optional, [[Notation conventions for methods#Named parameters|name allowed]], parameter is a string that contains a password to decrypt the private key, if necessary.</td></tr>
Line 18: Line 20:


===Return codes===
===Return codes===
<table>
<table class="thJustBold">
<tr><th>0</th><td>All is well.</td></tr>
<tr><th>0</th>
<tr><th>-1</th><td>Encrypted but no password specified.</td></tr>
<td>All is well.</td></tr>
<tr><th>-2</th><td>Encrypted and wrong password specified.</td></tr>
 
<tr><th>-3</th><td>Out of CCATEMP.</td></tr>
<tr><th>1</th>
<tr><th>-5</th><td><var>Stringlist</var> identifier missing.</td></tr>
<td>Encrypted but no password specified.</td></tr>
<tr><th>-6</th><td>Invalid <var>Stringlist</var> identifier.</td></tr>
 
<tr><th>-7</th><td>Insufficient storage.</td></tr>
<tr><th>2</th>
<tr><th>-10</th><td>Input <var>Stringlist</var> identifier missing.</td></tr>
<td>Encrypted and wrong password specified.</td></tr>
<tr><th>-11</th><td>Invalid input <var>Stringlist</var> identifier.</td></tr>
 
<tr><th>-12</th><td>Invalid input <var>Stringlist</var> data (not correctly base-64 encoded).</td></tr>
<tr><th>3</th>
<tr><th>-13</th><td>Invalid request/certificate (internal structure of certificate is not valid).</td></tr>
<td>Out of CCATEMP.</td></tr>
 
<tr><th>5</th>
<td><var>Stringlist</var> identifier missing.</td></tr>
 
<tr><th>6</th>
<td>Invalid <var>Stringlist</var> identifier.</td></tr>
 
<tr><th>7</th>
<td>Insufficient storage.</td></tr>
 
<tr><th>10</th>
<td>Input <var>Stringlist</var> identifier missing.</td></tr>
 
<tr><th>11</th>
<td>Invalid input <var>Stringlist</var> identifier.</td></tr>
 
<tr><th>12</th>
<td>Invalid input <var>Stringlist</var> data (not correctly base-64 encoded).</td></tr>
 
<tr><th>13</th>
<td>Invalid request/certificate (internal structure of certificate is not valid).</td></tr>
</table>
</table>


Line 37: Line 60:
information in an arbitrary order. Each list item  
information in an arbitrary order. Each list item  
is in ID=value format. These are the possible IDs:
is in ID=value format. These are the possible IDs:
<table>
<table class="thJustBold">
<tr><th>S.C</th><td>Subject country</td></tr>  
<tr><th>S.C</th>
<tr><th>S.S<td>Subject state or province </td></tr>  
<td>Subject country</td></tr>  
<tr><th>S.L<td>Subject locality - city, town, village, etc. </td></tr>  
 
<tr><th>S.O<td>Subject organization  </td></tr>   
<tr><th>S.S</th>
<tr><th>S.OU<td>Subject organization unit  </td></tr>   
<td>Subject state or province </td></tr>
<tr><th>S.CN<td>Subject common name  </td></tr>  
 
<tr><th>I.C<td>Issuer country </td></tr>  
<tr><th>S.L</th>
<tr><th>I.S<td>Issuer state or province  </td></tr>  
<td>Subject locality - city, town, village, etc. </td></tr>  
<tr><th>I.L<td>Issuer locality - city, town, village, etc. </td></tr>  
 
<tr><th>I.O<td>Issuer organization  </td></tr>  
<tr><th>S.O</th>
<tr><th>I.OU<td>Issuer organization unit  </td></tr>  
<td>Subject organization  </td></tr>   
<tr><th>I.CN<td>Issuer common name  </td></tr>  
 
<tr><th>EFF<td>Effective date in YYMMDDHHMISS format (GMT)  </td></tr>  
<tr><th>S.OU</th>
<tr><th>EXP<td>Expiration date in YYMMDDHHMISS format (GMT) </td></tr>  
<td>Subject organization unit  </td></tr>   
<tr><th>ALG<td>Key algorithm - currently always RSA </td></tr>   
 
<tr><th>N<td>Public modulus in hexadecimal  </td></tr>  
<tr><th>S.CN</th>
<tr><th>E<td>Public exponent in hexadecimal </td></tr>  
<td>Subject common name  </td></tr>  
 
<tr><th>I.C</th>
<td>Issuer country </td></tr>
<tr><th>I.S</th>
<td>Issuer state or province  </td></tr>  
 
<tr><th>I.L</th>
<td>Issuer locality: city, town, village, etc. </td></tr>  
 
<tr><th>I.O</th>
<td>Issuer organization  </td></tr>  
 
<tr><th>I.OU</th>
<td>Issuer organization unit  </td></tr>  
 
<tr><th>I.CN</th>
<td>Issuer common name  </td></tr>  
 
<tr><th>EFF</th>
<td>Effective date in YYMMDDHHMISS format (GMT)  </td></tr>  
 
<tr><th>EXP</th>
<td>Expiration date in YYMMDDHHMISS format (GMT) </td></tr>  
 
<tr><th>ALG</th>
<td>Key algorithm - currently always RSA </td></tr>   
 
<tr><th>N</th>
<td>Public modulus in hexadecimal  </td></tr>  
 
<tr><th>E</th>
<td>Public exponent in hexadecimal </td></tr>  
</table>
</table>
</li>
</ul>


==Examples==
==Examples==
In the following example, a private key is hard-coded into one <var>Stringlist</var>, then the information contained in the private key is extracted via <var>AppendCertificateInfo</var> into another <var>Stringlist</var>:
In the following example, a private key is hard-coded into one <var>Stringlist</var>, then the information contained in the private key is extracted via <var>AppendPrivateKeyInfo</var> into another <var>Stringlist</var>:
<p class="code">b
<p class="code">b


Line 89: Line 147:
</p>
</p>
The result is something like:
The result is something like:
<p class="output">
<p class="output">ALG=RSA  
ALG=RSA  
N=9BA4F09925EDE3E972AE1C32F5206AD8 ... A461AEFECF9D126339A8C4A23C3DF08B-
N=9BA4F09925EDE3E972AE1C32F5206AD8 ... A461AEFECF9D126339A8C4A23C3DF08B-
CB148E3DE556F42121452CA22089728D08 ... 4D1B3B356710E11ADC77A0C49D292B1F-
CB148E3DE556F42121452CA22089728D08 ... 4D1B3B356710E11ADC77A0C49D292B1F-
Line 99: Line 156:


==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>
<ul>
<li><var>[[AppendCertificateInfo (Stringlist function)|AppendCertificateInfo]]</var>
<li><var>[[ClientCertificate (System function)|ClientCertificate]]</var> </li><li><var>[[GeneratedPrivateKey (System function)|GeneratedPrivateKey]]</var> </li>
<li><var>[[AppendCertificateRequestInfo (Stringlist function)|AppendCertificateRequestInfo]]</var>
<li><var>[[AppendSignedCertificate (Stringlist function)|AppendSignedCertificate]]</var>
</ul>
</ul>
<p>
<var>Socket</var> methods: </p>
<ul>
<li><var>[[Certificate (Socket function)|Certificate]]</var> </li>
</ul>
{{Template:Stringlist:AppendPrivateKeyInfo footer}}
{{Template:Stringlist:AppendPrivateKeyInfo footer}}

Latest revision as of 15:14, 6 September 2018

Add RSA private key information to a Stringlist (Stringlist class)

[Requires Janus Network Security]

This callable method adds lines from the information section of an SSL private key to the end of a Stringlist.

Syntax

[%number =] sl:AppendPrivateKeyInfo[( [sl], [[Password=] string])]

Syntax terms

%numberAn, optional, numeric variable that is set to zero if the function is a success. The possible return codes are described below in Return codes.
sl A Stringlist object to receive the private key information.
sl A Stringlist object that contains the base64 encoded text of an RSA private key.
Password This optional, name allowed, parameter is a string that contains a password to decrypt the private key, if necessary.

Return codes

0 All is well.
1 Encrypted but no password specified.
2 Encrypted and wrong password specified.
3 Out of CCATEMP.
5 Stringlist identifier missing.
6 Invalid Stringlist identifier.
7 Insufficient storage.
10 Input Stringlist identifier missing.
11 Invalid input Stringlist identifier.
12 Invalid input Stringlist data (not correctly base-64 encoded).
13 Invalid request/certificate (internal structure of certificate is not valid).

Usage notes

  • The updated Stringlist contains an arbitrary amount of information in an arbitrary order. Each list item is in ID=value format. These are the possible IDs:
    S.C Subject country
    S.S Subject state or province
    S.L Subject locality - city, town, village, etc.
    S.O Subject organization
    S.OU Subject organization unit
    S.CN Subject common name
    I.C Issuer country
    I.S Issuer state or province
    I.L Issuer locality: city, town, village, etc.
    I.O Issuer organization
    I.OU Issuer organization unit
    I.CN Issuer common name
    EFF Effective date in YYMMDDHHMISS format (GMT)
    EXP Expiration date in YYMMDDHHMISS format (GMT)
    ALG Key algorithm - currently always RSA
    N Public modulus in hexadecimal
    E Public exponent in hexadecimal

Examples

In the following example, a private key is hard-coded into one Stringlist, then the information contained in the private key is extracted via AppendPrivateKeyInfo into another Stringlist:

b %sl is object stringlist %pkey is object stringlist %sl = new %pkey = new text to %pkey 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 %sl:appendPrivateKeyInfo(%pkey) %sl:print end

The result is something like:

ALG=RSA N=9BA4F09925EDE3E972AE1C32F5206AD8 ... A461AEFECF9D126339A8C4A23C3DF08B- CB148E3DE556F42121452CA22089728D08 ... 4D1B3B356710E11ADC77A0C49D292B1F- 16EF4F4E19D0CC284A88C0F8D472042329 ... 2507991BA55D64238448F0A853D11B87- FC0646091ABF25376EB6338B62E19D7529 ... E38E9B4EF2A554FB3248C0CADB E=03

See also

Stringlist methods:

String methods:

System methods:

Socket methods: