forked from openpgpjs/openpgpjs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
155 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
node_modules/ | ||
npm* | ||
test/lib/ | ||
test/typescript/definitions.js | ||
dist/ | ||
openpgp.store/ | ||
coverage | ||
test/fuzz/reports |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const { FuzzedDataProvider } = require('@jazzer.js/core'); | ||
|
||
/** | ||
* @param { Buffer } inputData | ||
*/ | ||
module.exports.fuzz = function(inputData) { | ||
import('../initOpenpgp.js').then(openpgp => { | ||
const data = new FuzzedDataProvider(inputData); | ||
const text = data.bufToPrintableString(inputData, 2, 444, 'utf-8'); | ||
return openpgp.default.createCleartextMessage({ text }); | ||
}); | ||
|
||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/** | ||
* @param { Buffer } inputData | ||
*/ | ||
module.exports.fuzz = function(inputData) { | ||
import('../initOpenpgp.js').then(openpgp => { | ||
return openpgp.default.createMessage({ binary: new Uint8Array(inputData) }); | ||
}); | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
const { FuzzedDataProvider } = require('@jazzer.js/core'); | ||
|
||
/** | ||
* @param { Buffer } inputData | ||
*/ | ||
module.exports.fuzz = function(inputData) { | ||
import('../initOpenpgp.js').then(openpgp => { | ||
const data = new FuzzedDataProvider(inputData); | ||
return openpgp.default.createMessage({ text: data.consumeString(444, 'utf-8') }); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const { FuzzedDataProvider } = require('@jazzer.js/core'); | ||
|
||
/** | ||
* @param { Buffer } inputData | ||
*/ | ||
module.exports.fuzz = function(inputData) { | ||
import('../initOpenpgp.js').then(openpgp => { | ||
const data = new FuzzedDataProvider(inputData); | ||
const asciiString = data.consumeString(111); | ||
const utf8String = data.consumeString(33, 'utf-8'); | ||
|
||
return openpgp.default.generateKey({ userIDs: [ | ||
{ name: utf8String }, | ||
{ email: utf8String }, | ||
{ comment: asciiString }, | ||
{ name: utf8String, email: utf8String, comment: asciiString } | ||
], | ||
passphrase: asciiString, | ||
format: 'object' }); | ||
}); | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const { FuzzedDataProvider } = require('@jazzer.js/core'); | ||
|
||
const ignored = ['Misformed armored text']; | ||
|
||
function ignoredError(error) { | ||
return ignored.some(message => error.message.includes(message)); | ||
} | ||
|
||
/** | ||
* @param { Buffer } inputData | ||
*/ | ||
module.exports.fuzz = function(inputData) { | ||
import('../initOpenpgp.js').then(openpgp => { | ||
const data = new FuzzedDataProvider(inputData); | ||
const fuzzedText = data.consumeString(333, 'utf-8'); | ||
const armoredKey = `-----BEGIN PGP PRIVATE KEY BLOCK----- ${fuzzedText} -----END PGP PRIVATE KEY BLOCK-----`; | ||
|
||
return openpgp.default.readKey({ armoredKey }) | ||
.catch(error => { | ||
if (error.message && !ignoredError(error)) { | ||
throw error; | ||
} | ||
}); | ||
}); | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
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 | ||
*/ | ||
module.exports.fuzz = function(inputData) { | ||
import('../initOpenpgp.js').then(openpgp => { | ||
const binaryKey = new Uint8Array(`-----BEGIN PGP PRIVATE KEY BLOCK----- ${inputData} -----END PGP PRIVATE KEY BLOCK-----`); | ||
|
||
return openpgp.default.readKey({ binaryKey }) | ||
.catch(error => { | ||
if (error.message && !ignoredError(error)) { | ||
throw error; | ||
} | ||
}); | ||
}); | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
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 | ||
*/ | ||
module.exports.fuzz = function(inputData) { | ||
import('../initOpenpgp.js').then(openpgp => { | ||
const binaryMessage = new Uint8Array(`-----BEGIN PGP MESSAGE----- ${inputData} -----END PGP MESSAGE-----`); | ||
|
||
return openpgp.default.readMessage({ binaryMessage }) | ||
.catch(error => { | ||
if (error.message && !ignoredError(error)) { | ||
throw error; | ||
} | ||
}); | ||
}); | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const { FuzzedDataProvider } = require('@jazzer.js/core'); | ||
|
||
const ignored = ['Misformed armored text']; | ||
|
||
function ignoredError(error) { | ||
return ignored.some(message => error.message.includes(message)); | ||
} | ||
|
||
/** | ||
* @param { Buffer } inputData | ||
*/ | ||
module.exports.fuzz = function(inputData) { | ||
import('../initOpenpgp.js').then(openpgp => { | ||
const data = new FuzzedDataProvider(inputData); | ||
const fuzzedText = data.consumeString(333, 'utf-8'); | ||
const armoredMessage = `-----BEGIN PGP MESSAGE----- ${fuzzedText} -----END PGP MESSAGE-----`; | ||
|
||
return openpgp.default.readMessage({ armoredMessage }) | ||
.catch(error => { | ||
if (error.message && !ignoredError(error)) { | ||
throw error; | ||
} | ||
}); | ||
}); | ||
}; | ||
|