I'm currently using [email protected] and base on logs and I'm getting an error "Unexpected packet type 6" on this part of my code "let privKeyObj = await openpgp.readPrivateKey({ armoredKey: privKey });".
I read the documentation and tried the available config and parameters as well but none of it solves my issue.
For the test file I'm trying to decrypt, here's the link https://drive.google.com/file/d/18oCuPZjQUBxmAD22VDD7FHKVXvjBwbUj/view?usp=sharing
For the private key, here's the link https://drive.google.com/file/d/1_X-hcmncKWf4GqqxRltdD4Avl7bsm3pd/view?usp=sharing
async function decryptV5 (buffer, allowUnauthenticatedMessages = false) {
const passphrase = 'pgwadmin'
let privKeyObj = await openpgp.readPrivateKey({ armoredKey: privKey });
if (passphrase) {
privKeyObj = await openpgp.decryptKey({
privateKey: privKeyObj,
passphrase,
});
}
// True if buffer starts with -----BEGIN PGP MESSAGE-----
const isEncryptedString = isEncryptedStringFunc(buffer);
const messageOption = {};
if (isEncryptedString) messageOption.armoredMessage = buffer.toString();
else messageOption.binaryMessage = buffer;
const message = await openpgp.readMessage(messageOption);
const option = {
message,
decryptionKeys: privKeyObj,
format: "binary",
};
if (allowUnauthenticatedMessages)
option.config = { allowUnauthenticatedMessages };
return new Promise((resolve, reject) => {
openpgp
.decrypt(option)
.then((result) => {
if (isEncryptedString) {
const toBuffer = Buffer.from(result.data);
resolve({ ...result, data: toBuffer });
}
resolve(result);
})
.catch((err) => {
console.log("ERRERRERRERRERRERR", err.message);
reject(err);
});
});
};