Chilkat C# 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
public string LastErrorHtml {get; }
Error information in HTML format for the last method called.
public string LastErrorText {get; }
Error information in plain-text format for the last method called.
public string LastErrorXml {get; }
Error information in XML format for the last method called.
Methods
public byte[] GetPkcs8();
Gets the private key in PKCS8 format. Returns a byte array. Returns null on failure
public string GetPkcs8Pem();
Gets the private key in PKCS8 PEM format. Returns a null on failure
public byte[] GetRsaDer();
Gets the private key in RSA DER format. Returns a byte array. Returns null on failure
public string GetRsaPem();
Gets the private key in RSA PEM format. Returns a null on failure
public 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
public bool LoadPem(string str);
Loads the private key from an in-memory PEM string. Returns true for success, false for failure.
public bool LoadPemFile(string filename);
Loads a private key from a PEM file. Returns true for success, false for failure.
public bool LoadPkcs8(byte[] data);
Loads a private key from in-memory PKCS8 byte data. Returns true for success, false for failure.
public bool LoadPkcs8File(string filename);
Loads a private key from a PKCS8 file. Returns true for success, false for failure.
public bool LoadPvk(byte[] data, string password);
Loads a private key from in-memory PVK byte data. Returns true for success, false for failure.
public bool LoadPvkFile(string filename, string password);
Loads a private key from a PVK format file. Returns true for success, false for failure.
public bool LoadRsaDer(byte[] data);
Loads a private key from in-memory RSA DER byte data. Returns true for success, false for failure.
public bool LoadRsaDerFile(string filename);
Loads a private key from an RSA DER format file. Returns true for success, false for failure.
public bool LoadXml(string xml);
Loads a private key from an in-memory XML string. Returns true for success, false for failure.
public bool LoadXmlFile(string filename);
Loads a private key from an XML file. Returns true for success, false for failure.
public bool SaveLastError(string filename);
Saves the last error information to an XML formatted file.
public bool SavePkcs8File(string filename);
Saves the private key to a PKCS8 format file. Returns true for success, false for failure.
public bool SavePkcs8PemFile(string filename);
Saves the private key to a PKCS8 PEM format file. Returns true for success, false for failure.
public bool SaveRsaDerFile(string filename);
Saves the private key to a RSA DER format file. Returns true for success, false for failure.
public bool SaveRsaPemFile(string filename);
Saves the private key to a RSA PEM format file. Returns true for success, false for failure.
public bool SaveXmlFile(string filename);
Saves the private key to an XML file. Returns true for success, false for failure.
|