PGP scripts written before v8.12
Syncplify Server! v8.12.0 replaced the OpenPGP engine of SyncJS. The five original calls keep their signatures and their return values, so existing scripts need no change:
function GeneratePGPKeys(keyPairName: string, directory: string, bits: number): boolean;
function PGPEncryptFile(inFile: string, outFile: string, pubKeyFile: string): boolean;
function PGPDecryptFile(inFile: string, outFile: string, privKeyFile: string): boolean;
function PGPSignFile(inFile: string, sigFile: string, pubKeyFile: string, privKeyFile: string): boolean;
function PGPVerifyFile(inFile: string, sigFile: string, pubKeyFile: string): boolean;Keys, messages and signatures written by earlier versions still load, decrypt and verify.
What behaves differently
- Keys and messages from other software now work. Earlier versions could not encrypt to a key exported by GnuPG, could not decrypt what GnuPG produced, and did not verify signatures made with a signing subkey.
GeneratePGPKeyswrites keys that GnuPG can import. The file names are the same, and the key pair name becomes the user ID of the key. Versions before v8.12 can still use these keys.- Old keys encrypt again at any age. Earlier versions stopped encrypting to a key made by
GeneratePGPKeysone year after its creation. - Output files are written only on success. A failed decryption leaves no output file, and a file that already exists at that path is left untouched. Writing the output onto the input file is now safe.
- A key file that holds several keys is read as before: the first key is used. A warning is now logged, because which key comes first is not always obvious.
PGPKey.FromFilerefuses such a file instead. - Keys without key usage flags, which some older tools write, work for everything their algorithm allows, as in GnuPG.
- A fourth argument to
PGPEncryptFileorPGPDecryptFileis now the options object. Earlier versions ignored extra arguments. A value such asfalse,0or""is still ignored, with a warning in the log; any other value that is not an object throws. - Failures explain themselves.
PGPLastResult().ErrorMsg()tells why a call returnedfalse.
The armor header
Encrypted output now starts with the standard -----BEGIN PGP MESSAGE----- line, which GnuPG and all other OpenPGP software require. Versions before v8.12 wrote -----BEGIN Message-----, which only Syncplify software reads, and they do not read the standard line.
Nothing breaks, because:
- Both headers are accepted on input.
- When every recipient key is a legacy key, which is a key that
GeneratePGPKeyswrote before v8.12, the output keeps the old header. Whoever holds such a key receives exactly what they always did.
One case needs your attention: a receiver that still runs a version before v8.12, with a key made by v8.12 or later. Pass LegacyArmor for that receiver:
PGPEncryptFile("/data/out/payroll.csv", "/data/out/payroll.csv.pgp",
"/data/keys/partner-exchange.pubkey", { LegacyArmor: true });{ LegacyArmor: false } does the opposite and always writes the standard header.
Legacy keys
A key that GeneratePGPKeys wrote before v8.12 keeps working in SyncJS, but GnuPG and other OpenPGP software cannot import it. The IsLegacy property of a key object tells them apart:
var key = PGPKey.FromFile("/data/keys/old-exchange.pubkey");
if (key.IsLegacy) {
Log.Warn("this key predates v8.12: other OpenPGP software cannot import it");
}To exchange files with a partner who does not use Syncplify software, create a new key with PGPKey.Generate and send them its public half.
