Chilkat.PrivateKey PHP Reference

Chilkat.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.

Object Creation

$obj = new COM("Chilkat.PrivateKey");

Properties

string LastErrorHtml (read-only)

Error information in HTML format for the last method called.

string LastErrorText (read-only)

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

string LastErrorXml (read-only)

Error information in XML format for the last method called.

Methods

VARIANT GetPkcs8()

Gets the private key in PKCS8 format.

Returns 1 for success, 0 for failure.

VARIANT GetPkcs8Encrypted(string password)

Writes the private key to password-protected PKCS8 format.

Returns 1 for success, 0 for failure.

string GetPkcs8EncryptedPem(string password)

Writes the private key to password-protected PKCS8 PEM format.

Returns a null on failure

string GetPkcs8Pem()

Gets the private key in PKCS8 PEM format.

Returns a null on failure

VARIANT GetRsaDer()

Gets the private key in RSA DER format.

Returns 1 for success, 0 for failure.

string GetRsaPem()

Gets the private key in RSA PEM format.

Returns a null on failure

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 null on failure

int LoadEncryptedPem(string pemStr, string password)

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

Returns 1 for success, 0 for failure.

bool LoadEncryptedPemFile(string filename, string password)

Loads a private key from an encrypted PEM file.

Returns 1 for success, 0 for failure.

bool LoadPem(string str)

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

Returns 1 for success, 0 for failure.

bool LoadPemFile(string filename)

Loads a private key from a PEM file.

Returns 1 for success, 0 for failure.

bool LoadPkcs8(VARIANT pkcs8Data)

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

Returns 1 for success, 0 for failure.

bool LoadPkcs8Encrypted(VARIANT data, string password)

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

Returns 1 for success, 0 for failure.

bool LoadPkcs8EncryptedFile(string filename, string password)

Loads a private key from a password-protected PKCS8 file.

Returns 1 for success, 0 for failure.

bool LoadPkcs8File(string filename)

Loads a private key from a PKCS8 file.

Returns 1 for success, 0 for failure.

bool LoadPvk(VARIANT pvkData, string password)

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

Returns 1 for success, 0 for failure.

bool LoadPvkFile(string filename, string password)

Loads a private key from a PVK format file.

Returns 1 for success, 0 for failure.

bool LoadRsaDer(VARIANT derData)

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

Returns 1 for success, 0 for failure.

bool LoadRsaDerFile(string filename)

Loads a private key from an RSA DER format file.

Returns 1 for success, 0 for failure.

bool LoadXml(string xmlDoc)

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

Returns 1 for success, 0 for failure.

bool LoadXmlFile(string filename)

Loads a private key from an XML file.

Returns 1 for success, 0 for failure.

bool SaveLastError(string filename)

Saves the last error information to an XML formatted file.

bool SavePkcs8EncryptedFile(string password, string filename)

Saves the private key to a password-protected PKCS8 format file.

Returns 1 for success, 0 for failure.

bool SavePkcs8EncryptedPemFile(string password, string filename)

Saves the private key to a password-protected PKCS8 PEM format file.

Returns 1 for success, 0 for failure.

bool SavePkcs8File(string filename)

Saves the private key to a PKCS8 format file.

Returns 1 for success, 0 for failure.

bool SavePkcs8PemFile(string filename)

Saves the private key to a PKCS8 PEM format file.

Returns 1 for success, 0 for failure.

bool SaveRsaDerFile(string filename)

Saves the private key to a RSA DER format file.

Returns 1 for success, 0 for failure.

bool SaveRsaPemFile(string filename)

Saves the private key to a RSA PEM format file.

Returns 1 for success, 0 for failure.

bool SaveXmlFile(string filename)

Saves the private key to an XML file.

Returns 1 for success, 0 for failure.