Chilkat VB.NET PrivateKey Class Reference

PrivateKey

* This is a freeware class/component/library.

Represents an RSA private key. Provides methods for importing and exporting to/from PEM, DER, PKCS8, PVK, and XML formats. Private keys can be imported/exported to both memory and files.

Properties

LastErrorHtml As String (ReadOnly)

Error information in HTML format for the last method called.

LastErrorText As String (ReadOnly)

Error information in plain-text format for the last method called.

LastErrorXml As String (ReadOnly)

Error information in XML format for the last method called.

Methods

Function GetPkcs8() As Byte()

Gets the private key in PKCS8 format.

Returns a byte array.

Returns Nothing on failure

Function GetPkcs8Pem() As String

Gets the private key in PKCS8 PEM format.

Returns Nothing on failure

Function GetRsaDer() As Byte()

Gets the private key in RSA DER format.

Returns a byte array.

Returns Nothing on failure

Function GetRsaPem() As String

Gets the private key in RSA PEM format.

Returns Nothing on failure

Function GetXml() As String

Returns the private key in XML format. The private key is returned unencrypted and the parts are base64 encoded. The XML has this structure:

<RSAKeyValue>
  <Modulus>...</Modulus>
  <Exponent>...</Exponent>
  <P>...</P>
  <Q>...</Q>
  <DP>...</DP>
  <DQ>...</DQ>
  <InverseQ>...</InverseQ>
  <D>...</D>
</RSAKeyValue>

Returns Nothing on failure

Function LoadPem(ByVal str As String) As Boolean

Loads the private key from an in-memory PEM string.

Returns true for success, false for failure.

Function LoadPemFile(ByVal filename As String) As Boolean

Loads a private key from a PEM file.

Returns true for success, false for failure.

Function LoadPkcs8(ByVal data As Byte()) As Boolean

Loads a private key from in-memory PKCS8 byte data.

Returns true for success, false for failure.

Function LoadPkcs8File(ByVal filename As String) As Boolean

Loads a private key from a PKCS8 file.

Returns true for success, false for failure.

Function LoadPvk(ByVal data As Byte(), ByVal password As String) As Boolean

Loads a private key from in-memory PVK byte data.

Returns true for success, false for failure.

Function LoadPvkFile(ByVal filename As String, ByVal password As String) As Boolean

Loads a private key from a PVK format file.

Returns true for success, false for failure.

Function LoadRsaDer(ByVal data As Byte()) As Boolean

Loads a private key from in-memory RSA DER byte data.

Returns true for success, false for failure.

Function LoadRsaDerFile(ByVal filename As String) As Boolean

Loads a private key from an RSA DER format file.

Returns true for success, false for failure.

Function LoadXml(ByVal xml As String) As Boolean

Loads a private key from an in-memory XML string.

Returns true for success, false for failure.

Function LoadXmlFile(ByVal filename As String) As Boolean

Loads a private key from an XML file.

Returns true for success, false for failure.

Function SaveLastError(ByVal filename As String) As Boolean

Saves the last error information to an XML formatted file.

Function SavePkcs8File(ByVal filename As String) As Boolean

Saves the private key to a PKCS8 format file.

Returns true for success, false for failure.

Function SavePkcs8PemFile(ByVal filename As String) As Boolean

Saves the private key to a PKCS8 PEM format file.

Returns true for success, false for failure.

Function SaveRsaDerFile(ByVal filename As String) As Boolean

Saves the private key to a RSA DER format file.

Returns true for success, false for failure.

Function SaveRsaPemFile(ByVal filename As String) As Boolean

Saves the private key to a RSA PEM format file.

Returns true for success, false for failure.

Function SaveXmlFile(ByVal filename As String) As Boolean

Saves the private key to an XML file.

Returns true for success, false for failure.