TPublicKey Delphi Reference
TPublicKey
* This is a freeware class/component/library.
Represents an RSA public key. Provides methods for importing and exporting to/from OpenSSL DER and PEM formats, RSA DER format, and XML format. Public keys can be imported/exported to both memory and files.
Object Creation
var
obj: IPublicKey;
...
begin
obj := TpublicKey.Create(Self).ControlInterface;
Properties
property LastErrorHtml: WideString readonly
Error information in HTML format for the last method called.
property LastErrorText: WideString readonly
Error information in plain-text format for the last method called.
property LastErrorXml: WideString readonly
Error information in XML format for the last method called.
Methods
function GetOpenSslDer(): OleVariant;
Gets the public key in OpenSSL DER format. Returns a zero-length byte array (as an OleVariant) on failure. An empty array will have a VarArrayHighBound of -1 meaning 0 elements.
function GetOpenSslPem(): WideString;
Gets the public key in OpenSSL PEM format. Returns a zero-length WideString on failure
function GetRsaDer(): OleVariant;
Gets the public key in RSA DER format. Returns a zero-length byte array (as an OleVariant) on failure. An empty array will have a VarArrayHighBound of -1 meaning 0 elements.
function GetXml(): WideString;
Gets the public key in XML format. The XML has this format where the key parts are base64 encoded:
<RSAKeyValue>
<Modulus>...</Modulus>
<Exponent>...</Exponent>
</RSAKeyValue>
Returns a zero-length WideString on failure
function LoadOpenSslDer(derData: OleVariant): Integer;
Loads a public key from in-memory OpenSSL DER formatted byte data. Returns 1 for success, 0 for failure.
function LoadOpenSslDerFile(filename: WideString): Integer;
Loads a public key from an OpenSSL DER format file. Returns 1 for success, 0 for failure.
function LoadOpenSslPem(pemStr: WideString): Integer;
Loads a public key from an OpenSSL PEM string. Returns 1 for success, 0 for failure.
function LoadOpenSslPemFile(filename: WideString): Integer;
Loads a public key from an OpenSSL PEM file. Returns 1 for success, 0 for failure.
function LoadPkcs1Pem(str: WideString): Integer;
To be documented soon...
function LoadRsaDer(derData: OleVariant): Integer;
Loads a public key from in-memory RSA DER formatted byte data. Returns 1 for success, 0 for failure.
function LoadRsaDerFile(filename: WideString): Integer;
Loads a public key from an RSA DER formatted file. Returns 1 for success, 0 for failure.
function LoadXml(xml: WideString): Integer;
Loads a public key from an XML string. Returns 1 for success, 0 for failure.
function LoadXmlFile(filename: WideString): Integer;
Loads a public key from an XML file. Returns 1 for success, 0 for failure.
function SaveLastError(filename: WideString): Integer;
Saves the last error information to an XML formatted file.
function SaveOpenSslDerFile(filename: WideString): Integer;
Saves the public key to an OpenSSL DER format file. Returns 1 for success, 0 for failure.
function SaveOpenSslPemFile(filename: WideString): Integer;
Saves the public key to an OpenSSL PEM format file. Returns 1 for success, 0 for failure.
function SaveRsaDerFile(filename: WideString): Integer;
Saves the public key to an RSA DER format file. Returns 1 for success, 0 for failure.
function SaveXmlFile(filename: WideString): Integer;
Saves the public key to an XML file. Returns 1 for success, 0 for failure.
|