PALATINELABSDocsENES

Pages

↑↓ to moveEnter to openEsc to close

PGP package guide

Use PGP to generate OpenPGP keys, encrypt and decrypt files, and create or verify detached signatures.

Version 2.17.1. Installed versions can differ. Examples are illustrative and not tested.

Jump to actions

Packages

Prerequisites

The examples form one flow: generate keys, encrypt and decrypt, then sign and verify.

Shared fields

FieldEditor fieldType; default; required/optionalUse
inputFilePathSource fileStringdefault ""requiredExisting input file, such as samples/message.txt⁠. Full path or relative to the Run folder.
outputFilePathDestination file (Sign: Signature file)Stringdefault ""requiredOutput file. It must differ from every input and key file.
keyFilePathPrivate key file (Decrypt, Sign) or Public key file (Encrypt, Verify)Stringdefault ""requiredPrivate key (Decrypt, Sign) or public key (Encrypt, Verify), as text or binary. If the file holds several keys, Decrypt uses the key the message was encrypted for, Encrypt and Sign use the first usable key, and Verify uses the signer's key.
passphrasePassphraseCredentialdefault empty CredentialoptionalCredential whose password protects the private key, or the new key in Generate key pair. The username is ignored. An empty password fails.
armorASCII armor the outputBooleandefault trueoptionaltrue writes text you can open in an editor (armored); false writes binary. Decrypt and Verify read both.
OutputEditor fieldType and use
fileDecrypted file⁠, Encrypted file or Signature fileFile value with the full path of the file written.

Actions

Decrypt file (pgpDecrypt)

Decrypt a text or binary OpenPGP message with the matching private key. The action checks that the file was not changed before it writes the output.

Inputs

Uses the shared fields: inputFilePath, outputFilePath, keyFilePath and passphrase.

Outputs

The shared file output (Decrypted file).

Example

First encrypt samples/message.txt with the sample public key. Set inputFilePath=samples/message.pgp, outputFilePath=samples/recovered.txt, keyFilePath=samples/keys/private.asc, passphrase=$keyPass$; bind file to recovered.

Expected result

recovered.txt has the same content as the original message. A wrong password or no matching private key fails. If the file was changed, the action fails and writes nothing.

Back to actions

Encrypt file (pgpEncrypt)

Encrypt a file with the receiver's public key (AES-256). Only the matching private key can open it.

Inputs

Uses the shared fields: inputFilePath, outputFilePath, keyFilePath and armor.

Outputs

The shared file output (Encrypted file).

Example

Use the sample public key from Generate key pair and prepare samples/message.txt containing sample message. Set inputFilePath=samples/message.txt, outputFilePath=samples/message.pgp, keyFilePath=samples/keys/public.asc, armor=true; bind file to encrypted.

Expected result

samples/message.pgp holds an armored encrypted message, not the original text. encrypted is its full File path. A missing input file, or a key file without an encryption key, fails.

Public-key encryption from message.txt to message.pgp, then private-key decryption to recovered.txt.
In this example, encrypt with public.asc. Decrypt with the matching private.asc and its passphrase. View full size

Back to actions

Generate key pair (pgpGenerateKeys)

Generate an armored RSA OpenPGP key pair. Test with a sample pair before you encrypt or sign real files.

Inputs

InputEditor fieldType; default; required/optionalUse
identityIdentityStringdefault ""optionalName written into the key, such as Training Key⁠. Must not be empty, although the editor does not mark it required. It shows in the Run log.
keySizeKey sizeNumberdefault 2048optionalRSA size in bits, at least 2048⁠. Use 2048 for the sample pair.
publicKeyFilePathPublic key fileStringdefault ""requiredOutput for the public key, such as samples/keys/public.asc⁠. Use a different path from the private key.
privateKeyFilePathPrivate key fileStringdefault ""requiredOutput for the password-protected private key, such as samples/keys/private.asc⁠. Restrict access to this file.

Also uses the shared fields: passphrase.

Outputs

OutputEditor fieldType and use
publicKeyPublic key fileFile value with the full path of the public key file.
privateKeyPrivate key fileFile value with the full path of the private key file.

Example

Create Credential variable keyPass with a sample password that is not empty, entered securely. Set identity=Training Key, passphrase=$keyPass$, keySize=2048, publicKeyFilePath=samples/keys/public.asc, privateKeyFilePath=samples/keys/private.asc. Bind outputs to publicKey and privateKey.

Expected result

The public file starts with -----BEGIN PGP PUBLIC KEY BLOCK-----; the private file starts with -----BEGIN PGP PRIVATE KEY BLOCK-----. An empty identity or password, or a key size below 2048, fails before any key is made.

Back to actions

Sign file (pgpSign)

Write a separate signature file (SHA-256) for the whole file. The file does not change.

Inputs

Uses the shared fields: inputFilePath, outputFilePath, keyFilePath, passphrase and armor.

Outputs

The shared file output (Signature file).

Example

Prepare samples/message.txt and the sample private key. Set inputFilePath=samples/message.txt, outputFilePath=samples/message.sig, keyFilePath=samples/keys/private.asc, passphrase=$keyPass$, armor=true; bind file to signature.

Expected result

message.sig starts with -----BEGIN PGP SIGNATURE-----. A wrong password or a key file without a signing key fails.

Back to actions

Verify signature (pgpVerify)

Check that the file matches its signature and that the signer's key is still valid. Only the first signature in the signature file is checked.

Inputs

InputEditor fieldType; default; required/optionalUse
signatureFilePathSignature fileStringdefault ""requiredExisting signature file, text or binary, made for exactly this file.

Also uses the shared fields: inputFilePath and keyFilePath.

Outputs

OutputEditor fieldType and use
resultAssign the output to an existing variableBoolean, for use in a branch. true means the file matches the signature and the key is valid.

Example

Sign samples/message.txt with the sample pair first. Set inputFilePath=samples/message.txt, signatureFilePath=samples/message.sig, keyFilePath=samples/keys/public.asc; bind result to Boolean valid.

Expected result

valid=true for the unchanged file and a valid key. A changed file, an unknown signer, or a key that is expired, revoked or dated in the future gives false. A missing or damaged file fails instead of giving false. true does not prove who owns the key.

Back to actions