OpenPGP Class

Properties   Methods   Events   Config Settings   Errors  

The OpenPGP class is used to encrypt/decrypt and sign/verify PGP messages.

Syntax

OpenPGP

Remarks

The OpenPGP class supports encrypting/decrypting and signing/verifying OpenPGP messages in the format specified by RFC 4880.

The Encrypt, Sign, and SignAndEncrypt methods are used to create a message to be sent to your partner. You can additionally create messages bound for multiple recipients with different keys, simultaneously encrypt and compress with the most popular compression algorithms, and control other aspects such as the encrypting algorithm to use.

When a message is received, the Decrypt, VerifySignature, and DecryptAndVerifySignature methods are used to process the incoming message.

The Key* properties specify the key (with private key) used to sign and decrypt.

The SignerKey* properties specify the key used to verify a signature.

The RecipientKey* properties specify the key used to encrypt.

Input and Output Properties

The class will determine the source and destination of the input and output based on which properties are set.

The order in which the input properties are checked is as follows:

When a valid source is found the search stops. The order in which the output properties are checked is as follows:

When using streams you may need to additionally set CloseInputStreamAfterProcessing or CloseOutputStreamAfterProcessing.

Property List


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

ASCIIArmorSpecifies whether to use ASCII armor to encode the output message.
AutoSelectAlgorithmsWhether to automatically select algorithms when encrypting or signing.
ClearSignatureSpecifies whether or not to create a cleartext signature.
CompressionMethodThe compression algorithm used.
DetachedSignatureSpecifies whether or not to generate a detached signature when signing a message.
EncryptingAlgorithmThe encryption algorithm used when encrypting.
InputFileThe file to process.
InputMessageThe message to process.
KeyCountThe number of records in the Key arrays.
KeyEncodedThe key.
KeyKeyringThe location of the keyring.
KeyPassphraseThe passphrase for the key's secret key (if any).
KeyUserIdThe user Id of the key.
MessageHeaderCountThe number of records in the MessageHeader arrays.
MessageHeaderFieldThis property contains the name of the HTTP header (this is the same case as it is delivered).
MessageHeaderValueThis property contains the header contents.
OutputFileThe output file.
OutputMessageThe output message after processing.
OverwriteIndicates whether or not the class should overwrite files.
RecipientKeyCountThe number of records in the RecipientKey arrays.
RecipientKeyEncodedThe key.
RecipientKeyKeyringThe location of the keyring.
RecipientKeyUserIdThe user Id of the key.
SignerKeyCountThe number of records in the SignerKey arrays.
SignerKeyEncodedThe key.
SignerKeyKeyringThe location of the keyring.
SignerKeyUserIdThe user Id of the key.
SigningAlgorithmThe signature hash algorithm used when signing.

Method List


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

ConfigSets or retrieves a configuration setting.
DecryptDecrypts the message.
DecryptAndVerifySignatureDecrypts and verifies the signature of the message.
EncryptEncrypts the message.
GetRecipientInfoGets recipient information for an encrypted message.
ResetResets the class properties.
SetInputStreamSets the stream from which the class will read data to encrypt or decrypt.
SetOutputStreamThe stream to which the class will write the fully encrypted or decrypted OpenPGP data.
SignSigns the message.
SignAndEncryptSigns and encrypts the current message.
VerifySignatureVerifies the signature of the current message.

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.

ErrorInformation about errors during data delivery.
KeyPassphraseFired if the passphrase of current key is incorrect or empty.
ProgressFired as progress is made.
RecipientInfoFired for each recipient key of the encrypted message.
SignatureInfoFired during verification of the signed message.
StatusShows the progress of the operation.
VerificationStatusFired after verification of the signed message.

Config Settings


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

AllowEmptyInputWhether to allow empty files for input.
AllowOldPacketTypeWhether to allow the older encrypted packet type.
CloseInputStreamAfterProcessingDetermines whether or not the input stream is closed after processing.
CloseOutputStreamAfterProcessingDetermines whether or not the output stream is closed after processing.
CompressionLevelThe level of compression used.
DeleteOutputFileOnErrorWhether to delete the output file on an error.
DetachedSignatureDataThe detached signature.
EnsureValidDSASignatureHashAlgorithmWhether or not to select a suitable signature hash algorithm automatically.
FileNameThe original name of the encrypted file.
KeyIdLengthThe length of the KeyId available.
KeySelectionMethodThe method used to select a key for encryption or signing.
LogLevelSpecifies the level of detail that is logged.
PGPZipDirThe directory used when creating or extracting a PGP zip file.
ProgressEventThresholdThe amount of data in bytes to process before firing the progress event.
PublicKeyringFileThe file name of the public keyring file.
ReadFromProgressEventWhether to read input data from inside the progress event.
RecursiveDecryptModeWhether the encrypted data should be decrypted recursively.
RequireEncryptionWhether to throw an error when decrypting and encryption is not detected.
RequireIntegrityProtectedPacketWhether an MDC packet is required for decryption.
RequireSignatureWhether to throw an error when verifying a signature and no signature is found.
RequireValidSignatureSpecifies if an invalid signature is considered an error condition.
SecretKeyringFileThe file name of the secret keyring file.
SplitHeadersControls whether ASCII Armor headers are split or not.
SymmetricPassphraseThe password used for symmetric encryption or decryption.
UseFipsCompliantAlgorithmsRestricts the usage to FIPS compliant algorithms only.
UsePlatformAESWhether to use the platform AES implementation.
VersionHeaderThe Version header value in the ASCII armored OpenPGP message.
WriteToProgressEventWhether to write output data so it is accessible from inside the progress event.
BuildInfoInformation about the product's build.
CodePageThe system code page used for Unicode to Multibyte translations.
LicenseInfoInformation about the current license.
MaskSensitiveWhether 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.
UseInternalSecurityAPITells the class whether or not to use the system security libraries or an internal implementation.

ASCIIArmor Property (OpenPGP Class)

Specifies whether to use ASCII armor to encode the output message.

Syntax

ANSI (Cross Platform)
int GetASCIIArmor();
int SetASCIIArmor(int bASCIIArmor); Unicode (Windows) BOOL GetASCIIArmor();
INT SetASCIIArmor(BOOL bASCIIArmor);
int ipworksencrypt_openpgp_getasciiarmor(void* lpObj);
int ipworksencrypt_openpgp_setasciiarmor(void* lpObj, int bASCIIArmor);
bool GetASCIIArmor();
int SetASCIIArmor(bool bASCIIArmor);

Default Value

FALSE

Remarks

This property controls whether or not ASCII armoring is used on the output message. The default value is False.

Data Type

Boolean

AutoSelectAlgorithms Property (OpenPGP Class)

Whether to automatically select algorithms when encrypting or signing.

Syntax

ANSI (Cross Platform)
int GetAutoSelectAlgorithms();
int SetAutoSelectAlgorithms(int iAutoSelectAlgorithms); Unicode (Windows) INT GetAutoSelectAlgorithms();
INT SetAutoSelectAlgorithms(INT iAutoSelectAlgorithms);
int ipworksencrypt_openpgp_getautoselectalgorithms(void* lpObj);
int ipworksencrypt_openpgp_setautoselectalgorithms(void* lpObj, int iAutoSelectAlgorithms);
int GetAutoSelectAlgorithms();
int SetAutoSelectAlgorithms(int iAutoSelectAlgorithms);

Default Value

0

Remarks

This property is set to the binary 'OR' of one or more options indicating which algorithms to automatically select.

When enabled automatic selection is performed by examining the perferred algorithms specified by the key.

When Encrypt is called the class will read the preferred encryption algorithm and compression method from the key specified in the RecipientKey* properties.

If multiple keys are specified the preferred encryption algorithm and compression method from the last key is used. The EncryptingAlgorithm and CompressionMethod properties are ignored.

When Sign is called the class will read the preferred MAC algorithm and compression method from the private key specified in the Key* properties. If multiple keys are specified the preferred MAC algorithm and compression method from the last key is used. The SigningAlgorithm and CompressionMethod properties are ignored.

The list below defines available options.

Compression Algorithm 1 (Hex 0x01)
Cipher Algorithm 2 (Hex 0x02)
MAC Algorithm 4 (Hex 0x04)

The default value is 0 which means algorithms are not automatically selected.

Data Type

Integer

ClearSignature Property (OpenPGP Class)

Specifies whether or not to create a cleartext signature.

Syntax

ANSI (Cross Platform)
int GetClearSignature();
int SetClearSignature(int bClearSignature); Unicode (Windows) BOOL GetClearSignature();
INT SetClearSignature(BOOL bClearSignature);
int ipworksencrypt_openpgp_getclearsignature(void* lpObj);
int ipworksencrypt_openpgp_setclearsignature(void* lpObj, int bClearSignature);
bool GetClearSignature();
int SetClearSignature(bool bClearSignature);

Default Value

FALSE

Remarks

This property controls whether or not a cleartext signature is created during signing. The default value is False. When set to true a clear text signature will be created when Sign is called.

Data Type

Boolean

CompressionMethod Property (OpenPGP Class)

The compression algorithm used.

Syntax

ANSI (Cross Platform)
char* GetCompressionMethod();
int SetCompressionMethod(const char* lpszCompressionMethod); Unicode (Windows) LPWSTR GetCompressionMethod();
INT SetCompressionMethod(LPCWSTR lpszCompressionMethod);
char* ipworksencrypt_openpgp_getcompressionmethod(void* lpObj);
int ipworksencrypt_openpgp_setcompressionmethod(void* lpObj, const char* lpszCompressionMethod);
QString GetCompressionMethod();
int SetCompressionMethod(QString qsCompressionMethod);

Default Value

"zip"

Remarks

This property specifies which compression method is used when generating output. Possible values are:

  • zip (default)
  • zlib
  • bzip2
  • none or uncompressed
Note: The level of compression is controlled by the CompressionLevel setting.

Data Type

String

DetachedSignature Property (OpenPGP Class)

Specifies whether or not to generate a detached signature when signing a message.

Syntax

ANSI (Cross Platform)
int GetDetachedSignature();
int SetDetachedSignature(int bDetachedSignature); Unicode (Windows) BOOL GetDetachedSignature();
INT SetDetachedSignature(BOOL bDetachedSignature);
int ipworksencrypt_openpgp_getdetachedsignature(void* lpObj);
int ipworksencrypt_openpgp_setdetachedsignature(void* lpObj, int bDetachedSignature);
bool GetDetachedSignature();
int SetDetachedSignature(bool bDetachedSignature);

Default Value

FALSE

Remarks

This property specifies whether or not a detached signature is created when signing a message. The default value is False.

If set to true the output will only be the signature. The data being signed will not be included in the output. If set to true ClearSignature will be ignored.

When this property is false (default) the signature is not detached. The output will contain both the signed data and the signature.

Data Type

Boolean

EncryptingAlgorithm Property (OpenPGP Class)

The encryption algorithm used when encrypting.

Syntax

ANSI (Cross Platform)
char* GetEncryptingAlgorithm();
int SetEncryptingAlgorithm(const char* lpszEncryptingAlgorithm); Unicode (Windows) LPWSTR GetEncryptingAlgorithm();
INT SetEncryptingAlgorithm(LPCWSTR lpszEncryptingAlgorithm);
char* ipworksencrypt_openpgp_getencryptingalgorithm(void* lpObj);
int ipworksencrypt_openpgp_setencryptingalgorithm(void* lpObj, const char* lpszEncryptingAlgorithm);
QString GetEncryptingAlgorithm();
int SetEncryptingAlgorithm(QString qsEncryptingAlgorithm);

Default Value

"AES128"

Remarks

This property specifies the encryption algorithm used when encrypting. Possible values are:

  • CAST5
  • 3DES or TripleDES
  • AES256
  • AES192
  • AES128 (default)
  • BLOWFISH
  • TWOFISH
  • IDEA

Data Type

String

InputFile Property (OpenPGP Class)

The file to process.

Syntax

ANSI (Cross Platform)
char* GetInputFile();
int SetInputFile(const char* lpszInputFile); Unicode (Windows) LPWSTR GetInputFile();
INT SetInputFile(LPCWSTR lpszInputFile);
char* ipworksencrypt_openpgp_getinputfile(void* lpObj);
int ipworksencrypt_openpgp_setinputfile(void* lpObj, const char* lpszInputFile);
QString GetInputFile();
int SetInputFile(QString qsInputFile);

Default Value

""

Remarks

This property specifies the file to be processed. Set this property to the full or relative path to the file which will be processed.

Input and Output Properties

The class will determine the source and destination of the input and output based on which properties are set.

The order in which the input properties are checked is as follows:

When a valid source is found the search stops. The order in which the output properties are checked is as follows:

When using streams you may need to additionally set CloseInputStreamAfterProcessing or CloseOutputStreamAfterProcessing.

Data Type

String

InputMessage Property (OpenPGP Class)

The message to process.

Syntax

ANSI (Cross Platform)
int GetInputMessage(char* &lpInputMessage, int &lenInputMessage);
int SetInputMessage(const char* lpInputMessage, int lenInputMessage); Unicode (Windows) INT GetInputMessage(LPSTR &lpInputMessage, INT &lenInputMessage);
INT SetInputMessage(LPCSTR lpInputMessage, INT lenInputMessage);
int ipworksencrypt_openpgp_getinputmessage(void* lpObj, char** lpInputMessage, int* lenInputMessage);
int ipworksencrypt_openpgp_setinputmessage(void* lpObj, const char* lpInputMessage, int lenInputMessage);
QByteArray GetInputMessage();
int SetInputMessage(QByteArray qbaInputMessage);

Default Value

""

Remarks

This property specifies the message to be processed. Set this property to the OpenPGP message content.

Input and Output Properties

The class will determine the source and destination of the input and output based on which properties are set.

The order in which the input properties are checked is as follows:

When a valid source is found the search stops. The order in which the output properties are checked is as follows:

When using streams you may need to additionally set CloseInputStreamAfterProcessing or CloseOutputStreamAfterProcessing.

Data Type

Binary String

KeyCount Property (OpenPGP Class)

The number of records in the Key arrays.

Syntax

ANSI (Cross Platform)
int GetKeyCount();
int SetKeyCount(int iKeyCount); Unicode (Windows) INT GetKeyCount();
INT SetKeyCount(INT iKeyCount);
int ipworksencrypt_openpgp_getkeycount(void* lpObj);
int ipworksencrypt_openpgp_setkeycount(void* lpObj, int iKeyCount);
int GetKeyCount();
int SetKeyCount(int iKeyCount);

Default Value

0

Remarks

This property controls the size of the following arrays:

The array indices start at 0 and end at KeyCount - 1.

This property is not available at design time.

Data Type

Integer

KeyEncoded Property (OpenPGP Class)

The key.

Syntax

ANSI (Cross Platform)
int GetKeyEncoded(int iKeyIndex, char* &lpKeyEncoded, int &lenKeyEncoded);
int SetKeyEncoded(int iKeyIndex, const char* lpKeyEncoded, int lenKeyEncoded); Unicode (Windows) INT GetKeyEncoded(INT iKeyIndex, LPSTR &lpKeyEncoded, INT &lenKeyEncoded);
INT SetKeyEncoded(INT iKeyIndex, LPCSTR lpKeyEncoded, INT lenKeyEncoded);
int ipworksencrypt_openpgp_getkeyencoded(void* lpObj, int keyindex, char** lpKeyEncoded, int* lenKeyEncoded);
int ipworksencrypt_openpgp_setkeyencoded(void* lpObj, int keyindex, const char* lpKeyEncoded, int lenKeyEncoded);
QByteArray GetKeyEncoded(int iKeyIndex);
int SetKeyEncoded(int iKeyIndex, QByteArray qbaKeyEncoded);

Default Value

""

Remarks

The key. This property is used to assign a specific key. The KeyUserId properties may also be used to specify a key.

The KeyIndex parameter specifies the index of the item in the array. The size of the array is controlled by the KeyCount property.

This property is not available at design time.

Data Type

Binary String

KeyKeyring Property (OpenPGP Class)

The location of the keyring.

Syntax

ANSI (Cross Platform)
char* GetKeyKeyring(int iKeyIndex);
int SetKeyKeyring(int iKeyIndex, const char* lpszKeyKeyring); Unicode (Windows) LPWSTR GetKeyKeyring(INT iKeyIndex);
INT SetKeyKeyring(INT iKeyIndex, LPCWSTR lpszKeyKeyring);
char* ipworksencrypt_openpgp_getkeykeyring(void* lpObj, int keyindex);
int ipworksencrypt_openpgp_setkeykeyring(void* lpObj, int keyindex, const char* lpszKeyKeyring);
QString GetKeyKeyring(int iKeyIndex);
int SetKeyKeyring(int iKeyIndex, QString qsKeyKeyring);

Default Value

""

Remarks

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 property is set the class will read the keyring and populate the Key* properties with the first key found in the keyring. Set KeyUserId to select a different key in the current keyring.

The KeyIndex parameter specifies the index of the item in the array. The size of the array is controlled by the KeyCount property.

This property is not available at design time.

Data Type

String

KeyPassphrase Property (OpenPGP Class)

The passphrase for the key's secret key (if any).

Syntax

ANSI (Cross Platform)
char* GetKeyPassphrase(int iKeyIndex);
int SetKeyPassphrase(int iKeyIndex, const char* lpszKeyPassphrase); Unicode (Windows) LPWSTR GetKeyPassphrase(INT iKeyIndex);
INT SetKeyPassphrase(INT iKeyIndex, LPCWSTR lpszKeyPassphrase);
char* ipworksencrypt_openpgp_getkeypassphrase(void* lpObj, int keyindex);
int ipworksencrypt_openpgp_setkeypassphrase(void* lpObj, int keyindex, const char* lpszKeyPassphrase);
QString GetKeyPassphrase(int iKeyIndex);
int SetKeyPassphrase(int iKeyIndex, QString qsKeyPassphrase);

Default Value

""

Remarks

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 property 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

The KeyIndex parameter specifies the index of the item in the array. The size of the array is controlled by the KeyCount property.

This property is not available at design time.

Data Type

String

KeyUserId Property (OpenPGP Class)

The user Id of the key.

Syntax

ANSI (Cross Platform)
char* GetKeyUserId(int iKeyIndex);
int SetKeyUserId(int iKeyIndex, const char* lpszKeyUserId); Unicode (Windows) LPWSTR GetKeyUserId(INT iKeyIndex);
INT SetKeyUserId(INT iKeyIndex, LPCWSTR lpszKeyUserId);
char* ipworksencrypt_openpgp_getkeyuserid(void* lpObj, int keyindex);
int ipworksencrypt_openpgp_setkeyuserid(void* lpObj, int keyindex, const char* lpszKeyUserId);
QString GetKeyUserId(int iKeyIndex);
int SetKeyUserId(int iKeyIndex, QString qsKeyUserId);

Default Value

""

Remarks

The user Id of the key. When a key is loaded this property is populated with the user Id associated with the key. This property may be set to load a key from the Keyring. When this property 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 property 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 property and KeyOtherUserIds 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.

When using this property 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.

The KeyIndex parameter specifies the index of the item in the array. The size of the array is controlled by the KeyCount property.

This property is not available at design time.

Data Type

String

MessageHeaderCount Property (OpenPGP Class)

The number of records in the MessageHeader arrays.

Syntax

ANSI (Cross Platform)
int GetMessageHeaderCount();
int SetMessageHeaderCount(int iMessageHeaderCount); Unicode (Windows) INT GetMessageHeaderCount();
INT SetMessageHeaderCount(INT iMessageHeaderCount);
int ipworksencrypt_openpgp_getmessageheadercount(void* lpObj);
int ipworksencrypt_openpgp_setmessageheadercount(void* lpObj, int iMessageHeaderCount);
int GetMessageHeaderCount();
int SetMessageHeaderCount(int iMessageHeaderCount);

Default Value

0

Remarks

This property controls the size of the following arrays:

The array indices start at 0 and end at MessageHeaderCount - 1.

This property is not available at design time.

Data Type

Integer

MessageHeaderField Property (OpenPGP Class)

This property contains the name of the HTTP header (this is the same case as it is delivered).

Syntax

ANSI (Cross Platform)
char* GetMessageHeaderField(int iMessageHeaderIndex);
int SetMessageHeaderField(int iMessageHeaderIndex, const char* lpszMessageHeaderField); Unicode (Windows) LPWSTR GetMessageHeaderField(INT iMessageHeaderIndex);
INT SetMessageHeaderField(INT iMessageHeaderIndex, LPCWSTR lpszMessageHeaderField);
char* ipworksencrypt_openpgp_getmessageheaderfield(void* lpObj, int messageheaderindex);
int ipworksencrypt_openpgp_setmessageheaderfield(void* lpObj, int messageheaderindex, const char* lpszMessageHeaderField);
QString GetMessageHeaderField(int iMessageHeaderIndex);
int SetMessageHeaderField(int iMessageHeaderIndex, QString qsMessageHeaderField);

Default Value

""

Remarks

This property contains the name of the HTTP Header (this is the same case as it is delivered).

The MessageHeaderIndex parameter specifies the index of the item in the array. The size of the array is controlled by the MessageHeaderCount property.

This property is not available at design time.

Data Type

String

MessageHeaderValue Property (OpenPGP Class)

This property contains the header contents.

Syntax

ANSI (Cross Platform)
char* GetMessageHeaderValue(int iMessageHeaderIndex);
int SetMessageHeaderValue(int iMessageHeaderIndex, const char* lpszMessageHeaderValue); Unicode (Windows) LPWSTR GetMessageHeaderValue(INT iMessageHeaderIndex);
INT SetMessageHeaderValue(INT iMessageHeaderIndex, LPCWSTR lpszMessageHeaderValue);
char* ipworksencrypt_openpgp_getmessageheadervalue(void* lpObj, int messageheaderindex);
int ipworksencrypt_openpgp_setmessageheadervalue(void* lpObj, int messageheaderindex, const char* lpszMessageHeaderValue);
QString GetMessageHeaderValue(int iMessageHeaderIndex);
int SetMessageHeaderValue(int iMessageHeaderIndex, QString qsMessageHeaderValue);

Default Value

""

Remarks

This property contains the Header contents.

The MessageHeaderIndex parameter specifies the index of the item in the array. The size of the array is controlled by the MessageHeaderCount property.

This property is not available at design time.

Data Type

String

OutputFile Property (OpenPGP Class)

The output file.

Syntax

ANSI (Cross Platform)
char* GetOutputFile();
int SetOutputFile(const char* lpszOutputFile); Unicode (Windows) LPWSTR GetOutputFile();
INT SetOutputFile(LPCWSTR lpszOutputFile);
char* ipworksencrypt_openpgp_getoutputfile(void* lpObj);
int ipworksencrypt_openpgp_setoutputfile(void* lpObj, const char* lpszOutputFile);
QString GetOutputFile();
int SetOutputFile(QString qsOutputFile);

Default Value

""

Remarks

This property specifies the file to which the output will be written. This may be set to an absolute or relative path.

Input and Output Properties

The class will determine the source and destination of the input and output based on which properties are set.

The order in which the input properties are checked is as follows:

When a valid source is found the search stops. The order in which the output properties are checked is as follows:

When using streams you may need to additionally set CloseInputStreamAfterProcessing or CloseOutputStreamAfterProcessing.

Data Type

String

OutputMessage Property (OpenPGP Class)

The output message after processing.

Syntax

ANSI (Cross Platform)
int GetOutputMessage(char* &lpOutputMessage, int &lenOutputMessage);
int SetOutputMessage(const char* lpOutputMessage, int lenOutputMessage); Unicode (Windows) INT GetOutputMessage(LPSTR &lpOutputMessage, INT &lenOutputMessage);
INT SetOutputMessage(LPCSTR lpOutputMessage, INT lenOutputMessage);
int ipworksencrypt_openpgp_getoutputmessage(void* lpObj, char** lpOutputMessage, int* lenOutputMessage);
int ipworksencrypt_openpgp_setoutputmessage(void* lpObj, const char* lpOutputMessage, int lenOutputMessage);
QByteArray GetOutputMessage();
int SetOutputMessage(QByteArray qbaOutputMessage);

Default Value

""

Remarks

This property will be populated with the output from the operation if OutputFile is not set.

Input and Output Properties

The class will determine the source and destination of the input and output based on which properties are set.

The order in which the input properties are checked is as follows:

When a valid source is found the search stops. The order in which the output properties are checked is as follows:

When using streams you may need to additionally set CloseInputStreamAfterProcessing or CloseOutputStreamAfterProcessing.

Data Type

Binary String

Overwrite Property (OpenPGP Class)

Indicates whether or not the class should overwrite files.

Syntax

ANSI (Cross Platform)
int GetOverwrite();
int SetOverwrite(int bOverwrite); Unicode (Windows) BOOL GetOverwrite();
INT SetOverwrite(BOOL bOverwrite);
int ipworksencrypt_openpgp_getoverwrite(void* lpObj);
int ipworksencrypt_openpgp_setoverwrite(void* lpObj, int bOverwrite);
bool GetOverwrite();
int SetOverwrite(bool bOverwrite);

Default Value

FALSE

Remarks

This property indicates whether or not the class will overwrite OutputFile. If Overwrite is False, an error will be thrown whenever OutputFile exists before an operation. The default value is False.

Data Type

Boolean

RecipientKeyCount Property (OpenPGP Class)

The number of records in the RecipientKey arrays.

Syntax

ANSI (Cross Platform)
int GetRecipientKeyCount();
int SetRecipientKeyCount(int iRecipientKeyCount); Unicode (Windows) INT GetRecipientKeyCount();
INT SetRecipientKeyCount(INT iRecipientKeyCount);
int ipworksencrypt_openpgp_getrecipientkeycount(void* lpObj);
int ipworksencrypt_openpgp_setrecipientkeycount(void* lpObj, int iRecipientKeyCount);
int GetRecipientKeyCount();
int SetRecipientKeyCount(int iRecipientKeyCount);

Default Value

0

Remarks

This property controls the size of the following arrays:

The array indices start at 0 and end at RecipientKeyCount - 1.

This property is not available at design time.

Data Type

Integer

RecipientKeyEncoded Property (OpenPGP Class)

The key.

Syntax

ANSI (Cross Platform)
int GetRecipientKeyEncoded(int iRecipientKeyIndex, char* &lpRecipientKeyEncoded, int &lenRecipientKeyEncoded);
int SetRecipientKeyEncoded(int iRecipientKeyIndex, const char* lpRecipientKeyEncoded, int lenRecipientKeyEncoded); Unicode (Windows) INT GetRecipientKeyEncoded(INT iRecipientKeyIndex, LPSTR &lpRecipientKeyEncoded, INT &lenRecipientKeyEncoded);
INT SetRecipientKeyEncoded(INT iRecipientKeyIndex, LPCSTR lpRecipientKeyEncoded, INT lenRecipientKeyEncoded);
int ipworksencrypt_openpgp_getrecipientkeyencoded(void* lpObj, int recipientkeyindex, char** lpRecipientKeyEncoded, int* lenRecipientKeyEncoded);
int ipworksencrypt_openpgp_setrecipientkeyencoded(void* lpObj, int recipientkeyindex, const char* lpRecipientKeyEncoded, int lenRecipientKeyEncoded);
QByteArray GetRecipientKeyEncoded(int iRecipientKeyIndex);
int SetRecipientKeyEncoded(int iRecipientKeyIndex, QByteArray qbaRecipientKeyEncoded);

Default Value

""

Remarks

The key. This property is used to assign a specific key. The RecipientKeyUserId properties may also be used to specify a key.

The RecipientKeyIndex parameter specifies the index of the item in the array. The size of the array is controlled by the RecipientKeyCount property.

This property is not available at design time.

Data Type

Binary String

RecipientKeyKeyring Property (OpenPGP Class)

The location of the keyring.

Syntax

ANSI (Cross Platform)
char* GetRecipientKeyKeyring(int iRecipientKeyIndex);
int SetRecipientKeyKeyring(int iRecipientKeyIndex, const char* lpszRecipientKeyKeyring); Unicode (Windows) LPWSTR GetRecipientKeyKeyring(INT iRecipientKeyIndex);
INT SetRecipientKeyKeyring(INT iRecipientKeyIndex, LPCWSTR lpszRecipientKeyKeyring);
char* ipworksencrypt_openpgp_getrecipientkeykeyring(void* lpObj, int recipientkeyindex);
int ipworksencrypt_openpgp_setrecipientkeykeyring(void* lpObj, int recipientkeyindex, const char* lpszRecipientKeyKeyring);
QString GetRecipientKeyKeyring(int iRecipientKeyIndex);
int SetRecipientKeyKeyring(int iRecipientKeyIndex, QString qsRecipientKeyKeyring);

Default Value

""

Remarks

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 property is set the class will read the keyring and populate the Key* properties with the first key found in the keyring. Set KeyUserId to select a different key in the current keyring.

The RecipientKeyIndex parameter specifies the index of the item in the array. The size of the array is controlled by the RecipientKeyCount property.

This property is not available at design time.

Data Type

String

RecipientKeyUserId Property (OpenPGP Class)

The user Id of the key.

Syntax

ANSI (Cross Platform)
char* GetRecipientKeyUserId(int iRecipientKeyIndex);
int SetRecipientKeyUserId(int iRecipientKeyIndex, const char* lpszRecipientKeyUserId); Unicode (Windows) LPWSTR GetRecipientKeyUserId(INT iRecipientKeyIndex);
INT SetRecipientKeyUserId(INT iRecipientKeyIndex, LPCWSTR lpszRecipientKeyUserId);
char* ipworksencrypt_openpgp_getrecipientkeyuserid(void* lpObj, int recipientkeyindex);
int ipworksencrypt_openpgp_setrecipientkeyuserid(void* lpObj, int recipientkeyindex, const char* lpszRecipientKeyUserId);
QString GetRecipientKeyUserId(int iRecipientKeyIndex);
int SetRecipientKeyUserId(int iRecipientKeyIndex, QString qsRecipientKeyUserId);

Default Value

""

Remarks

The user Id of the key. When a key is loaded this property is populated with the user Id associated with the key. This property may be set to load a key from the Keyring. When this property 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 property 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 property and KeyOtherUserIds 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.

When using this property 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.

The RecipientKeyIndex parameter specifies the index of the item in the array. The size of the array is controlled by the RecipientKeyCount property.

This property is not available at design time.

Data Type

String

SignerKeyCount Property (OpenPGP Class)

The number of records in the SignerKey arrays.

Syntax

ANSI (Cross Platform)
int GetSignerKeyCount();
int SetSignerKeyCount(int iSignerKeyCount); Unicode (Windows) INT GetSignerKeyCount();
INT SetSignerKeyCount(INT iSignerKeyCount);
int ipworksencrypt_openpgp_getsignerkeycount(void* lpObj);
int ipworksencrypt_openpgp_setsignerkeycount(void* lpObj, int iSignerKeyCount);
int GetSignerKeyCount();
int SetSignerKeyCount(int iSignerKeyCount);

Default Value

0

Remarks

This property controls the size of the following arrays:

The array indices start at 0 and end at SignerKeyCount - 1.

This property is not available at design time.

Data Type

Integer

SignerKeyEncoded Property (OpenPGP Class)

The key.

Syntax

ANSI (Cross Platform)
int GetSignerKeyEncoded(int iSignerKeyIndex, char* &lpSignerKeyEncoded, int &lenSignerKeyEncoded);
int SetSignerKeyEncoded(int iSignerKeyIndex, const char* lpSignerKeyEncoded, int lenSignerKeyEncoded); Unicode (Windows) INT GetSignerKeyEncoded(INT iSignerKeyIndex, LPSTR &lpSignerKeyEncoded, INT &lenSignerKeyEncoded);
INT SetSignerKeyEncoded(INT iSignerKeyIndex, LPCSTR lpSignerKeyEncoded, INT lenSignerKeyEncoded);
int ipworksencrypt_openpgp_getsignerkeyencoded(void* lpObj, int signerkeyindex, char** lpSignerKeyEncoded, int* lenSignerKeyEncoded);
int ipworksencrypt_openpgp_setsignerkeyencoded(void* lpObj, int signerkeyindex, const char* lpSignerKeyEncoded, int lenSignerKeyEncoded);
QByteArray GetSignerKeyEncoded(int iSignerKeyIndex);
int SetSignerKeyEncoded(int iSignerKeyIndex, QByteArray qbaSignerKeyEncoded);

Default Value

""

Remarks

The key. This property is used to assign a specific key. The SignerKeyUserId properties may also be used to specify a key.

The SignerKeyIndex parameter specifies the index of the item in the array. The size of the array is controlled by the SignerKeyCount property.

This property is not available at design time.

Data Type

Binary String

SignerKeyKeyring Property (OpenPGP Class)

The location of the keyring.

Syntax

ANSI (Cross Platform)
char* GetSignerKeyKeyring(int iSignerKeyIndex);
int SetSignerKeyKeyring(int iSignerKeyIndex, const char* lpszSignerKeyKeyring); Unicode (Windows) LPWSTR GetSignerKeyKeyring(INT iSignerKeyIndex);
INT SetSignerKeyKeyring(INT iSignerKeyIndex, LPCWSTR lpszSignerKeyKeyring);
char* ipworksencrypt_openpgp_getsignerkeykeyring(void* lpObj, int signerkeyindex);
int ipworksencrypt_openpgp_setsignerkeykeyring(void* lpObj, int signerkeyindex, const char* lpszSignerKeyKeyring);
QString GetSignerKeyKeyring(int iSignerKeyIndex);
int SetSignerKeyKeyring(int iSignerKeyIndex, QString qsSignerKeyKeyring);

Default Value

""

Remarks

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 property is set the class will read the keyring and populate the Key* properties with the first key found in the keyring. Set KeyUserId to select a different key in the current keyring.

The SignerKeyIndex parameter specifies the index of the item in the array. The size of the array is controlled by the SignerKeyCount property.

This property is not available at design time.

Data Type

String

SignerKeyUserId Property (OpenPGP Class)

The user Id of the key.

Syntax

ANSI (Cross Platform)
char* GetSignerKeyUserId(int iSignerKeyIndex);
int SetSignerKeyUserId(int iSignerKeyIndex, const char* lpszSignerKeyUserId); Unicode (Windows) LPWSTR GetSignerKeyUserId(INT iSignerKeyIndex);
INT SetSignerKeyUserId(INT iSignerKeyIndex, LPCWSTR lpszSignerKeyUserId);
char* ipworksencrypt_openpgp_getsignerkeyuserid(void* lpObj, int signerkeyindex);
int ipworksencrypt_openpgp_setsignerkeyuserid(void* lpObj, int signerkeyindex, const char* lpszSignerKeyUserId);
QString GetSignerKeyUserId(int iSignerKeyIndex);
int SetSignerKeyUserId(int iSignerKeyIndex, QString qsSignerKeyUserId);

Default Value

""

Remarks

The user Id of the key. When a key is loaded this property is populated with the user Id associated with the key. This property may be set to load a key from the Keyring. When this property 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 property 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 property and KeyOtherUserIds 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.

When using this property 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.

The SignerKeyIndex parameter specifies the index of the item in the array. The size of the array is controlled by the SignerKeyCount property.

This property is not available at design time.

Data Type

String

SigningAlgorithm Property (OpenPGP Class)

The signature hash algorithm used when signing.

Syntax

ANSI (Cross Platform)
char* GetSigningAlgorithm();
int SetSigningAlgorithm(const char* lpszSigningAlgorithm); Unicode (Windows) LPWSTR GetSigningAlgorithm();
INT SetSigningAlgorithm(LPCWSTR lpszSigningAlgorithm);
char* ipworksencrypt_openpgp_getsigningalgorithm(void* lpObj);
int ipworksencrypt_openpgp_setsigningalgorithm(void* lpObj, const char* lpszSigningAlgorithm);
QString GetSigningAlgorithm();
int SetSigningAlgorithm(QString qsSigningAlgorithm);

Default Value

"SHA256"

Remarks

This property specifies the signature hash algorithm used when signing. Possible values are:

  • SHA1
  • MD5
  • SHA256 (default)
  • SHA384
  • SHA512
  • SHA224
  • RIPEMD160

Data Type

String

Config Method (OpenPGP Class)

Sets or retrieves a configuration setting.

Syntax

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

Unicode (Windows)
LPWSTR Config(LPCWSTR lpszConfigurationString);
char* ipworksencrypt_openpgp_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.

Decrypt Method (OpenPGP Class)

Decrypts the message.

Syntax

ANSI (Cross Platform)
int Decrypt();

Unicode (Windows)
INT Decrypt();
int ipworksencrypt_openpgp_decrypt(void* lpObj);
int Decrypt();

Remarks

This method decrypts the specified message.

The message will be decrypted using the keys specified in the Key* properties. Before decryption begins the class will fire the RecipientInfo event with information about the encrypted message, including the key used to encrypt the message. Within this event you may use the available information to load the correct key into Keys.

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

DecryptAndVerifySignature Method (OpenPGP Class)

Decrypts and verifies the signature of the message.

Syntax

ANSI (Cross Platform)
int DecryptAndVerifySignature();

Unicode (Windows)
INT DecryptAndVerifySignature();
int ipworksencrypt_openpgp_decryptandverifysignature(void* lpObj);
int DecryptAndVerifySignature();

Remarks

This method attempts to both decrypt and verify the signature of the message. All of the properties affected by calling the Decrypt and VerifySignature methods are affected in the same manner.

This method may be used when the data is signed, encrypted, or signed and encrypted. For instance, if the data is encrypted but not signed you may still use this method and the class will perform the decryption without error.

The message will be decrypted using the keys specified in the Key* properties. Before decryption begins the class will fire the RecipientInfo event with information about the encrypted message, including the key used to encrypt the message. Within this event you may use the available information to load the correct key into Keys.

The message will be verified using the keys specified in the SignerKey* properties. Before verification begins the class will fire the SignatureInfo event with information about the signature including the key used to sign the message. Within this event you may use the information available to load the correct key into the SignerKey* properties.

By default, if the signature is not valid the class fails with an error. The configuration setting RequireValidSignature may be set to False to disable this requirement. When RequireValidSignature is set to False, the Status parameter of the VerificationStatus event should be checked to determine the result of the operation.

NOTE: This method does not attempt to check the validity of the signing key itself.

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

Encrypt Method (OpenPGP Class)

Encrypts the message.

Syntax

ANSI (Cross Platform)
int Encrypt();

Unicode (Windows)
INT Encrypt();
int ipworksencrypt_openpgp_encrypt(void* lpObj);
int Encrypt();

Remarks

This method encrypts the specified message.

The message is encrypted with the public keys specified in the RecipientKey* properties.

When encrypting, the following properties may be used to further configure the class:

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

GetRecipientInfo Method (OpenPGP Class)

Gets recipient information for an encrypted message.

Syntax

ANSI (Cross Platform)
int GetRecipientInfo();

Unicode (Windows)
INT GetRecipientInfo();
int ipworksencrypt_openpgp_getrecipientinfo(void* lpObj);
int GetRecipientInfo();

Remarks

This method will fire a RecipientInfo event for every recipient key for which the message has been encrypted. The event will provide the KeyId, which can be used to identify the correct key to be used for decryption.

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 (OpenPGP Class)

Resets the class properties.

Syntax

ANSI (Cross Platform)
int Reset();

Unicode (Windows)
INT Reset();
int ipworksencrypt_openpgp_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.)

SetInputStream Method (OpenPGP Class)

Sets the stream from which the class will read data to encrypt or decrypt.

Syntax

ANSI (Cross Platform)
int SetInputStream(IPWorksEncryptStream* sInputStream);

Unicode (Windows)
INT SetInputStream(IPWorksEncryptStream* sInputStream);
int ipworksencrypt_openpgp_setinputstream(void* lpObj, IPWorksEncryptStream* sInputStream);
int SetInputStream(IPWorksEncryptStream* sInputStream);

Remarks

This method sets the stream from which the class will read data to encrypt or decrypt. If an input stream is set before the class attempts to encode or decode an OpenPGP message, the data is read from the input stream instead of from the InputFile or InputMessage properties.

Encrypt and/or Sign

You can call this method to set the input stream that you would like to sign and/or encrypt. Then call Sign, Encrypt, or SignAndEncrypt to sign and/or encrypt the message. The appropriate ASCII Armor headers will be generated in MessageHeaders.

Decrypt and/or Verify

You can call this method to specify a valid input stream that contains the signed and/or encrypted data you would like to verify or decrypt. Then call VerifySignature, Decrypt, or DecryptAndVerifySignature to verify and/or decrypt the message.

The content of the stream will be read from the current position all the way to the end and no bytes will be skipped.

Input and Output Properties

The class will determine the source and destination of the input and output based on which properties are set.

The order in which the input properties are checked is as follows:

When a valid source is found the search stops. The order in which the output properties are checked is as follows:

When using streams you may need to additionally set CloseInputStreamAfterProcessing or CloseOutputStreamAfterProcessing.

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

SetOutputStream Method (OpenPGP Class)

The stream to which the class will write the fully encrypted or decrypted OpenPGP data.

Syntax

ANSI (Cross Platform)
int SetOutputStream(IPWorksEncryptStream* sOutputStream);

Unicode (Windows)
INT SetOutputStream(IPWorksEncryptStream* sOutputStream);
int ipworksencrypt_openpgp_setoutputstream(void* lpObj, IPWorksEncryptStream* sOutputStream);
int SetOutputStream(IPWorksEncryptStream* sOutputStream);

Remarks

This method sets the stream to which the class will write the fully encrypted or decrypted OpenPGP data. If an output stream is set before the class attempts to encode or decode an OpenPGP message, the class will write the data to the output stream instead of populating OutputMessage or writing to OutputFile.

Sign and/or Encrypt

To sign and/or encrypt a message to an output stream, you must first populate the Message property with the data you would like to sign and/or encrypt. Next, this method must be called with a valid output stream for which the class may write the signed or encrypted data. Then call Sign, Encrypt, or SignAndEncrypt to sign and/or encrypt the message. The appropriate ASCII Armor headers will be generated in MessageHeaders.

Decrypt and/or Verify

If you would like to decrypt a message or verify its signature and write the resulting message to an output stream, you should set the Message property to the signed and/or encrypted message you would like to verify or decrypt. Next, you must call this method to specify a valid stream for the component to write the data to. Then call VerifySignature, Decrypt, or DecryptAndVerifySignature to verify and/or decrypt the message.

Input and Output Properties

The class will determine the source and destination of the input and output based on which properties are set.

The order in which the input properties are checked is as follows:

When a valid source is found the search stops. The order in which the output properties are checked is as follows:

  • SetOutputStream
  • OutputFile
  • OutputMessage: The output data is written to this property if no other destination is specified.

When using streams you may need to additionally set CloseInputStreamAfterProcessing or CloseOutputStreamAfterProcessing.

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

Sign Method (OpenPGP Class)

Signs the message.

Syntax

ANSI (Cross Platform)
int Sign();

Unicode (Windows)
INT Sign();
int ipworksencrypt_openpgp_sign(void* lpObj);
int Sign();

Remarks

This method signs the specified message.

The message is signed with the private key specified in the Key* properties.

When signing, the following properties may be used to further configure the class:

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

SignAndEncrypt Method (OpenPGP Class)

Signs and encrypts the current message.

Syntax

ANSI (Cross Platform)
int SignAndEncrypt();

Unicode (Windows)
INT SignAndEncrypt();
int ipworksencrypt_openpgp_signandencrypt(void* lpObj);
int SignAndEncrypt();

Remarks

This method signs and encrypts the specified message.

The message is encrypted with the public keys specified in the RecipientKey* properties and signed with the private key specified in the Key* properties .

When encrypting, the following properties may be used to further configure the class:

When signing, the following properties may be used to further configure the class:

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

VerifySignature Method (OpenPGP Class)

Verifies the signature of the current message.

Syntax

ANSI (Cross Platform)
int VerifySignature();

Unicode (Windows)
INT VerifySignature();
int ipworksencrypt_openpgp_verifysignature(void* lpObj);
int VerifySignature();

Remarks

This method verifies the signature of the message.

The message will be verified using the keys specified in the SignerKey* properties. Before verification begins the class will fire the SignatureInfo event with information about the signature including the key used to sign the message. Within this event you may use the information available to load the correct key into the SignerKey* properties.

By default, if the signature is not valid the class fails with an error. The configuration setting RequireValidSignature may be set to False to disable this requirement. When RequireValidSignature is set to False, the Status parameter of the VerificationStatus event should be checked to determine the result of the operation.

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

Error Event (OpenPGP Class)

Information about errors during data delivery.

Syntax

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

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

  const QString &Description();

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

Remarks

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

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

KeyPassphrase Event (OpenPGP Class)

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

Syntax

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

virtual INT IPWORKSENCRYPT_CALL FireKeyPassphrase(LPSTR &lpszUserId, LPSTR &lpszKeyId, LPSTR &lpszPassphrase);
class OpenPGPKeyPassphraseEventParams {
public:
  const QString &UserId();

  const QString &KeyId();

  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(OpenPGPKeyPassphraseEventParams *e);
// Or, subclass OpenPGP and override this emitter function. virtual int FireKeyPassphrase(OpenPGPKeyPassphraseEventParams *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 KeyPassphrase property before attempting the operation.

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:

Progress Event (OpenPGP Class)

Fired as progress is made.

Syntax

ANSI (Cross Platform)
virtual int FireProgress(OpenPGPProgressEventParams *e);
typedef struct {
int64 BytesProcessed;
int PercentProcessed;
int Operation;
int IsEOF; int reserved; } OpenPGPProgressEventParams;
Unicode (Windows) virtual INT FireProgress(OpenPGPProgressEventParams *e);
typedef struct {
LONG64 BytesProcessed;
INT PercentProcessed;
INT Operation;
BOOL IsEOF; INT reserved; } OpenPGPProgressEventParams;
#define EID_OPENPGP_PROGRESS 3

virtual INT IPWORKSENCRYPT_CALL FireProgress(LONG64 &lBytesProcessed, INT &iPercentProcessed, INT &iOperation, BOOL &bIsEOF);
class OpenPGPProgressEventParams {
public:
  qint64 BytesProcessed();

  int PercentProcessed();

  int Operation();

  bool IsEOF();
  void SetIsEOF(bool bIsEOF);

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

Remarks

This event is fired automatically as data is processed by the class.

The PercentProcessed parameter indicates the current status of the operation.

The BytesProcessed parameter holds the total number of bytes processed so far.

The Operation parameter is only applicable when either ReadFromProgressEvent or WriteToProgressEvent is set to True. This parameter defines whether a Read or Write operation is required. If the configuration settings are not set this parameter will always return 0. Possible values are:

0None
1Read
2Write

The IsEOF parameter is only applicable when either ReadFromProgressEvent or WriteToProgressEvent is set to True. This parameter defines whether the Read or Write operation is complete. When the Operation is Read (1) this parameter must be set to indicate that all data has been supplied to the class. When the Operation is Write (2) this value may be queried to determine when all data has been processed.

RecipientInfo Event (OpenPGP Class)

Fired for each recipient key of the encrypted message.

Syntax

ANSI (Cross Platform)
virtual int FireRecipientInfo(OpenPGPRecipientInfoEventParams *e);
typedef struct {
const char *KeyId;
const char *PublicKeyAlgorithm; int reserved; } OpenPGPRecipientInfoEventParams;
Unicode (Windows) virtual INT FireRecipientInfo(OpenPGPRecipientInfoEventParams *e);
typedef struct {
LPCWSTR KeyId;
LPCWSTR PublicKeyAlgorithm; INT reserved; } OpenPGPRecipientInfoEventParams;
#define EID_OPENPGP_RECIPIENTINFO 4

virtual INT IPWORKSENCRYPT_CALL FireRecipientInfo(LPSTR &lpszKeyId, LPSTR &lpszPublicKeyAlgorithm);
class OpenPGPRecipientInfoEventParams {
public:
  const QString &KeyId();

  const QString &PublicKeyAlgorithm();

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

Remarks

This event fires when the Decrypt or DecryptAndVerifySignature method is called.

KeyId is the Id of the key used to encrypt the message. If a subkey was used to encrypt the message this will be the Id of that subkey. It is the hex-encoded, 4- or 8-byte Id of the key. It is the same as the last 4 or 8 bytes of the fingerprint. For instance:

BF52A0AB
This can be used to identify the correct key to specify in Keys. Keys can be set from within this event as this event fires directly before the decryption process begins.

SignatureInfo Event (OpenPGP Class)

Fired during verification of the signed message.

Syntax

ANSI (Cross Platform)
virtual int FireSignatureInfo(OpenPGPSignatureInfoEventParams *e);
typedef struct {
const char *KeyId;
const char *SigningAlgorithm;
const char *PublicKeyAlgorithm; int reserved; } OpenPGPSignatureInfoEventParams;
Unicode (Windows) virtual INT FireSignatureInfo(OpenPGPSignatureInfoEventParams *e);
typedef struct {
LPCWSTR KeyId;
LPCWSTR SigningAlgorithm;
LPCWSTR PublicKeyAlgorithm; INT reserved; } OpenPGPSignatureInfoEventParams;
#define EID_OPENPGP_SIGNATUREINFO 5

virtual INT IPWORKSENCRYPT_CALL FireSignatureInfo(LPSTR &lpszKeyId, LPSTR &lpszSigningAlgorithm, LPSTR &lpszPublicKeyAlgorithm);
class OpenPGPSignatureInfoEventParams {
public:
  const QString &KeyId();

  const QString &SigningAlgorithm();

  const QString &PublicKeyAlgorithm();

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

Remarks

This event fires when the VerifySignature or DecryptAndVerifySignature method is called. It provides information about the signature of the message.

KeyId is the Id of the key used to sign the message. If a subkey was used to sign the message this will be the Id of that subkey. It is the hex-encoded, 4- or 8-byte Id of the key. It is the same as the last 4 or 8 bytes of the Fingerprint. For instance:

BF52A0AB
This can be used to identify the correct key to specify in the SignerKey* properties. This property can be set from within this event as this event fires directly before the verification process begins.

SigningAlgorithm describes the hash algorithm used when the message was originally signed. This value is applicable only to the message signature, not the key used to sign the message. Possible values are:

  • SHA1
  • SHA256
  • SHA384
  • SHA512
  • SHA224
  • MD5

PublicKeyAlgorithm is the algorithm of the public key used to sign the message. Possible values are:

  • RSA
  • DSA
  • ECDSA
  • EdDSA

Status Event (OpenPGP Class)

Shows the progress of the operation.

Syntax

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

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

  int EventRetVal();
  void SetEventRetVal(int iRetVal);
};
// To handle, connect one or more slots to this signal. void Status(OpenPGPStatusEventParams *e);
// Or, subclass OpenPGP and override this emitter function. virtual int FireStatus(OpenPGPStatusEventParams *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.

VerificationStatus Event (OpenPGP Class)

Fired after verification of the signed message.

Syntax

ANSI (Cross Platform)
virtual int FireVerificationStatus(OpenPGPVerificationStatusEventParams *e);
typedef struct {
const char *KeyId;
int Status; int reserved; } OpenPGPVerificationStatusEventParams;
Unicode (Windows) virtual INT FireVerificationStatus(OpenPGPVerificationStatusEventParams *e);
typedef struct {
LPCWSTR KeyId;
INT Status; INT reserved; } OpenPGPVerificationStatusEventParams;
#define EID_OPENPGP_VERIFICATIONSTATUS 7

virtual INT IPWORKSENCRYPT_CALL FireVerificationStatus(LPSTR &lpszKeyId, INT &iStatus);
class OpenPGPVerificationStatusEventParams {
public:
  const QString &KeyId();

  int Status();

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

Remarks

This event fires when VerifySignature or DecryptAndVerifySignature is called. It provides information about the result.

KeyId is the Id of the key used to sign the message. It is the hex-encoded, 4-or 8-byte Id of the key. It is the same as the last 4 or 8 bytes of the Fingerprint. For instance:

BF52A0AB

Status holds the result of the operation. Possible values are:

0Verification succeeded
1Verification failed
2The required key could not be found
3Verification succeeded but the key is expired.

IPWorksEncryptStream Type

Syntax

IPWorksEncryptStream (declared in ipworksencrypt.h)

Remarks

The OpenPGP class includes one or more API members that take a stream object as a parameter. To use such API members, create a concrete class that implements the IPWorksEncryptStream interface and pass the OpenPGP class an instance of that concrete class.

When implementing the IPWorksEncryptStream interface's properties and methods, they must behave as described below. If the concrete class's implementation does not behave as expected, undefined behavior may occur.

Properties

CanRead Whether the stream supports reading.

bool CanRead() { return true; }
CanSeek Whether the stream supports seeking.

bool CanSeek() { return true; }
CanWrite Whether the stream supports writing.

bool CanWrite() { return true; }
Length Gets the length of the stream, in bytes.

int64 GetLength() = 0;

Methods

Close Closes the stream, releasing all resources currently allocated for it.

void Close() {}

This method is called automatically when an IPWorksEncryptStream object is deleted.

Flush Forces all data held by the stream's buffers to be written out to storage.

int Flush() { return 0; }

Must return 0 if flushing is successful; or -1 if an error occurs or the stream is closed. If the stream does not support writing, this method must do nothing and return 0.

Read Reads a sequence of bytes from the stream and advances the current position within the stream by the number of bytes read.

int Read(void* buffer, int count) = 0;

Buffer specifies the buffer to populate with data from the stream. Count specifies the number of bytes that should be read from the stream.

Must return the total number of bytes read into Buffer; this may be less than Count if that many bytes are not currently available, or 0 if the end of the stream has been reached. Must return -1 if an error occurs, if reading is not supported, or if the stream is closed.

Seek Sets the current position within the stream based on a particular point of origin.

int64 Seek(int64 offset, int seekOrigin) = 0;

Offset specifies the offset in the stream to seek to, relative to SeekOrigin. Valid values for SeekOrigin are:

  • 0: Seek from beginning.
  • 1: Seek from current position.
  • 2: Seek from end.

Must return the new position within the stream; or -1 if an error occurs, if seeking is not supported, or if the stream is closed (however, see note below). If -1 is returned, the current position within the stream must remain unchanged.

Note: If the stream is not closed, it must always be possible to call this method with an Offset of 0 and a SeekOrigin of 1 to obtain the current position within the stream, even if seeking is not otherwise supported.

Write Writes a sequence of bytes to the stream and advances the current position within the stream by the number of bytes written.

int Write(const void* buffer, int count) = 0;

Buffer specifies the buffer with data to write to the stream. Count specifies the number of bytes that should be written to the stream.

Must return the total number of bytes written to the stream; this may be less than Count if that many bytes could not be written. Must return -1 if an error occurs, if writing is not supported, or if the stream is closed.

Config Settings (OpenPGP 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.

OpenPGP Config Settings

AllowEmptyInput:   Whether to allow empty files for input.

This setting controls whether the class allows empty input when processing. When True, the class will process 0 byte files specified by InputFile, or 0 byte messages specified by InputMessage. The default value is False.

AllowOldPacketType:   Whether to allow the older encrypted packet type.

By default the class will only encrypt data using the newer and more secure integrity protected data packet type. Old implementations such as PGP 6.5.8 may require the older less secure data packet type.

When set to True the class will read the features from the recipient key to determine if the older packet type is required. If the key does require the old packet type, then the older packet type will be used. If the key does not require the old packet type, then the new integrity protected packet type will still be used.

By default this value is False. This means under no conditions is the older less secure packet type used. The newer integrity protected packet type is always used.

Only enable this setting if you have a requirement to do so.

CloseInputStreamAfterProcessing:   Determines whether or not the input stream is closed after processing.

Determines whether or not the input stream set by SetInputStream is closed after processing is complete. The default value is True.

CloseOutputStreamAfterProcessing:   Determines whether or not the output stream is closed after processing.

Determines whether or not the output stream set by SetOutputStream is closed after processing is complete. The default value is True.

CompressionLevel:   The level of compression used.

This setting specifies the level of compression used: possible values depend on the value of CompressionMethod and are detailed below.

zlib 1-6
zip 1-6
bzip21-9
Higher values will cause the class to compress better; lower values will cause the class to compress faster. The default value for all methods is 4.
DeleteOutputFileOnError:   Whether to delete the output file on an error.

Set this to true to automatically delete any partially written OutputFile if an error occurs. The default is false

DetachedSignatureData:   The detached signature.

This setting is used to specify the detached signature before calling VerifySignature. The message data should be specified normally and this setting should be set to the detached signature data. Both hex-string and OpenPGP ASCII-armored message formats are allowed. Hex-encoded data should be provided as a string like so:

89011C04000102000605025100459B000A0910E2...
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 KeyCurve 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

FileName:   The original name of the encrypted file.

When encrypting, this configuration setting can be used to specify the original name of the encrypted data. When specifying an InputFile to encrypt from, this is included automatically in the encrypted packet. After decrypting, this will contain the file name of the original encrypted file.

KeyIdLength:   The length of the KeyId available.

This controls the length of KeyId available when RecipientInfo fires. Possible values are 4 (default) or 8.

KeySelectionMethod:   The method used to select a key for encryption or signing.

When more than one key is present this class can be configured to automatically select a key based on certain criteria (described below) or allow for manual selection.

0 Automatic selection, first suitable subkey. Expired keys accepted.
1 Automatic selection, first suitable subkey. Expired keys not accepted.
2 Automatic selection, newest suitable subkey. Expired keys not accepted (Default).
99 Manual Selection.
A key's suitability is determined by its usage flags.

Manual Selection

To manually select a key for any operation pass the key's Id in the constructor. Openpgp pgp = new Openpgp(); pgp.Config("KeySelectionMethod=99"); pgp.RecipientKeys.Add(new Key(@"C:\path\to\key.asc", "7CA1376C39768977")); // Key with Id 7CA1376C39768977 will be used for encryption.

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.
PGPZipDir:   The directory used when creating or extracting a PGP zip file.

A PGP zip file is a Tar archive that is encrypted. It is commonly used by utilities to protect multiple files in one OpenPGP message. The class supports creating and extracting these types of files.

  • To create a PGP zip file set this value to a location on disk including a filemask and call Encrypt. For instance: OpenPGP1.Config("PGPZipDir=C:\MyFiles\*.txt"); OpenPGP1.OutputFile = "C:\PGPZip.pgp"; OpenPGP1.Encrypt(); The created file returned in the OutputFile property is the PGP zip. If InputFile is specified it is used to temporarily hold the Tar archive while creating the PGP zip file. The temporary file is not automatically deleted. If InputFile is not specified the Tar archive is held in memory while creating the PGP zip file.
  • To extract a PGP zip file set this value to a location on disk and call Decrypt. For instance: OpenPGP1.Config("PGPZipDir=C:\MyFiles"); OpenPGP1.InputFile = "C:\PGPZip.pgp"; OpenPGP1.Decrypt(); The extracted files will be present in the specified directory. If OutputFile is specified it is used to temporarily hold the Tar archive. The temporary file is not automatically deleted. If OutputFile is not specified the Tar archive is held in memory while extracting the PGP zip file. Note that if the OpenPGP message supplied is not a PGP zip file the decryption will occur as normal without error.

ProgressEventThreshold:   The amount of data in bytes to process before firing the progress event.

When encrypting or decrypting, the Progress event is fired as data is processed by the class. When this setting is specified, the event will only fire after processing at least the specified number of bytes. The default value is 0.

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.

ReadFromProgressEvent:   Whether to read input data from inside the progress event.

When set to True this setting allows input data to be specified from within the Progress event. The class will repeatedly fire the Progress event to ask for data. Inside the event set InputMessage when the Operation parameter of the event is 1 (Read). When all data has been provided set the IsEOF parameter of the event to True. This allows input data to be chunked and provided piece by piece. The default value is False.

RecursiveDecryptMode:   Whether the encrypted data should be decrypted recursively.

In some instances data will be encrypted multiple times. This configuration option determines how the class will handle this situation. Options are:

0Automatic - If the PGP message contains the special header version "PGP Command Line" then recursive decryption will be attempted. (Default)
1Always attempt recursive decryption.
2Never attempt recursive decryption.
RequireEncryption:   Whether to throw an error when decrypting and encryption is not detected.

By default, the component's decryption methods will succeed if the message is not encrypted. To cause an error to be thrown in this case, set this option to true.

The default value is false.

RequireIntegrityProtectedPacket:   Whether an MDC packet is required for decryption.

When set to true, the class will throw an exception if the message being decrypted does not contain a Message Detection Code (MDC) packet. The default value is false.

RequireSignature:   Whether to throw an error when verifying a signature and no signature is found.

By default, the component's signature verification methods will succeed if the message is not signed. To cause an error to be thrown in this case, set this option to true.

The default value is false.

RequireValidSignature:   Specifies if an invalid signature is considered an error condition.

By default, if the signature is not valid the class fails with an error. This setting may be set to False to disable this requirement. When False, the Status parameter of the VerificationStatus event should be checked to determine the result of the operation. The default value is True.

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.

SplitHeaders:   Controls whether ASCII Armor headers are split or not.

By default, when headers are specified via MessageHeaders, the class will split headers over a certain length onto multiple lines. This is done to avoid potential errors during transport of the message. If false, the headers will be on one line regardless of length. The default value is True.

SymmetricPassphrase:   The password used for symmetric encryption or decryption.

This setting specifies the passphrase when using symmetric encryption. If a value is provided, symmetric encryption/decryption will be attempted. In this case no keys are used for either encryption or decryption. Only Encrypt and Decrypt are valid operations when a value is set. Sign, SignAndEncrypt, VerifySignature, and DecryptAndVerifySignature are not valid operations when using this option.

UseFipsCompliantAlgorithms:   Restricts the usage to FIPS compliant algorithms only.

When enabled the class will only support FIPS compliant algorithms. If a non-FIPS compliant algorithm is used an exception is thrown. The following algorithms are supported when this setting is True:

  • 3DES
  • AES128
  • AES192
  • AES256
  • RSA
  • DSA
  • SHA1
  • SHA256
  • SHA384
  • SHA512
  • SHA224
The default value is False.
UsePlatformAES:   Whether to use the platform AES implementation.

By default class will use an internal implementation to perform AES. This is more self-contained and managed. In certain scenarios it may be better to use the platform's implementation. Set this to true to perform AES using the platform implementation. This is only available on Unix. The default is false.

VersionHeader:   The Version header value in the ASCII armored OpenPGP message.

This setting specifies the Version header value included in the ASCII armored OpenPGP message. This may be set before calling Encrypt, Sign, or SignAndEncrypt. The default value is "IPWorks! OpenPGP 2022".

This setting will be populated after calling Decrypt, VerifySignature, or DecryptAndVerifySignature.

WriteToProgressEvent:   Whether to write output data so it is accessible from inside the progress event.

When set to True this setting allows output data to be obtained from within the Progress event. The class will repeatedly fire the Progress event to provide output data. Inside the event check OutputMessage when the Operation parameter of the event is 2 (Write). The IsEOF parameter should be checked inside the event to determine when all output data has been provided. This allows output data to be chunked and obtained piece by piece. The default value is False.

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.
MaskSensitive:   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.

UseInternalSecurityAPI:   Tells the class 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 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 (OpenPGP 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.