mirror of
https://github.com/openpgpjs/openpgpjs.git
synced 2025-11-24 14:35:51 +00:00
since coverage does not work as expected at all, we can use esm. So if jazzer at some point, add esm support for esm, we can easily add it
23 lines
603 B
JavaScript
23 lines
603 B
JavaScript
import openpgp from '../initOpenpgp.js';
|
|
|
|
const ignored = ['This message / key probably does not conform to a valid OpenPGP format'];
|
|
|
|
function ignoredError(error) {
|
|
return ignored.some(message => error.message.includes(message));
|
|
}
|
|
|
|
/**
|
|
* @param { Buffer } inputData
|
|
*/
|
|
export function fuzz (inputData) {
|
|
const binaryMessage = new Uint8Array(`-----BEGIN PGP MESSAGE-----\n ${inputData.toString('base64')} -----END PGP MESSAGE-----`);
|
|
|
|
return openpgp.readMessage({ binaryMessage })
|
|
.catch(error => {
|
|
if (error.message && !ignoredError(error)) {
|
|
throw error;
|
|
}
|
|
});
|
|
}
|
|
|