PublicKey C Library Reference

PublicKey

* This is a freeware class/C library/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.

Create/Dispose

HCkPublicKey CkPublicKey_Create(void);

Creates an instance of the CkPublicKey object and returns a handle (i.e. a "void *" pointer). The handle is passed in the 1st argument for the functions listed on this page.

void CkPublicKey_Dispose(HCkPublicKey handle);

Objects created by calling CkPublicKey_Create must be freed by calling this method. A memory leak occurs if a handle is not disposed by calling this function.

C "Properties"

void CkPublicKey_getLastErrorHtml(HCkPublicKey handle, HCkString retval);

Error information in HTML format for the last method called.

void CkPublicKey_getLastErrorText(HCkPublicKey handle, HCkString retval);

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

void CkPublicKey_getLastErrorXml(HCkPublicKey handle, HCkString retval);

Error information in XML format for the last method called.

BOOL CkPublicKey_getUtf8(HCkPublicKey handle);
void CkPublicKey_putUtf8(HCkPublicKey handle, BOOL newVal);

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.

C "Methods"

BOOL CkPublicKey_GetOpenSslDer(HCkPublicKey handle, HCkByteData data);

Gets the public key in OpenSSL DER format.

BOOL CkPublicKey_GetOpenSslPem(HCkPublicKey handle, HCkString str);

Gets the public key in OpenSSL PEM format.

BOOL CkPublicKey_GetRsaDer(HCkPublicKey handle, HCkByteData data);

Gets the public key in RSA DER format.

BOOL CkPublicKey_GetXml(HCkPublicKey handle, HCkString str);

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>

BOOL CkPublicKey_LoadOpenSslDer(HCkPublicKey handle, HCkByteData data);

Loads a public key from in-memory OpenSSL DER formatted byte data.

Returns TRUE for success, FALSE for failure.

BOOL CkPublicKey_LoadOpenSslDerFile(HCkPublicKey handle, const char *filename);

Loads a public key from an OpenSSL DER format file.

Returns TRUE for success, FALSE for failure.

BOOL CkPublicKey_LoadOpenSslPem(HCkPublicKey handle, const char *str);

Loads a public key from an OpenSSL PEM string.

Returns TRUE for success, FALSE for failure.

BOOL CkPublicKey_LoadOpenSslPemFile(HCkPublicKey handle, const char *filename);

Loads a public key from an OpenSSL PEM file.

Returns TRUE for success, FALSE for failure.

BOOL CkPublicKey_LoadRsaDer(HCkPublicKey handle, HCkByteData data);

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

Returns TRUE for success, FALSE for failure.

BOOL CkPublicKey_LoadRsaDerFile(HCkPublicKey handle, const char *filename);

Loads a public key from an RSA DER formatted file.

Returns TRUE for success, FALSE for failure.

BOOL CkPublicKey_LoadXml(HCkPublicKey handle, const char *xml);

Loads a public key from an XML string.

Returns TRUE for success, FALSE for failure.

BOOL CkPublicKey_LoadXmlFile(HCkPublicKey handle, const char *filename);

Loads a public key from an XML file.

Returns TRUE for success, FALSE for failure.

BOOL CkPublicKey_SaveLastError(HCkPublicKey handle, const char *filename);

Saves the last error information to an XML formatted file.

BOOL CkPublicKey_SaveOpenSslDerFile(HCkPublicKey handle, const char *filename);

Saves the public key to an OpenSSL DER format file.

Returns TRUE for success, FALSE for failure.

BOOL CkPublicKey_SaveOpenSslPemFile(HCkPublicKey handle, const char *filename);

Saves the public key to an OpenSSL PEM format file.

Returns TRUE for success, FALSE for failure.

BOOL CkPublicKey_SaveRsaDerFile(HCkPublicKey handle, const char *filename);

Saves the public key to an RSA DER format file.

Returns TRUE for success, FALSE for failure.

BOOL CkPublicKey_SaveXmlFile(HCkPublicKey handle, const char *filename);

Saves the public key to an XML file.

Returns TRUE for success, FALSE for failure.

const char *CkPublicKey_getOpenSslPem(HCkPublicKey handle);

Gets the public key in OpenSSL PEM format.

const char *CkPublicKey_getXml(HCkPublicKey handle);

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>

const char *CkPublicKey_lastErrorHtml(HCkPublicKey handle);

Error information in HTML format for the last method called.

const char *CkPublicKey_lastErrorText(HCkPublicKey handle);

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

const char *CkPublicKey_lastErrorXml(HCkPublicKey handle);

Error information in XML format for the last method called.