CkPrivateKey Ruby Programming
Reference Documentation

CkPrivateKey

* 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

# str is a CkString object (output)
LastErrorHtml( str )

Error information in HTML format for the last method called.

# str is a CkString object (output)
LastErrorText( str )

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

# str is a CkString object (output)
LastErrorXml( str )

Error information in XML format for the last method called.

# Returns a boolean value
get_Utf8( )

# b is a boolean (input)
put_Utf8( b )

When set to true, all "const char *" arguments are expected to be utf-8 strings. If set to false, the "const char *" arguments are expected to be ANSI strings.

Methods

# data is a CkByteData object (output)
# Returns a boolean value
GetPkcs8( data )

Gets the private key in PKCS8 format.

# str is a CkString object (output)
# Returns a boolean value
GetPkcs8Pem( str )

Gets the private key in PKCS8 PEM format.

Returns true for success, false for failure.

# data is a CkByteData object (output)
# Returns a boolean value
GetRsaDer( data )

Gets the private key in RSA DER format.

# str is a CkString object (output)
# Returns a boolean value
GetRsaPem( str )

Gets the private key in RSA PEM format.

Returns true for success, false for failure.

# str is a CkString object (output)
# Returns a boolean value
GetXml( str )

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 true for success, false for failure.

# str is a string (input)
# Returns a boolean value
LoadPem( str )

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

Returns true for success, false for failure.

# filename is a string (input)
# Returns a boolean value
LoadPemFile( filename )

Loads a private key from a PEM file.

Returns true for success, false for failure.

# data is a CkByteData object (output)
# Returns a boolean value
LoadPkcs8( data )

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

Returns true for success, false for failure.

# filename is a string (input)
# Returns a boolean value
LoadPkcs8File( filename )

Loads a private key from a PKCS8 file.

Returns true for success, false for failure.

# data is a CkByteData object (output)
# password is a string (input)
# Returns a boolean value
LoadPvk( data, password )

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

Returns true for success, false for failure.

# filename is a string (input)
# password is a string (input)
# Returns a boolean value
LoadPvkFile( filename, password )

Loads a private key from a PVK format file.

Returns true for success, false for failure.

# data is a CkByteData object (output)
# Returns a boolean value
LoadRsaDer( data )

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

Returns true for success, false for failure.

# filename is a string (input)
# Returns a boolean value
LoadRsaDerFile( filename )

Loads a private key from an RSA DER format file.

Returns true for success, false for failure.

# xml is a string (input)
# Returns a boolean value
LoadXml( xml )

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

Returns true for success, false for failure.

# filename is a string (input)
# Returns a boolean value
LoadXmlFile( filename )

Loads a private key from an XML file.

Returns true for success, false for failure.

# filename is a string (input)
# Returns a boolean value
SaveLastError( filename )

Saves the last error information to an XML formatted file.

# filename is a string (input)
# Returns a boolean value
SavePkcs8File( filename )

Saves the private key to a PKCS8 format file.

Returns true for success, false for failure.

# filename is a string (input)
# Returns a boolean value
SavePkcs8PemFile( filename )

Saves the private key to a PKCS8 PEM format file.

Returns true for success, false for failure.

# filename is a string (input)
# Returns a boolean value
SaveRsaDerFile( filename )

Saves the private key to a RSA DER format file.

Returns true for success, false for failure.

# filename is a string (input)
# Returns a boolean value
SaveRsaPemFile( filename )

Saves the private key to a RSA PEM format file.

Returns true for success, false for failure.

# filename is a string (input)
# Returns a boolean value
SaveXmlFile( filename )

Saves the private key to an XML file.

Returns true for success, false for failure.

# Returns a string
getPkcs8Pem( )

Gets the private key in PKCS8 PEM format.

# Returns a string
getRsaPem( )

Gets the private key in RSA PEM format.

# Returns a string
getXml( )

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 a string
lastErrorHtml( )

Error information in HTML format for the last method called.

# Returns a string
lastErrorText( )

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

# Returns a string
lastErrorXml( )

Error information in XML format for the last method called.