mirror of
https://github.com/openpgpjs/openpgpjs.git
synced 2025-11-24 06:25:50 +00:00
27 lines
652 B
JavaScript
27 lines
652 B
JavaScript
import { FuzzedDataProvider } from '@jazzer.js/core';
|
|
|
|
import { generateKey } from 'openpgp';
|
|
|
|
const MAX_NAME_LENGTH = 30;
|
|
const MAX_COMMENT_LENGTH = 500;
|
|
|
|
/**
|
|
* @param { Buffer } inputData
|
|
*/
|
|
export function fuzz (inputData) {
|
|
|
|
const data = new FuzzedDataProvider(inputData);
|
|
const asciiString = data.consumeString(MAX_COMMENT_LENGTH);
|
|
const utf8String = data.consumeString(MAX_NAME_LENGTH, 'utf-8');
|
|
|
|
return generateKey({ userIDs: [
|
|
{ name: utf8String },
|
|
{ email: utf8String },
|
|
{ comment: asciiString },
|
|
{ name: utf8String, email: utf8String, comment: asciiString }
|
|
],
|
|
passphrase: asciiString,
|
|
format: 'object' });
|
|
}
|
|
|