Lint all tests (#1235)
This commit is contained in:
parent
8f8517702e
commit
b6edfe646b
|
@ -1 +1,3 @@
|
||||||
src/compression
|
dist
|
||||||
|
test/lib/
|
||||||
|
test/typescript/definitions.js
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
"browsertest": "npm start -- -o test/unittests.html",
|
"browsertest": "npm start -- -o test/unittests.html",
|
||||||
"browserstack": "karma start test/karma.conf.js",
|
"browserstack": "karma start test/karma.conf.js",
|
||||||
"coverage": "nyc npm test",
|
"coverage": "nyc npm test",
|
||||||
"lint": "eslint 'src/**/*.js' 'test/crypto/**/*.js'",
|
"lint": "eslint .",
|
||||||
"docs": "jsdoc --configure .jsdocrc.js --destination docs --recurse README.md src",
|
"docs": "jsdoc --configure .jsdocrc.js --destination docs --recurse README.md src",
|
||||||
"preversion": "rm -rf dist docs node_modules && npm install && npm test",
|
"preversion": "rm -rf dist docs node_modules && npm install && npm test",
|
||||||
"version": "npm run docs && git add -A docs",
|
"version": "npm run docs && git add -A docs",
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
/* eslint-disable no-process-env */
|
||||||
|
|
||||||
import { builtinModules } from 'module';
|
import { builtinModules } from 'module';
|
||||||
|
|
||||||
import resolve from '@rollup/plugin-node-resolve';
|
import resolve from '@rollup/plugin-node-resolve';
|
||||||
|
@ -65,7 +67,7 @@ export default Object.assign([
|
||||||
resolve(),
|
resolve(),
|
||||||
commonjs(),
|
commonjs(),
|
||||||
replace({
|
replace({
|
||||||
'OpenPGP.js VERSION': `OpenPGP.js ${pkg.version}`,
|
'OpenPGP.js VERSION': `OpenPGP.js ${pkg.version}`
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -93,7 +95,7 @@ export default Object.assign([
|
||||||
{
|
{
|
||||||
input: 'test/unittests.js',
|
input: 'test/unittests.js',
|
||||||
output: [
|
output: [
|
||||||
{ file: 'test/lib/unittests-bundle.js', format: 'es', intro, sourcemap: true },
|
{ file: 'test/lib/unittests-bundle.js', format: 'es', intro, sourcemap: true }
|
||||||
],
|
],
|
||||||
inlineDynamicImports: true,
|
inlineDynamicImports: true,
|
||||||
external: ['../..', '../../..'],
|
external: ['../..', '../../..'],
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
/* eslint-disable import/newline-after-import, import/first */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Export high level API functions.
|
* Export high level API functions.
|
||||||
* Usage:
|
* Usage:
|
||||||
*
|
*
|
||||||
* import { encrypt } from 'openpgp'
|
* import { encrypt } from 'openpgp';
|
||||||
* encrypt({ message, publicKeys })
|
* encrypt({ message, publicKeys });
|
||||||
*/
|
*/
|
||||||
export {
|
export {
|
||||||
encrypt, decrypt, sign, verify,
|
encrypt, decrypt, sign, verify,
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
/* eslint-disable callback-return */
|
|
||||||
/**
|
/**
|
||||||
* @requires web-stream-tools
|
* @requires web-stream-tools
|
||||||
* @requires packet/all_packets
|
* @requires packet/all_packets
|
||||||
|
|
|
@ -9,21 +9,21 @@ module.exports = () => describe("ASCII armor", function() {
|
||||||
function getArmor(headers, signatureHeaders) {
|
function getArmor(headers, signatureHeaders) {
|
||||||
return ['-----BEGIN PGP SIGNED MESSAGE-----']
|
return ['-----BEGIN PGP SIGNED MESSAGE-----']
|
||||||
.concat(headers)
|
.concat(headers)
|
||||||
.concat(
|
.concat([
|
||||||
['',
|
'',
|
||||||
'sign this',
|
'sign this',
|
||||||
'-----BEGIN PGP SIGNATURE-----']
|
'-----BEGIN PGP SIGNATURE-----'
|
||||||
)
|
])
|
||||||
.concat(signatureHeaders || ['Version: GnuPG v2.0.22 (GNU/Linux)'])
|
.concat(signatureHeaders || ['Version: GnuPG v2.0.22 (GNU/Linux)'])
|
||||||
.concat(
|
.concat([
|
||||||
['',
|
'',
|
||||||
'iJwEAQECAAYFAlMrPj0ACgkQ4IT3RGwgLJfYkQQAgHMQieazCVdfGAfzQM69Egm5',
|
'iJwEAQECAAYFAlMrPj0ACgkQ4IT3RGwgLJfYkQQAgHMQieazCVdfGAfzQM69Egm5',
|
||||||
'HhcQszODD898wpoGCHgiNdNo1+5nujQAtXnkcxM+Vf7onfbTvUqut/siyO3fzqhK',
|
'HhcQszODD898wpoGCHgiNdNo1+5nujQAtXnkcxM+Vf7onfbTvUqut/siyO3fzqhK',
|
||||||
'LQ9DiQUwJMBE8nOwVR7Mpc4kLNngMTNaHAjZaVaDpTCrklPY+TPHIZnu0B6Ur+6t',
|
'LQ9DiQUwJMBE8nOwVR7Mpc4kLNngMTNaHAjZaVaDpTCrklPY+TPHIZnu0B6Ur+6t',
|
||||||
'skTzzVXIxMYw8ihbHfk=',
|
'skTzzVXIxMYw8ihbHfk=',
|
||||||
'=e/eA',
|
'=e/eA',
|
||||||
'-----END PGP SIGNATURE-----']
|
'-----END PGP SIGNATURE-----'
|
||||||
).join('\n');
|
]).join('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
it('Parse cleartext signed message', async function () {
|
it('Parse cleartext signed message', async function () {
|
||||||
|
@ -81,8 +81,8 @@ module.exports = () => describe("ASCII armor", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Filter whitespace in blank line', async function () {
|
it('Filter whitespace in blank line', async function () {
|
||||||
let msg =
|
let msg = [
|
||||||
['-----BEGIN PGP SIGNED MESSAGE-----',
|
'-----BEGIN PGP SIGNED MESSAGE-----',
|
||||||
'Hash: SHA1',
|
'Hash: SHA1',
|
||||||
' \f\r\t\u00a0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000',
|
' \f\r\t\u00a0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000',
|
||||||
'sign this',
|
'sign this',
|
||||||
|
@ -94,7 +94,8 @@ module.exports = () => describe("ASCII armor", function() {
|
||||||
'LQ9DiQUwJMBE8nOwVR7Mpc4kLNngMTNaHAjZaVaDpTCrklPY+TPHIZnu0B6Ur+6t',
|
'LQ9DiQUwJMBE8nOwVR7Mpc4kLNngMTNaHAjZaVaDpTCrklPY+TPHIZnu0B6Ur+6t',
|
||||||
'skTzzVXIxMYw8ihbHfk=',
|
'skTzzVXIxMYw8ihbHfk=',
|
||||||
'=e/eA',
|
'=e/eA',
|
||||||
'-----END PGP SIGNATURE-----'].join('\n');
|
'-----END PGP SIGNATURE-----'
|
||||||
|
].join('\n');
|
||||||
|
|
||||||
msg = await openpgp.readArmoredCleartextMessage(msg);
|
msg = await openpgp.readArmoredCleartextMessage(msg);
|
||||||
expect(msg).to.be.an.instanceof(openpgp.CleartextMessage);
|
expect(msg).to.be.an.instanceof(openpgp.CleartextMessage);
|
||||||
|
@ -127,8 +128,8 @@ module.exports = () => describe("ASCII armor", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Exception if wrong armor header type', async function () {
|
it('Exception if wrong armor header type', async function () {
|
||||||
let msg =
|
let msg = [
|
||||||
['-----BEGIN PGP SIGNED MESSAGE\u2010\u2010\u2010\u2010\u2010\nHash:SHA1\n\nIs this properly-----',
|
'-----BEGIN PGP SIGNED MESSAGE\u2010\u2010\u2010\u2010\u2010\nHash:SHA1\n\nIs this properly-----',
|
||||||
'',
|
'',
|
||||||
'sign this',
|
'sign this',
|
||||||
'-----BEGIN PGP SIGNNATURE-----',
|
'-----BEGIN PGP SIGNNATURE-----',
|
||||||
|
@ -139,15 +140,16 @@ module.exports = () => describe("ASCII armor", function() {
|
||||||
'LQ9DiQUwJMBE8nOwVR7Mpc4kLNngMTNaHAjZaVaDpTCrklPY+TPHIZnu0B6Ur+6t',
|
'LQ9DiQUwJMBE8nOwVR7Mpc4kLNngMTNaHAjZaVaDpTCrklPY+TPHIZnu0B6Ur+6t',
|
||||||
'skTzzVXIxMYw8ihbHfk=',
|
'skTzzVXIxMYw8ihbHfk=',
|
||||||
'=e/eA',
|
'=e/eA',
|
||||||
'-----END PGP SIGNNATURE-----'].join('\n');
|
'-----END PGP SIGNNATURE-----'
|
||||||
|
].join('\n');
|
||||||
|
|
||||||
msg = openpgp.readArmoredCleartextMessage(msg);
|
msg = openpgp.readArmoredCleartextMessage(msg);
|
||||||
await expect(msg).to.be.rejectedWith(Error, /Unknown ASCII armor type/);
|
await expect(msg).to.be.rejectedWith(Error, /Unknown ASCII armor type/);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Armor checksum validation - mismatch', async function () {
|
it('Armor checksum validation - mismatch', async function () {
|
||||||
const privKey =
|
const privKey = [
|
||||||
['-----BEGIN PGP PRIVATE KEY BLOCK-----',
|
'-----BEGIN PGP PRIVATE KEY BLOCK-----',
|
||||||
'Version: OpenPGP.js v0.3.0',
|
'Version: OpenPGP.js v0.3.0',
|
||||||
'Comment: https://openpgpjs.org',
|
'Comment: https://openpgpjs.org',
|
||||||
'',
|
'',
|
||||||
|
@ -164,7 +166,8 @@ module.exports = () => describe("ASCII armor", function() {
|
||||||
'ABMFAlLm1+4JEBD8MASZrpALAhsMAAC3IgD8DnLGbMnpLtrX72RCkPW1ffLq',
|
'ABMFAlLm1+4JEBD8MASZrpALAhsMAAC3IgD8DnLGbMnpLtrX72RCkPW1ffLq',
|
||||||
'71vlXMJNXvoCeuejiRw=',
|
'71vlXMJNXvoCeuejiRw=',
|
||||||
'=wJN@',
|
'=wJN@',
|
||||||
'-----END PGP PRIVATE KEY BLOCK-----'].join('\n');
|
'-----END PGP PRIVATE KEY BLOCK-----'
|
||||||
|
].join('\n');
|
||||||
|
|
||||||
// try with default config
|
// try with default config
|
||||||
await expect(openpgp.readArmoredKey(privKey)).to.be.rejectedWith(/Ascii armor integrity check on message failed/);
|
await expect(openpgp.readArmoredKey(privKey)).to.be.rejectedWith(/Ascii armor integrity check on message failed/);
|
||||||
|
@ -289,8 +292,8 @@ module.exports = () => describe("ASCII armor", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Accept header with trailing whitespace', async function () {
|
it('Accept header with trailing whitespace', async function () {
|
||||||
const privKey =
|
const privKey = [
|
||||||
['-----BEGIN PGP PRIVATE KEY BLOCK-----',
|
'-----BEGIN PGP PRIVATE KEY BLOCK-----',
|
||||||
'Version: OpenPGP.js v0.3.0',
|
'Version: OpenPGP.js v0.3.0',
|
||||||
'Comment: https://openpgpjs.org',
|
'Comment: https://openpgpjs.org',
|
||||||
'',
|
'',
|
||||||
|
@ -308,7 +311,8 @@ module.exports = () => describe("ASCII armor", function() {
|
||||||
'71vlXMJNXvoCeuejiRw=',
|
'71vlXMJNXvoCeuejiRw=',
|
||||||
'=wJNM',
|
'=wJNM',
|
||||||
'-----END PGP PRIVATE KEY BLOCK-----',
|
'-----END PGP PRIVATE KEY BLOCK-----',
|
||||||
''].join('\t \r\n');
|
''
|
||||||
|
].join('\t \r\n');
|
||||||
|
|
||||||
const result = await openpgp.readArmoredKey(privKey);
|
const result = await openpgp.readArmoredKey(privKey);
|
||||||
expect(result).to.be.an.instanceof(openpgp.Key);
|
expect(result).to.be.an.instanceof(openpgp.Key);
|
||||||
|
@ -321,7 +325,7 @@ module.exports = () => describe("ASCII armor", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Do not add extraneous blank line when base64 ends on line break', async function () {
|
it('Do not add extraneous blank line when base64 ends on line break', async function () {
|
||||||
let pubKey = `-----BEGIN PGP PUBLIC KEY BLOCK-----
|
const pubKey = `-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||||
|
|
||||||
xsFNBFuR4MABEACoJ9e8zvhj80mFWJzxDErNnD78taGh7hJTs/H1CIIAykjf
|
xsFNBFuR4MABEACoJ9e8zvhj80mFWJzxDErNnD78taGh7hJTs/H1CIIAykjf
|
||||||
NEvTWcnnDI2dsK7J+dBQq9R40G5YYDUvA2dMztqq5BuaUlJvdSiQtqMcirhF
|
NEvTWcnnDI2dsK7J+dBQq9R40G5YYDUvA2dMztqq5BuaUlJvdSiQtqMcirhF
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
|
|
||||||
const random = require('../../src/crypto/random');
|
const random = require('../../src/crypto/random');
|
||||||
const util = require('../../src/util');
|
const util = require('../../src/util');
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ module.exports = () => (openpgp.config.ci ? describe.skip : describe)('Brainpool
|
||||||
//only x25519 crypto is fully functional in lightbuild
|
//only x25519 crypto is fully functional in lightbuild
|
||||||
if (!openpgp.config.useIndutnyElliptic && !util.getNodeCrypto()) {
|
if (!openpgp.config.useIndutnyElliptic && !util.getNodeCrypto()) {
|
||||||
before(function() {
|
before(function() {
|
||||||
this.skip();
|
this.skip(); // eslint-disable-line no-invalid-this
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const data = {
|
const data = {
|
||||||
|
@ -108,7 +108,7 @@ tkYrARUF5n9K9+TEasU4z1k898YkS5cIzFyBSGMhGDzdj7t1K93EyOxXPc84
|
||||||
EJ4QcD/oQ6x1M/8X/iKQCtxZP8RnlrbH7ExkNON5s5g=
|
EJ4QcD/oQ6x1M/8X/iKQCtxZP8RnlrbH7ExkNON5s5g=
|
||||||
=KDoL
|
=KDoL
|
||||||
-----END PGP MESSAGE-----`,
|
-----END PGP MESSAGE-----`,
|
||||||
message_with_leading_zero_in_hash_old_elliptic_implementation: 'test message\n199',
|
message_with_leading_zero_in_hash_old_elliptic_implementation: 'test message\n199'
|
||||||
},
|
},
|
||||||
juliet: {
|
juliet: {
|
||||||
id: '37e16a986b8af99e',
|
id: '37e16a986b8af99e',
|
||||||
|
@ -201,7 +201,7 @@ EJ4QcD/oQ6x1M/8X/iKQCtxZP8RnlrbH7ExkNON5s5g=
|
||||||
it('Verify clear signed message', async function () {
|
it('Verify clear signed message', async function () {
|
||||||
const pub = await load_pub_key('juliet');
|
const pub = await load_pub_key('juliet');
|
||||||
const msg = await openpgp.readArmoredCleartextMessage(data.juliet.message_signed);
|
const msg = await openpgp.readArmoredCleartextMessage(data.juliet.message_signed);
|
||||||
return openpgp.verify({publicKeys: [pub], message: msg}).then(function(result) {
|
return openpgp.verify({ publicKeys: [pub], message: msg }).then(function(result) {
|
||||||
expect(result).to.exist;
|
expect(result).to.exist;
|
||||||
expect(result.data).to.equal(data.juliet.message);
|
expect(result.data).to.equal(data.juliet.message);
|
||||||
expect(result.signatures).to.have.length(1);
|
expect(result.signatures).to.have.length(1);
|
||||||
|
@ -210,10 +210,10 @@ EJ4QcD/oQ6x1M/8X/iKQCtxZP8RnlrbH7ExkNON5s5g=
|
||||||
});
|
});
|
||||||
it('Sign message', async function () {
|
it('Sign message', async function () {
|
||||||
const romeoPrivate = await load_priv_key('romeo');
|
const romeoPrivate = await load_priv_key('romeo');
|
||||||
const signed = await openpgp.sign({privateKeys: [romeoPrivate], message: openpgp.CleartextMessage.fromText(data.romeo.message)});
|
const signed = await openpgp.sign({ privateKeys: [romeoPrivate], message: openpgp.CleartextMessage.fromText(data.romeo.message) });
|
||||||
const romeoPublic = await load_pub_key('romeo');
|
const romeoPublic = await load_pub_key('romeo');
|
||||||
const msg = await openpgp.readArmoredCleartextMessage(signed);
|
const msg = await openpgp.readArmoredCleartextMessage(signed);
|
||||||
const result = await openpgp.verify({publicKeys: [romeoPublic], message: msg});
|
const result = await openpgp.verify({ publicKeys: [romeoPublic], message: msg });
|
||||||
|
|
||||||
expect(result).to.exist;
|
expect(result).to.exist;
|
||||||
expect(result.data).to.equal(data.romeo.message);
|
expect(result.data).to.equal(data.romeo.message);
|
||||||
|
@ -235,7 +235,7 @@ EJ4QcD/oQ6x1M/8X/iKQCtxZP8RnlrbH7ExkNON5s5g=
|
||||||
const juliet = await load_priv_key('juliet');
|
const juliet = await load_priv_key('juliet');
|
||||||
const romeo = await load_pub_key('romeo');
|
const romeo = await load_pub_key('romeo');
|
||||||
const msg = await openpgp.readArmoredMessage(data.romeo.message_encrypted_with_leading_zero_in_hash);
|
const msg = await openpgp.readArmoredMessage(data.romeo.message_encrypted_with_leading_zero_in_hash);
|
||||||
const result = await openpgp.decrypt({privateKeys: juliet, publicKeys: [romeo], message: msg});
|
const result = await openpgp.decrypt({ privateKeys: juliet, publicKeys: [romeo], message: msg });
|
||||||
|
|
||||||
expect(result).to.exist;
|
expect(result).to.exist;
|
||||||
expect(result.data).to.equal(data.romeo.message_with_leading_zero_in_hash);
|
expect(result.data).to.equal(data.romeo.message_with_leading_zero_in_hash);
|
||||||
|
@ -248,8 +248,8 @@ EJ4QcD/oQ6x1M/8X/iKQCtxZP8RnlrbH7ExkNON5s5g=
|
||||||
openpgp.config.useNative = false;
|
openpgp.config.useNative = false;
|
||||||
const juliet = await load_priv_key('juliet');
|
const juliet = await load_priv_key('juliet');
|
||||||
const romeo = await load_pub_key('romeo');
|
const romeo = await load_pub_key('romeo');
|
||||||
const msg = await openpgp.readArmoredMessage(data.romeo. message_encrypted_with_leading_zero_in_hash_signed_by_elliptic_with_old_implementation);
|
const msg = await openpgp.readArmoredMessage(data.romeo.message_encrypted_with_leading_zero_in_hash_signed_by_elliptic_with_old_implementation);
|
||||||
const result = await openpgp.decrypt({privateKeys: juliet, publicKeys: [romeo], message: msg});
|
const result = await openpgp.decrypt({ privateKeys: juliet, publicKeys: [romeo], message: msg });
|
||||||
openpgp.config.useNative = useNative;
|
openpgp.config.useNative = useNative;
|
||||||
expect(result).to.exist;
|
expect(result).to.exist;
|
||||||
expect(result.data).to.equal(data.romeo.message_with_leading_zero_in_hash_old_elliptic_implementation);
|
expect(result.data).to.equal(data.romeo.message_with_leading_zero_in_hash_old_elliptic_implementation);
|
||||||
|
@ -260,12 +260,12 @@ EJ4QcD/oQ6x1M/8X/iKQCtxZP8RnlrbH7ExkNON5s5g=
|
||||||
it('Encrypt and sign message', async function () {
|
it('Encrypt and sign message', async function () {
|
||||||
const romeoPrivate = await load_priv_key('romeo');
|
const romeoPrivate = await load_priv_key('romeo');
|
||||||
const julietPublic = await load_pub_key('juliet');
|
const julietPublic = await load_pub_key('juliet');
|
||||||
const encrypted = await openpgp.encrypt({publicKeys: [julietPublic], privateKeys: [romeoPrivate], message: openpgp.Message.fromText(data.romeo.message)});
|
const encrypted = await openpgp.encrypt({ publicKeys: [julietPublic], privateKeys: [romeoPrivate], message: openpgp.Message.fromText(data.romeo.message) });
|
||||||
|
|
||||||
const message = await openpgp.readArmoredMessage(encrypted);
|
const message = await openpgp.readArmoredMessage(encrypted);
|
||||||
const romeoPublic = await load_pub_key('romeo');
|
const romeoPublic = await load_pub_key('romeo');
|
||||||
const julietPrivate = await load_priv_key('juliet');
|
const julietPrivate = await load_priv_key('juliet');
|
||||||
const result = await openpgp.decrypt({privateKeys: julietPrivate, publicKeys: [romeoPublic], message: message});
|
const result = await openpgp.decrypt({ privateKeys: julietPrivate, publicKeys: [romeoPublic], message: message });
|
||||||
|
|
||||||
expect(result).to.exist;
|
expect(result).to.exist;
|
||||||
expect(result.data).to.equal(data.romeo.message);
|
expect(result.data).to.equal(data.romeo.message);
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
/* globals tryTests: true */
|
|
||||||
|
|
||||||
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
|
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
|
||||||
|
|
||||||
const chai = require('chai');
|
const chai = require('chai');
|
||||||
|
@ -11,7 +9,7 @@ const expect = chai.expect;
|
||||||
module.exports = () => describe('Elliptic Curve Cryptography for NIST P-256,P-384,P-521 curves @lightweight', function () {
|
module.exports = () => describe('Elliptic Curve Cryptography for NIST P-256,P-384,P-521 curves @lightweight', function () {
|
||||||
function omnibus() {
|
function omnibus() {
|
||||||
it('Omnibus NIST P-256 Test', function () {
|
it('Omnibus NIST P-256 Test', function () {
|
||||||
const options = { userIds: {name: "Hi", email: "hi@hel.lo"}, curve: "p256" };
|
const options = { userIds: { name: "Hi", email: "hi@hel.lo" }, curve: "p256" };
|
||||||
const testData = input.createSomeMessage();
|
const testData = input.createSomeMessage();
|
||||||
const testData2 = input.createSomeMessage();
|
const testData2 = input.createSomeMessage();
|
||||||
return openpgp.generateKey(options).then(function (firstKey) {
|
return openpgp.generateKey(options).then(function (firstKey) {
|
||||||
|
@ -70,17 +68,17 @@ module.exports = () => describe('Elliptic Curve Cryptography for NIST P-256,P-38
|
||||||
|
|
||||||
it('Sign message', async function () {
|
it('Sign message', async function () {
|
||||||
const testData = input.createSomeMessage();
|
const testData = input.createSomeMessage();
|
||||||
let options = { userIds: {name: "Hi", email: "hi@hel.lo"}, curve: "p256" };
|
const options = { userIds: { name: "Hi", email: "hi@hel.lo" }, curve: "p256" };
|
||||||
const firstKey = await openpgp.generateKey(options);
|
const firstKey = await openpgp.generateKey(options);
|
||||||
const signature = await openpgp.sign({ message: openpgp.CleartextMessage.fromText(testData), privateKeys: firstKey.key });
|
const signature = await openpgp.sign({ message: openpgp.CleartextMessage.fromText(testData), privateKeys: firstKey.key });
|
||||||
const msg = await openpgp.readArmoredCleartextMessage(signature);
|
const msg = await openpgp.readArmoredCleartextMessage(signature);
|
||||||
const result = await openpgp.verify({ message: msg, publicKeys: firstKey.key.toPublic()});
|
const result = await openpgp.verify({ message: msg, publicKeys: firstKey.key.toPublic() });
|
||||||
expect(result.signatures[0].valid).to.be.true;
|
expect(result.signatures[0].valid).to.be.true;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('encrypt and sign message', async function () {
|
it('encrypt and sign message', async function () {
|
||||||
const testData = input.createSomeMessage();
|
const testData = input.createSomeMessage();
|
||||||
let options = { userIds: {name: "Hi", email: "hi@hel.lo"}, curve: "p256" };
|
let options = { userIds: { name: "Hi", email: "hi@hel.lo" }, curve: "p256" };
|
||||||
const firstKey = await openpgp.generateKey(options);
|
const firstKey = await openpgp.generateKey(options);
|
||||||
options = { userIds: { name: "Bye", email: "bye@good.bye" }, curve: "p256" };
|
options = { userIds: { name: "Bye", email: "bye@good.bye" }, curve: "p256" };
|
||||||
const secondKey = await openpgp.generateKey(options);
|
const secondKey = await openpgp.generateKey(options);
|
||||||
|
@ -94,7 +92,7 @@ module.exports = () => describe('Elliptic Curve Cryptography for NIST P-256,P-38
|
||||||
{ message: msg,
|
{ message: msg,
|
||||||
privateKeys: secondKey.key,
|
privateKeys: secondKey.key,
|
||||||
publicKeys: [firstKey.key.toPublic()] }
|
publicKeys: [firstKey.key.toPublic()] }
|
||||||
)
|
);
|
||||||
expect(result.signatures[0].valid).to.be.true;
|
expect(result.signatures[0].valid).to.be.true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
/* globals tryTests: true */
|
|
||||||
|
|
||||||
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
|
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
|
||||||
const util = require('../../src/util');
|
const util = require('../../src/util');
|
||||||
|
|
||||||
|
@ -11,7 +9,7 @@ const expect = chai.expect;
|
||||||
module.exports = () => describe('Elliptic Curve Cryptography for secp256k1 curve @lightweight', function () {
|
module.exports = () => describe('Elliptic Curve Cryptography for secp256k1 curve @lightweight', function () {
|
||||||
if (!openpgp.config.useIndutnyElliptic && !util.getNodeCrypto()) {
|
if (!openpgp.config.useIndutnyElliptic && !util.getNodeCrypto()) {
|
||||||
before(function() {
|
before(function() {
|
||||||
this.skip();
|
this.skip(); // eslint-disable-line no-invalid-this
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const data = {
|
const data = {
|
||||||
|
@ -177,7 +175,7 @@ module.exports = () => describe('Elliptic Curve Cryptography for secp256k1 curve
|
||||||
it('Verify clear signed message', async function () {
|
it('Verify clear signed message', async function () {
|
||||||
const pub = await load_pub_key('juliet');
|
const pub = await load_pub_key('juliet');
|
||||||
const msg = await openpgp.readArmoredCleartextMessage(data.juliet.message_signed);
|
const msg = await openpgp.readArmoredCleartextMessage(data.juliet.message_signed);
|
||||||
return openpgp.verify({publicKeys: [pub], message: msg}).then(function(result) {
|
return openpgp.verify({ publicKeys: [pub], message: msg }).then(function(result) {
|
||||||
expect(result).to.exist;
|
expect(result).to.exist;
|
||||||
expect(result.data).to.equal(data.juliet.message);
|
expect(result.data).to.equal(data.juliet.message);
|
||||||
expect(result.signatures).to.have.length(1);
|
expect(result.signatures).to.have.length(1);
|
||||||
|
@ -186,10 +184,10 @@ module.exports = () => describe('Elliptic Curve Cryptography for secp256k1 curve
|
||||||
});
|
});
|
||||||
it('Sign message', async function () {
|
it('Sign message', async function () {
|
||||||
const romeoPrivate = await load_priv_key('romeo');
|
const romeoPrivate = await load_priv_key('romeo');
|
||||||
const signed = await openpgp.sign({privateKeys: [romeoPrivate], message: openpgp.CleartextMessage.fromText(data.romeo.message)});
|
const signed = await openpgp.sign({ privateKeys: [romeoPrivate], message: openpgp.CleartextMessage.fromText(data.romeo.message) });
|
||||||
const romeoPublic = await load_pub_key('romeo');
|
const romeoPublic = await load_pub_key('romeo');
|
||||||
const msg = await openpgp.readArmoredCleartextMessage(signed);
|
const msg = await openpgp.readArmoredCleartextMessage(signed);
|
||||||
const result = await openpgp.verify({publicKeys: [romeoPublic], message: msg});
|
const result = await openpgp.verify({ publicKeys: [romeoPublic], message: msg });
|
||||||
|
|
||||||
expect(result).to.exist;
|
expect(result).to.exist;
|
||||||
expect(result.data).to.equal(data.romeo.message);
|
expect(result.data).to.equal(data.romeo.message);
|
||||||
|
@ -200,7 +198,7 @@ module.exports = () => describe('Elliptic Curve Cryptography for secp256k1 curve
|
||||||
const juliet = await load_pub_key('juliet');
|
const juliet = await load_pub_key('juliet');
|
||||||
const romeo = await load_priv_key('romeo');
|
const romeo = await load_priv_key('romeo');
|
||||||
const msg = await openpgp.readArmoredMessage(data.juliet.message_encrypted);
|
const msg = await openpgp.readArmoredMessage(data.juliet.message_encrypted);
|
||||||
const result = await openpgp.decrypt({privateKeys: romeo, publicKeys: [juliet], message: msg});
|
const result = await openpgp.decrypt({ privateKeys: romeo, publicKeys: [juliet], message: msg });
|
||||||
|
|
||||||
expect(result).to.exist;
|
expect(result).to.exist;
|
||||||
expect(result.data).to.equal(data.juliet.message);
|
expect(result.data).to.equal(data.juliet.message);
|
||||||
|
@ -210,12 +208,12 @@ module.exports = () => describe('Elliptic Curve Cryptography for secp256k1 curve
|
||||||
it('Encrypt and sign message', async function () {
|
it('Encrypt and sign message', async function () {
|
||||||
const romeoPrivate = await load_priv_key('romeo');
|
const romeoPrivate = await load_priv_key('romeo');
|
||||||
const julietPublic = await load_pub_key('juliet');
|
const julietPublic = await load_pub_key('juliet');
|
||||||
const encrypted = await openpgp.encrypt({publicKeys: [julietPublic], privateKeys: [romeoPrivate], message: openpgp.Message.fromText(data.romeo.message)});
|
const encrypted = await openpgp.encrypt({ publicKeys: [julietPublic], privateKeys: [romeoPrivate], message: openpgp.Message.fromText(data.romeo.message) });
|
||||||
|
|
||||||
const message = await openpgp.readArmoredMessage(encrypted);
|
const message = await openpgp.readArmoredMessage(encrypted);
|
||||||
const romeoPublic = await load_pub_key('romeo');
|
const romeoPublic = await load_pub_key('romeo');
|
||||||
const julietPrivate = await load_priv_key('juliet');
|
const julietPrivate = await load_priv_key('juliet');
|
||||||
const result = await openpgp.decrypt({privateKeys: julietPrivate, publicKeys: [romeoPublic], message: message});
|
const result = await openpgp.decrypt({ privateKeys: julietPrivate, publicKeys: [romeoPublic], message: message });
|
||||||
|
|
||||||
expect(result).to.exist;
|
expect(result).to.exist;
|
||||||
expect(result.data).to.equal(data.romeo.message);
|
expect(result.data).to.equal(data.romeo.message);
|
||||||
|
@ -224,7 +222,7 @@ module.exports = () => describe('Elliptic Curve Cryptography for secp256k1 curve
|
||||||
});
|
});
|
||||||
it('Generate key', function () {
|
it('Generate key', function () {
|
||||||
const options = {
|
const options = {
|
||||||
userIds: {name: "Hamlet (secp256k1)", email: "hamlet@example.net"},
|
userIds: { name: "Hamlet (secp256k1)", email: "hamlet@example.net" },
|
||||||
curve: "secp256k1",
|
curve: "secp256k1",
|
||||||
passphrase: "ophelia"
|
passphrase: "ophelia"
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,7 +5,7 @@ const chai = require('chai');
|
||||||
const { expect } = chai;
|
const { expect } = chai;
|
||||||
|
|
||||||
module.exports = () => describe.skip('HKP unit tests', function() {
|
module.exports = () => describe.skip('HKP unit tests', function() {
|
||||||
this.timeout(60000);
|
this.timeout(60000); // eslint-disable-line no-invalid-this
|
||||||
|
|
||||||
let hkp;
|
let hkp;
|
||||||
|
|
||||||
|
@ -106,17 +106,17 @@ module.exports = () => describe.skip('HKP unit tests', function() {
|
||||||
'-----END PGP PUBLIC KEY BLOCK-----';
|
'-----END PGP PUBLIC KEY BLOCK-----';
|
||||||
|
|
||||||
const revocation_certificate = `-----BEGIN PGP PUBLIC KEY BLOCK-----
|
const revocation_certificate = `-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||||
Comment: This is a revocation certificate
|
Comment: This is a revocation certificate
|
||||||
|
|
||||||
iQFFBCABCAAvFiEE6mWHlKTGvbGenE8BstiRuVIg7eYFAlxec9cRHQB0aGlzIGlz
|
iQFFBCABCAAvFiEE6mWHlKTGvbGenE8BstiRuVIg7eYFAlxec9cRHQB0aGlzIGlz
|
||||||
IGEgdGVzdC4ACgkQstiRuVIg7eZkywf/QuHU6WaOGmI635xsV8GNyvOOHzDpVuzM
|
IGEgdGVzdC4ACgkQstiRuVIg7eZkywf/QuHU6WaOGmI635xsV8GNyvOOHzDpVuzM
|
||||||
AYGIKOLf1l661aS1MIvbXGxI86a3CzLs3K9nqUS7uAZ89vhf6L8RDZSkpn2GzY3K
|
AYGIKOLf1l661aS1MIvbXGxI86a3CzLs3K9nqUS7uAZ89vhf6L8RDZSkpn2GzY3K
|
||||||
JQb0ZM+qf2TGkVDZ/wI8H/BMkJGCLbvbn6Ywk/o4GQIl/ISJPQTiC5VixayLEUQ3
|
JQb0ZM+qf2TGkVDZ/wI8H/BMkJGCLbvbn6Ywk/o4GQIl/ISJPQTiC5VixayLEUQ3
|
||||||
6dnENegfEIptSOPNBOelRPfbT8tqcR6SxibjXYxlCqvdSgt7lui06vGcejl4qNgZ
|
6dnENegfEIptSOPNBOelRPfbT8tqcR6SxibjXYxlCqvdSgt7lui06vGcejl4qNgZ
|
||||||
oNMuvQNShV2G9KkPda3AZWCIWzUBuKN5UuE06u68iclH2ckEicQvnmxHnJU/BSC9
|
oNMuvQNShV2G9KkPda3AZWCIWzUBuKN5UuE06u68iclH2ckEicQvnmxHnJU/BSC9
|
||||||
h3bdqlMa87hRGnWluKpJT+XRP0UGiN8UGWo8OEpdz8KbvVTCUVya4g==
|
h3bdqlMa87hRGnWluKpJT+XRP0UGiN8UGWo8OEpdz8KbvVTCUVya4g==
|
||||||
=Wjv9
|
=Wjv9
|
||||||
-----END PGP PUBLIC KEY BLOCK-----`
|
-----END PGP PUBLIC KEY BLOCK-----`;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
hkp = new openpgp.HKP(openpgp.config.keyserver);
|
hkp = new openpgp.HKP(openpgp.config.keyserver);
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
/* eslint-disable max-lines */
|
||||||
/* globals tryTests: true */
|
/* globals tryTests: true */
|
||||||
|
|
||||||
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
|
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
|
||||||
|
@ -94,7 +95,7 @@ nGHIp2NmbJZnYgl8Ps23qF+LKTa1eE+AmMQYzUHSGuka2lp6OglwWzg/dEw=
|
||||||
=/vbH
|
=/vbH
|
||||||
-----END PGP PUBLIC KEY BLOCK-----`;
|
-----END PGP PUBLIC KEY BLOCK-----`;
|
||||||
|
|
||||||
const priv_key_arm4 = `-----BEGIN PGP PRIVATE KEY BLOCK-----
|
/* const priv_key_arm4 = `-----BEGIN PGP PRIVATE KEY BLOCK-----
|
||||||
Version: GnuPG 2.1.15 (GNU/Linux)
|
Version: GnuPG 2.1.15 (GNU/Linux)
|
||||||
|
|
||||||
lQIGBFqaDSwBBADKDvHX5y77ws3tYY1nK/LdXzHZ3RUHNXwDO3ZurG6q3ZWgM/g2
|
lQIGBFqaDSwBBADKDvHX5y77ws3tYY1nK/LdXzHZ3RUHNXwDO3ZurG6q3ZWgM/g2
|
||||||
|
@ -128,7 +129,7 @@ uUrp9Qp76CnKqUsUjcVxq7DJBi/lewyGGYSVAFt6/0Xyg/8YTEa/c4Dri/HMOtrf
|
||||||
bgjp/doIVaZLOXZYfqRcpy3z0M6BierOPB3D+fdaTfd7gIrQnGHIp2NmbJZnYgl8
|
bgjp/doIVaZLOXZYfqRcpy3z0M6BierOPB3D+fdaTfd7gIrQnGHIp2NmbJZnYgl8
|
||||||
Ps23qF+LKTa1eE+AmMQYzUHSGuka2lp6OglwWzg/dEw=
|
Ps23qF+LKTa1eE+AmMQYzUHSGuka2lp6OglwWzg/dEw=
|
||||||
=mr3M
|
=mr3M
|
||||||
-----END PGP PRIVATE KEY BLOCK-----`;
|
-----END PGP PRIVATE KEY BLOCK-----`; */
|
||||||
|
|
||||||
const revocation_certificate_arm4 = `-----BEGIN PGP PUBLIC KEY BLOCK-----
|
const revocation_certificate_arm4 = `-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||||
Version: GnuPG 2.1.15 (GNU/Linux)
|
Version: GnuPG 2.1.15 (GNU/Linux)
|
||||||
|
@ -1407,7 +1408,7 @@ cKFQz1DDfFCfVpSIJRGozQ==
|
||||||
-----END PGP PUBLIC KEY BLOCK-----
|
-----END PGP PUBLIC KEY BLOCK-----
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const revoked_primary_user = `-----BEGIN PGP PUBLIC KEY BLOCK-----
|
/* const revoked_primary_user = `-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||||
|
|
||||||
mQENBE2V9vABCADR6780VEDx0P/Hk+qvGeDkGY/CDKkFIquksfVnWUatmN4mVfcS
|
mQENBE2V9vABCADR6780VEDx0P/Hk+qvGeDkGY/CDKkFIquksfVnWUatmN4mVfcS
|
||||||
yqzmyZ08kAcXQVlU1i+/EeFSQ6vXEP/ZjH9en4YjOGrvmSIrNl4j4vhlJG3Mbao0
|
yqzmyZ08kAcXQVlU1i+/EeFSQ6vXEP/ZjH9en4YjOGrvmSIrNl4j4vhlJG3Mbao0
|
||||||
|
@ -1688,7 +1689,7 @@ dh1PTAyfau1IRO3V/ivRaYs32jvMno6zP575CKLJOIyLREm8dbQRRd7h1+ZBxtQf
|
||||||
Jn9lY1FGcIqjyOYanmsOEsSsKZS/exyNIjwi0WRPze+SASRzE/8=
|
Jn9lY1FGcIqjyOYanmsOEsSsKZS/exyNIjwi0WRPze+SASRzE/8=
|
||||||
=qfwW
|
=qfwW
|
||||||
-----END PGP PUBLIC KEY BLOCK-----
|
-----END PGP PUBLIC KEY BLOCK-----
|
||||||
`;
|
`; */
|
||||||
|
|
||||||
const key_created_2030 = `-----BEGIN PGP PUBLIC KEY BLOCK-----
|
const key_created_2030 = `-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,8 @@ const keyring = new openpgp.Keyring();
|
||||||
|
|
||||||
module.exports = () => describe("Keyring", async function() {
|
module.exports = () => describe("Keyring", async function() {
|
||||||
const user = 'whiteout.test@t-online.de';
|
const user = 'whiteout.test@t-online.de';
|
||||||
const passphrase = 'asdf';
|
// const passphrase = 'asdf';
|
||||||
const keySize = 512;
|
// const keySize = 512;
|
||||||
const keyId = 'f6f60e9b42cdff4c';
|
const keyId = 'f6f60e9b42cdff4c';
|
||||||
const keyFingerP = '5856cef789c3a307e8a1b976f6f60e9b42cdff4c';
|
const keyFingerP = '5856cef789c3a307e8a1b976f6f60e9b42cdff4c';
|
||||||
const pubkey = '-----BEGIN PGP PUBLIC KEY BLOCK-----\n' +
|
const pubkey = '-----BEGIN PGP PUBLIC KEY BLOCK-----\n' +
|
||||||
|
|
|
@ -24,12 +24,12 @@ module.exports = () => describe('Oid tests', function() {
|
||||||
const oid = new OID();
|
const oid = new OID();
|
||||||
expect(oid.read(data)).to.equal(data.length);
|
expect(oid.read(data)).to.equal(data.length);
|
||||||
expect(oid.oid).to.exist;
|
expect(oid.oid).to.exist;
|
||||||
expect(oid.oid).to.have.length(data.length-1);
|
expect(oid.oid).to.have.length(data.length - 1);
|
||||||
expect(oid.toHex()).to.equal(util.uint8ArrayToHex(data.subarray(1)));
|
expect(oid.toHex()).to.equal(util.uint8ArrayToHex(data.subarray(1)));
|
||||||
const result = oid.write();
|
const result = oid.write();
|
||||||
expect(result).to.exist;
|
expect(result).to.exist;
|
||||||
expect(result).to.have.length(data.length);
|
expect(result).to.have.length(data.length);
|
||||||
expect(result[0]).to.equal(data.length-1);
|
expect(result[0]).to.equal(data.length - 1);
|
||||||
expect(
|
expect(
|
||||||
util.uint8ArrayToHex(result.subarray(1))
|
util.uint8ArrayToHex(result.subarray(1))
|
||||||
).to.equal(util.uint8ArrayToHex(data.subarray(1)));
|
).to.equal(util.uint8ArrayToHex(data.subarray(1)));
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
/* eslint-disable max-lines */
|
||||||
/* globals tryTests: true */
|
/* globals tryTests: true */
|
||||||
|
|
||||||
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
|
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
|
||||||
|
@ -12,8 +13,8 @@ chai.use(require('chai-as-promised'));
|
||||||
|
|
||||||
const expect = chai.expect;
|
const expect = chai.expect;
|
||||||
|
|
||||||
const pub_key =
|
const pub_key = [
|
||||||
['-----BEGIN PGP PUBLIC KEY BLOCK-----',
|
'-----BEGIN PGP PUBLIC KEY BLOCK-----',
|
||||||
'Version: GnuPG v2.0.19 (GNU/Linux)',
|
'Version: GnuPG v2.0.19 (GNU/Linux)',
|
||||||
'',
|
'',
|
||||||
'mI0EUmEvTgEEANyWtQQMOybQ9JltDqmaX0WnNPJeLILIM36sw6zL0nfTQ5zXSS3+',
|
'mI0EUmEvTgEEANyWtQQMOybQ9JltDqmaX0WnNPJeLILIM36sw6zL0nfTQ5zXSS3+',
|
||||||
|
@ -35,10 +36,11 @@ const pub_key =
|
||||||
'AtNTq6ihLMD5v1d82ZC7tNatdlDMGWnIdvEMCv2GZcuIqDQ9rXWs49e7tq1NncLY',
|
'AtNTq6ihLMD5v1d82ZC7tNatdlDMGWnIdvEMCv2GZcuIqDQ9rXWs49e7tq1NncLY',
|
||||||
'hz3tYjKhoFTKEIq3y3Pp',
|
'hz3tYjKhoFTKEIq3y3Pp',
|
||||||
'=h/aX',
|
'=h/aX',
|
||||||
'-----END PGP PUBLIC KEY BLOCK-----'].join('\n');
|
'-----END PGP PUBLIC KEY BLOCK-----'
|
||||||
|
].join('\n');
|
||||||
|
|
||||||
const priv_key =
|
const priv_key = [
|
||||||
['-----BEGIN PGP PRIVATE KEY BLOCK-----',
|
'-----BEGIN PGP PRIVATE KEY BLOCK-----',
|
||||||
'Version: GnuPG v2.0.19 (GNU/Linux)',
|
'Version: GnuPG v2.0.19 (GNU/Linux)',
|
||||||
'',
|
'',
|
||||||
'lQH+BFJhL04BBADclrUEDDsm0PSZbQ6pml9FpzTyXiyCyDN+rMOsy9J300Oc10kt',
|
'lQH+BFJhL04BBADclrUEDDsm0PSZbQ6pml9FpzTyXiyCyDN+rMOsy9J300Oc10kt',
|
||||||
|
@ -75,10 +77,11 @@ const priv_key =
|
||||||
'SXuqKcWqoEuO7OBSEFThCXBfUYMC01OrqKEswPm/V3zZkLu01q12UMwZach28QwK',
|
'SXuqKcWqoEuO7OBSEFThCXBfUYMC01OrqKEswPm/V3zZkLu01q12UMwZach28QwK',
|
||||||
'/YZly4ioND2tdazj17u2rU2dwtiHPe1iMqGgVMoQirfLc+k=',
|
'/YZly4ioND2tdazj17u2rU2dwtiHPe1iMqGgVMoQirfLc+k=',
|
||||||
'=lw5e',
|
'=lw5e',
|
||||||
'-----END PGP PRIVATE KEY BLOCK-----'].join('\n');
|
'-----END PGP PRIVATE KEY BLOCK-----'
|
||||||
|
].join('\n');
|
||||||
|
|
||||||
const pub_key_de =
|
const pub_key_de = [
|
||||||
['-----BEGIN PGP PUBLIC KEY BLOCK-----',
|
'-----BEGIN PGP PUBLIC KEY BLOCK-----',
|
||||||
'Version: GnuPG v2.0.22 (GNU/Linux)',
|
'Version: GnuPG v2.0.22 (GNU/Linux)',
|
||||||
'',
|
'',
|
||||||
'mQMuBFLVgdQRCACOlpq0cd1IazNjOEpWPZvx/O3JMbdDs3B3iCG0Mo5OUZ8lpKU5',
|
'mQMuBFLVgdQRCACOlpq0cd1IazNjOEpWPZvx/O3JMbdDs3B3iCG0Mo5OUZ8lpKU5',
|
||||||
|
@ -116,10 +119,11 @@ const pub_key_de =
|
||||||
'y61IhKbJCOlQxyem+kepjNapkhKDAQDIDL38bZWU4Rm0nq82Xb4yaI0BCWDcFkHV',
|
'y61IhKbJCOlQxyem+kepjNapkhKDAQDIDL38bZWU4Rm0nq82Xb4yaI0BCWDcFkHV',
|
||||||
'og2umGfGng==',
|
'og2umGfGng==',
|
||||||
'=v3+L',
|
'=v3+L',
|
||||||
'-----END PGP PUBLIC KEY BLOCK-----'].join('\n');
|
'-----END PGP PUBLIC KEY BLOCK-----'
|
||||||
|
].join('\n');
|
||||||
|
|
||||||
const priv_key_de =
|
const priv_key_de = [
|
||||||
['-----BEGIN PGP PRIVATE KEY BLOCK-----',
|
'-----BEGIN PGP PRIVATE KEY BLOCK-----',
|
||||||
'Version: GnuPG v2.0.22 (GNU/Linux)',
|
'Version: GnuPG v2.0.22 (GNU/Linux)',
|
||||||
'',
|
'',
|
||||||
'lQN5BFLVgdQRCACOlpq0cd1IazNjOEpWPZvx/O3JMbdDs3B3iCG0Mo5OUZ8lpKU5',
|
'lQN5BFLVgdQRCACOlpq0cd1IazNjOEpWPZvx/O3JMbdDs3B3iCG0Mo5OUZ8lpKU5',
|
||||||
|
@ -160,7 +164,8 @@ const priv_key_de =
|
||||||
'ijpKCgD9HC+RyNOutHhPFbgSvyH3cY6Rbnh1MFAUH3SG4gmiE8kA/A679f/+Izs1',
|
'ijpKCgD9HC+RyNOutHhPFbgSvyH3cY6Rbnh1MFAUH3SG4gmiE8kA/A679f/+Izs1',
|
||||||
'DHTORVqAOdoOcu5Qh7AQg1GdSmfFAsx2',
|
'DHTORVqAOdoOcu5Qh7AQg1GdSmfFAsx2',
|
||||||
'=kyeP',
|
'=kyeP',
|
||||||
'-----END PGP PRIVATE KEY BLOCK-----'].join('\n');
|
'-----END PGP PRIVATE KEY BLOCK-----'
|
||||||
|
].join('\n');
|
||||||
|
|
||||||
const priv_key_2000_2008 = `-----BEGIN PGP PRIVATE KEY BLOCK-----
|
const priv_key_2000_2008 = `-----BEGIN PGP PRIVATE KEY BLOCK-----
|
||||||
|
|
||||||
|
@ -292,19 +297,20 @@ const passphrase = 'hello world';
|
||||||
const plaintext = input.createSomeMessage();
|
const plaintext = input.createSomeMessage();
|
||||||
const password1 = 'I am a password';
|
const password1 = 'I am a password';
|
||||||
const password2 = 'I am another password';
|
const password2 = 'I am another password';
|
||||||
const password3 = 'I am a third password';
|
|
||||||
|
|
||||||
const twoPasswordGPGFail = ['-----BEGIN PGP MESSAGE-----',
|
const twoPasswordGPGFail = [
|
||||||
'Version: OpenPGP.js v3.0.0',
|
'-----BEGIN PGP MESSAGE-----',
|
||||||
'Comment: https://openpgpjs.org',
|
'Version: OpenPGP.js v3.0.0',
|
||||||
'',
|
'Comment: https://openpgpjs.org',
|
||||||
'wy4ECQMIWjj3WEfWxGpgrfb3vXu0TS9L8UNTBvNZFIjltGjMVkLFD+/afgs5',
|
'',
|
||||||
'aXt0wy4ECQMIrFo3TFN5xqtgtB+AaAjBcWJrA4bvIPBpJ38PbMWeF0JQgrqg',
|
'wy4ECQMIWjj3WEfWxGpgrfb3vXu0TS9L8UNTBvNZFIjltGjMVkLFD+/afgs5',
|
||||||
'j3uehxXy0mUB5i7B61g0ho+YplyFGM0s9XayJCnu40tWmr5LqqsRxuwrhJKR',
|
'aXt0wy4ECQMIrFo3TFN5xqtgtB+AaAjBcWJrA4bvIPBpJ38PbMWeF0JQgrqg',
|
||||||
'migslOF/l6Y9F0F9xGIZWGhxp3ugQPjVKjj8fOH7ap14mLm60C8q8AOxiSmL',
|
'j3uehxXy0mUB5i7B61g0ho+YplyFGM0s9XayJCnu40tWmr5LqqsRxuwrhJKR',
|
||||||
'ubsd/hL7FPZatUYAAZVA0a6hmQ==',
|
'migslOF/l6Y9F0F9xGIZWGhxp3ugQPjVKjj8fOH7ap14mLm60C8q8AOxiSmL',
|
||||||
'=cHCV',
|
'ubsd/hL7FPZatUYAAZVA0a6hmQ==',
|
||||||
'-----END PGP MESSAGE-----'].join('\n');
|
'=cHCV',
|
||||||
|
'-----END PGP MESSAGE-----'
|
||||||
|
].join('\n');
|
||||||
|
|
||||||
const ecdh_msg_bad = `-----BEGIN PGP MESSAGE-----
|
const ecdh_msg_bad = `-----BEGIN PGP MESSAGE-----
|
||||||
Version: ProtonMail
|
Version: ProtonMail
|
||||||
|
@ -690,7 +696,7 @@ module.exports = () => describe('OpenPGP.js public api tests', function() {
|
||||||
it('should work in JS', function() {
|
it('should work in JS', function() {
|
||||||
openpgp.config.useNative = false;
|
openpgp.config.useNative = false;
|
||||||
const opt = {
|
const opt = {
|
||||||
userIds: [{ name: 'Test User', email: 'text@example.com' }],
|
userIds: [{ name: 'Test User', email: 'text@example.com' }]
|
||||||
};
|
};
|
||||||
|
|
||||||
return openpgp.generateKey(opt).then(function(newKey) {
|
return openpgp.generateKey(opt).then(function(newKey) {
|
||||||
|
@ -703,7 +709,7 @@ module.exports = () => describe('OpenPGP.js public api tests', function() {
|
||||||
it('should work in with native crypto', function() {
|
it('should work in with native crypto', function() {
|
||||||
openpgp.config.useNative = true;
|
openpgp.config.useNative = true;
|
||||||
const opt = {
|
const opt = {
|
||||||
userIds: [{ name: 'Test User', email: 'text@example.com' }],
|
userIds: [{ name: 'Test User', email: 'text@example.com' }]
|
||||||
};
|
};
|
||||||
|
|
||||||
return openpgp.generateKey(opt).then(function(newKey) {
|
return openpgp.generateKey(opt).then(function(newKey) {
|
||||||
|
@ -1346,7 +1352,7 @@ module.exports = () => describe('OpenPGP.js public api tests', function() {
|
||||||
|
|
||||||
it('should encrypt/sign and decrypt/verify with generated key', function () {
|
it('should encrypt/sign and decrypt/verify with generated key', function () {
|
||||||
const genOpt = {
|
const genOpt = {
|
||||||
userIds: [{ name: 'Test User', email: 'text@example.com' }],
|
userIds: [{ name: 'Test User', email: 'text@example.com' }]
|
||||||
};
|
};
|
||||||
|
|
||||||
return openpgp.generateKey(genOpt).then(async function(newKey) {
|
return openpgp.generateKey(genOpt).then(async function(newKey) {
|
||||||
|
@ -1378,7 +1384,7 @@ module.exports = () => describe('OpenPGP.js public api tests', function() {
|
||||||
|
|
||||||
it('should encrypt/sign and decrypt/verify with generated key and detached signatures', async function () {
|
it('should encrypt/sign and decrypt/verify with generated key and detached signatures', async function () {
|
||||||
const newKey = await openpgp.generateKey({
|
const newKey = await openpgp.generateKey({
|
||||||
userIds: [{ name: 'Test User', email: 'text@example.com' }],
|
userIds: [{ name: 'Test User', email: 'text@example.com' }]
|
||||||
});
|
});
|
||||||
const newPublicKey = await openpgp.readArmoredKey(newKey.publicKeyArmored);
|
const newPublicKey = await openpgp.readArmoredKey(newKey.publicKeyArmored);
|
||||||
const newPrivateKey = await openpgp.readArmoredKey(newKey.privateKeyArmored);
|
const newPrivateKey = await openpgp.readArmoredKey(newKey.privateKeyArmored);
|
||||||
|
@ -1744,8 +1750,8 @@ module.exports = () => describe('OpenPGP.js public api tests', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("3DES decrypt", function() {
|
describe("3DES decrypt", function() {
|
||||||
const pgp_msg =
|
const pgp_msg = [
|
||||||
['-----BEGIN PGP MESSAGE-----',
|
'-----BEGIN PGP MESSAGE-----',
|
||||||
'Version: GnuPG/MacGPG2 v2.0.19 (Darwin)',
|
'Version: GnuPG/MacGPG2 v2.0.19 (Darwin)',
|
||||||
'Comment: GPGTools - https://gpgtools.org',
|
'Comment: GPGTools - https://gpgtools.org',
|
||||||
'',
|
'',
|
||||||
|
@ -1755,10 +1761,11 @@ module.exports = () => describe('OpenPGP.js public api tests', function() {
|
||||||
'ASm9aZ3H6FerNhm8RezDY5vRn6xw3o/wH5YEBvV2BEmmFKZ2BlqFQxqChr8UNwd1',
|
'ASm9aZ3H6FerNhm8RezDY5vRn6xw3o/wH5YEBvV2BEmmFKZ2BlqFQxqChr8UNwd1',
|
||||||
'Ieebnq0HtBPE8YU/L0U=',
|
'Ieebnq0HtBPE8YU/L0U=',
|
||||||
'=JyIa',
|
'=JyIa',
|
||||||
'-----END PGP MESSAGE-----'].join('\n');
|
'-----END PGP MESSAGE-----'
|
||||||
|
].join('\n');
|
||||||
|
|
||||||
const priv_key =
|
const priv_key = [
|
||||||
['-----BEGIN PGP PRIVATE KEY BLOCK-----',
|
'-----BEGIN PGP PRIVATE KEY BLOCK-----',
|
||||||
'Version: GnuPG/MacGPG2 v2.0.19 (Darwin)',
|
'Version: GnuPG/MacGPG2 v2.0.19 (Darwin)',
|
||||||
'Comment: GPGTools - https://gpgtools.org',
|
'Comment: GPGTools - https://gpgtools.org',
|
||||||
'',
|
'',
|
||||||
|
@ -1793,7 +1800,8 @@ module.exports = () => describe('OpenPGP.js public api tests', function() {
|
||||||
'CHaOn1Xl2gmYTq2KiJkgtLuwptYU1iSj7vvSHKy0+nYIckOZB4pRCOjknT08O4ZJ',
|
'CHaOn1Xl2gmYTq2KiJkgtLuwptYU1iSj7vvSHKy0+nYIckOZB4pRCOjknT08O4ZJ',
|
||||||
'22q10ausyQXoOxXfDWVwKA==',
|
'22q10ausyQXoOxXfDWVwKA==',
|
||||||
'=IkKW',
|
'=IkKW',
|
||||||
'-----END PGP PRIVATE KEY BLOCK-----'].join('\n');
|
'-----END PGP PRIVATE KEY BLOCK-----'
|
||||||
|
].join('\n');
|
||||||
|
|
||||||
it('Decrypt message', async function() {
|
it('Decrypt message', async function() {
|
||||||
const privKey = await openpgp.readArmoredKey(priv_key);
|
const privKey = await openpgp.readArmoredKey(priv_key);
|
||||||
|
@ -1902,14 +1910,14 @@ module.exports = () => describe('OpenPGP.js public api tests', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Streaming encrypt and decrypt small message roundtrip', async function() {
|
it('Streaming encrypt and decrypt small message roundtrip', async function() {
|
||||||
let plaintext = [];
|
const plaintext = [];
|
||||||
let i = 0;
|
let i = 0;
|
||||||
const useNativeStream = (() => { try { new global.ReadableStream(); return true; } catch (e) { return false; } })();
|
const useNativeStream = (() => { try { new global.ReadableStream(); return true; } catch (e) { return false; } })(); // eslint-disable-line no-new
|
||||||
const ReadableStream = useNativeStream ? global.ReadableStream : openpgp.stream.ReadableStream;
|
const ReadableStream = useNativeStream ? global.ReadableStream : openpgp.stream.ReadableStream;
|
||||||
const data = new ReadableStream({
|
const data = new ReadableStream({
|
||||||
async pull(controller) {
|
async pull(controller) {
|
||||||
if (i++ < 4) {
|
if (i++ < 4) {
|
||||||
let randomBytes = await random.getRandomBytes(10);
|
const randomBytes = await random.getRandomBytes(10);
|
||||||
controller.enqueue(randomBytes);
|
controller.enqueue(randomBytes);
|
||||||
plaintext.push(randomBytes.slice());
|
plaintext.push(randomBytes.slice());
|
||||||
} else {
|
} else {
|
||||||
|
@ -2235,7 +2243,7 @@ module.exports = () => describe('OpenPGP.js public api tests', function() {
|
||||||
streaming: 'web',
|
streaming: 'web',
|
||||||
format: 'binary'
|
format: 'binary'
|
||||||
};
|
};
|
||||||
const useNativeStream = (() => { try { new global.ReadableStream(); return true; } catch (e) { return false; } })();
|
const useNativeStream = (() => { try { new global.ReadableStream(); return true; } catch (e) { return false; } })(); // eslint-disable-line no-new
|
||||||
return openpgp.sign(signOpt).then(async function (signed) {
|
return openpgp.sign(signOpt).then(async function (signed) {
|
||||||
expect(openpgp.stream.isStream(signed)).to.equal(useNativeStream ? 'web' : 'ponyfill');
|
expect(openpgp.stream.isStream(signed)).to.equal(useNativeStream ? 'web' : 'ponyfill');
|
||||||
const message = await openpgp.readMessage(signed);
|
const message = await openpgp.readMessage(signed);
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
/* eslint-disable max-lines */
|
||||||
|
|
||||||
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
|
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
|
||||||
const crypto = require('../../src/crypto');
|
const crypto = require('../../src/crypto');
|
||||||
const util = require('../../src/util');
|
const util = require('../../src/util');
|
||||||
|
@ -8,7 +10,6 @@ chai.use(require('chai-as-promised'));
|
||||||
|
|
||||||
const { expect } = chai;
|
const { expect } = chai;
|
||||||
const input = require('./testInputs.js');
|
const input = require('./testInputs.js');
|
||||||
const { PacketList } = require('../../dist/node/openpgp.min');
|
|
||||||
|
|
||||||
function stringify(array) {
|
function stringify(array) {
|
||||||
if (openpgp.stream.isStream(array)) {
|
if (openpgp.stream.isStream(array)) {
|
||||||
|
@ -154,7 +155,7 @@ module.exports = () => describe("Packet", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Sym. encrypted AEAD protected packet (AEAD)', async function() {
|
it('Sym. encrypted AEAD protected packet (AEAD)', async function() {
|
||||||
let aeadProtectVal = openpgp.config.aeadProtect;
|
const aeadProtectVal = openpgp.config.aeadProtect;
|
||||||
openpgp.config.aeadProtect = true;
|
openpgp.config.aeadProtect = true;
|
||||||
const testText = input.createSomeMessage();
|
const testText = input.createSomeMessage();
|
||||||
|
|
||||||
|
@ -188,14 +189,14 @@ module.exports = () => describe("Packet", function() {
|
||||||
cryptStub.onCall(0).callsFake(async function() {
|
cryptStub.onCall(0).callsFake(async function() {
|
||||||
cryptCallsActive++;
|
cryptCallsActive++;
|
||||||
try {
|
try {
|
||||||
return await crypt.apply(this, arguments);
|
return await crypt.apply(this, arguments); // eslint-disable-line no-invalid-this
|
||||||
} finally {
|
} finally {
|
||||||
cryptCallsActive--;
|
cryptCallsActive--;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
cryptStub.onCall(1).callsFake(function() {
|
cryptStub.onCall(1).callsFake(function() {
|
||||||
expect(cryptCallsActive).to.equal(1);
|
expect(cryptCallsActive).to.equal(1);
|
||||||
return crypt.apply(this, arguments);
|
return crypt.apply(this, arguments); // eslint-disable-line no-invalid-this
|
||||||
});
|
});
|
||||||
cryptStub.callThrough();
|
cryptStub.callThrough();
|
||||||
return cryptStub;
|
return cryptStub;
|
||||||
|
@ -207,8 +208,8 @@ module.exports = () => describe("Packet", function() {
|
||||||
const encryptStub = cryptStub(webCrypto, 'encrypt');
|
const encryptStub = cryptStub(webCrypto, 'encrypt');
|
||||||
const decryptStub = cryptStub(webCrypto, 'decrypt');
|
const decryptStub = cryptStub(webCrypto, 'decrypt');
|
||||||
|
|
||||||
let aeadProtectVal = openpgp.config.aeadProtect;
|
const aeadProtectVal = openpgp.config.aeadProtect;
|
||||||
let aeadChunkSizeByteVal = openpgp.config.aeadChunkSizeByte;
|
const aeadChunkSizeByteVal = openpgp.config.aeadChunkSizeByte;
|
||||||
openpgp.config.aeadProtect = true;
|
openpgp.config.aeadProtect = true;
|
||||||
openpgp.config.aeadChunkSizeByte = 0;
|
openpgp.config.aeadChunkSizeByte = 0;
|
||||||
const testText = input.createSomeMessage();
|
const testText = input.createSomeMessage();
|
||||||
|
@ -248,7 +249,7 @@ module.exports = () => describe("Packet", function() {
|
||||||
const nodeCrypto = util.getNodeCrypto();
|
const nodeCrypto = util.getNodeCrypto();
|
||||||
if (!nodeCrypto) return;
|
if (!nodeCrypto) return;
|
||||||
|
|
||||||
let packetBytes = util.hexToUint8Array(`
|
const packetBytes = util.hexToUint8Array(`
|
||||||
d4 4a 01 07 01 0e b7 32 37 9f 73 c4 92 8d e2 5f
|
d4 4a 01 07 01 0e b7 32 37 9f 73 c4 92 8d e2 5f
|
||||||
ac fe 65 17 ec 10 5d c1 1a 81 dc 0c b8 a2 f6 f3
|
ac fe 65 17 ec 10 5d c1 1a 81 dc 0c b8 a2 f6 f3
|
||||||
d9 00 16 38 4a 56 fc 82 1a e1 1a e8 db cb 49 86
|
d9 00 16 38 4a 56 fc 82 1a e1 1a e8 db cb 49 86
|
||||||
|
@ -256,8 +257,8 @@ module.exports = () => describe("Packet", function() {
|
||||||
ab 01 3d e1 25 95 86 90 6e ab 24 76
|
ab 01 3d e1 25 95 86 90 6e ab 24 76
|
||||||
`.replace(/\s+/g, ''));
|
`.replace(/\s+/g, ''));
|
||||||
|
|
||||||
let aeadProtectVal = openpgp.config.aeadProtect;
|
const aeadProtectVal = openpgp.config.aeadProtect;
|
||||||
let aeadChunkSizeByteVal = openpgp.config.aeadChunkSizeByte;
|
const aeadChunkSizeByteVal = openpgp.config.aeadChunkSizeByte;
|
||||||
openpgp.config.aeadProtect = true;
|
openpgp.config.aeadProtect = true;
|
||||||
openpgp.config.aeadChunkSizeByte = 14;
|
openpgp.config.aeadChunkSizeByte = 14;
|
||||||
|
|
||||||
|
@ -276,7 +277,7 @@ module.exports = () => describe("Packet", function() {
|
||||||
|
|
||||||
const msg2 = new openpgp.PacketList();
|
const msg2 = new openpgp.PacketList();
|
||||||
|
|
||||||
let randomBytesStub = stub(nodeCrypto, 'randomBytes');
|
const randomBytesStub = stub(nodeCrypto, 'randomBytes');
|
||||||
randomBytesStub.returns(iv);
|
randomBytesStub.returns(iv);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -485,7 +486,7 @@ module.exports = () => describe("Packet", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Sym. encrypted session key reading/writing (AEAD)', async function() {
|
it('Sym. encrypted session key reading/writing (AEAD)', async function() {
|
||||||
let aeadProtectVal = openpgp.config.aeadProtect;
|
const aeadProtectVal = openpgp.config.aeadProtect;
|
||||||
openpgp.config.aeadProtect = true;
|
openpgp.config.aeadProtect = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -529,25 +530,25 @@ module.exports = () => describe("Packet", function() {
|
||||||
const nodeCrypto = util.getNodeCrypto();
|
const nodeCrypto = util.getNodeCrypto();
|
||||||
if (!nodeCrypto) return;
|
if (!nodeCrypto) return;
|
||||||
|
|
||||||
let aeadProtectVal = openpgp.config.aeadProtect;
|
const aeadProtectVal = openpgp.config.aeadProtect;
|
||||||
let aeadChunkSizeByteVal = openpgp.config.aeadChunkSizeByte;
|
const aeadChunkSizeByteVal = openpgp.config.aeadChunkSizeByte;
|
||||||
let s2kIterationCountByteVal = openpgp.config.s2kIterationCountByte;
|
const s2kIterationCountByteVal = openpgp.config.s2kIterationCountByte;
|
||||||
openpgp.config.aeadProtect = true;
|
openpgp.config.aeadProtect = true;
|
||||||
openpgp.config.aeadChunkSizeByte = 14;
|
openpgp.config.aeadChunkSizeByte = 14;
|
||||||
openpgp.config.s2kIterationCountByte = 0x90;
|
openpgp.config.s2kIterationCountByte = 0x90;
|
||||||
|
|
||||||
let salt = util.hexToUint8Array(`cd5a9f70fbe0bc65`);
|
const salt = util.hexToUint8Array(`cd5a9f70fbe0bc65`);
|
||||||
let sessionKey = util.hexToUint8Array(`86 f1 ef b8 69 52 32 9f 24 ac d3 bf d0 e5 34 6d`.replace(/\s+/g, ''));
|
const sessionKey = util.hexToUint8Array(`86 f1 ef b8 69 52 32 9f 24 ac d3 bf d0 e5 34 6d`.replace(/\s+/g, ''));
|
||||||
let sessionIV = util.hexToUint8Array(`bc 66 9e 34 e5 00 dc ae dc 5b 32 aa 2d ab 02 35`.replace(/\s+/g, ''));
|
const sessionIV = util.hexToUint8Array(`bc 66 9e 34 e5 00 dc ae dc 5b 32 aa 2d ab 02 35`.replace(/\s+/g, ''));
|
||||||
let dataIV = util.hexToUint8Array(`b7 32 37 9f 73 c4 92 8d e2 5f ac fe 65 17 ec 10`.replace(/\s+/g, ''));
|
const dataIV = util.hexToUint8Array(`b7 32 37 9f 73 c4 92 8d e2 5f ac fe 65 17 ec 10`.replace(/\s+/g, ''));
|
||||||
|
|
||||||
let randomBytesStub = stub(nodeCrypto, 'randomBytes');
|
const randomBytesStub = stub(nodeCrypto, 'randomBytes');
|
||||||
randomBytesStub.onCall(0).returns(salt);
|
randomBytesStub.onCall(0).returns(salt);
|
||||||
randomBytesStub.onCall(1).returns(sessionKey);
|
randomBytesStub.onCall(1).returns(sessionKey);
|
||||||
randomBytesStub.onCall(2).returns(sessionIV);
|
randomBytesStub.onCall(2).returns(sessionIV);
|
||||||
randomBytesStub.onCall(3).returns(dataIV);
|
randomBytesStub.onCall(3).returns(dataIV);
|
||||||
|
|
||||||
let packetBytes = util.hexToUint8Array(`
|
const packetBytes = util.hexToUint8Array(`
|
||||||
c3 3e 05 07 01 03 08 cd 5a 9f 70 fb e0 bc 65 90
|
c3 3e 05 07 01 03 08 cd 5a 9f 70 fb e0 bc 65 90
|
||||||
bc 66 9e 34 e5 00 dc ae dc 5b 32 aa 2d ab 02 35
|
bc 66 9e 34 e5 00 dc ae dc 5b 32 aa 2d ab 02 35
|
||||||
9d ee 19 d0 7c 34 46 c4 31 2a 34 ae 19 67 a2 fb
|
9d ee 19 d0 7c 34 46 c4 31 2a 34 ae 19 67 a2 fb
|
||||||
|
@ -607,25 +608,25 @@ module.exports = () => describe("Packet", function() {
|
||||||
const nodeCrypto = util.getNodeCrypto();
|
const nodeCrypto = util.getNodeCrypto();
|
||||||
if (!nodeCrypto) return;
|
if (!nodeCrypto) return;
|
||||||
|
|
||||||
let aeadProtectVal = openpgp.config.aeadProtect;
|
const aeadProtectVal = openpgp.config.aeadProtect;
|
||||||
let aeadChunkSizeByteVal = openpgp.config.aeadChunkSizeByte;
|
const aeadChunkSizeByteVal = openpgp.config.aeadChunkSizeByte;
|
||||||
let s2kIterationCountByteVal = openpgp.config.s2kIterationCountByte;
|
const s2kIterationCountByteVal = openpgp.config.s2kIterationCountByte;
|
||||||
openpgp.config.aeadProtect = true;
|
openpgp.config.aeadProtect = true;
|
||||||
openpgp.config.aeadChunkSizeByte = 14;
|
openpgp.config.aeadChunkSizeByte = 14;
|
||||||
openpgp.config.s2kIterationCountByte = 0x90;
|
openpgp.config.s2kIterationCountByte = 0x90;
|
||||||
|
|
||||||
let salt = util.hexToUint8Array(`9f0b7da3e5ea6477`);
|
const salt = util.hexToUint8Array(`9f0b7da3e5ea6477`);
|
||||||
let sessionKey = util.hexToUint8Array(`d1 f0 1b a3 0e 13 0a a7 d2 58 2c 16 e0 50 ae 44`.replace(/\s+/g, ''));
|
const sessionKey = util.hexToUint8Array(`d1 f0 1b a3 0e 13 0a a7 d2 58 2c 16 e0 50 ae 44`.replace(/\s+/g, ''));
|
||||||
let sessionIV = util.hexToUint8Array(`99 e3 26 e5 40 0a 90 93 6c ef b4 e8 eb a0 8c`.replace(/\s+/g, ''));
|
const sessionIV = util.hexToUint8Array(`99 e3 26 e5 40 0a 90 93 6c ef b4 e8 eb a0 8c`.replace(/\s+/g, ''));
|
||||||
let dataIV = util.hexToUint8Array(`5e d2 bc 1e 47 0a be 8f 1d 64 4c 7a 6c 8a 56`.replace(/\s+/g, ''));
|
const dataIV = util.hexToUint8Array(`5e d2 bc 1e 47 0a be 8f 1d 64 4c 7a 6c 8a 56`.replace(/\s+/g, ''));
|
||||||
|
|
||||||
let randomBytesStub = stub(nodeCrypto, 'randomBytes');
|
const randomBytesStub = stub(nodeCrypto, 'randomBytes');
|
||||||
randomBytesStub.onCall(0).returns(salt);
|
randomBytesStub.onCall(0).returns(salt);
|
||||||
randomBytesStub.onCall(1).returns(sessionKey);
|
randomBytesStub.onCall(1).returns(sessionKey);
|
||||||
randomBytesStub.onCall(2).returns(sessionIV);
|
randomBytesStub.onCall(2).returns(sessionIV);
|
||||||
randomBytesStub.onCall(3).returns(dataIV);
|
randomBytesStub.onCall(3).returns(dataIV);
|
||||||
|
|
||||||
let packetBytes = util.hexToUint8Array(`
|
const packetBytes = util.hexToUint8Array(`
|
||||||
c3 3d 05 07 02 03 08 9f 0b 7d a3 e5 ea 64 77 90
|
c3 3d 05 07 02 03 08 9f 0b 7d a3 e5 ea 64 77 90
|
||||||
99 e3 26 e5 40 0a 90 93 6c ef b4 e8 eb a0 8c 67
|
99 e3 26 e5 40 0a 90 93 6c ef b4 e8 eb a0 8c 67
|
||||||
73 71 6d 1f 27 14 54 0a 38 fc ac 52 99 49 da c5
|
73 71 6d 1f 27 14 54 0a 38 fc ac 52 99 49 da c5
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
/* eslint-disable max-lines */
|
||||||
|
/* globals tryTests: true */
|
||||||
|
|
||||||
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
|
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
|
||||||
const util = require('../../src/util');
|
const util = require('../../src/util');
|
||||||
|
|
||||||
|
@ -658,8 +661,8 @@ Blk+CJ7ytHy6En8542bB/yC+Z9/zWbVuhg==
|
||||||
=jmT1
|
=jmT1
|
||||||
-----END PGP PUBLIC KEY BLOCK-----`;
|
-----END PGP PUBLIC KEY BLOCK-----`;
|
||||||
|
|
||||||
const msg_sig_expired =
|
const msg_sig_expired = [
|
||||||
['-----BEGIN PGP MESSAGE-----',
|
'-----BEGIN PGP MESSAGE-----',
|
||||||
'Comment: GPGTools - https://gpgtools.org',
|
'Comment: GPGTools - https://gpgtools.org',
|
||||||
'',
|
'',
|
||||||
'owEBWwKk/ZANAwAKAeyAexA3gWZ0AawUYgloZWxsby50eHRaX2WpaGVsbG+JAjME',
|
'owEBWwKk/ZANAwAKAeyAexA3gWZ0AawUYgloZWxsby50eHRaX2WpaGVsbG+JAjME',
|
||||||
|
@ -676,10 +679,11 @@ Blk+CJ7ytHy6En8542bB/yC+Z9/zWbVuhg==
|
||||||
'kLlUC1zKjFPpRhO27ImTJuImil4lR2/CFjB1duG3JGJQaYIq8RFJOjvTVY29wl0i',
|
'kLlUC1zKjFPpRhO27ImTJuImil4lR2/CFjB1duG3JGJQaYIq8RFJOjvTVY29wl0i',
|
||||||
'pFy6y1Ofv2lLHB9K7N7dvvee2nvpUMkLEL52oFQ6Jc7sdg==',
|
'pFy6y1Ofv2lLHB9K7N7dvvee2nvpUMkLEL52oFQ6Jc7sdg==',
|
||||||
'=Q4tk',
|
'=Q4tk',
|
||||||
'-----END PGP MESSAGE-----'].join('\n');
|
'-----END PGP MESSAGE-----'
|
||||||
|
].join('\n');
|
||||||
|
|
||||||
const flowcrypt_stripped_key =
|
const flowcrypt_stripped_key = [
|
||||||
['-----BEGIN PGP PRIVATE KEY BLOCK-----',
|
'-----BEGIN PGP PRIVATE KEY BLOCK-----',
|
||||||
'',
|
'',
|
||||||
'lQIVBFttsQgBEADZT3v1LUGqP/hhUWmjfHVh6MErZAqsmbUIgsUKCDpQ4hrRpot2',
|
'lQIVBFttsQgBEADZT3v1LUGqP/hhUWmjfHVh6MErZAqsmbUIgsUKCDpQ4hrRpot2',
|
||||||
'V3ZIMbbEGSjbUvyT/2quAtLRHx9/FK1MA3q0qVrUGmiXx78IiAuQ7sZOTjYXBDnq',
|
'V3ZIMbbEGSjbUvyT/2quAtLRHx9/FK1MA3q0qVrUGmiXx78IiAuQ7sZOTjYXBDnq',
|
||||||
|
@ -820,7 +824,8 @@ Blk+CJ7ytHy6En8542bB/yC+Z9/zWbVuhg==
|
||||||
'hBr9NrB2VFHtdaWf2YqBGb7c1xusmEuGLcGUqFGCXo/g/lOSPijea91puCf9bgKy',
|
'hBr9NrB2VFHtdaWf2YqBGb7c1xusmEuGLcGUqFGCXo/g/lOSPijea91puCf9bgKy',
|
||||||
'0P7n+O0V3W1QpkI4ne5TE2vBFUFo9K5IFe4qBI1JPjbLTfOI2lojx8P12+lqWug=',
|
'0P7n+O0V3W1QpkI4ne5TE2vBFUFo9K5IFe4qBI1JPjbLTfOI2lojx8P12+lqWug=',
|
||||||
'=NbaL',
|
'=NbaL',
|
||||||
'-----END PGP PRIVATE KEY BLOCK-----'].join("\n");
|
'-----END PGP PRIVATE KEY BLOCK-----'
|
||||||
|
].join("\n");
|
||||||
|
|
||||||
const signature_with_critical_notation = `-----BEGIN PGP MESSAGE-----
|
const signature_with_critical_notation = `-----BEGIN PGP MESSAGE-----
|
||||||
|
|
||||||
|
@ -832,7 +837,7 @@ vwjE8mqJXetNMfj8r2SCyvkEnlVRYR+/mnge+ib56FdJ8uKtqSxyvgA=
|
||||||
=fRXs
|
=fRXs
|
||||||
-----END PGP MESSAGE-----`;
|
-----END PGP MESSAGE-----`;
|
||||||
|
|
||||||
const signature_with_non_human_readable_notations = `-----BEGIN PGP SIGNATURE-----
|
const signature_with_non_human_readable_notations = `-----BEGIN PGP SIGNATURE-----
|
||||||
|
|
||||||
wncEARYKAB8FAl2TS9MYFAAAAAAADAADdGVzdEBrZXkuY29tAQIDAAoJEGZ9
|
wncEARYKAB8FAl2TS9MYFAAAAAAADAADdGVzdEBrZXkuY29tAQIDAAoJEGZ9
|
||||||
gtV/iL8hrhMBAOQ/UgqRTbx1Z8inGmRdUx1cJU1SR4Pnq/eJNH/CFk5DAP0Q
|
gtV/iL8hrhMBAOQ/UgqRTbx1Z8inGmRdUx1cJU1SR4Pnq/eJNH/CFk5DAP0Q
|
||||||
|
@ -1449,7 +1454,7 @@ hkJiXopCSWKSlQInL1devkJJUWJmTmZeugJYlpdLAagQJM0JpsCqIQZwKgAA
|
||||||
const pubKey = await openpgp.readArmoredKey(pub_key_arm2);
|
const pubKey = await openpgp.readArmoredKey(pub_key_arm2);
|
||||||
const privKey = await openpgp.readArmoredKey(priv_key_arm2);
|
const privKey = await openpgp.readArmoredKey(priv_key_arm2);
|
||||||
await privKey.decrypt('hello world');
|
await privKey.decrypt('hello world');
|
||||||
return openpgp.sign({ privateKeys:[privKey], message: openpgp.Message.fromText(plaintext), detached: true}).then(async function(signed) {
|
return openpgp.sign({ privateKeys:[privKey], message: openpgp.Message.fromText(plaintext), detached: true }).then(async function(signed) {
|
||||||
const signature = await openpgp.readArmoredSignature(signed);
|
const signature = await openpgp.readArmoredSignature(signed);
|
||||||
return openpgp.verify({ publicKeys:[pubKey], message: openpgp.Message.fromBinary(util.encodeUtf8(plaintext)), signature: signature });
|
return openpgp.verify({ publicKeys:[pubKey], message: openpgp.Message.fromBinary(util.encodeUtf8(plaintext)), signature: signature });
|
||||||
}).then(function(cleartextSig) {
|
}).then(function(cleartextSig) {
|
||||||
|
@ -1466,7 +1471,7 @@ hkJiXopCSWKSlQInL1devkJJUWJmTmZeugJYlpdLAagQJM0JpsCqIQZwKgAA
|
||||||
const pubKey = await openpgp.readArmoredKey(pub_key_arm2);
|
const pubKey = await openpgp.readArmoredKey(pub_key_arm2);
|
||||||
const privKey = await openpgp.readArmoredKey(priv_key_arm2);
|
const privKey = await openpgp.readArmoredKey(priv_key_arm2);
|
||||||
await privKey.decrypt('hello world');
|
await privKey.decrypt('hello world');
|
||||||
return openpgp.sign({ privateKeys:[privKey], message:openpgp.Message.fromBinary(plaintextArray), detached: true}).then(async function(signed) {
|
return openpgp.sign({ privateKeys:[privKey], message:openpgp.Message.fromBinary(plaintextArray), detached: true }).then(async function(signed) {
|
||||||
const signature = await openpgp.readArmoredSignature(signed);
|
const signature = await openpgp.readArmoredSignature(signed);
|
||||||
return openpgp.verify({ publicKeys:[pubKey], message: openpgp.Message.fromText(plaintext), signature: signature });
|
return openpgp.verify({ publicKeys:[pubKey], message: openpgp.Message.fromText(plaintext), signature: signature });
|
||||||
}).then(function(cleartextSig) {
|
}).then(function(cleartextSig) {
|
||||||
|
@ -1482,12 +1487,12 @@ hkJiXopCSWKSlQInL1devkJJUWJmTmZeugJYlpdLAagQJM0JpsCqIQZwKgAA
|
||||||
const pubKey = await openpgp.readArmoredKey(pub_key_arm2);
|
const pubKey = await openpgp.readArmoredKey(pub_key_arm2);
|
||||||
const privKey = await openpgp.readArmoredKey(priv_key_arm2);
|
const privKey = await openpgp.readArmoredKey(priv_key_arm2);
|
||||||
await Promise.all([privKey.primaryKey.decrypt('hello world'), privKey.subKeys[0].keyPacket.decrypt('hello world')]);
|
await Promise.all([privKey.primaryKey.decrypt('hello world'), privKey.subKeys[0].keyPacket.decrypt('hello world')]);
|
||||||
return openpgp.sign({ privateKeys:[privKey], message: openpgp.Message.fromText(plaintext), detached: true}).then(async function(signed) {
|
return openpgp.sign({ privateKeys:[privKey], message: openpgp.Message.fromText(plaintext), detached: true }).then(async function(signed) {
|
||||||
const signature = await openpgp.readArmoredSignature(signed);
|
const signature = await openpgp.readArmoredSignature(signed);
|
||||||
return openpgp.encrypt({ message: openpgp.Message.fromBinary(util.encodeUtf8(plaintext)), publicKeys: [pubKey], signature })
|
return openpgp.encrypt({ message: openpgp.Message.fromBinary(util.encodeUtf8(plaintext)), publicKeys: [pubKey], signature });
|
||||||
}).then(async data => {
|
}).then(async data => {
|
||||||
const csMsg = await openpgp.readArmoredMessage(data);
|
const csMsg = await openpgp.readArmoredMessage(data);
|
||||||
return openpgp.decrypt({ message: csMsg, privateKeys: [ privKey ], publicKeys: [ pubKey ] });
|
return openpgp.decrypt({ message: csMsg, privateKeys: [privKey], publicKeys: [pubKey] });
|
||||||
}).then(function(cleartextSig) {
|
}).then(function(cleartextSig) {
|
||||||
expect(cleartextSig).to.exist;
|
expect(cleartextSig).to.exist;
|
||||||
expect(cleartextSig.signatures).to.have.length(1);
|
expect(cleartextSig.signatures).to.have.length(1);
|
||||||
|
@ -1543,7 +1548,7 @@ hkJiXopCSWKSlQInL1devkJJUWJmTmZeugJYlpdLAagQJM0JpsCqIQZwKgAA
|
||||||
|
|
||||||
expect(pubKey).to.exist;
|
expect(pubKey).to.exist;
|
||||||
expect(pubKey.users[0].selfCertifications[0].keyNeverExpires).to.be.false;
|
expect(pubKey.users[0].selfCertifications[0].keyNeverExpires).to.be.false;
|
||||||
expect(pubKey.users[0].selfCertifications[0].keyExpirationTime).to.equal(5*365*24*60*60);
|
expect(pubKey.users[0].selfCertifications[0].keyExpirationTime).to.equal(5 * 365 * 24 * 60 * 60);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Write unhashed subpackets', async function() {
|
it('Write unhashed subpackets', async function() {
|
||||||
|
@ -1697,9 +1702,9 @@ iTuGu4fEU1UligAXSrZmCdE=
|
||||||
-----END PGP PUBLIC KEY BLOCK-----`;
|
-----END PGP PUBLIC KEY BLOCK-----`;
|
||||||
|
|
||||||
const key = await openpgp.readArmoredKey(armoredKeyWithPhoto);
|
const key = await openpgp.readArmoredKey(armoredKeyWithPhoto);
|
||||||
for (const user of key.users) {
|
await Promise.all(key.users.map(async user => {
|
||||||
await user.verify(key.primaryKey);
|
await user.verify(key.primaryKey);
|
||||||
}
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should verify a shorter RSA signature', async function () {
|
it('should verify a shorter RSA signature', async function () {
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
/* eslint-disable max-lines */
|
||||||
|
/* globals tryTests: true */
|
||||||
|
|
||||||
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
|
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
|
||||||
const random = require('../../src/crypto/random');
|
const random = require('../../src/crypto/random');
|
||||||
const util = require('../../src/util');
|
const util = require('../../src/util');
|
||||||
|
@ -11,11 +14,11 @@ const { expect } = chai;
|
||||||
|
|
||||||
const { stream } = openpgp;
|
const { stream } = openpgp;
|
||||||
|
|
||||||
const useNativeStream = (() => { try { new global.ReadableStream(); return true; } catch (e) { return false; } })();
|
const useNativeStream = (() => { try { new global.ReadableStream(); return true; } catch (e) { return false; } })(); // eslint-disable-line no-new
|
||||||
const ReadableStream = useNativeStream ? global.ReadableStream : openpgp.stream.ReadableStream;
|
const ReadableStream = useNativeStream ? global.ReadableStream : openpgp.stream.ReadableStream;
|
||||||
|
|
||||||
const pub_key =
|
const pub_key = [
|
||||||
['-----BEGIN PGP PUBLIC KEY BLOCK-----',
|
'-----BEGIN PGP PUBLIC KEY BLOCK-----',
|
||||||
'Version: GnuPG v2.0.19 (GNU/Linux)',
|
'Version: GnuPG v2.0.19 (GNU/Linux)',
|
||||||
'',
|
'',
|
||||||
'mI0EUmEvTgEEANyWtQQMOybQ9JltDqmaX0WnNPJeLILIM36sw6zL0nfTQ5zXSS3+',
|
'mI0EUmEvTgEEANyWtQQMOybQ9JltDqmaX0WnNPJeLILIM36sw6zL0nfTQ5zXSS3+',
|
||||||
|
@ -37,10 +40,11 @@ const pub_key =
|
||||||
'AtNTq6ihLMD5v1d82ZC7tNatdlDMGWnIdvEMCv2GZcuIqDQ9rXWs49e7tq1NncLY',
|
'AtNTq6ihLMD5v1d82ZC7tNatdlDMGWnIdvEMCv2GZcuIqDQ9rXWs49e7tq1NncLY',
|
||||||
'hz3tYjKhoFTKEIq3y3Pp',
|
'hz3tYjKhoFTKEIq3y3Pp',
|
||||||
'=h/aX',
|
'=h/aX',
|
||||||
'-----END PGP PUBLIC KEY BLOCK-----'].join('\n');
|
'-----END PGP PUBLIC KEY BLOCK-----'
|
||||||
|
].join('\n');
|
||||||
|
|
||||||
const priv_key =
|
const priv_key = [
|
||||||
['-----BEGIN PGP PRIVATE KEY BLOCK-----',
|
'-----BEGIN PGP PRIVATE KEY BLOCK-----',
|
||||||
'Version: GnuPG v2.0.19 (GNU/Linux)',
|
'Version: GnuPG v2.0.19 (GNU/Linux)',
|
||||||
'',
|
'',
|
||||||
'lQH+BFJhL04BBADclrUEDDsm0PSZbQ6pml9FpzTyXiyCyDN+rMOsy9J300Oc10kt',
|
'lQH+BFJhL04BBADclrUEDDsm0PSZbQ6pml9FpzTyXiyCyDN+rMOsy9J300Oc10kt',
|
||||||
|
@ -77,7 +81,8 @@ const priv_key =
|
||||||
'SXuqKcWqoEuO7OBSEFThCXBfUYMC01OrqKEswPm/V3zZkLu01q12UMwZach28QwK',
|
'SXuqKcWqoEuO7OBSEFThCXBfUYMC01OrqKEswPm/V3zZkLu01q12UMwZach28QwK',
|
||||||
'/YZly4ioND2tdazj17u2rU2dwtiHPe1iMqGgVMoQirfLc+k=',
|
'/YZly4ioND2tdazj17u2rU2dwtiHPe1iMqGgVMoQirfLc+k=',
|
||||||
'=lw5e',
|
'=lw5e',
|
||||||
'-----END PGP PRIVATE KEY BLOCK-----'].join('\n');
|
'-----END PGP PRIVATE KEY BLOCK-----'
|
||||||
|
].join('\n');
|
||||||
|
|
||||||
const passphrase = 'hello world';
|
const passphrase = 'hello world';
|
||||||
|
|
||||||
|
@ -99,7 +104,7 @@ const brainpoolPub = [
|
||||||
'oml1QWkiI6BtbLD39Su6zQKR7u+Y',
|
'oml1QWkiI6BtbLD39Su6zQKR7u+Y',
|
||||||
'=wB7z',
|
'=wB7z',
|
||||||
'-----END PGP PUBLIC KEY BLOCK-----'
|
'-----END PGP PUBLIC KEY BLOCK-----'
|
||||||
].join('\n');
|
].join('\n');
|
||||||
|
|
||||||
const brainpoolPriv = [
|
const brainpoolPriv = [
|
||||||
'-----BEGIN PGP PRIVATE KEY BLOCK-----',
|
'-----BEGIN PGP PRIVATE KEY BLOCK-----',
|
||||||
|
@ -123,7 +128,7 @@ const brainpoolPriv = [
|
||||||
'v6i5Smbioml1QWkiI6BtbLD39Su6zQKR7u+Y',
|
'v6i5Smbioml1QWkiI6BtbLD39Su6zQKR7u+Y',
|
||||||
'=uGZP',
|
'=uGZP',
|
||||||
'-----END PGP PRIVATE KEY BLOCK-----'
|
'-----END PGP PRIVATE KEY BLOCK-----'
|
||||||
].join('\n');
|
].join('\n');
|
||||||
|
|
||||||
const brainpoolPass = '321';
|
const brainpoolPass = '321';
|
||||||
|
|
||||||
|
@ -165,7 +170,14 @@ const xPriv = [
|
||||||
const xPass = 'sun';
|
const xPass = 'sun';
|
||||||
|
|
||||||
|
|
||||||
let privKey, pubKey, plaintext, data, i, canceled, expectedType, dataArrived;
|
let privKey;
|
||||||
|
let pubKey;
|
||||||
|
let plaintext;
|
||||||
|
let data;
|
||||||
|
let i;
|
||||||
|
let canceled;
|
||||||
|
let expectedType;
|
||||||
|
let dataArrived;
|
||||||
|
|
||||||
function tests() {
|
function tests() {
|
||||||
it('Encrypt small message', async function() {
|
it('Encrypt small message', async function() {
|
||||||
|
@ -179,7 +191,7 @@ function tests() {
|
||||||
});
|
});
|
||||||
const encrypted = await openpgp.encrypt({
|
const encrypted = await openpgp.encrypt({
|
||||||
message: openpgp.Message.fromBinary(data),
|
message: openpgp.Message.fromBinary(data),
|
||||||
passwords: ['test'],
|
passwords: ['test']
|
||||||
});
|
});
|
||||||
const msgAsciiArmored = await openpgp.stream.readToEnd(encrypted);
|
const msgAsciiArmored = await openpgp.stream.readToEnd(encrypted);
|
||||||
const message = await openpgp.readArmoredMessage(msgAsciiArmored);
|
const message = await openpgp.readArmoredMessage(msgAsciiArmored);
|
||||||
|
@ -193,7 +205,7 @@ function tests() {
|
||||||
it('Encrypt larger message', async function() {
|
it('Encrypt larger message', async function() {
|
||||||
const encrypted = await openpgp.encrypt({
|
const encrypted = await openpgp.encrypt({
|
||||||
message: openpgp.Message.fromBinary(data),
|
message: openpgp.Message.fromBinary(data),
|
||||||
passwords: ['test'],
|
passwords: ['test']
|
||||||
});
|
});
|
||||||
const reader = openpgp.stream.getReader(encrypted);
|
const reader = openpgp.stream.getReader(encrypted);
|
||||||
expect(await reader.peekBytes(1024)).to.match(/^-----BEGIN PGP MESSAGE-----\n/);
|
expect(await reader.peekBytes(1024)).to.match(/^-----BEGIN PGP MESSAGE-----\n/);
|
||||||
|
@ -212,7 +224,7 @@ function tests() {
|
||||||
it('Input stream should be canceled when canceling encrypted stream', async function() {
|
it('Input stream should be canceled when canceling encrypted stream', async function() {
|
||||||
const encrypted = await openpgp.encrypt({
|
const encrypted = await openpgp.encrypt({
|
||||||
message: openpgp.Message.fromBinary(data),
|
message: openpgp.Message.fromBinary(data),
|
||||||
passwords: ['test'],
|
passwords: ['test']
|
||||||
});
|
});
|
||||||
const reader = openpgp.stream.getReader(encrypted);
|
const reader = openpgp.stream.getReader(encrypted);
|
||||||
expect(await reader.readBytes(1024)).to.match(/^-----BEGIN PGP MESSAGE-----\n/);
|
expect(await reader.readBytes(1024)).to.match(/^-----BEGIN PGP MESSAGE-----\n/);
|
||||||
|
@ -236,7 +248,7 @@ function tests() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Encrypt and decrypt larger message roundtrip', async function() {
|
it('Encrypt and decrypt larger message roundtrip', async function() {
|
||||||
let aeadProtectValue = openpgp.config.aeadProtect;
|
const aeadProtectValue = openpgp.config.aeadProtect;
|
||||||
openpgp.config.aeadProtect = false;
|
openpgp.config.aeadProtect = false;
|
||||||
const encrypted = await openpgp.encrypt({
|
const encrypted = await openpgp.encrypt({
|
||||||
message: openpgp.Message.fromBinary(data),
|
message: openpgp.Message.fromBinary(data),
|
||||||
|
@ -261,8 +273,8 @@ function tests() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Encrypt and decrypt larger message roundtrip (allowUnauthenticatedStream=true)', async function() {
|
it('Encrypt and decrypt larger message roundtrip (allowUnauthenticatedStream=true)', async function() {
|
||||||
let aeadProtectValue = openpgp.config.aeadProtect;
|
const aeadProtectValue = openpgp.config.aeadProtect;
|
||||||
let allowUnauthenticatedStreamValue = openpgp.config.allowUnauthenticatedStream;
|
const allowUnauthenticatedStreamValue = openpgp.config.allowUnauthenticatedStream;
|
||||||
openpgp.config.aeadProtect = false;
|
openpgp.config.aeadProtect = false;
|
||||||
openpgp.config.allowUnauthenticatedStream = true;
|
openpgp.config.allowUnauthenticatedStream = true;
|
||||||
try {
|
try {
|
||||||
|
@ -293,7 +305,7 @@ function tests() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Encrypt and decrypt larger message roundtrip using public keys (allowUnauthenticatedStream=true)', async function() {
|
it('Encrypt and decrypt larger message roundtrip using public keys (allowUnauthenticatedStream=true)', async function() {
|
||||||
let allowUnauthenticatedStreamValue = openpgp.config.allowUnauthenticatedStream;
|
const allowUnauthenticatedStreamValue = openpgp.config.allowUnauthenticatedStream;
|
||||||
openpgp.config.allowUnauthenticatedStream = true;
|
openpgp.config.allowUnauthenticatedStream = true;
|
||||||
try {
|
try {
|
||||||
const encrypted = await openpgp.encrypt({
|
const encrypted = await openpgp.encrypt({
|
||||||
|
@ -322,7 +334,7 @@ function tests() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Encrypt and decrypt larger message roundtrip using curve x25519 (allowUnauthenticatedStream=true)', async function() {
|
it('Encrypt and decrypt larger message roundtrip using curve x25519 (allowUnauthenticatedStream=true)', async function() {
|
||||||
let allowUnauthenticatedStreamValue = openpgp.config.allowUnauthenticatedStream;
|
const allowUnauthenticatedStreamValue = openpgp.config.allowUnauthenticatedStream;
|
||||||
openpgp.config.allowUnauthenticatedStream = true;
|
openpgp.config.allowUnauthenticatedStream = true;
|
||||||
const priv = await openpgp.readArmoredKey(xPriv);
|
const priv = await openpgp.readArmoredKey(xPriv);
|
||||||
const pub = await openpgp.readArmoredKey(xPub);
|
const pub = await openpgp.readArmoredKey(xPub);
|
||||||
|
@ -354,7 +366,7 @@ function tests() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Encrypt and decrypt larger message roundtrip using curve brainpool (allowUnauthenticatedStream=true)', async function() {
|
it('Encrypt and decrypt larger message roundtrip using curve brainpool (allowUnauthenticatedStream=true)', async function() {
|
||||||
let allowUnauthenticatedStreamValue = openpgp.config.allowUnauthenticatedStream;
|
const allowUnauthenticatedStreamValue = openpgp.config.allowUnauthenticatedStream;
|
||||||
openpgp.config.allowUnauthenticatedStream = true;
|
openpgp.config.allowUnauthenticatedStream = true;
|
||||||
const priv = await openpgp.readArmoredKey(brainpoolPriv);
|
const priv = await openpgp.readArmoredKey(brainpoolPriv);
|
||||||
const pub = await openpgp.readArmoredKey(brainpoolPub);
|
const pub = await openpgp.readArmoredKey(brainpoolPub);
|
||||||
|
@ -386,9 +398,9 @@ function tests() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Detect MDC modifications (allowUnauthenticatedStream=true)', async function() {
|
it('Detect MDC modifications (allowUnauthenticatedStream=true)', async function() {
|
||||||
let aeadProtectValue = openpgp.config.aeadProtect;
|
const aeadProtectValue = openpgp.config.aeadProtect;
|
||||||
openpgp.config.aeadProtect = false;
|
openpgp.config.aeadProtect = false;
|
||||||
let allowUnauthenticatedStreamValue = openpgp.config.allowUnauthenticatedStream;
|
const allowUnauthenticatedStreamValue = openpgp.config.allowUnauthenticatedStream;
|
||||||
openpgp.config.allowUnauthenticatedStream = true;
|
openpgp.config.allowUnauthenticatedStream = true;
|
||||||
try {
|
try {
|
||||||
const encrypted = await openpgp.encrypt({
|
const encrypted = await openpgp.encrypt({
|
||||||
|
@ -423,7 +435,7 @@ function tests() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Detect armor checksum error (allowUnauthenticatedStream=true)', async function() {
|
it('Detect armor checksum error (allowUnauthenticatedStream=true)', async function() {
|
||||||
let allowUnauthenticatedStreamValue = openpgp.config.allowUnauthenticatedStream;
|
const allowUnauthenticatedStreamValue = openpgp.config.allowUnauthenticatedStream;
|
||||||
openpgp.config.allowUnauthenticatedStream = true;
|
openpgp.config.allowUnauthenticatedStream = true;
|
||||||
try {
|
try {
|
||||||
const encrypted = await openpgp.encrypt({
|
const encrypted = await openpgp.encrypt({
|
||||||
|
@ -458,7 +470,7 @@ function tests() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Detect armor checksum error when not passing public keys (allowUnauthenticatedStream=true)', async function() {
|
it('Detect armor checksum error when not passing public keys (allowUnauthenticatedStream=true)', async function() {
|
||||||
let allowUnauthenticatedStreamValue = openpgp.config.allowUnauthenticatedStream;
|
const allowUnauthenticatedStreamValue = openpgp.config.allowUnauthenticatedStream;
|
||||||
openpgp.config.allowUnauthenticatedStream = true;
|
openpgp.config.allowUnauthenticatedStream = true;
|
||||||
try {
|
try {
|
||||||
const encrypted = await openpgp.encrypt({
|
const encrypted = await openpgp.encrypt({
|
||||||
|
@ -802,13 +814,13 @@ function tests() {
|
||||||
it('Encrypt and decrypt larger text message roundtrip (AEAD)', async function() {
|
it('Encrypt and decrypt larger text message roundtrip (AEAD)', async function() {
|
||||||
openpgp.config.aeadChunkSizeByte = 0;
|
openpgp.config.aeadChunkSizeByte = 0;
|
||||||
|
|
||||||
let plaintext = [];
|
const plaintext = [];
|
||||||
let i = 0;
|
let i = 0;
|
||||||
const data = new ReadableStream({
|
const data = new ReadableStream({
|
||||||
async pull(controller) {
|
async pull(controller) {
|
||||||
await new Promise(resolve => setTimeout(resolve, 10));
|
await new Promise(resolve => setTimeout(resolve, 10));
|
||||||
if (i++ < 10) {
|
if (i++ < 10) {
|
||||||
let randomData = input.createSomeMessage();
|
const randomData = input.createSomeMessage();
|
||||||
controller.enqueue(randomData);
|
controller.enqueue(randomData);
|
||||||
plaintext.push(randomData);
|
plaintext.push(randomData);
|
||||||
} else {
|
} else {
|
||||||
|
@ -875,7 +887,7 @@ function tests() {
|
||||||
it('Input stream should be canceled when canceling decrypted stream (AEAD)', async function() {
|
it('Input stream should be canceled when canceling decrypted stream (AEAD)', async function() {
|
||||||
const encrypted = await openpgp.encrypt({
|
const encrypted = await openpgp.encrypt({
|
||||||
message: openpgp.Message.fromBinary(data),
|
message: openpgp.Message.fromBinary(data),
|
||||||
passwords: ['test'],
|
passwords: ['test']
|
||||||
});
|
});
|
||||||
|
|
||||||
const message = await openpgp.readArmoredMessage(encrypted);
|
const message = await openpgp.readArmoredMessage(encrypted);
|
||||||
|
@ -905,9 +917,9 @@ module.exports = () => describe('Streaming', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
let test = ++currentTest;
|
const test = ++currentTest;
|
||||||
|
|
||||||
let dataArrivedPromise = new Promise(resolve => {
|
const dataArrivedPromise = new Promise(resolve => {
|
||||||
dataArrived = resolve;
|
dataArrived = resolve;
|
||||||
});
|
});
|
||||||
plaintext = [];
|
plaintext = [];
|
||||||
|
@ -918,7 +930,7 @@ module.exports = () => describe('Streaming', function() {
|
||||||
await new Promise(setTimeout);
|
await new Promise(setTimeout);
|
||||||
if (test === currentTest && i++ < 100) {
|
if (test === currentTest && i++ < 100) {
|
||||||
if (i === 4) await dataArrivedPromise;
|
if (i === 4) await dataArrivedPromise;
|
||||||
let randomBytes = await random.getRandomBytes(1024);
|
const randomBytes = await random.getRandomBytes(1024);
|
||||||
controller.enqueue(randomBytes);
|
controller.enqueue(randomBytes);
|
||||||
plaintext.push(randomBytes);
|
plaintext.push(randomBytes);
|
||||||
} else {
|
} else {
|
||||||
|
@ -951,7 +963,7 @@ module.exports = () => describe('Streaming', function() {
|
||||||
|
|
||||||
it('Node: Encrypt and decrypt text message roundtrip', async function() {
|
it('Node: Encrypt and decrypt text message roundtrip', async function() {
|
||||||
dataArrived(); // Do not wait until data arrived.
|
dataArrived(); // Do not wait until data arrived.
|
||||||
const plaintext = fs.readFileSync(__filename.replace('streaming.js', 'openpgp.js'), 'utf8');
|
const plaintext = fs.readFileSync(__filename.replace('streaming.js', 'openpgp.js'), 'utf8'); // eslint-disable-line no-sync
|
||||||
const data = fs.createReadStream(__filename.replace('streaming.js', 'openpgp.js'), { encoding: 'utf8' });
|
const data = fs.createReadStream(__filename.replace('streaming.js', 'openpgp.js'), { encoding: 'utf8' });
|
||||||
const encrypted = await openpgp.encrypt({
|
const encrypted = await openpgp.encrypt({
|
||||||
message: openpgp.Message.fromText(data),
|
message: openpgp.Message.fromText(data),
|
||||||
|
@ -970,7 +982,7 @@ module.exports = () => describe('Streaming', function() {
|
||||||
|
|
||||||
it('Node: Encrypt and decrypt binary message roundtrip', async function() {
|
it('Node: Encrypt and decrypt binary message roundtrip', async function() {
|
||||||
dataArrived(); // Do not wait until data arrived.
|
dataArrived(); // Do not wait until data arrived.
|
||||||
const plaintext = fs.readFileSync(__filename.replace('streaming.js', 'openpgp.js'));
|
const plaintext = fs.readFileSync(__filename.replace('streaming.js', 'openpgp.js')); // eslint-disable-line no-sync
|
||||||
const data = fs.createReadStream(__filename.replace('streaming.js', 'openpgp.js'));
|
const data = fs.createReadStream(__filename.replace('streaming.js', 'openpgp.js'));
|
||||||
const encrypted = await openpgp.encrypt({
|
const encrypted = await openpgp.encrypt({
|
||||||
message: openpgp.Message.fromBinary(data),
|
message: openpgp.Message.fromBinary(data),
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
|
|
||||||
const util = require('../../src/util');
|
const util = require('../../src/util');
|
||||||
|
|
||||||
const chai = require('chai');
|
const chai = require('chai');
|
||||||
|
@ -42,7 +41,7 @@ module.exports = () => describe('Util unit tests', function() {
|
||||||
expect(util.isArray(data)).to.be.true;
|
expect(util.isArray(data)).to.be.true;
|
||||||
});
|
});
|
||||||
it('should return true for type Array', function() {
|
it('should return true for type Array', function() {
|
||||||
const data = Array();
|
const data = Array(); // eslint-disable-line no-array-constructor
|
||||||
expect(util.isArray(data)).to.be.true;
|
expect(util.isArray(data)).to.be.true;
|
||||||
});
|
});
|
||||||
it('should return true for inherited type of Array', function() {
|
it('should return true for inherited type of Array', function() {
|
||||||
|
@ -144,8 +143,8 @@ module.exports = () => describe('Util unit tests', function() {
|
||||||
|
|
||||||
describe("Misc.", function() {
|
describe("Misc.", function() {
|
||||||
it('util.readNumber should not overflow until full range of uint32', function () {
|
it('util.readNumber should not overflow until full range of uint32', function () {
|
||||||
const ints = [Math.pow(2, 20), Math.pow(2, 25), Math.pow(2, 30), Math.pow(2, 32) - 1];
|
const ints = [2 ** 20, 2 ** 25, 2 ** 30, 2 ** 32 - 1];
|
||||||
for(let i = 0; i < ints.length; i++) {
|
for (let i = 0; i < ints.length; i++) {
|
||||||
expect(util.readNumber(util.writeNumber(ints[i], 4))).to.equal(ints[i]);
|
expect(util.readNumber(util.writeNumber(ints[i], 4))).to.equal(ints[i]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -155,7 +154,7 @@ module.exports = () => describe('Util unit tests', function() {
|
||||||
it('util.encodeZBase32 encodes correctly', function() {
|
it('util.encodeZBase32 encodes correctly', function() {
|
||||||
const encoded = util.encodeZBase32(util.strToUint8Array('test-wkd'));
|
const encoded = util.encodeZBase32(util.strToUint8Array('test-wkd'));
|
||||||
expect(encoded).to.equal('qt1zg7bpq7ise');
|
expect(encoded).to.equal('qt1zg7bpq7ise');
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,6 +4,7 @@ const chai = require('chai');
|
||||||
|
|
||||||
const { expect } = chai;
|
const { expect } = chai;
|
||||||
|
|
||||||
|
/* eslint-disable no-invalid-this */
|
||||||
module.exports = () => describe.skip('WKD unit tests', function() {
|
module.exports = () => describe.skip('WKD unit tests', function() {
|
||||||
this.timeout(60000);
|
this.timeout(60000);
|
||||||
|
|
||||||
|
|
|
@ -174,7 +174,7 @@ module.exports = () => (openpgp.config.ci ? describe.skip : describe)('X25519 Cr
|
||||||
const name = 'light';
|
const name = 'light';
|
||||||
const randomData = input.createSomeMessage();
|
const randomData = input.createSomeMessage();
|
||||||
const priv = await load_priv_key(name);
|
const priv = await load_priv_key(name);
|
||||||
const signed = await openpgp.sign({ privateKeys: [priv], message: openpgp.CleartextMessage.fromText(randomData)});
|
const signed = await openpgp.sign({ privateKeys: [priv], message: openpgp.CleartextMessage.fromText(randomData) });
|
||||||
const pub = await load_pub_key(name);
|
const pub = await load_pub_key(name);
|
||||||
const msg = await openpgp.readArmoredCleartextMessage(signed);
|
const msg = await openpgp.readArmoredCleartextMessage(signed);
|
||||||
const result = await openpgp.verify({ publicKeys: [pub], message: msg });
|
const result = await openpgp.verify({ publicKeys: [pub], message: msg });
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
/* eslint-disable no-process-env */
|
||||||
|
|
||||||
module.exports = function(config) {
|
module.exports = function(config) {
|
||||||
config.set({
|
config.set({
|
||||||
|
|
||||||
|
@ -36,13 +38,13 @@ module.exports = function(config) {
|
||||||
{
|
{
|
||||||
pattern: 'test/**/*',
|
pattern: 'test/**/*',
|
||||||
included: false
|
included: false
|
||||||
},
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
proxies: {
|
proxies: {
|
||||||
'/lib': '/base/test/lib',
|
'/lib': '/base/test/lib',
|
||||||
'/worker': '/base/test/worker',
|
'/worker': '/base/test/worker',
|
||||||
'/dist': '/base/dist',
|
'/dist': '/base/dist'
|
||||||
},
|
},
|
||||||
|
|
||||||
// list of files to exclude
|
// list of files to exclude
|
||||||
|
@ -109,7 +111,7 @@ module.exports = function(config) {
|
||||||
real_mobile: true,
|
real_mobile: true,
|
||||||
os: 'ios',
|
os: 'ios',
|
||||||
os_version: '12'
|
os_version: '12'
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
captureTimeout: 6e5,
|
captureTimeout: 6e5,
|
||||||
|
@ -124,7 +126,7 @@ module.exports = function(config) {
|
||||||
'bs_firefox_68',
|
'bs_firefox_68',
|
||||||
'bs_chrome_68',
|
'bs_chrome_68',
|
||||||
'bs_safari_11_1',
|
'bs_safari_11_1',
|
||||||
'bs_ios_12',
|
'bs_ios_12'
|
||||||
],
|
],
|
||||||
|
|
||||||
// Continuous Integration mode
|
// Continuous Integration mode
|
||||||
|
|
|
@ -68,7 +68,7 @@ fhGyl7nA7UCwgsqf7ZPBhRg=
|
||||||
=nbjQ
|
=nbjQ
|
||||||
-----END PGP SIGNATURE-----`;
|
-----END PGP SIGNATURE-----`;
|
||||||
async function getOtherPubKey() {
|
async function getOtherPubKey() {
|
||||||
return await readArmoredKey(OTHERPUBKEY);
|
return readArmoredKey(OTHERPUBKEY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
|
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
|
||||||
|
|
||||||
const { key, cleartext, enums, PacketList, SignaturePacket } = openpgp;
|
|
||||||
|
|
||||||
const chai = require('chai');
|
const chai = require('chai');
|
||||||
chai.use(require('chai-as-promised'));
|
chai.use(require('chai-as-promised'));
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ Dc2vwS83Aja9iWrIEg==
|
||||||
-----END PGP PRIVATE KEY BLOCK-----`;
|
-----END PGP PRIVATE KEY BLOCK-----`;
|
||||||
|
|
||||||
async function getInvalidKey() {
|
async function getInvalidKey() {
|
||||||
return await readArmoredKey(INVALID_KEY);
|
return readArmoredKey(INVALID_KEY);
|
||||||
}
|
}
|
||||||
async function makeKeyValid() {
|
async function makeKeyValid() {
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
/* globals openpgp: true */
|
||||||
|
|
||||||
(typeof window !== 'undefined' ? window : global).globalThis = (typeof window !== 'undefined' ? window : global);
|
(typeof window !== 'undefined' ? window : global).globalThis = (typeof window !== 'undefined' ? window : global);
|
||||||
|
|
||||||
(typeof window !== 'undefined' ? window : global).resolves = function(val) {
|
(typeof window !== 'undefined' ? window : global).resolves = function(val) {
|
||||||
|
@ -34,7 +36,7 @@ describe('Unit Tests', function () {
|
||||||
if (key && key !== 'grep') {
|
if (key && key !== 'grep') {
|
||||||
openpgp.config[key] = decodeURIComponent(value);
|
openpgp.config[key] = decodeURIComponent(value);
|
||||||
try {
|
try {
|
||||||
openpgp.config[key] = window.eval(openpgp.config[key]);
|
openpgp.config[key] = window.eval(openpgp.config[key]); // eslint-disable-line no-eval
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -18,7 +18,7 @@ function tests() {
|
||||||
try {
|
try {
|
||||||
globalThis.eval('(async function() {})');
|
globalThis.eval('(async function() {})');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e); // eslint-disable-line no-console
|
||||||
this.skip();
|
this.skip();
|
||||||
}
|
}
|
||||||
const worker = new Worker('./worker/worker_example.js');
|
const worker = new Worker('./worker/worker_example.js');
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
/* globals openpgp: true */
|
||||||
|
|
||||||
importScripts('../../dist/openpgp.js');
|
importScripts('../../dist/openpgp.js');
|
||||||
|
|
||||||
const publicKeyArmored = `-----BEGIN PGP PUBLIC KEY BLOCK-----
|
const publicKeyArmored = `-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||||
|
@ -71,7 +73,7 @@ onmessage = async function({ data: { action, message }, ports: [port] }) {
|
||||||
}
|
}
|
||||||
port.postMessage({ result });
|
port.postMessage({ result });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e); // eslint-disable-line no-console
|
||||||
port.postMessage({ error: e.message });
|
port.postMessage({ error: e.message });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user