-
I'm having some issues getting GPG keys generated with gpg4win to correctly encrypt a binary (without a signature). It seems at some stage recently, GPG keys that were generated with this software do not appear to work, and I am completely lost as to what might be causing it. To further confuse matters, older keys (generated around about 2021) seem to work perfectly fine, even from the exact same software. The key was generated today using gpg4win (Kleopatra) with all of the default GUI options (as
My code: const openpgp_keys = await Promise.all(raw_pgp_keys.map(armoredKey => openpgp.readKey({ armoredKey })));
const rawFileContents = new Uint8Array(await file.arrayBuffer());
const fileToEncrypt = await openpgp.createMessage({binary: rawFileContents, filename: file.name});
const encryptionOperation = await openpgp.encrypt({
message: fileToEncrypt,
encryptionKeys: openpgp_keys,
format: 'binary',
config: { preferredCompressionAlgorithm: openpgp.enums.compression.zip }
}); I get the following error (this occurs at the point I run
Using this key with desktop software appears to work perfectly fine, the issue looks to be exclusive to OpenPGP.js. I have no idea what could be causing this, but it feels very much like it could be a bug given this is not a complicated operation, older keys work perfectly fine, and I'm using defaults from popular software (unless I'm missing a Happy to supply further details if needed! I'm rather desperate for an idea as to what might be wrong... |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 4 replies
-
If it helps, I compared the
The Windows-generated key does not work, but the macOS generated key does work. Just a hunch, could this have something to do with AEAD? |
Beta Was this translation helpful? Give feedback.
-
Hi @TCFox , I can encrypt fine using the key and code you posted, can you confirm this is the key that gives issues to you? |
Beta Was this translation helpful? Give feedback.
-
I'm converting this to a discussion for now. Feel free to provide more details and we can review whether it is actually an issue on our side :) |
Beta Was this translation helpful? Give feedback.
-
After a lot of rather lengthy investigation, it turns out this was due to a very subtle bug in a different library further upstream in our project, which was corrupting our PGP keys in extremely subtle ways. Didn't have anything to do with OpenPGP.js in the end. Thanks for looking into it though! |
Beta Was this translation helpful? Give feedback.
Hi @TCFox , I can encrypt fine using the key and code you posted, can you confirm this is the key that gives issues to you?