KeyMgr Class

Properties   Methods   Events   Config Settings   Errors  

The KeyMgr class is used to create and manage OpenPGP keys.

Syntax

KeyMgr

Remarks

The KeyMgr class supports key management according to the specifications outlined in RFC 4880, in addition to draft-ietf-openpgp-crypto-refresh-13, which introduces support for OpenPGP Version 6. You can create, delete, import, export, and manage keys, including both individual keys and keyrings.

Property List


The following is the full list of the properties of the class with short descriptions. Click on the links for further details.

KeyThe currently selected key.
KeyringThe location on disk of the keyring.

Method List


The following is the full list of the methods of the class with short descriptions. Click on the links for further details.

AddRevokerAdds a designated revoker to the key.
AddUserIdAdds the specified user Id to the current key.
ChangeExpirationDateChanges the expiration date of the key.
ChangePassphraseChanges the passphrase of the current key.
ConfigSets or retrieves a configuration setting.
CreateKeyCreates an OpenPGP key pair.
CreateSubKeyCreates a new subkey.
DeleteKeyDeletes the specified key.
ExportPublicKeyExports the public key of the current key.
ExportSecretKeyExports the private key of the current key.
ImportKeyImports the key specified by UserId to the current keyring.
ImportKeyBImports the key specified by UserId to the current keyring.
ListKeysLists keys in the specified Keyring .
ListSignaturesLists all signatures of the current key.
ListSubkeysLists the subkeys of the currently selected key.
LoadKeyringLoads the keyring from disk.
LoadKeyringBLoads the keyring from SecretKeyringData and PublicKeyringData .
ResetResets the class properties.
RevokeKeyRevokes the specified key.
SaveKeyringSaves the current Keyring to disk.
SignUserIdSigns the specified user Id of the current key.
VerifyPassphraseVerifies the passphrase of specified key.

Event List


The following is the full list of the events fired by the class with short descriptions. Click on the links for further details.

ErrorFired when information is available about errors during data delivery.
KeyListFires for each key in the keyring when ListKeys is called.
KeyPassphraseFired if the passphrase of current key is incorrect or empty.
SignatureListFires for each signature of the current key when ListSignatures is called.
StatusShows the progress of the operation.
SubkeyListFires once for each subkey listed when ListSubkeys is called.

Config Settings


The following is a list of config settings for the class with short descriptions. Click on the links for further details.

AllowEmptyPasswordWhether a key can be created without a password.
Argon2IterationsSpecifies the number of iterations used for Argon2.
Argon2MemorySizeExpSpecifies the exponent used to calculate the memory size used when creating a key.
Argon2ParallelismSpecifies the degree of parallelism used for Argon2.
ContinueOnInvalidKeyWhether to continue loading the keyring when an invalid key is found.
CreateRSASubkeyforEncryptWhether to create a subkey when creating an RSA key.
CurrentKeyPrimaryKeyUsageFlagsThe usage flags of the currently selected primary key.
CurveThe elliptic curve used when creating a key.
EnsureValidDSASignatureHashAlgorithmWhether or not to select a suitable signature hash algorithm automatically.
ImportAllKeysWhether or not to import all keys found in a key file.
KeyBoxProtectionModeSpecifies the keybox protection mode used when saving a keyring.
KeyEncryptionAlgorithmThe encryption algorithm used when creating a key.
KeyIdLengthSpecifies the length of the key's Id.
KeyPreferredAEADAlgorithmsIndicates the preferred AEAD encryption algorithms associated with the currently selected key.
KeyPreferredCompressionAlgorithmsIndicates the preferred compression algorithms associated with the currently selected key.
KeyPreferredHashAlgorithmsIndicates the preferred hash algorithms associated with the currently selected key.
KeyPreferredSymmetricAlgorithmsIndicates the preferred symmetric algorithms associated with the currently selected key.
KeyringFormatSpecifies the keyring format to use when saving a keyring.
KeyUsageFlags that show intended use for the key being created.
KeyValidityTimeThe validity period for the key being created.
KeyVersionSpecifies the OpenPGP version for the key being created.
LogLevelSpecifies the level of detail that is logged.
PreferredAEADAlgorithmsSpecifies a key's preferred AEAD encryption algorithms when creating a key.
PreferredCompressionAlgorithmsSpecifies a key's preferred compression algorithms when creating a key.
PreferredHashAlgorithmsSpecifies a key's preferred hash algorithms when creating a key.
PreferredSymmetricAlgorithmsSpecifies a key's preferred symmetric algorithms when creating a key.
PublicKeyAlgorithmThe public key algorithm for the key being created.
PublicKeyLengthSpecifies the public key length when creating a key.
PublicKeyringFileThe file name of the public keyring file.
PublicKeySignatureHashAlgorithmThe public key signature hash algorithm used when creating a key.
RawKeyDataReturns detailed key and keyring data for debugging purposes.
RevocationCodeThe reason why the key was revoked.
RevocationReasonText describing why the key was revoked.
RevokerThe revoker's key Id.
SecretKeyringFileThe file name of the secret keyring file.
SubKeyAlgorithmThe public key algorithm for the subkey being created.
SubKeyCurveThe elliptic curve of the sub key.
SubKeyLengthSpecifies the public subkey length when creating a key or subkey.
SubKeyUsageFlags that show intended use for the subkey being created.
UseArgon2Whether to use Argon2 for key derivation when creating a key.
VersionHeaderThe Version header value in ASCII armored public keys.
BuildInfoInformation about the product's build.
CodePageThe system code page used for Unicode to Multibyte translations.
LicenseInfoInformation about the current license.
MaskSensitiveDataWhether sensitive data is masked in log messages.
ProcessIdleEventsWhether the class uses its internal event loop to process events when the main thread is idle.
SelectWaitMillisThe length of time in milliseconds the class will wait when DoEvents is called if there are no events to process.
UseFIPSCompliantAPITells the class whether or not to use FIPS certified APIs.
UseInternalSecurityAPIWhether or not to use the system security libraries or an internal implementation.

Key Property (KeyMgr Class)

The currently selected key.

Syntax

IPWorksOpenPGPKey* GetKey();
int SetKey(IPWorksOpenPGPKey* val);
char* ipworksopenpgp_keymgr_getkeycurve(void* lpObj);
char* ipworksopenpgp_keymgr_getkeyeffectivedate(void* lpObj);
int ipworksopenpgp_keymgr_getkeyencoded(void* lpObj, char** lpKeyEncoded, int* lenKeyEncoded);
int ipworksopenpgp_keymgr_setkeyencoded(void* lpObj, const char* lpKeyEncoded, int lenKeyEncoded);
char* ipworksopenpgp_keymgr_getkeyexpirationdate(void* lpObj);
char* ipworksopenpgp_keymgr_getkeyfingerprint(void* lpObj);
int ipworksopenpgp_keymgr_setkeyfingerprint(void* lpObj, const char* lpszKeyFingerprint);
char* ipworksopenpgp_keymgr_getkeyid(void* lpObj);
int ipworksopenpgp_keymgr_setkeyid(void* lpObj, const char* lpszKeyId);
char* ipworksopenpgp_keymgr_getkeyotheruserids(void* lpObj);
char* ipworksopenpgp_keymgr_getkeypassphrase(void* lpObj);
int ipworksopenpgp_keymgr_setkeypassphrase(void* lpObj, const char* lpszKeyPassphrase);
char* ipworksopenpgp_keymgr_getkeypublickey(void* lpObj);
char* ipworksopenpgp_keymgr_getkeypublickeyalgorithm(void* lpObj);
int ipworksopenpgp_keymgr_getkeypublickeylength(void* lpObj);
int ipworksopenpgp_keymgr_getkeyrevoked(void* lpObj);
char* ipworksopenpgp_keymgr_getkeysecretkey(void* lpObj);
int ipworksopenpgp_keymgr_getkeysecretkeyavailable(void* lpObj);
char* ipworksopenpgp_keymgr_getkeyusage(void* lpObj);
int ipworksopenpgp_keymgr_getkeyusageflags(void* lpObj);
char* ipworksopenpgp_keymgr_getkeyuserid(void* lpObj);
int ipworksopenpgp_keymgr_setkeyuserid(void* lpObj, const char* lpszKeyUserId);
int ipworksopenpgp_keymgr_getkeyversion(void* lpObj);
QString GetKeyCurve();

QString GetKeyEffectiveDate();

QByteArray GetKeyEncoded();
int SetKeyEncoded(QByteArray qbaKeyEncoded); QString GetKeyExpirationDate(); QString GetKeyFingerprint();
int SetKeyFingerprint(QString qsKeyFingerprint); QString GetKeyId();
int SetKeyId(QString qsKeyId); QString GetKeyOtherUserIds(); QString GetKeyPassphrase();
int SetKeyPassphrase(QString qsKeyPassphrase); QString GetKeyPublicKey(); QString GetKeyPublicKeyAlgorithm(); int GetKeyPublicKeyLength(); bool GetKeyRevoked(); QString GetKeySecretKey(); bool GetKeySecretKeyAvailable(); QString GetKeyUsage(); int GetKeyUsageFlags(); QString GetKeyUserId();
int SetKeyUserId(QString qsKeyUserId); int GetKeyVersion();

Remarks

This property holds the currently selected key. It is populated after calling ImportKey or after setting Keyring. This may also be set to directly load an existing key. Both public keys and secret keys are supported.

This property is not available at design time.

Data Type

IPWorksOpenPGPKey

Keyring Property (KeyMgr Class)

The location on disk of the keyring.

Syntax

ANSI (Cross Platform)
char* GetKeyring();

Unicode (Windows)
LPWSTR GetKeyring();
char* ipworksopenpgp_keymgr_getkeyring(void* lpObj);
QString GetKeyring();

Default Value

""

Remarks

To load a keyring use the LoadKeyring method.

This property is read-only.

Data Type

String

AddRevoker Method (KeyMgr Class)

Adds a designated revoker to the key.

Syntax

ANSI (Cross Platform)
int AddRevoker(const char* lpszUserId);

Unicode (Windows)
INT AddRevoker(LPCWSTR lpszUserId);
int ipworksopenpgp_keymgr_addrevoker(void* lpObj, const char* lpszUserId);
int AddRevoker(const QString& qsUserId);

Remarks

This method adds a designated revoker to the selected Key. The UserId parameter specifies the revoker to add. The revoker's key must be present in the current keyring. Use this with caution: once added, a revoker cannot be removed. The key's passphrase is required for this operation and may be specified via Passphrase or through the KeyPassphrase event.

The UserId format is:

FirstName LastName (Comment) <Email>
Not all values are required when selecting or generating a key, but at least FirstName or Email are required.

Note that for OpenPGP v6, a key may be created with or without a UserId, as the field is optional. If a key was created without a UserId, the key's Fingerprint can be used as it's identifier instead.

Error Handling (C++)

This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)

AddUserId Method (KeyMgr Class)

Adds the specified user Id to the current key.

Syntax

ANSI (Cross Platform)
int AddUserId(const char* lpszUserId);

Unicode (Windows)
INT AddUserId(LPCWSTR lpszUserId);
int ipworksopenpgp_keymgr_adduserid(void* lpObj, const char* lpszUserId);
int AddUserId(const QString& qsUserId);

Remarks

The key's passphrase is required for this operation and may be specified via Passphrase or through the KeyPassphrase event.

The UserId format is:

FirstName LastName (Comment) <Email>
Not all values are required when selecting or generating a key, but at least FirstName or Email are required.

Note that for OpenPGP v6, a key may be created with or without a UserId, as the field is optional. If a key was created without a UserId, the key's Fingerprint can be used as it's identifier instead.

Error Handling (C++)

This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)

ChangeExpirationDate Method (KeyMgr Class)

Changes the expiration date of the key.

Syntax

ANSI (Cross Platform)
int ChangeExpirationDate(int iExpirationDate);

Unicode (Windows)
INT ChangeExpirationDate(INT iExpirationDate);
int ipworksopenpgp_keymgr_changeexpirationdate(void* lpObj, int iExpirationDate);
int ChangeExpirationDate(int iExpirationDate);

Remarks

This method changes the expiration date of the current Key. The ExpirationDate parameter specifies the number of days for which the key is valid starting today. For instance a value of "31" means the key is valid for the next 31 days.

The special value "0" means the key will never expire.

The key's passphrase is required for this operation and may be specified via Passphrase or through the KeyPassphrase event.

Note: See KeyValidityTime for information on specifying the expiration date when creating the key with CreateKey.

Error Handling (C++)

This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)

ChangePassphrase Method (KeyMgr Class)

Changes the passphrase of the current key.

Syntax

ANSI (Cross Platform)
int ChangePassphrase(const char* lpszPassphrase);

Unicode (Windows)
INT ChangePassphrase(LPCWSTR lpszPassphrase);
int ipworksopenpgp_keymgr_changepassphrase(void* lpObj, const char* lpszPassphrase);
int ChangePassphrase(const QString& qsPassphrase);

Remarks

The Passphrase parameter specifies the new passphrase.

The key's passphrase is required for this operation and may be specified via Passphrase or through the KeyPassphrase event.

Error Handling (C++)

This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)

Config Method (KeyMgr Class)

Sets or retrieves a configuration setting.

Syntax

ANSI (Cross Platform)
char* Config(const char* lpszConfigurationString);

Unicode (Windows)
LPWSTR Config(LPCWSTR lpszConfigurationString);
char* ipworksopenpgp_keymgr_config(void* lpObj, const char* lpszConfigurationString);
QString Config(const QString& qsConfigurationString);

Remarks

Config is a generic method available in every class. It is used to set and retrieve configuration settings for the class.

These settings are similar in functionality to properties, but they are rarely used. In order to avoid "polluting" the property namespace of the class, access to these internal properties is provided through the Config method.

To set a configuration setting named PROPERTY, you must call Config("PROPERTY=VALUE"), where VALUE is the value of the setting expressed as a string. For boolean values, use the strings "True", "False", "0", "1", "Yes", or "No" (case does not matter).

To read (query) the value of a configuration setting, you must call Config("PROPERTY"). The value will be returned as a string.

Error Handling (C++)

This method returns a String value; after it returns, call the GetLastErrorCode() method to obtain its result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message.

CreateKey Method (KeyMgr Class)

Creates an OpenPGP key pair.

Syntax

ANSI (Cross Platform)
int CreateKey(const char* lpszUserId, const char* lpszPassphrase);

Unicode (Windows)
INT CreateKey(LPCWSTR lpszUserId, LPCWSTR lpszPassphrase);
int ipworksopenpgp_keymgr_createkey(void* lpObj, const char* lpszUserId, const char* lpszPassphrase);
int CreateKey(const QString& qsUserId, const QString& qsPassphrase);

Remarks

This method creates a new OpenPGP key pair. The UserId parameter specifies the user Id of the key. If KeyVersion is 6, this parameter may be an empty string.

The UserId format is:

FirstName LastName (Comment) <Email>
Not all values are required when selecting or generating a key, but at least FirstName or Email are required.

Note that for OpenPGP v6, a key may be created with or without a UserId, as the field is optional. If a key was created without a UserId, the key's Fingerprint can be used as it's identifier instead.

Additional configuration settings may be set to further configure the details of the key (and subkey) being created. Please see the following settings for details:

Error Handling (C++)

This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)

CreateSubKey Method (KeyMgr Class)

Creates a new subkey.

Syntax

ANSI (Cross Platform)
int CreateSubKey();

Unicode (Windows)
INT CreateSubKey();
int ipworksopenpgp_keymgr_createsubkey(void* lpObj);
int CreateSubKey();

Remarks

This method creates a new subkey. Before calling this method the Id property must be set to a valid private key.

The following settings may optionally be set to define specific values for the created subkey:

Error Handling (C++)

This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)

DeleteKey Method (KeyMgr Class)

Deletes the specified key.

Syntax

ANSI (Cross Platform)
int DeleteKey(const char* lpszUserId);

Unicode (Windows)
INT DeleteKey(LPCWSTR lpszUserId);
int ipworksopenpgp_keymgr_deletekey(void* lpObj, const char* lpszUserId);
int DeleteKey(const QString& qsUserId);

Remarks

This method deletes the key specified by UserId from the current keyring. Below is a table of the type of Ids that may be specified to identify the key:

Id Type Example
UserId FirstName LastName <user@mail.com>
UserId (name only) FirstName LastName
UserId (first name only) FirstName
UserId (email only) user@mail.com
Short KeyId 89C9D7B1
Long KeyId F7B7D49C89C9D7B1
Fingerprint (OpenPGP v6 only) 2A62207E927A9C125B9226FE764E796ECE849D623FFA03C845B8B2A5B6398EC8

Error Handling (C++)

This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)

ExportPublicKey Method (KeyMgr Class)

Exports the public key of the current key.

Syntax

ANSI (Cross Platform)
int ExportPublicKey(const char* lpszFileName, int buseAsciiArmor);

Unicode (Windows)
INT ExportPublicKey(LPCWSTR lpszFileName, BOOL buseAsciiArmor);
int ipworksopenpgp_keymgr_exportpublickey(void* lpObj, const char* lpszFileName, int buseAsciiArmor);
int ExportPublicKey(const QString& qsFileName, bool buseAsciiArmor);

Remarks

This method exports the public key of the currently selected Key. The FileName parameter specifies the file on disk to which the public key will be written. The UseAsciiArmor parameter determines whether or not ASCII armoring is used when writing the key to disk.

Note: When UseAsciiArmor is set to True the VersionHeader setting may also be set to specify your own header value.

Error Handling (C++)

This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)

ExportSecretKey Method (KeyMgr Class)

Exports the private key of the current key.

Syntax

ANSI (Cross Platform)
int ExportSecretKey(const char* lpszFileName, int buseAsciiArmor);

Unicode (Windows)
INT ExportSecretKey(LPCWSTR lpszFileName, BOOL buseAsciiArmor);
int ipworksopenpgp_keymgr_exportsecretkey(void* lpObj, const char* lpszFileName, int buseAsciiArmor);
int ExportSecretKey(const QString& qsFileName, bool buseAsciiArmor);

Remarks

This method exports the private key of the currently selected Key. The FileName parameter specifies the file on disk that the private key will be written to. The UseAsciiArmor parameter determines whether or not ASCII armoring is used when writing the key to disk.

Error Handling (C++)

This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)

ImportKey Method (KeyMgr Class)

Imports the key specified by UserId to the current keyring.

Syntax

ANSI (Cross Platform)
int ImportKey(const char* lpszFileName, const char* lpszUserId);

Unicode (Windows)
INT ImportKey(LPCWSTR lpszFileName, LPCWSTR lpszUserId);
int ipworksopenpgp_keymgr_importkey(void* lpObj, const char* lpszFileName, const char* lpszUserId);
int ImportKey(const QString& qsFileName, const QString& qsUserId);

Remarks

This method imports the key specified by UserId from the key file specified by FileName into the current Keyring. The imported key will be automatically selected and available in the Key property.

If the FileName specifies a key file which contains multiple keys only the key belonging to UserId will be imported.

If UserId is set to "*" or "" (empty string) all keys in the key file will be imported. The ImportAllKeys setting controls the behavior of the class in this case.

Note: If you simply wish to select a key in the current ring set UserId instead.

Error Handling (C++)

This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)

ImportKeyB Method (KeyMgr Class)

Imports the key specified by UserId to the current keyring.

Syntax

ANSI (Cross Platform)
int ImportKeyB(const char* lpData, int lenData, const char* lpszUserId);

Unicode (Windows)
INT ImportKeyB(LPCSTR lpData, INT lenData, LPCWSTR lpszUserId);
int ipworksopenpgp_keymgr_importkeyb(void* lpObj, const char* lpData, int lenData, const char* lpszUserId);
int ImportKeyB(QByteArray qbaData, const QString& qsUserId);

Remarks

This method imports the key specified by UserId from the key data specified by Data into the current Keyring. The imported key will be automatically selected and available in the Key property.

If the Data specifies key data that contains multiple keys only the key belonging to UserId will be imported.

If UserId is set to "*" or "" (empty string) all keys in the key data will be imported. The ImportAllKeys setting controls the behavior of the class in this case.

Note: If you simply wish to select a key in the current ring set UserId instead.

Error Handling (C++)

This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)

ListKeys Method (KeyMgr Class)

Lists keys in the specified Keyring .

Syntax

ANSI (Cross Platform)
char* ListKeys();

Unicode (Windows)
LPWSTR ListKeys();
char* ipworksopenpgp_keymgr_listkeys(void* lpObj);
QString ListKeys();

Remarks

This method lists the keys (public/private key pairs) in the specified keyring. The results are provided through the KeyList event.

KeyList data will also be returned from this method, however it is recommended to use the KeyList event if possible.

Error Handling (C++)

This method returns a String value; after it returns, call the GetLastErrorCode() method to obtain its result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message.

ListSignatures Method (KeyMgr Class)

Lists all signatures of the current key.

Syntax

ANSI (Cross Platform)
char* ListSignatures();

Unicode (Windows)
LPWSTR ListSignatures();
char* ipworksopenpgp_keymgr_listsignatures(void* lpObj);
QString ListSignatures();

Remarks

This method lists all the signatures of the currently selected key. The SignatureList event will fire for each signature.

SignatureList data will also be returned from this method. However, it is recommended to use the SignatureList event if possible.

Error Handling (C++)

This method returns a String value; after it returns, call the GetLastErrorCode() method to obtain its result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message.

ListSubkeys Method (KeyMgr Class)

Lists the subkeys of the currently selected key.

Syntax

ANSI (Cross Platform)
char* ListSubkeys();

Unicode (Windows)
LPWSTR ListSubkeys();
char* ipworksopenpgp_keymgr_listsubkeys(void* lpObj);
QString ListSubkeys();

Remarks

This method lists all subkeys of current key. The SubkeyList event will be fired for each subkey.

SubkeyList data will also be returned from this method, however it is recommended to use the SubkeyList event if possible.

Error Handling (C++)

This method returns a String value; after it returns, call the GetLastErrorCode() method to obtain its result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message.

LoadKeyring Method (KeyMgr Class)

Loads the keyring from disk.

Syntax

ANSI (Cross Platform)
int LoadKeyring(const char* lpszKeyringPath);

Unicode (Windows)
INT LoadKeyring(LPCWSTR lpszKeyringPath);
int ipworksopenpgp_keymgr_loadkeyring(void* lpObj, const char* lpszKeyringPath);
int LoadKeyring(const QString& qsKeyringPath);

Remarks

This method loads the keyring from disk. If the keyring is stored in a directory, set KeyringPath to the directory. The directory must contain the files "secring.gpg" and "pubring.gpg". A keyring may also be stored in a single file. If the keyring is a file KeyringPath should be set to the path of the file.

When this method is called the class will read the keyring and populate the Key property with the first key found in the keyring. Set UserId to select a different key in the current keyring.

Error Handling (C++)

This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)

LoadKeyringB Method (KeyMgr Class)

Loads the keyring from SecretKeyringData and PublicKeyringData .

Syntax

ANSI (Cross Platform)
int LoadKeyringB(const char* lpSecretKeyringData, int lenSecretKeyringData, const char* lpPublicKeyringData, int lenPublicKeyringData);

Unicode (Windows)
INT LoadKeyringB(LPCSTR lpSecretKeyringData, INT lenSecretKeyringData, LPCSTR lpPublicKeyringData, INT lenPublicKeyringData);
int ipworksopenpgp_keymgr_loadkeyringb(void* lpObj, const char* lpSecretKeyringData, int lenSecretKeyringData, const char* lpPublicKeyringData, int lenPublicKeyringData);
int LoadKeyringB(QByteArray qbaSecretKeyringData, QByteArray qbaPublicKeyringData);

Remarks

This method loads the keyring from SecretKeyringData and PublicKeyringData.

When this method is called the class will read the keyring and populate the Key property with the first key found in the keyring. Set UserId to select a different key in the current keyring.

Error Handling (C++)

This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)

Reset Method (KeyMgr Class)

Resets the class properties.

Syntax

ANSI (Cross Platform)
int Reset();

Unicode (Windows)
INT Reset();
int ipworksopenpgp_keymgr_reset(void* lpObj);
int Reset();

Remarks

This method resets all message and key properties to their default values.

Error Handling (C++)

This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)

RevokeKey Method (KeyMgr Class)

Revokes the specified key.

Syntax

ANSI (Cross Platform)
char* RevokeKey(const char* lpszKeyId);

Unicode (Windows)
LPWSTR RevokeKey(LPCWSTR lpszKeyId);
char* ipworksopenpgp_keymgr_revokekey(void* lpObj, const char* lpszKeyId);
QString RevokeKey(const QString& qsKeyId);

Remarks

This method revokes the key specified by KeyId and returns the revocation certificate.

When creating a revocation certificate there are two supported formats. The first format includes only the revocation signature. This format is returned by this method. The second format includes both the public key and the revocation signature. This format can be obtained by calling ExportPublicKey after calling this method. Both formats are common, and both formats are acceptable when calling ImportKey.

Before calling this method a key must be selected and available in the Key property.

The KeyId may be the Id of the main key or a subkey. For OpenPGP v4 keys and earlier, the key Id corresponds to the last 4 or 8 bytes of the key's Fingerprint. For OpenPGP v6 keys, the key Id corresponds to the first 8 bytes of the key's Fingerprint instead. For instance:

5E70662EA810E768

Error Handling (C++)

This method returns a String value; after it returns, call the GetLastErrorCode() method to obtain its result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message.

SaveKeyring Method (KeyMgr Class)

Saves the current Keyring to disk.

Syntax

ANSI (Cross Platform)
int SaveKeyring(const char* lpszKeyringPath);

Unicode (Windows)
INT SaveKeyring(LPCWSTR lpszKeyringPath);
int ipworksopenpgp_keymgr_savekeyring(void* lpObj, const char* lpszKeyringPath);
int SaveKeyring(const QString& qsKeyringPath);

Remarks

This method saves the current keyring to disk. There are two output options. The keyring may either be saved to a single key file or may be saved to a directory.

To save the keyring to a directory set KeyringPath to the path. The directory must already exist. The class will create a "pubring.gpg" and "secring.gpg" file in the specified directory. If the files already exist they will be overwritten.

To save the keyring to a key file set KeyringPath to a path and file name. If the file already exists it will be overwritten.

Error Handling (C++)

This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)

SignUserId Method (KeyMgr Class)

Signs the specified user Id of the current key.

Syntax

ANSI (Cross Platform)
int SignUserId(const char* lpszUserId, const char* lpszIssuerUserId);

Unicode (Windows)
INT SignUserId(LPCWSTR lpszUserId, LPCWSTR lpszIssuerUserId);
int ipworksopenpgp_keymgr_signuserid(void* lpObj, const char* lpszUserId, const char* lpszIssuerUserId);
int SignUserId(const QString& qsUserId, const QString& qsIssuerUserId);

Remarks

This method signs the UserId with the IssuerUserId.

To sign all user Ids in the current key set the UserId parameter to "*".

The key's passphrase is required for this operation and may be specified via Passphrase or through the KeyPassphrase event.

Error Handling (C++)

This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)

VerifyPassphrase Method (KeyMgr Class)

Verifies the passphrase of specified key.

Syntax

ANSI (Cross Platform)
bool VerifyPassphrase(const char* lpszPassphrase);

Unicode (Windows)
INT VerifyPassphrase(LPCWSTR lpszPassphrase);
bool ipworksopenpgp_keymgr_verifypassphrase(void* lpObj, const char* lpszPassphrase);
bool VerifyPassphrase(const QString& qsPassphrase);

Remarks

This method verifies the passphrase of the key specified by UserId.

If the password is correct, this method returns True; otherwise, this method returns False.

Error Handling (C++)

This method returns a Boolean value; after it returns, call the GetLastErrorCode() method to obtain its result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message.

Error Event (KeyMgr Class)

Fired when information is available about errors during data delivery.

Syntax

ANSI (Cross Platform)
virtual int FireError(KeyMgrErrorEventParams *e);
typedef struct {
int ErrorCode;
const char *Description; int reserved; } KeyMgrErrorEventParams;
Unicode (Windows) virtual INT FireError(KeyMgrErrorEventParams *e);
typedef struct {
INT ErrorCode;
LPCWSTR Description; INT reserved; } KeyMgrErrorEventParams;
#define EID_KEYMGR_ERROR 1

virtual INT IPWORKSOPENPGP_CALL FireError(INT &iErrorCode, LPSTR &lpszDescription);
class KeyMgrErrorEventParams {
public:
  int ErrorCode();

  const QString &Description();

  int EventRetVal();
  void SetEventRetVal(int iRetVal);
};
// To handle, connect one or more slots to this signal. void Error(KeyMgrErrorEventParams *e);
// Or, subclass KeyMgr and override this emitter function. virtual int FireError(KeyMgrErrorEventParams *e) {...}

Remarks

The Error event is fired in case of exceptional conditions during message processing. Normally the class fails with an error.

The ErrorCode parameter contains an error code, and the Description parameter contains a textual description of the error. For a list of valid error codes and their descriptions, please refer to the Error Codes section.

KeyList Event (KeyMgr Class)

Fires for each key in the keyring when ListKeys is called.

Syntax

ANSI (Cross Platform)
virtual int FireKeyList(KeyMgrKeyListEventParams *e);
typedef struct {
const char *UserId;
const char *KeyId;
const char *Fingerprint;
int HasSecretKey;
const char *PublicKeyAlgorithm;
int PublicKeyLength;
const char *Curve; int reserved; } KeyMgrKeyListEventParams;
Unicode (Windows) virtual INT FireKeyList(KeyMgrKeyListEventParams *e);
typedef struct {
LPCWSTR UserId;
LPCWSTR KeyId;
LPCWSTR Fingerprint;
BOOL HasSecretKey;
LPCWSTR PublicKeyAlgorithm;
INT PublicKeyLength;
LPCWSTR Curve; INT reserved; } KeyMgrKeyListEventParams;
#define EID_KEYMGR_KEYLIST 2

virtual INT IPWORKSOPENPGP_CALL FireKeyList(LPSTR &lpszUserId, LPSTR &lpszKeyId, LPSTR &lpszFingerprint, BOOL &bHasSecretKey, LPSTR &lpszPublicKeyAlgorithm, INT &iPublicKeyLength, LPSTR &lpszCurve);
class KeyMgrKeyListEventParams {
public:
  const QString &UserId();

  const QString &KeyId();

  const QString &Fingerprint();

  bool HasSecretKey();

  const QString &PublicKeyAlgorithm();

  int PublicKeyLength();

  const QString &Curve();

  int EventRetVal();
  void SetEventRetVal(int iRetVal);
};
// To handle, connect one or more slots to this signal. void KeyList(KeyMgrKeyListEventParams *e);
// Or, subclass KeyMgr and override this emitter function. virtual int FireKeyList(KeyMgrKeyListEventParams *e) {...}

Remarks

This event fires once for each key in the Keyring when ListKeys is called.

UserId holds the current user Id of the key.

The UserId format is:

FirstName LastName (Comment) <Email>
Not all values are required when selecting or generating a key, but at least FirstName or Email are required.

Note that for OpenPGP v6, a key may be created with or without a UserId, as the field is optional. If a key was created without a UserId, the key's Fingerprint can be used as it's identifier instead.

KeyId is the hex-encoded, 4-byte or 8-byte Id of the key. For OpenPGP v4 keys and earlier, the key Id corresponds to the last 4 or 8 bytes of the key's Fingerprint. For OpenPGP v6 keys, the key Id corresponds to the first 8 bytes of the key's Fingerprint instead. For instance:

5E70662EA810E768

Fingerprint holds the hex-encoded, 20-byte fingerprint of the key. This is in the form:

5E70662EA810E768391A2FE8F7B7D49C89C9D7B1

HasSecretKey returns True if the key contains a secret key.

PublicKeyAlgorithm is the public key algorithm. Possible values are:

  • RSA
  • DSA
  • ECDSA
  • EdDSA
  • Ed25519
  • Ed448

PublicKeyLength is the length of the public key. Common values are 512, 1024, and 2048. If the PublicKeyAlgorithm is ECDSA, EdDSA, Ed25519, or Ed448, the length of the public key is determined by the Curve. Possible lengths are:

CurvePublic Key Length (bits)
secp256r1 256
secp384r1 384
secp521r1 528
secp256k1 256
Ed25519 256
Ed448 456

Curve is the curve used by the key when PublicKeyAlgorithm is ECDSA, EdDSA, Ed25519, or Ed448. Possible values are:

CurveValid Public Key AlgorithmsDescription
secp256r1 ECDSA NIST curve P-256
secp384r1 ECDSA NIST curve P-384
secp521r1 ECDSA NIST curve P-521
secp256k1 ECDSA Secp256k1
Ed25519 EdDSA, Ed25519 Ed25519
Ed448 Ed448 Ed448

KeyPassphrase Event (KeyMgr Class)

Fired if the passphrase of current key is incorrect or empty.

Syntax

ANSI (Cross Platform)
virtual int FireKeyPassphrase(KeyMgrKeyPassphraseEventParams *e);
typedef struct {
const char *UserId;
const char *KeyId;
const char *Fingerprint;
char *Passphrase; int reserved; } KeyMgrKeyPassphraseEventParams;
Unicode (Windows) virtual INT FireKeyPassphrase(KeyMgrKeyPassphraseEventParams *e);
typedef struct {
LPCWSTR UserId;
LPCWSTR KeyId;
LPCWSTR Fingerprint;
LPWSTR Passphrase; INT reserved; } KeyMgrKeyPassphraseEventParams;
#define EID_KEYMGR_KEYPASSPHRASE 3

virtual INT IPWORKSOPENPGP_CALL FireKeyPassphrase(LPSTR &lpszUserId, LPSTR &lpszKeyId, LPSTR &lpszFingerprint, LPSTR &lpszPassphrase);
class KeyMgrKeyPassphraseEventParams {
public:
  const QString &UserId();

  const QString &KeyId();

  const QString &Fingerprint();

  const QString &Passphrase();
  void SetPassphrase(const QString &qsPassphrase);

  int EventRetVal();
  void SetEventRetVal(int iRetVal);
};
// To handle, connect one or more slots to this signal. void KeyPassphrase(KeyMgrKeyPassphraseEventParams *e);
// Or, subclass KeyMgr and override this emitter function. virtual int FireKeyPassphrase(KeyMgrKeyPassphraseEventParams *e) {...}

Remarks

This event fires when the passphrase for the key is required. The passphrase must be specified before operations requiring the secret key are attempted. The passphrase may be supplied by setting the Passphrase parameter in this event, or by specifying the Passphrase field before attempting the operation.

The passphrase is required when using the following methods in KeyMgr:

When using the OpenPGP class, or an email-based class, the following methods require a passphrase for the key:

  • Decrypt
  • Sign
  • SignAndEncrypt

UserId holds the user Id of the key the passphrase is required for.

The UserId format is:

FirstName LastName (Comment) <Email>
Not all values are required when selecting or generating a key, but at least FirstName or Email are required.

Note that for OpenPGP v6, a key may be created with or without a UserId, as the field is optional. If a key was created without a UserId, the key's Fingerprint can be used as it's identifier instead.

KeyId is the hex-encoded, 4-byte or 8-byte Id of the key the passphrase is required for. For OpenPGP v4 keys and earlier, the key Id corresponds to the last 4 or 8 bytes of the key's Fingerprint. For OpenPGP v6 keys, the key Id corresponds to the first 8 bytes of the key's Fingerprint instead. For instance:

5E70662EA810E768

Fingerprint holds the hex-encoded, 20-byte fingerprint of the key the passphrase is required for. This is in the form:

5E70662EA810E768391A2FE8F7B7D49C89C9D7B1

SignatureList Event (KeyMgr Class)

Fires for each signature of the current key when ListSignatures is called.

Syntax

ANSI (Cross Platform)
virtual int FireSignatureList(KeyMgrSignatureListEventParams *e);
typedef struct {
const char *KeyId;
const char *Fingerprint;
const char *UserId;
const char *IssuerFingerprint;
const char *IssuerKeyId;
const char *IssuerUserId;
const char *PublicKeyAlgorithm;
const char *Curve;
const char *HashAlgorithm;
const char *EffectiveDate;
int SignatureClass;
int ValidityStatus; int reserved; } KeyMgrSignatureListEventParams;
Unicode (Windows) virtual INT FireSignatureList(KeyMgrSignatureListEventParams *e);
typedef struct {
LPCWSTR KeyId;
LPCWSTR Fingerprint;
LPCWSTR UserId;
LPCWSTR IssuerFingerprint;
LPCWSTR IssuerKeyId;
LPCWSTR IssuerUserId;
LPCWSTR PublicKeyAlgorithm;
LPCWSTR Curve;
LPCWSTR HashAlgorithm;
LPCWSTR EffectiveDate;
INT SignatureClass;
INT ValidityStatus; INT reserved; } KeyMgrSignatureListEventParams;
#define EID_KEYMGR_SIGNATURELIST 4

virtual INT IPWORKSOPENPGP_CALL FireSignatureList(LPSTR &lpszKeyId, LPSTR &lpszFingerprint, LPSTR &lpszUserId, LPSTR &lpszIssuerFingerprint, LPSTR &lpszIssuerKeyId, LPSTR &lpszIssuerUserId, LPSTR &lpszPublicKeyAlgorithm, LPSTR &lpszCurve, LPSTR &lpszHashAlgorithm, LPSTR &lpszEffectiveDate, INT &iSignatureClass, INT &iValidityStatus);
class KeyMgrSignatureListEventParams {
public:
  const QString &KeyId();

  const QString &Fingerprint();

  const QString &UserId();

  const QString &IssuerFingerprint();

  const QString &IssuerKeyId();

  const QString &IssuerUserId();

  const QString &PublicKeyAlgorithm();

  const QString &Curve();

  const QString &HashAlgorithm();

  const QString &EffectiveDate();

  int SignatureClass();

  int ValidityStatus();

  int EventRetVal();
  void SetEventRetVal(int iRetVal);
};
// To handle, connect one or more slots to this signal. void SignatureList(KeyMgrSignatureListEventParams *e);
// Or, subclass KeyMgr and override this emitter function. virtual int FireSignatureList(KeyMgrSignatureListEventParams *e) {...}

Remarks

This event fires once for each signature of the current key when ListSignatures is called.

The KeyId, UserId, and Fingerprint parameters contain relevant information for the current key. Similarly, the IssuerKeyId, IssuerUserId, and IssuerFingerprint parameters contain relevant information for the issuer's key. The format of these parameters are described below.

KeyId and IssuerKeyId hold the hex-encoded, 4- or 8-byte Id of the respective key. For OpenPGP v4 keys and earlier, the key Id corresponds to the last 4 or 8 bytes of the key's Fingerprint. For OpenPGP v6 keys, the key Id corresponds to the first 8 bytes of the key's Fingerprint instead. For instance:

5E70662EA810E768

UserId and IssuerUserId hold the user Id of the respective key. The UserId format is:

FirstName LastName (Comment) <Email>
Not all values are required when selecting or generating a key, but at least FirstName or Email are required.

Note that for OpenPGP v6, a key may be created with or without a UserId, as the field is optional. If a key was created without a UserId, the key's Fingerprint can be used as it's identifier instead.

Fingerprint and IssuerFingerprint hold the hex-encoded, 20-byte fingerprint of the respective key. This is in the form:

5E70662EA810E768391A2FE8F7B7D49C89C9D7B1

Note that if IssuerUserId and IssuerFingerprint are empty, this indicates that the issuer's key could not be found in the current keyring.

PublicKeyAlgorithm is the public key algorithm. Possible values are:

  • RSA
  • DSA
  • ECDSA
  • EdDSA
  • Ed25519
  • Ed448

Curve is the curve used by the key when PublicKeyAlgorithm is ECDSA, EdDSA, Ed25519, or Ed448. Possible values are:

CurveValid Public Key AlgorithmsDescription
secp256r1 ECDSA NIST curve P-256
secp384r1 ECDSA NIST curve P-384
secp521r1 ECDSA NIST curve P-521
secp256k1 ECDSA Secp256k1
Ed25519 EdDSA, Ed25519 Ed25519
Ed448 Ed448 Ed448

HashAlgorithm is the hash algorithm used by the signature. Possible values are:

  • SHA1
  • MD5
  • SHA256
  • SHA384
  • SHA512
  • SHA224
  • RIPEMD160
  • SHA3-256
  • SHA3-512

EffectiveDate is the date when this signature became valid. The following example illustrates the format of an encoded date: 23-Jan-2000 15:00:00 .

SignatureClass is the type of signature. Possible values are:

16Generic Signature
17Personal Signature
18Casual Signature
19Positive Signature (self-signed)

ValidityStatus specifies the current validity status of the signature. Possible values are:

1Invalid
2Valid
3Unknown (the issuer's public key could not be found)

Status Event (KeyMgr Class)

Shows the progress of the operation.

Syntax

ANSI (Cross Platform)
virtual int FireStatus(KeyMgrStatusEventParams *e);
typedef struct {
const char *Message; int reserved; } KeyMgrStatusEventParams;
Unicode (Windows) virtual INT FireStatus(KeyMgrStatusEventParams *e);
typedef struct {
LPCWSTR Message; INT reserved; } KeyMgrStatusEventParams;
#define EID_KEYMGR_STATUS 5

virtual INT IPWORKSOPENPGP_CALL FireStatus(LPSTR &lpszMessage);
class KeyMgrStatusEventParams {
public:
  const QString &Message();

  int EventRetVal();
  void SetEventRetVal(int iRetVal);
};
// To handle, connect one or more slots to this signal. void Status(KeyMgrStatusEventParams *e);
// Or, subclass KeyMgr and override this emitter function. virtual int FireStatus(KeyMgrStatusEventParams *e) {...}

Remarks

The event is fired for informational and logging purposes only. It may be used to track the progress of an operation.

The level of detail is controlled by the LogLevel setting.

SubkeyList Event (KeyMgr Class)

Fires once for each subkey listed when ListSubkeys is called.

Syntax

ANSI (Cross Platform)
virtual int FireSubkeyList(KeyMgrSubkeyListEventParams *e);
typedef struct {
const char *KeyId;
const char *Fingerprint;
const char *PublicKeyAlgorithm;
int PublicKeyLength;
const char *Curve;
int UsageFlags;
const char *Usage;
const char *EffectiveDate;
const char *ExpirationDate;
int Revoked; int reserved; } KeyMgrSubkeyListEventParams;
Unicode (Windows) virtual INT FireSubkeyList(KeyMgrSubkeyListEventParams *e);
typedef struct {
LPCWSTR KeyId;
LPCWSTR Fingerprint;
LPCWSTR PublicKeyAlgorithm;
INT PublicKeyLength;
LPCWSTR Curve;
INT UsageFlags;
LPCWSTR Usage;
LPCWSTR EffectiveDate;
LPCWSTR ExpirationDate;
BOOL Revoked; INT reserved; } KeyMgrSubkeyListEventParams;
#define EID_KEYMGR_SUBKEYLIST 6

virtual INT IPWORKSOPENPGP_CALL FireSubkeyList(LPSTR &lpszKeyId, LPSTR &lpszFingerprint, LPSTR &lpszPublicKeyAlgorithm, INT &iPublicKeyLength, LPSTR &lpszCurve, INT &iUsageFlags, LPSTR &lpszUsage, LPSTR &lpszEffectiveDate, LPSTR &lpszExpirationDate, BOOL &bRevoked);
class KeyMgrSubkeyListEventParams {
public:
  const QString &KeyId();

  const QString &Fingerprint();

  const QString &PublicKeyAlgorithm();

  int PublicKeyLength();

  const QString &Curve();

  int UsageFlags();

  const QString &Usage();

  const QString &EffectiveDate();

  const QString &ExpirationDate();

  bool Revoked();

  int EventRetVal();
  void SetEventRetVal(int iRetVal);
};
// To handle, connect one or more slots to this signal. void SubkeyList(KeyMgrSubkeyListEventParams *e);
// Or, subclass KeyMgr and override this emitter function. virtual int FireSubkeyList(KeyMgrSubkeyListEventParams *e) {...}

Remarks

This event fires once for each subkey when ListSubkeys is called.

KeyId is the hex-encoded, 4- or 8-byte Id of the key. For OpenPGP v4 keys and earlier, the key Id corresponds to the last 4 or 8 bytes of the key's Fingerprint. For OpenPGP v6 keys, the key Id corresponds to the first 8 bytes of the key's Fingerprint instead. For instance:

5E70662EA810E768

Fingerprint holds the hex-encoded, 20-byte fingerprint of the key. This is in the form:

5E70662EA810E768391A2FE8F7B7D49C89C9D7B1

PublicKeyAlgorithm is the public key algorithm of the subkey. Possible values are:

  • RSA
  • DSA
  • ElGamal
  • ECDSA
  • EdDSA
  • ECDH
  • Ed25519
  • Ed448
  • X25519
  • X448

PublicKeyLength is the length of the subkey. Common values are 512, 1024, and 2048. If PublicKeyAlgorithm is ECDSA, EdDSA, ECDH, Ed25519, Ed448, X25519, or X448, the length of the public key is determined by the Curve. Possible lengths are:

CurvePublic Key Length (bits)
secp256r1 256
secp384r1 384
secp521r1 528
secp256k1 256
Ed25519 256
Ed448 456
Curve25519 256
Curve448 448

Curve is the curve used by the key when PublicKeyAlgorithm is ECDSA, EdDSA, ECDH, Ed25519, Ed448, X25519, or X448. Possible values are:

Subkey CurvePossible Subkey AlgorithmsDescription
secp256r1 ECDSA, ECDH NIST curve P-256
secp384r1 ECDSA, ECDH NIST curve P-384
secp521r1 ECDSA, ECDH NIST curve P-521
secp256k1 ECDSA, ECDH Secp256k1
Ed25519 EdDSA, Ed25519 Ed25519
Ed448 EdDSA, Ed448 Ed448
Curve25519 ECDH, X25519 Curve25519
Curve448 X448 Curve448

Usage is the textual description of UsageFlags.

The value will be of one or more of the following strings, separated by commas:

  • Certifying Other Certificates
  • Signing Emails and Files
  • Encrypting Emails and Files
  • Split Key
  • Authenticate Against Servers
  • Group Key

UsageFlags is an integer flag that shows the intended use for the key. The value is a combination of the following flags:

0x01This key may be used to certify other keys.
0x02This key may be used to sign data.
0x0CThis key may be used to encrypt communications and encrypt storage.
0x10The private component of this key may have been split by a secret-sharing mechanism.
0x20This key may be used for authentication.
0x80The private component of this key may be in the possession of more than one person.

EffectiveDate is the date when this key became valid. The following example illustrates the format of an encoded date: 23-Jan-2000 15:00:00.

ExpirationDate is the date the key expires. After this date the key will no longer be valid. The following example illustrates the format of an encoded date: 23-Jan-2000 15:00:00. If the ExpirationDate is not populated this indicates that the key never expires.

Revoked Indicates whether the subkey is revoked or not.

Key Type

The OpenPGP key being used.

Syntax

IPWorksOpenPGPKey (declared in ipworksopenpgp.h)

Remarks

This type describes the current key. The key may be a public or secret key. The fields are used to identify or select the key.

The following fields are available:

Fields

Curve
char* (read-only)

Default Value: ""

This field specifies the elliptic curve if PublicKeyAlgorithm is ECDSA, EdDSA, Ed25519, or Ed448. Possible values are:

CurveValid Public Key AlgorithmsDescription
secp256r1 ECDSA NIST curve P-256
secp384r1 ECDSA NIST curve P-384
secp521r1 ECDSA NIST curve P-521
secp256k1 ECDSA Secp256k1
Ed25519 EdDSA, Ed25519 Ed25519
Ed448 Ed448 Ed448

EffectiveDate
char* (read-only)

Default Value: ""

The date when this key becomes valid. Prior to this it is not valid. The following is an example of a valid encoded date:

23-Jan-2000 15:00:00.

Encoded
char*

Default Value: ""

The key. This field can be used to assign a specific key. The Fingerprint, Id, and UserId fields may also be used to specify a key.

ExpirationDate
char* (read-only)

Default Value: ""

The date the key expires. After this date the key will no longer be valid. The following is an example of a valid encoded date:

23-Jan-2001 15:00:00.

Fingerprint
char*

Default Value: ""

The hex-encoded, 20-byte fingerprint of the key.

When a key is loaded, this field is populated with the Fingerprint associated with the key. This field may be set to load a key from the Keyring. When this field is set the classwill search the Keyring for a key associated with the Fingerprint specified.

This is in the form:

5E70662EA810E768391A2FE8F7B7D49C89C9D7B1

Id
char*

Default Value: ""

The hex-encoded, 4-byte or 8-byte key Id. For OpenPGP v4 keys and earlier, the key Id corresponds to the last 4 or 8 bytes of the key's Fingerprint. For OpenPGP v6 keys, the key Id corresponds to the first 8 bytes of the key's Fingerprint instead. For instance:

5E70662EA810E768

When a key is loaded, this field is populated with the Id associated with the key. This field may be set to load a key from the Keyring. When this field is set the class will search the Keyring for a key associated with the Id specified.

The KeyIdLength setting may be set to control the length of the returned key Id.

Note: It is recommended to use the Fingerprint field when loading a key from the Keyring, as it is possible for different keys to have the same Id.

Keyring
char*

Default Value: ""

The location of the keyring.

If the keyring is stored in a directory, set this property to the directory. The directory must contain the files "secring.gpg" and "pubring.gpg". A keyring may also be stored in a single file. If the keyring is a file this property should be set to the path of the file.

When This field is set the class will read the keyring and populate the Key property with the first key found in the keyring. Set UserId to select a different key in the current keyring.

OtherUserIds
char* (read-only)

Default Value: ""

If the specified key has alternate user Ids associated with it, this field returns a comma-separated list of the other user Ids.

Passphrase
char*

Default Value: ""

The passphrase for the key's secret key (if any). This must be specified before operations requiring the secret key are attempted. The passphrase may be supplied in this field or through the KeyPassphrase event, which will fire when a passphrase is required.

The passphrase is required when using the following methods in KeyMgr:

  • AddUserId
  • SignUserId
  • ChangeExpirationDate
  • ChangePassphrase

When using the OpenPGP class, or an email-based class, the following methods require a passphrase for the key:

  • Decrypt
  • Sign
  • SignAndEncrypt

PublicKey
char* (read-only)

Default Value: ""

The public key of the key. The key is provided as ASCII armored data.

PublicKeyAlgorithm
char* (read-only)

Default Value: ""

A text description of the public key algorithm of the key. Possible values are:

  • RSA
  • DSA
  • ECDSA
  • EdDSA
  • Ed25519
  • Ed448
  • RSA-Legacy

PublicKeyLength
int (read-only)

Default Value: 0

The length of the public key in bits. Common values are 512, 1024, and 2048.

If the PublicKeyAlgorithm field is ECDSA, EdDSA, Ed25519, or Ed448, the length of the public key is determined by the Curve. Possible lengths are:

CurvePublic Key Length (bits)
secp256r1 256
secp384r1 384
secp521r1 528
secp256k1 256
Ed25519 256
Ed448 456

Revoked
int (read-only)

Default Value: FALSE

Whether or not the key is revoked.

SecretKey
char* (read-only)

Default Value: ""

The secret key of the key (if available). The key is provided as ASCII armored data.

SecretKeyAvailable
int (read-only)

Default Value: FALSE

Whether or not a secret key is available for the selected key.

Usage
char* (read-only)

Default Value: ""

A text description of UsageFlags.

The value will be of one or more of the following strings, separated by commas:

  • Certifying Other Certificates
  • Signing Emails and Files
  • Encrypting Emails and Files
  • Split Key
  • Authenticate Against Servers
  • Group Key

UsageFlags
int (read-only)

Default Value: 47

Flags that show the intended use for the key. The default value is 0x0F. The value of UsageFlags is a combination of the following flags:

0x01This key may be used to certify other keys.
0x02This key may be used to sign data.
0x0CThis key may be used to encrypt communications and encrypt storage.
0x10The private component of this key may have been split by a secret-sharing mechanism.
0x20This key may be used for authentication.
0x80The private component of this key may be in the possession of more than one person.

Please refer to the Usage field for a text representation of UsageFlags.

UserId
char*

Default Value: ""

The user Id of the key. When a key is loaded this field is populated with the user Id associated with the key. This field may be set to load a key from the Keyring. When this field is set the class will search the Keyring for a key associated with the UserId specified.

When loading a key with multiple user Ids, this field will be populated with the UserId that was most recently added to the key. To discover all of the UserIds associated with a key query this field and OtherUserIds after loading the key.

The UserId format is:

FirstName LastName (Comment) <Email>
Not all values are required when selecting or generating a key, but at least FirstName or Email are required.

Note that for OpenPGP v6, a key may be created with or without a UserId, as the field is optional. If a key was created without a UserId, the key's Fingerprint can be used as it's identifier instead.

When using this field to select a key you may also specify the key's Id, or any of its subkeys' Ids, instead of a user Id. The class will then search for a key with a matching Id. This is helpful in situations where you do not have the UserId but still need to load the key, such as within the OpenPGP class's RecipientInfo event.

Version
int (read-only)

Default Value: 4

This field can be used to query the OpenPGP version of the currently selected Key. Possible values are:

  • 4 - OpenPGP v4 (default)
  • 6 - OpenPGP v6

Config Settings (KeyMgr Class)

The class accepts one or more of the following configuration settings. Configuration settings are similar in functionality to properties, but they are rarely used. In order to avoid "polluting" the property namespace of the class, access to these internal properties is provided through the Config method.

KeyMgr Config Settings

AllowEmptyPassword:   Whether a key can be created without a password.

This controls whether a password will be used to encrypt a key. When true, CreateKey will accept an empty string as the password, leaving the key unencrypted. The default is false.

Argon2Iterations:   Specifies the number of iterations used for Argon2.

This configuration setting specifies the number of iterations performed when calling CreateKey and UseArgon2 is True. The default value is 3. Valid values range from 1 to 2^(32)-1. Higher values provide more brute-force protection for the key passphrase at the cost of performance. This configuration can be used to tune the running time independently of the memory size (see Argon2MemorySizeExp).

Argon2MemorySizeExp:   Specifies the exponent used to calculate the memory size used when creating a key.

This configuration setting specifies the exponent used when calculating the memory size used when calling CreateKey and UseArgon2 is True. The default value is 16. Valid values range from 3 to 31, though the minimum can vary depending on the value of Argon2Parallelism (see below). The memory size (in KB) is calculated as 2^exp, where exp is the value of this configuration setting. For example, the default memory size would be: 2^(16) = 65,536 KB.

Note: The memory size must be an integer number of kilobytes ranging from 8*p to 2^(32)-1, where p is the value of Argon2Parallelism. Therefore, Argon2MemorySizeExp must be an integer ranging from 3+ceil(log2(p)) to 31. For example, if Argon2Parallelism is set to 8, valid values for Argon2MemorySizeExp range from 6 to 31.

Argon2Parallelism:   Specifies the degree of parallelism used for Argon2.

This configuration setting specifies the degree of parallelism, or the number of lanes, used when CreateKey is called and UseArgon2 is set to True. The default value is 4. Valid values range from 1 to 2^(24)-1.

ContinueOnInvalidKey:   Whether to continue loading the keyring when an invalid key is found.

This setting determines whether the class will continue loading keys when an invalid key is found. This is applicable when calling LoadKeyring. If set to False (default) the class fails with an error. If set to True the class will fire the Error event with information about the key which failed to load, and then continue loading additional keys.

CreateRSASubkeyforEncrypt:   Whether to create a subkey when creating an RSA key.

This setting determines whether the class will additionally create a subkey marked for encryption when calling CreateKey when PublicKeyAlgorithm is set to RSA. The default is true.

CurrentKeyPrimaryKeyUsageFlags:   The usage flags of the currently selected primary key.

When queried, this will return the usage flags of the currently selected primary key, returned in decimal representation. Individual flags may be checked against the list at UsageFlags.

Curve:   The elliptic curve used when creating a key.

This configuration setting specifies the curve to use when calling CreateKey. This is only applicable when PublicKeyAlgorithm is set to ECDSA, EdDSA, Ed25519, or Ed448. Possible curves and PublicKeyAlgorithm combinations are:

CurveValid Public Key AlgorithmsDescription
secp256r1 ECDSA NIST curve P-256
secp384r1 ECDSA NIST curve P-384
secp521r1 ECDSA NIST curve P-521
secp256k1 ECDSA Secp256k1
Ed25519 EdDSA, Ed25519 Ed25519
Ed448 Ed448 Ed448

EnsureValidDSASignatureHashAlgorithm:   Whether or not to select a suitable signature hash algorithm automatically.

This setting specifies whether the class ensures a valid hash algorithm is selected for use with the loaded DSA or ECDSA key. The default value is True.

DSA Notes

DSA requires that the hash be 160 bits or larger, which means MD5 is not a suitable algorithm. When DSA Signature Hash Algorithm selection is enabled (default) the class will use the preferred algorithm from the key if it meets the requirements for DSA. If the preferred algorithm is MD5 and does not meed the requirements for DSA the class will automatically use a suitable algorithm based on the Q element of the DSA key (may be SHA1, SHA224, or SHA256).

ECDSA Notes

The ECDSA Signature Hash Algorithm requirements are directly related to the Curve used by the key. When this setting is enabled (default) the class will use the preferred algorithm from the key if it meets the requirements for ECDSA. If the preferred algorithm does not meet the requirements the class will automatically select a valid hash algorithm based on the curve as follows:

CurveHash Algorithm
secp256r1 SHA256
secp384r1 SHA384
secp521r1 SHA512
secp256k1 SHA256

ImportAllKeys:   Whether or not to import all keys found in a key file.

When calling ImportKey with a UserId parameter of "*" or "", the class will import all keys found in the file if this property is set to True (default). If this is set to False when the UserId parameter of ImportKey is set to "*" or "", only the first key found in the file will be imported. The default value is True.

KeyBoxProtectionMode:   Specifies the keybox protection mode used when saving a keyring.

This configuration setting specifies the keybox protection mode used when calling SaveKeyring. This is only applicable when KeyringFormat is set to 2 (GPG 2.1 and newer). Possible values are as follows:

0openpgp-s2k3-sha1-aes-cbc (default)
1openpgp-s2k3-sha1-aes256-cbc
2openpgp-s2k3-ocb-aes

KeyEncryptionAlgorithm:   The encryption algorithm used when creating a key.

Specifies the encryption algorithm to use when calling CreateKey. The default value is AES128. Possible values are:

  • CAST5
  • 3DES
  • AES256
  • AES192
  • AES128
  • IDEA
  • BLOWFISH
  • AES256-OCB (AEAD)
  • AES192-OCB (AEAD)
  • AES128-OCB (AEAD)
  • AES256-GCM (AEAD)
  • AES192-GCM (AEAD)
  • AES128-GCM (AEAD)

The listed AEAD encryption algorithms (AES*-OCB or AES*-GCM) are only relevant if UseArgon2 is enabled. In this case, this config must be set to one of the above AEAD encryption algorithms. If UseArgon2 is disabled, and an AEAD encryption algorithm is specified, the AEAD mode (OCB or GCM) will be ignored.

KeyIdLength:   Specifies the length of the key's Id.

When querying the Id field the value will be returned with the length (in octets) specified. The default value is 8. The only other acceptable value is 4.

For OpenPGP v4 keys and earlier, the key Id corresponds to the last 4 or 8 bytes of the key's Fingerprint. For OpenPGP v6 keys, the key Id corresponds to the first 8 bytes of the key's Fingerprint instead. For instance:

5E70662EA810E768

KeyPreferredAEADAlgorithms:   Indicates the preferred AEAD encryption algorithms associated with the currently selected key.

This configuration setting indicates the preferred AEAD encryption algorithms associated with the currently selected Key. This configuration setting is read-only.

This configuration setting will return a comma-separated list of the key's preferred AEAD encryption algorithms. For example: "AES256-OCB, AES256-GCM, AES192-OCB, AES192-GCM, AES128-OCB, AES128-GCM"

KeyPreferredCompressionAlgorithms:   Indicates the preferred compression algorithms associated with the currently selected key.

This configuration setting indicates the preferred compression algorithms associated with the currently selected Key. This configuration setting is read-only.

This configuration setting will return a comma-separated list of the key's preferred compression algorithms. For example: "ZIP, ZLIB, BZip2, Uncompressed"

KeyPreferredHashAlgorithms:   Indicates the preferred hash algorithms associated with the currently selected key.

This configuration setting indicates the preferred hash algorithms associated with the currently selected Key. This configuration setting is read-only.

This configuration setting will return a comma-separated list of the key's preferred hash algorithms. For example: "SHA256, SHA384, SHA224, SHA1, MD5, RIPEMD160"

KeyPreferredSymmetricAlgorithms:   Indicates the preferred symmetric algorithms associated with the currently selected key.

This configuration setting indicates the preferred symmetric algorithms associated with the currently selected Key. This configuration setting is read-only.

This configuration setting will return a comma-separated list of the key's preferred symmetric algorithms. For example: "AES256, AES192, AES128, Blowfish, Twofish, IDEA, TripleDES, CAST5"

KeyringFormat:   Specifies the keyring format to use when saving a keyring.

This configuration setting specifies the keyring format to use when calling SaveKeyring. GPG has two formats to store multiple keys. Supported values are as follows:

Config ValueKeyring Format
1GPG 2.0 and older (Default)
2GPG 2.1 and newer

Versions 2.0 and older use keyrings. Public keys are stored in pubring.gpg. Secret keys are stored in secring.gpg.

Versions 2.1 and newer use a keybox. Public keys are stored in a .kbx file. Private keys are stored in private-keys-v1.d. The default keybox protection mode is openpgp-s2k3-sha1-aes-cbc. See KeyBoxProtectionMode for additional details.

For example:

keymgr1.Config("KeyringFormat=2"); keymgr1.SaveKeyring("C:\\keyring");

KeyUsage:   Flags that show intended use for the key being created.

When calling CreateKey this setting defines the flags that show the intended use for the key. The default value is (0x0F). The value of KeyUsage is a combination of the following flags:

0x01This key may be used to certify other keys.
0x02This key may be used to sign data.
0x0CThis key may be used to encrypt communications and encrypt storage.
0x10The private component of this key may have been split by a secret-sharing mechanism.
0x20This key may be used for authentication.
0x80The private component of this key may be in the possession of more than one person.

Note that if KeyVersion is 6 and SubKeyAlgorithm is RSA, the key must have both signing and encrypting capabilities (0x0F).

KeyValidityTime:   The validity period for the key being created.

When CreateKey creates a new key, the key is valid the moment it is created. KeyValidityTime determines the number of days until expiration. The default value is 365 days. The special value 0 means the key will never expire.

KeyVersion:   Specifies the OpenPGP version for the key being created.

This configuration is used to specify the OpenPGP version for the key being created via CreateKey. Possible values are:

  • 4 (OpenPGP v4)
  • 6 (OpenPGP v6)

LogLevel:   Specifies the level of detail that is logged.

This setting controls the level of detail that is logged through the Status event. Possible values are:

0 (None)No events are logged.
1 (Info - default)Informational events are logged.
2 (Verbose)Detailed data is logged.
3 (Debug)Debug data is logged.
PreferredAEADAlgorithms:   Specifies a key's preferred AEAD encryption algorithms when creating a key.

This configuration setting is used to specify a key's preferred AEAD encryption algorithms when calling CreateKey. This can be set as a combination of the following hex values (in string format):

  • 0702 - AES128-OCB
  • 0703 - AES128-GCM
  • 0802 - AES192-OCB
  • 0803 - AES192-GCM
  • 0902 - AES256-OCB
  • 0903 - AES256-GCM

For example, to set the preferred AEAD encryption algorithms to AES256-OCB and AES256-GCM, this config can be set like so:

// AES256-OCB (0902), AES256-GCM (0903) keyMgr.Config("PreferredAEADAlgorithms=09020903"); keyMgr.CreateKey("test", "test");

By default, this configuration setting is equal to the following string: 090209030802080307020703

PreferredCompressionAlgorithms:   Specifies a key's preferred compression algorithms when creating a key.

This configuration setting is used to specify a key's preferred compression algorithms when calling CreateKey. This can be set as a combination of the following hex values (in string format):

  • 00 - Uncompressed
  • 01 - ZIP
  • 02 - ZLIB
  • 03 - BZip2

For example, to set the preferred compression algorithms to ZIP and ZLIB, this config can be set like so:

// ZIP (01), ZLIB (02) keyMgr.Config("PreferredCompressionAlgorithms=0102"); keyMgr.CreateKey("test", "test");

By default, this configuration setting is equal to the following string: 01020300

PreferredHashAlgorithms:   Specifies a key's preferred hash algorithms when creating a key.

This configuration setting is used to specify a key's preferred hash algorithms when calling CreateKey. This can be set as a combination of the following hex values (in string format):

  • 01 - MD5
  • 02 - SHA1
  • 03 - RIPEMD60
  • 08 - SHA256
  • 09 - SHA384
  • 0a - SHA512
  • 0b - SHA224
  • 0c - SHA3_256
  • 0f - SHA3_512

For example, to set the preferred hash algorithms to SHA256, SHA384, and SHA512, this config can be set like so:

// SHA256 (08), SHA384 (09), SHA512 (0a) keyMgr.Config("PreferredHashAlgorithms=08090a"); keyMgr.CreateKey("test", "test");

By default, this configuration setting is equal to the following string: 08090a0b020103

PreferredSymmetricAlgorithms:   Specifies a key's preferred symmetric algorithms when creating a key.

This configuration setting is used to specify a key's preferred symmetric algorithms when calling CreateKey. This can be set as a combination of the following hex values (in string format):

  • 00 - Plaintext
  • 01 - IDEA
  • 02 - TripleDES
  • 03 - CAST5
  • 04 - Blowfish
  • 07 - AES128
  • 08 - AES192
  • 09 - AES256
  • 0a - Twofish

For example, to set the preferred symmetric algorithms to AES256, AES192, and AES128, this config can be set like so:

// AES256 (09), AES192 (08), AES128 (07) keyMgr.Config("PreferredSymmetricAlgorithms=090807"); keyMgr.CreateKey("test", "test");

By default, this configuration setting is equal to the following string: 090807040a010203

PublicKeyAlgorithm:   The public key algorithm for the key being created.

Specifies the public key algorithm to use when creating the key via CreateKey. By default, this config will be set to automatic and the class will automatically choose an appropriate algorithm depending on the KeyVersion. For OpenPGP v4, EdDSA will be selected as the default. For OpenPGP v6, Ed25519 will be selected as the default.

Supported values depend on the KeyVersion. Please see below for supported values for each version.

Public Key AlgorithmSupported for OpenPGP v4Supported for OpenPGP v6
RSA
DSA
ECDSA
EdDSA
Ed25519
Ed448
RSA-Legacy

When creating an RSA key and KeyVersion is specified as 6, note that the PublicKeyLength must be greater than or equal to 3072 (default).

When creating a DSA key only PublicKeyLength values of 512 and 1024 are supported. Additionally the PublicKeySignatureHashAlgorithm value "MD5" is not supported with DSA keys.

When creating an ECDSA, EdDSA, Ed25519, or Ed448 key, the PublicKeyLength value is automatically determined based on the Curve. If Curve is not specified, the following defaults will be used:

Public Key AlgorithmDefault Curve
ECDSA secp256r1
EdDSA Ed25519
Ed25519 Ed25519
Ed448 Ed448

The below configurations may be utilized to configure the subkey associated with this key. By default, the class will automatically select appropriate values based on the PublicKeyAlgorithm and SubKeyUsage.

Note: The RSA-Legacy algorithm should not be used under normal circumstances. It should only be used to create PGP 2.6.2 compatible keys, when required. This type of key will not have subkeys.

PublicKeyLength:   Specifies the public key length when creating a key.

Specifies the length of the public key when calling CreateKey. The default value is 3072.

This configuration setting is only applicable when PublicKeyAlgorithm is specified as RSA or DSA.

Note that when PublicKeyAlgorithm is set to RSA and KeyVersion is set to 6, the public key length must be greater than or equal to 3072. Additionally, if PublicKeyAlgorithm is set to DSA, only public key length values of 512 and 1024 are supported.

PublicKeyringFile:   The file name of the public keyring file.

This specifies the name of the public keyring file. The default value is "pubring.gpg". This may be set to a file name only, or a full path including the file name.

PublicKeySignatureHashAlgorithm:   The public key signature hash algorithm used when creating a key.

This setting specifies the public key signature algorithm to be used when calling CreateKey. The default value is "SHA256". Possible values are:

  • SHA1
  • MD5
  • SHA256 (default)
  • SHA384
  • SHA512
  • SHA224
  • RIPEMD160
  • SHA3-256
  • SHA3-512
RawKeyData:   Returns detailed key and keyring data for debugging purposes.

This setting will return detailed debugging information about the current key and keyring.

RevocationCode:   The reason why the key was revoked.

This setting specifies why the key was revoked. It is only applicable if Revoked is True. This may be set before calling RevokeKey and may be inspected after importing and selecting a revoked key. Possible values are:

0No reason specified
1Key is superseded
2Key material has been compromised
3Key is retired and no longer used
4User Id information is no longer valid
100-110Private Use
The default value is 0.
RevocationReason:   Text describing why the key was revoked.

This setting specifies text description of why the key was revoked. It is only applicable if Revoked is True. This may be set before calling RevokeKey and may be queried after importing and selecting a revoked key. The default value is an empty string.

Revoker:   The revoker's key Id.

This setting returns the key Id of the designated revoker associated with this key. This will only be present if a separate revoker was added to the key (for instance by calling AddRevoker). If more than one revoker was added this setting will return a comma-separated list of key Ids.

SecretKeyringFile:   The file name of the secret keyring file.

This specifies the name of the secret keyring file. The default value is "secring.gpg". This may be set to a file name only, or a full path including the file name.

SubKeyAlgorithm:   The public key algorithm for the subkey being created.

Specifies the public key algorithm for a subkey created when calling CreateKey or CreateSubKey. The default value is empty string and the class will automatically select an appropriate algorithm based on PublicKeyAlgorithm and SubKeyUsage.

Supported values depend on the KeyVersion. Please see below for applicable values for each supported version.

Public Key Algorithm Supported Subkey Operations Supported for OpenPGP v4 Supported for OpenPGP v6
RSA Sign and Encrypt
DSA Sign
ElGamal Encrypt
ECDSA Sign
EdDSA Sign
ECDH Encrypt
Ed25519 Sign
Ed448 Sign
X25519 Encrypt
X448 Encrypt

The SubKeyCurve configuration setting is applicable for subkey algorithms ECDH, ECDSA, EdDSA, Ed25519, Ed448, X25519, or X448. If SubKeyCurve is not specified, the following subkey curves will be used by default for each SubKeyAlgorithm:

Sub Key AlgorithmDefault Curve
ECDSA secp256r1
ECDH secp256r1
EdDSA Ed25519
Ed25519 Ed25519
Ed448 Ed448
X25519 Curve25519
X448 Curve448

Note that the SubKeyLength will be automatically determined by the specified SubKeyCurve, if applicable.

SubKeyCurve:   The elliptic curve of the sub key.

This configuration setting may optionally be specified to set a curve for the subkey which differs from the key curve specified by Curve. This is applicable in either of the following scenarios:

  1. When calling CreateKey and PublicKeyAlgorithm is set to ECDSA, EdDSA, Ed25519, or Ed448, and SubKeyAlgorithm is unspecified.
  2. When calling CreateKey or CreateSubKey and SubKeyAlgorithm is set to ECDH, ECDSA, EdDSA, Ed25519, Ed448, X25519, or X448.
Possible values for the SubKeyCurve and associated SubKeyAlgorithm's are:

Subkey CurvePossible Subkey AlgorithmsDescription
secp256r1 ECDSA, ECDH NIST curve P-256
secp384r1 ECDSA, ECDH NIST curve P-384
secp521r1 ECDSA, ECDH NIST curve P-521
secp256k1 ECDSA, ECDH Secp256k1
Ed25519 EdDSA, Ed25519 Ed25519
Ed448 EdDSA, Ed448 Ed448
Curve25519 ECDH, X25519 Curve25519
Curve448 X448 Curve448

Note if KeyVersion is set to 6, Curve25519 is not a valid subkey curve for ECDH.

SubKeyLength:   Specifies the public subkey length when creating a key or subkey.

This setting is applicable when creating keys with CreateKey, or creating subkeys with CreateSubKey. This specifies the length of the public subkey. The default value is 0, in which case the subkey will have the length specified by PublicKeyLength.

This configuration setting is only applicable when PublicKeyAlgorithm is specified as RSA, DSA, or ElGamal.

Note that when PublicKeyAlgorithm is set to RSA, it is highly recommended that the subkey length is at least 3072. Additionally, if PublicKeyAlgorithm is set to DSA, only subkey length values of 512 and 1024 are supported.

SubKeyUsage:   Flags that show intended use for the subkey being created.

When calling CreateKey or CreateSubKey this setting defines the flags that show the intended use for the key. The default value is (0x0C). The value of SubKeyUsage is a combination of the following flags:

0x01This key may be used to certify other keys.
0x02This key may be used to sign data.
0x0CThis key may be used to encrypt communications and encrypt storage.
0x10The private component of this key may have been split by a secret-sharing mechanism.
0x20This key may be used for authentication.
0x80The private component of this key may be in the possession of more than one person.

Note that if KeyVersion is 6 and SubKeyAlgorithm is RSA, the key must have both signing and encrypting capabilities (0x0F).

UseArgon2:   Whether to use Argon2 for key derivation when creating a key.

Determines whether the Argon2 algorithm is used as the String-to-Key (S2K) method for passphrase-based key derivation when CreateKey is called. The default value is False.

The following configuration settings are applicable when this config is set to True:

Note if UseArgon2 is enabled, an AEAD encryption algorithm must be specified by KeyEncryptionAlgorithm (e.g., AES192-OCB). Please see KeyEncryptionAlgorithm for additional details.

VersionHeader:   The Version header value in ASCII armored public keys.

This setting specifies the Version header value included in newly created public keys. This includes keys that are exported via ExportPublicKey where the UseAsciiArmor parameter is true. The default value is "IPWorks OpenPGP 2024".

Base Config Settings

BuildInfo:   Information about the product's build.

When queried, this setting will return a string containing information about the product's build.

CodePage:   The system code page used for Unicode to Multibyte translations.

The default code page is Unicode UTF-8 (65001).

The following is a list of valid code page identifiers:

IdentifierName
037IBM EBCDIC - U.S./Canada
437OEM - United States
500IBM EBCDIC - International
708Arabic - ASMO 708
709Arabic - ASMO 449+, BCON V4
710Arabic - Transparent Arabic
720Arabic - Transparent ASMO
737OEM - Greek (formerly 437G)
775OEM - Baltic
850OEM - Multilingual Latin I
852OEM - Latin II
855OEM - Cyrillic (primarily Russian)
857OEM - Turkish
858OEM - Multilingual Latin I + Euro symbol
860OEM - Portuguese
861OEM - Icelandic
862OEM - Hebrew
863OEM - Canadian-French
864OEM - Arabic
865OEM - Nordic
866OEM - Russian
869OEM - Modern Greek
870IBM EBCDIC - Multilingual/ROECE (Latin-2)
874ANSI/OEM - Thai (same as 28605, ISO 8859-15)
875IBM EBCDIC - Modern Greek
932ANSI/OEM - Japanese, Shift-JIS
936ANSI/OEM - Simplified Chinese (PRC, Singapore)
949ANSI/OEM - Korean (Unified Hangul Code)
950ANSI/OEM - Traditional Chinese (Taiwan; Hong Kong SAR, PRC)
1026IBM EBCDIC - Turkish (Latin-5)
1047IBM EBCDIC - Latin 1/Open System
1140IBM EBCDIC - U.S./Canada (037 + Euro symbol)
1141IBM EBCDIC - Germany (20273 + Euro symbol)
1142IBM EBCDIC - Denmark/Norway (20277 + Euro symbol)
1143IBM EBCDIC - Finland/Sweden (20278 + Euro symbol)
1144IBM EBCDIC - Italy (20280 + Euro symbol)
1145IBM EBCDIC - Latin America/Spain (20284 + Euro symbol)
1146IBM EBCDIC - United Kingdom (20285 + Euro symbol)
1147IBM EBCDIC - France (20297 + Euro symbol)
1148IBM EBCDIC - International (500 + Euro symbol)
1149IBM EBCDIC - Icelandic (20871 + Euro symbol)
1200Unicode UCS-2 Little-Endian (BMP of ISO 10646)
1201Unicode UCS-2 Big-Endian
1250ANSI - Central European
1251ANSI - Cyrillic
1252ANSI - Latin I
1253ANSI - Greek
1254ANSI - Turkish
1255ANSI - Hebrew
1256ANSI - Arabic
1257ANSI - Baltic
1258ANSI/OEM - Vietnamese
1361Korean (Johab)
10000MAC - Roman
10001MAC - Japanese
10002MAC - Traditional Chinese (Big5)
10003MAC - Korean
10004MAC - Arabic
10005MAC - Hebrew
10006MAC - Greek I
10007MAC - Cyrillic
10008MAC - Simplified Chinese (GB 2312)
10010MAC - Romania
10017MAC - Ukraine
10021MAC - Thai
10029MAC - Latin II
10079MAC - Icelandic
10081MAC - Turkish
10082MAC - Croatia
12000Unicode UCS-4 Little-Endian
12001Unicode UCS-4 Big-Endian
20000CNS - Taiwan
20001TCA - Taiwan
20002Eten - Taiwan
20003IBM5550 - Taiwan
20004TeleText - Taiwan
20005Wang - Taiwan
20105IA5 IRV International Alphabet No. 5 (7-bit)
20106IA5 German (7-bit)
20107IA5 Swedish (7-bit)
20108IA5 Norwegian (7-bit)
20127US-ASCII (7-bit)
20261T.61
20269ISO 6937 Non-Spacing Accent
20273IBM EBCDIC - Germany
20277IBM EBCDIC - Denmark/Norway
20278IBM EBCDIC - Finland/Sweden
20280IBM EBCDIC - Italy
20284IBM EBCDIC - Latin America/Spain
20285IBM EBCDIC - United Kingdom
20290IBM EBCDIC - Japanese Katakana Extended
20297IBM EBCDIC - France
20420IBM EBCDIC - Arabic
20423IBM EBCDIC - Greek
20424IBM EBCDIC - Hebrew
20833IBM EBCDIC - Korean Extended
20838IBM EBCDIC - Thai
20866Russian - KOI8-R
20871IBM EBCDIC - Icelandic
20880IBM EBCDIC - Cyrillic (Russian)
20905IBM EBCDIC - Turkish
20924IBM EBCDIC - Latin-1/Open System (1047 + Euro symbol)
20932JIS X 0208-1990 & 0121-1990
20936Simplified Chinese (GB2312)
21025IBM EBCDIC - Cyrillic (Serbian, Bulgarian)
21027Extended Alpha Lowercase
21866Ukrainian (KOI8-U)
28591ISO 8859-1 Latin I
28592ISO 8859-2 Central Europe
28593ISO 8859-3 Latin 3
28594ISO 8859-4 Baltic
28595ISO 8859-5 Cyrillic
28596ISO 8859-6 Arabic
28597ISO 8859-7 Greek
28598ISO 8859-8 Hebrew
28599ISO 8859-9 Latin 5
28605ISO 8859-15 Latin 9
29001Europa 3
38598ISO 8859-8 Hebrew
50220ISO 2022 Japanese with no halfwidth Katakana
50221ISO 2022 Japanese with halfwidth Katakana
50222ISO 2022 Japanese JIS X 0201-1989
50225ISO 2022 Korean
50227ISO 2022 Simplified Chinese
50229ISO 2022 Traditional Chinese
50930Japanese (Katakana) Extended
50931US/Canada and Japanese
50933Korean Extended and Korean
50935Simplified Chinese Extended and Simplified Chinese
50936Simplified Chinese
50937US/Canada and Traditional Chinese
50939Japanese (Latin) Extended and Japanese
51932EUC - Japanese
51936EUC - Simplified Chinese
51949EUC - Korean
51950EUC - Traditional Chinese
52936HZ-GB2312 Simplified Chinese
54936Windows XP: GB18030 Simplified Chinese (4 Byte)
57002ISCII Devanagari
57003ISCII Bengali
57004ISCII Tamil
57005ISCII Telugu
57006ISCII Assamese
57007ISCII Oriya
57008ISCII Kannada
57009ISCII Malayalam
57010ISCII Gujarati
57011ISCII Punjabi
65000Unicode UTF-7
65001Unicode UTF-8
The following is a list of valid code page identifiers for Mac OS only:
IdentifierName
1ASCII
2NEXTSTEP
3JapaneseEUC
4UTF8
5ISOLatin1
6Symbol
7NonLossyASCII
8ShiftJIS
9ISOLatin2
10Unicode
11WindowsCP1251
12WindowsCP1252
13WindowsCP1253
14WindowsCP1254
15WindowsCP1250
21ISO2022JP
30MacOSRoman
10UTF16String
0x90000100UTF16BigEndian
0x94000100UTF16LittleEndian
0x8c000100UTF32String
0x98000100UTF32BigEndian
0x9c000100UTF32LittleEndian
65536Proprietary

LicenseInfo:   Information about the current license.

When queried, this setting will return a string containing information about the license this instance of a class is using. It will return the following information:

  • Product: The product the license is for.
  • Product Key: The key the license was generated from.
  • License Source: Where the license was found (e.g., RuntimeLicense, License File).
  • License Type: The type of license installed (e.g., Royalty Free, Single Server).
  • Last Valid Build: The last valid build number for which the license will work.
MaskSensitiveData:   Whether sensitive data is masked in log messages.

In certain circumstances it may be beneficial to mask sensitive data, like passwords, in log messages. Set this to true to mask sensitive data. The default is true.

This setting only works on these classes: AS3Receiver, AS3Sender, Atom, Client(3DS), FTP, FTPServer, IMAP, OFTPClient, SSHClient, SCP, Server(3DS), Sexec, SFTP, SFTPServer, SSHServer, TCPClient, TCPServer.

ProcessIdleEvents:   Whether the class uses its internal event loop to process events when the main thread is idle.

If set to False, the class will not fire internal idle events. Set this to False to use the class in a background thread on Mac OS. By default, this setting is True.

SelectWaitMillis:   The length of time in milliseconds the class will wait when DoEvents is called if there are no events to process.

If there are no events to process when DoEvents is called, the class will wait for the amount of time specified here before returning. The default value is 20.

UseFIPSCompliantAPI:   Tells the class whether or not to use FIPS certified APIs.

When set to true, the class will utilize the underlying operating system's certified APIs. Java editions, regardless of OS, utilize Bouncy Castle Federal Information Processing Standards (FIPS), while all other Windows editions make use of Microsoft security libraries.

On Linux, the C++ edition requires installation of the FIPS-enabled OpenSSL library. The OpenSSL FIPS provider version must be at least 3.0.0. For additional information and instructions regarding the installation and activation of the FIPS-enabled OpenSSL library, please refer to the following link: https://github.com/openssl/openssl/blob/master/README-FIPS.md

To ensure the class utilizes the FIPS-enabled OpenSSL library, the obfuscated source code should first be compiled with OpenSSL enabled, as described in the Supported Platforms section. Additionally, the FIPS module should be enabled and active. If the obfuscated source code is not compiled as mentioned, or the FIPS module is inactive, the class will throw an appropriate error assuming FIPS mode is enabled.

FIPS mode can be enabled by setting the UseFIPSCompliantAPI configuration setting to true. This is a static setting that applies to all instances of all classes of the toolkit within the process. It is recommended to enable or disable this setting once before the component has been used to establish a connection. Enabling FIPS while an instance of the component is active and connected may result in unexpected behavior.

For more details, please see the FIPS 140-2 Compliance article.

Note: This setting is applicable only on Windows.

Note: Enabling FIPS compliance requires a special license; please contact sales@nsoftware.com for details.

UseInternalSecurityAPI:   Whether or not to use the system security libraries or an internal implementation.

When set to false, the class will use the system security libraries by default to perform cryptographic functions where applicable.

Setting this configuration setting to true tells the class to use the internal implementation instead of using the system security libraries.

On Windows, this setting is set to false by default. On Linux/macOS, this setting is set to true by default.

To use the system security libraries for Linux, OpenSSL support must be enabled. For more information on how to enable OpenSSL, please refer to the OpenSSL Notes section.

Trappable Errors (KeyMgr Class)

Error Handling (C++)

Call the GetLastErrorCode() method to obtain the last called method's result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. Known error codes are listed below. If an error occurs, the GetLastError() method can be called to retrieve the associated error message.

OpenPGP Errors

101   Cannot decode ASCII Armor data.
102   Unknown ASCII Armor data type.
103   Checksum failed.
104   Unknown ASCII Armor header.
105   Cannot decode PGP packet.
106   Cannot encode PGP packet.
107   Unknown PGP packet tag.
108   Unsupported version.
109   Unsupported algorithm.
110   Unknown subpacket.
111   Internal error.
112   Feature not supported.
113   Secret data was not encrypted.
114   Cannot find the key.
115   Error reading file.
116   Error writing file.
117   Error reading key.
118   Error writing key.
119   Cannot verify signature.
120   Cannot create signature.
121   Invalid UserId.
122   Invalid passphrase.
123   Data encryption failed.
124   Error creating key.
125   Unsupported symmetric algorithm.
126   Unsupported hash.
127   Unsupported compression algorithm.
128   Invalid key usage.
129   Component is busy.
130   Error decrypting data.
131   Data is not compressed.
132   Error decompressing data.
133   Error compressing data.
134   Unsupported signature.
135   Failed to overwrite file.
141   No input.
142   Signing was required, but the message was not signed.
143   Encryption was required, but the message was not encrypted.
146   No data integrity packet was found (MDC), but one was required.
200   Out of memory.