ESLint is happy!

This commit is contained in:
Mahrud Sayrafi 2018-01-04 01:10:12 -08:00 committed by Sanjana Rajan
parent 370a15e2a1
commit 11a2d0070b
37 changed files with 476 additions and 163 deletions

366
.eslintrc.js Normal file
View File

@ -0,0 +1,366 @@
module.exports = {
"extends": "airbnb-base",
"parserOptions": { "sourceType": "module" },
"env": {
"browser": true,
"es6": true,
"node": true
},
"globals": { // TODO are all these necessary?
"console": true,
"Promise": true,
"importScripts": true,
"process": true,
"Event": true,
"describe": true,
"it": true,
"sinon": true,
"mocha": true,
"before": true,
"beforeEach": true,
"after": true,
"afterEach": true,
"escape": true,
"unescape": true,
"postMessage": true,
"resolves": true,
"rejects": true
},
"rules": {
// Auto generated rules:
"accessor-pairs": "error",
"array-bracket-newline": "error",
"array-bracket-spacing": [
"error",
"never"
],
"array-callback-return": "error",
"array-element-newline": "off",
"arrow-body-style": "off",
"arrow-parens": [
"error",
"as-needed"
],
"arrow-spacing": [
"error",
{
"after": true,
"before": true
}
],
"block-scoped-var": "off",
"block-spacing": [
"error",
"always"
],
"brace-style": "off",
"callback-return": "error",
"camelcase": [
"error",
{
"properties": "never"
}
],
"capitalized-comments": "off",
"class-methods-use-this": "error",
"comma-dangle": [ "error", "never" ],
"comma-spacing": "off",
"comma-style": [
"error",
"last"
],
"complexity": "off",
"computed-property-spacing": [
"error",
"never"
],
"consistent-return": "off",
"consistent-this": "error",
"curly": "error",
"default-case": "off",
"dot-location": "error",
"dot-notation": [
"error",
{
"allowKeywords": true
}
],
"eol-last": "off",
"eqeqeq": "error",
"for-direction": "error",
"func-call-spacing": "error",
"func-name-matching": "error",
"func-names": [
"error",
"never"
],
"func-style": "off",
"function-paren-newline": "off",
"generator-star-spacing": "error",
"getter-return": "error",
"global-require": "off",
"guard-for-in": "off",
"handle-callback-err": "error",
"id-blacklist": "error",
"id-length": "off",
"id-match": "error",
"implicit-arrow-linebreak": [
"error",
"beside"
],
"init-declarations": "off",
"jsx-quotes": "error",
"key-spacing": "off",
"keyword-spacing": "off",
"line-comment-position": "off",
"linebreak-style": [
"error",
"unix"
],
"lines-around-comment": "off",
"lines-around-directive": "error",
"lines-between-class-members": "error",
"max-depth": "off",
"max-len": "off",
"max-lines": "off",
"max-nested-callbacks": "error",
"max-params": "off",
"max-statements": "off",
"max-statements-per-line": "off",
"multiline-comment-style": "off",
"multiline-ternary": "off",
"new-parens": "error",
"newline-after-var": "off",
"newline-before-return": "off",
"newline-per-chained-call": "off",
"no-alert": "error",
"no-array-constructor": "error",
"no-await-in-loop": "error",
"no-bitwise": "off",
"no-buffer-constructor": "error",
"no-caller": "error",
"no-catch-shadow": "error",
"no-confusing-arrow": "error",
"no-continue": "off",
"no-div-regex": "error",
"no-duplicate-imports": "error",
"no-else-return": "off",
"no-empty": [
"error",
{
"allowEmptyCatch": true
}
],
"no-empty-function": "off",
"no-eq-null": "error",
"no-eval": "error",
"no-extend-native": "error",
"no-extra-bind": "error",
"no-extra-label": "error",
"no-extra-parens": "off",
"no-floating-decimal": "error",
"no-implicit-globals": "error",
"no-implied-eval": "error",
"no-inline-comments": "off",
"no-inner-declarations": [
"error",
"functions"
],
"no-invalid-this": "error",
"no-iterator": "error",
"no-label-var": "error",
"no-labels": "error",
"no-lone-blocks": "error",
"no-lonely-if": "error",
"no-loop-func": "error",
"no-magic-numbers": "off",
"no-mixed-operators": "off",
"no-mixed-requires": "error",
"no-multi-assign": "error",
"no-multi-spaces": [
"error",
{
"ignoreEOLComments": true
}
],
"no-multi-str": "error",
"no-multiple-empty-lines": "error",
"no-native-reassign": "error",
"no-negated-condition": "off",
"no-negated-in-lhs": "error",
"no-nested-ternary": "off",
"no-new": "error",
"no-new-func": "error",
"no-new-object": "error",
"no-new-require": "error",
"no-new-wrappers": "error",
"no-octal-escape": "error",
"no-param-reassign": "off",
"no-path-concat": "error",
"no-plusplus": "off",
"no-process-env": "error",
"no-process-exit": "error",
"no-proto": "error",
"no-prototype-builtins": "off",
"no-restricted-globals": "error",
"no-restricted-imports": "error",
"no-restricted-modules": "error",
"no-restricted-properties": "error",
"no-restricted-syntax": "error",
"no-return-assign": "error",
"no-return-await": "error",
"no-script-url": "error",
"no-self-compare": "error",
"no-shadow": "off",
"no-shadow-restricted-names": "error",
"no-spaced-func": "error",
"no-sync": "error",
"no-tabs": "error",
"no-template-curly-in-string": "error",
"no-ternary": "off",
"no-throw-literal": "error",
"no-undef-init": "error",
"no-undefined": "off",
"no-unmodified-loop-condition": "error",
"no-unneeded-ternary": [
"error",
{
"defaultAssignment": true
}
],
"no-unused-expressions": "error",
"no-use-before-define": "off",
"no-useless-call": "error",
"no-useless-computed-key": "error",
"no-useless-concat": "error",
"no-useless-constructor": "error",
"no-useless-rename": "error",
"no-useless-return": "error",
"no-var": "off",
"no-void": "error",
"no-warning-comments": "off",
"no-whitespace-before-property": "error",
"no-with": "error",
"nonblock-statement-body-position": "error",
"object-curly-newline": "off",
"object-curly-spacing": "off",
"object-property-newline": [
"error",
{
"allowMultiplePropertiesPerLine": true
}
],
"object-shorthand": "off",
"one-var": "off",
"one-var-declaration-per-line": [
"error",
"initializations"
],
"operator-assignment": "off",
"operator-linebreak": [
"error",
"after"
],
"padded-blocks": "off",
"padding-line-between-statements": "error",
"prefer-arrow-callback": "off",
"prefer-const": "off",
"prefer-destructuring": "off",
"prefer-numeric-literals": "error",
"prefer-promise-reject-errors": "error",
"prefer-reflect": "off",
"prefer-rest-params": "off",
"prefer-spread": "off",
"prefer-template": "off",
"quote-props": "off",
"quotes": "off",
"radix": [
"error",
"as-needed"
],
"require-await": "error",
"require-jsdoc": "off",
"rest-spread-spacing": "error",
"semi": "off",
"semi-spacing": [
"error",
{
"after": true,
"before": false
}
],
"semi-style": [
"error",
"last"
],
"sort-imports": "off",
"sort-keys": "off",
"sort-vars": "off",
"space-before-blocks": "off",
"space-before-function-paren": "off",
"space-in-parens": [
"error",
"never"
],
"space-infix-ops": "off",
"space-unary-ops": "error",
"spaced-comment": "off",
"strict": "off",
"switch-colon-spacing": "error",
"symbol-description": "error",
"template-curly-spacing": "error",
"template-tag-spacing": "error",
"unicode-bom": [
"error",
"never"
],
"valid-jsdoc": "off",
"vars-on-top": "off",
"wrap-iife": "error",
"wrap-regex": "off",
"yield-star-spacing": "error",
"yoda": [
"error",
"never"
],
// Custom silencers:
"camelcase": 0,
"no-debugger": 0,
"no-multi-assign": 0,
"no-underscore-dangle": 0,
"one-var-declaration-per-line": 0,
// Custom errors:
"no-undef": 2,
"no-trailing-spaces": 2,
"no-mixed-operators": [ 2, {"groups": [["&", "|", "^", "~", "<<", ">>", ">>>"], ["&&", "||"]]}],
"no-use-before-define": [ 2, { "functions": false, "classes": true, "variables": false }],
"no-unused-expressions": [ 2, { "allowShortCircuit": true } ],
// Custom warnings:
"no-console": 0,
"no-unused-vars": 0,
"indent": [ 0, 2, { "SwitchCase": 1 } ],
// Consider fixing these:
"new-cap": [ 0, { "properties": false, "capIsNewExceptionPattern": "^type_.*" }],
"no-lonely-if": 0,
"no-fallthrough": 0,
"consistent-this": 0,
"no-invalid-this": 0,
"callback-return": 0,
"no-useless-call": 0, // only occurs for workers
"import/extensions": 0,
"no-useless-escape": 0,
"no-case-declarations": 0,
"no-restricted-syntax": 0,
"no-array-constructor": 0,
"no-constant-condition": 0,
"no-buffer-constructor": 0, // deprecated
"no-restricted-properties": 0 // Math.pow
}
};

View File

@ -1,4 +0,0 @@
{
"disallowTrailingWhitespace": true,
"validateIndentation": 2
}

View File

@ -1,36 +0,0 @@
{
"node": true,
"browser": true,
"nonew": true,
"curly": true,
"eqeqeq": true,
"immed": true,
"regexp": true,
"evil": true,
"eqnull": true,
"expr": true,
"undef": true,
"unused": true,
"esnext": true,
"globals": {
"console": true,
"Promise": true,
"importScripts": true,
"process": true,
"Event": true,
"describe": true,
"it": true,
"sinon": true,
"mocha": true,
"before": true,
"beforeEach": true,
"after": true,
"afterEach": true,
"escape": true,
"unescape": true,
"postMessage": true,
"resolves": true,
"rejects": true
}
}

View File

@ -20,7 +20,7 @@ module.exports = function(grunt) {
'src/encoding/**/*.js', 'src/encoding/**/*.js',
'src/hkp/**/*.js', 'src/hkp/**/*.js',
'src/keyring/**/*.js', 'src/keyring/**/*.js',
'src/packet/**/*.jss', 'src/packet/**/*.js',
'src/type/**/*.js', 'src/type/**/*.js',
'src/worker/**/*.js', 'src/worker/**/*.js',
'src/*.js', 'src/*.js',
@ -71,7 +71,7 @@ module.exports = function(grunt) {
debug: true, debug: true,
standalone: 'openpgp' standalone: 'openpgp'
}, },
external: [ 'crypto', 'buffer', 'node-localstorage', 'node-fetch' ], external: [ 'crypto', 'buffer', 'node-localstorage', 'node-fetch', 'asn1.js' ],
transform: [ transform: [
["babelify", { ["babelify", {
plugins: ["transform-async-to-generator", plugins: ["transform-async-to-generator",
@ -158,19 +158,9 @@ module.exports = function(grunt) {
wrap_line_length: 120 wrap_line_length: 120
} }
}, },
jshint: { eslint: {
src: lintFiles, target: lintFiles,
build: ['Gruntfile.js', '*.json'], options: { configFile: '.eslintrc.js' }
options: {
jshintrc: '.jshintrc'
}
},
jscs: {
src: lintFiles,
build: ['Gruntfile.js'],
options: {
config: ".jscsrc"
}
}, },
jsdoc: { jsdoc: {
dist: { dist: {
@ -264,9 +254,8 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-text-replace'); grunt.loadNpmTasks('grunt-text-replace');
grunt.loadNpmTasks('grunt-jsbeautifier'); grunt.loadNpmTasks('grunt-jsbeautifier');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-jscs');
grunt.loadNpmTasks('grunt-jsdoc'); grunt.loadNpmTasks('grunt-jsdoc');
grunt.loadNpmTasks('gruntify-eslint');
grunt.loadNpmTasks('grunt-mocha-istanbul'); grunt.loadNpmTasks('grunt-mocha-istanbul');
grunt.loadNpmTasks('grunt-mocha-test'); grunt.loadNpmTasks('grunt-mocha-test');
grunt.loadNpmTasks('grunt-contrib-copy'); grunt.loadNpmTasks('grunt-contrib-copy');
@ -313,7 +302,7 @@ module.exports = function(grunt) {
grunt.registerTask('default',['clean', 'copy:zlib', 'browserify', 'version', 'uglify', 'replace_min']); grunt.registerTask('default',['clean', 'copy:zlib', 'browserify', 'version', 'uglify', 'replace_min']);
grunt.registerTask('documentation', ['jsdoc']); grunt.registerTask('documentation', ['jsdoc']);
// Test/Dev tasks // Test/Dev tasks
grunt.registerTask('test', [ 'mochaTest']); grunt.registerTask('test', [ 'eslint', 'mochaTest']);
grunt.registerTask('coverage', ['mocha_istanbul:coverage']); grunt.registerTask('coverage', ['mocha_istanbul:coverage']);
grunt.registerTask('saucelabs', ['default', 'copy:browsertest', 'connect:test', 'saucelabs-mocha']); grunt.registerTask('saucelabs', ['default', 'copy:browsertest', 'connect:test', 'saucelabs-mocha']);

View File

@ -736,7 +736,7 @@ var U2 = new Uint32Array([
0xdc31d7ca,0xd138d9c1,0xc623cbdc,0xcb2ac5d7, 0xdc31d7ca,0xd138d9c1,0xc623cbdc,0xcb2ac5d7,
0xe815efe6,0xe51ce1ed,0xf207f3f0,0xff0efdfb, 0xe815efe6,0xe51ce1ed,0xf207f3f0,0xff0efdfb,
0xb479a792,0xb970a999,0xae6bbb84,0xa362b58f, 0xb479a792,0xb970a999,0xae6bbb84,0xa362b58f,
0x805d9fbe,0x8d5491b5,0x9a4f83a8,0x97468da3, 0x805d9fbe,0x8d5491b5,0x9a4f83a8,0x97468da3
]); ]);
var U3 = new Uint32Array([ var U3 = new Uint32Array([

View File

@ -312,8 +312,8 @@ Blowfish.prototype.encrypt_block = function(vector) {
var ret = []; var ret = [];
for (ii = 0; ii < this.BLOCKSIZE / 2; ++ii) { for (ii = 0; ii < this.BLOCKSIZE / 2; ++ii) {
ret[ii + 0] = (vals[0] >>> (24 - 8 * (ii)) & 0x00FF); ret[ii + 0] = ((vals[0] >>> (24 - 8 * (ii))) & 0x00FF);
ret[ii + off] = (vals[1] >>> (24 - 8 * (ii)) & 0x00FF); ret[ii + off] = ((vals[1] >>> (24 - 8 * (ii))) & 0x00FF);
// vals[ 0 ] = ( vals[ 0 ] >>> 8 ); // vals[ 0 ] = ( vals[ 0 ] >>> 8 );
// vals[ 1 ] = ( vals[ 1 ] >>> 8 ); // vals[ 1 ] = ( vals[ 1 ] >>> 8 );
} }

View File

@ -51,8 +51,8 @@ function OpenpgpSymencCast5() {
var dst = new Array(src.length); var dst = new Array(src.length);
for (var i = 0; i < src.length; i += 8) { for (var i = 0; i < src.length; i += 8) {
var l = src[i] << 24 | src[i + 1] << 16 | src[i + 2] << 8 | src[i + 3]; var l = (src[i] << 24) | (src[i + 1] << 16) | (src[i + 2] << 8) | src[i + 3];
var r = src[i + 4] << 24 | src[i + 5] << 16 | src[i + 6] << 8 | src[i + 7]; var r = (src[i + 4] << 24) | (src[i + 5] << 16) | (src[i + 6] << 8) | src[i + 7];
var t; var t;
t = r; t = r;
@ -124,8 +124,8 @@ function OpenpgpSymencCast5() {
var dst = new Array(src.length); var dst = new Array(src.length);
for (var i = 0; i < src.length; i += 8) { for (var i = 0; i < src.length; i += 8) {
var l = src[i] << 24 | src[i + 1] << 16 | src[i + 2] << 8 | src[i + 3]; var l = (src[i] << 24) | (src[i + 1] << 16) | (src[i + 2] << 8) | src[i + 3];
var r = src[i + 4] << 24 | src[i + 5] << 16 | src[i + 6] << 8 | src[i + 7]; var r = (src[i + 4] << 24) | (src[i + 5] << 16) | (src[i + 6] << 8) | src[i + 7];
var t; var t;
t = r; t = r;
@ -256,7 +256,7 @@ function OpenpgpSymencCast5() {
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
j = i * 4; j = i * 4;
t[i] = inn[j] << 24 | inn[j + 1] << 16 | inn[j + 2] << 8 | inn[j + 3]; t[i] = (inn[j] << 24) | (inn[j + 1] << 16) | (inn[j + 2] << 8) | inn[j + 3];
} }
var x = [6, 7, 4, 5]; var x = [6, 7, 4, 5];

View File

@ -35,13 +35,13 @@ function des(keys, message, encrypt, mode, iv, padding) {
0x1010000, 0x1010400, 0x1000000, 0x1000000, 0x400, 0x1010004, 0x10000, 0x10400, 0x1000004, 0x400, 0x4, 0x1000404, 0x1010000, 0x1010400, 0x1000000, 0x1000000, 0x400, 0x1010004, 0x10000, 0x10400, 0x1000004, 0x400, 0x4, 0x1000404,
0x10404, 0x1010404, 0x10004, 0x1010000, 0x1000404, 0x1000004, 0x404, 0x10404, 0x1010400, 0x404, 0x1000400, 0x10404, 0x1010404, 0x10004, 0x1010000, 0x1000404, 0x1000004, 0x404, 0x10404, 0x1010400, 0x404, 0x1000400,
0x1000400, 0, 0x10004, 0x10400, 0, 0x1010004); 0x1000400, 0, 0x10004, 0x10400, 0, 0x1010004);
var spfunction2 = new Array(-0x7fef7fe0, -0x7fff8000, 0x8000, 0x108020, 0x100000, 0x20, -0x7fefffe0, -0x7fff7fe0, - var spfunction2 = new Array(-0x7fef7fe0, -0x7fff8000, 0x8000, 0x108020, 0x100000, 0x20, -0x7fefffe0, -0x7fff7fe0,
0x7fffffe0, -0x7fef7fe0, -0x7fef8000, -0x80000000, -0x7fff8000, 0x100000, 0x20, -0x7fefffe0, 0x108000, 0x100020, - -0x7fffffe0, -0x7fef7fe0, -0x7fef8000, -0x80000000, -0x7fff8000, 0x100000, 0x20, -0x7fefffe0, 0x108000, 0x100020,
0x7fff7fe0, 0, -0x80000000, 0x8000, 0x108020, -0x7ff00000, 0x100020, -0x7fffffe0, 0, 0x108000, 0x8020, -0x7fef8000, - -0x7fff7fe0, 0, -0x80000000, 0x8000, 0x108020, -0x7ff00000, 0x100020, -0x7fffffe0, 0, 0x108000, 0x8020, -0x7fef8000,
0x7ff00000, 0x8020, 0, 0x108020, -0x7fefffe0, 0x100000, -0x7fff7fe0, -0x7ff00000, -0x7fef8000, 0x8000, -0x7ff00000, - -0x7ff00000, 0x8020, 0, 0x108020, -0x7fefffe0, 0x100000, -0x7fff7fe0, -0x7ff00000, -0x7fef8000, 0x8000, -0x7ff00000,
0x7fff8000, 0x20, -0x7fef7fe0, 0x108020, 0x20, 0x8000, -0x80000000, 0x8020, -0x7fef8000, 0x100000, -0x7fffffe0, -0x7fff8000, 0x20, -0x7fef7fe0, 0x108020, 0x20, 0x8000, -0x80000000, 0x8020, -0x7fef8000, 0x100000, -0x7fffffe0,
0x100020, -0x7fff7fe0, -0x7fffffe0, 0x100020, 0x108000, 0, -0x7fff8000, 0x8020, -0x80000000, -0x7fefffe0, - 0x100020, -0x7fff7fe0, -0x7fffffe0, 0x100020, 0x108000, 0, -0x7fff8000, 0x8020, -0x80000000, -0x7fefffe0,
0x7fef7fe0, 0x108000); -0x7fef7fe0, 0x108000);
var spfunction3 = new Array(0x208, 0x8020200, 0, 0x8020008, 0x8000200, 0, 0x20208, 0x8000200, 0x20008, 0x8000008, var spfunction3 = new Array(0x208, 0x8020200, 0, 0x8020008, 0x8000200, 0, 0x20208, 0x8000200, 0x20008, 0x8000008,
0x8000008, 0x20000, 0x8020208, 0x20008, 0x8020000, 0x208, 0x8000000, 0x8, 0x8020200, 0x200, 0x20200, 0x8020000, 0x8000008, 0x20000, 0x8020208, 0x20008, 0x8020000, 0x208, 0x8000000, 0x8, 0x8020200, 0x200, 0x20200, 0x8020000,
0x8020008, 0x20208, 0x8000208, 0x20200, 0x20000, 0x8000208, 0x8, 0x8020208, 0x200, 0x8000000, 0x8020200, 0x8000000, 0x8020008, 0x20208, 0x8000208, 0x20200, 0x20000, 0x8000208, 0x8, 0x8020208, 0x200, 0x8000000, 0x8020200, 0x8000000,
@ -220,7 +220,6 @@ function des(keys, message, encrypt, mode, iv, padding) {
} //end of des } //end of des
//des_createKeys //des_createKeys
//this takes as input a 64 bit key (even though only 56 bits are used) //this takes as input a 64 bit key (even though only 56 bits are used)
//as an array of 2 integers, and returns 16 48 bit keys //as an array of 2 integers, and returns 16 48 bit keys

View File

@ -104,7 +104,7 @@ export default {
default: default:
return []; return [];
} }
})(); }());
return result; return result;
}, },
@ -155,7 +155,7 @@ export default {
default: default:
return null; return null;
} }
})(); }());
var result = new type_mpi(bn); var result = new type_mpi(bn);
return result; return result;

View File

@ -22,9 +22,10 @@
'use strict'; 'use strict';
import asmCrypto from 'asmcrypto-lite';
import util from '../util.js'; import util from '../util.js';
import config from '../config'; import config from '../config';
import asmCrypto from 'asmcrypto-lite';
const webCrypto = util.getWebCrypto(); // no GCM support in IE11, Safari 9 const webCrypto = util.getWebCrypto(); // no GCM support in IE11, Safari 9
const nodeCrypto = util.getNodeCrypto(); const nodeCrypto = util.getNodeCrypto();
const Buffer = util.getNodeBuffer(); const Buffer = util.getNodeBuffer();

View File

@ -8,9 +8,9 @@
'use strict'; 'use strict';
import sha from './sha.js';
import asmCrypto from 'asmcrypto-lite';
import Rusha from 'rusha'; import Rusha from 'rusha';
import asmCrypto from 'asmcrypto-lite';
import sha from './sha.js';
import md5 from './md5.js'; import md5 from './md5.js';
import ripemd from './ripe-md.js'; import ripemd from './ripe-md.js';
import util from '../../util.js'; import util from '../../util.js';

View File

@ -92,7 +92,6 @@ function mixOneRound(a, b, c, d, e, x, s, roundNumber) {
default: default:
throw new Error("Bogus round number"); throw new Error("Bogus round number");
break;
} }
a = ROL(a, s) + e; a = ROL(a, s) + e;

View File

@ -1320,7 +1320,7 @@ var jsSHA = function(srcString, inputFormat, encoding)
} }
/* Validate the numRounds argument */ /* Validate the numRounds argument */
if ((numRounds !== parseInt(numRounds, 10)) || (1 > numRounds)) if ((numRounds !== parseInt(numRounds)) || (1 > numRounds))
{ {
throw "numRounds must a integer >= 1"; throw "numRounds must a integer >= 1";
} }

View File

@ -37,7 +37,7 @@ const mod = {
/** @see module:crypto/pkcs5 */ /** @see module:crypto/pkcs5 */
pkcs5: pkcs5, pkcs5: pkcs5,
/** @see module:crypto/aes_kw */ /** @see module:crypto/aes_kw */
aes_kw: aes_kw, aes_kw: aes_kw
}; };
for (var i in crypto) { for (var i in crypto) {

View File

@ -37,22 +37,17 @@ import hash from './hash';
*/ */
var hash_headers = []; var hash_headers = [];
hash_headers[1] = [0x30, 0x20, 0x30, 0x0c, 0x06, 0x08, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x02, 0x05, 0x05, 0x00, 0x04, hash_headers[1] = [0x30, 0x20, 0x30, 0x0c, 0x06, 0x08, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x02, 0x05, 0x05, 0x00, 0x04,
0x10 0x10];
];
hash_headers[2] = [0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, 0x14]; hash_headers[2] = [0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, 0x14];
hash_headers[3] = [0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x24, 0x03, 0x02, 0x01, 0x05, 0x00, 0x04, 0x14]; hash_headers[3] = [0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x24, 0x03, 0x02, 0x01, 0x05, 0x00, 0x04, 0x14];
hash_headers[8] = [0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05, 0x00, hash_headers[8] = [0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05, 0x00,
0x04, 0x20 0x04, 0x20];
];
hash_headers[9] = [0x30, 0x41, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02, 0x05, 0x00, hash_headers[9] = [0x30, 0x41, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02, 0x05, 0x00,
0x04, 0x30 0x04, 0x30];
];
hash_headers[10] = [0x30, 0x51, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03, 0x05, hash_headers[10] = [0x30, 0x51, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03, 0x05,
0x00, 0x04, 0x40 0x00, 0x04, 0x40];
];
hash_headers[11] = [0x30, 0x2d, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x04, 0x05, hash_headers[11] = [0x30, 0x2d, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x04, 0x05,
0x00, 0x04, 0x1C 0x00, 0x04, 0x1C];
];
/** /**
* Create padding with secure random data * Create padding with secure random data

View File

@ -170,7 +170,7 @@ function webGenKeyPair(namedCurve) {
name: "ECDSA", name: "ECDSA",
// FIXME // FIXME
// name: "ECDH", // name: "ECDH",
namedCurve: namedCurve, // "P-256", "P-384", or "P-521" namedCurve: namedCurve // "P-256", "P-384", or "P-521"
}, },
// FIXME // FIXME
false, // whether the key is extractable (i.e. can be used in exportKey) false, // whether the key is extractable (i.e. can be used in exportKey)

View File

@ -211,5 +211,6 @@ async function nodeVerify(curve, hash_algo, signature, m, Q) {
const verify = nodeCrypto.createVerify(enums.read(enums.hash, hash_algo)); const verify = nodeCrypto.createVerify(enums.read(enums.hash, hash_algo));
verify.write(m); verify.write(m);
verify.end(); verify.end();
return await verify.verify(publicKey, signature); const result = await verify.verify(publicKey, signature);
return result;
} }

View File

@ -27,6 +27,7 @@
import type_mpi from '../type/mpi.js'; import type_mpi from '../type/mpi.js';
import util from '../util.js'; import util from '../util.js';
const nodeCrypto = util.detectNode() && require('crypto'); const nodeCrypto = util.detectNode() && require('crypto');
export default { export default {

View File

@ -115,7 +115,6 @@ function addheader() {
} }
/** /**
* Calculates a checksum over the given data and returns it base64 encoded * Calculates a checksum over the given data and returns it base64 encoded
* @param {String} data Data to create a CRC-24 checksum for * @param {String} data Data to create a CRC-24 checksum for

View File

@ -39,7 +39,7 @@ function s2r(t, o) {
r.push(b64s.charAt((c >> 2) & 63)); r.push(b64s.charAt((c >> 2) & 63));
a = (c & 3) << 4; a = (c & 3) << 4;
} else if (s === 1) { } else if (s === 1) {
r.push(b64s.charAt((a | (c >> 4) & 15))); r.push(b64s.charAt(a | ((c >> 4) & 15)));
a = (c & 15) << 2; a = (c & 15) << 2;
} else if (s === 2) { } else if (s === 2) {
r.push(b64s.charAt(a | ((c >> 6) & 3))); r.push(b64s.charAt(a | ((c >> 6) & 3)));
@ -99,7 +99,7 @@ function r2s(t) {
c = b64s.indexOf(t.charAt(n)); c = b64s.indexOf(t.charAt(n));
if (c >= 0) { if (c >= 0) {
if (s) { if (s) {
r.push(a | (c >> (6 - s)) & 255); r.push(a | ((c >> (6 - s)) & 255));
} }
s = (s + 2) & 7; s = (s + 2) & 7;
a = (c << s) & 255; a = (c << s) & 255;

View File

@ -1,3 +1,5 @@
/* eslint-disable import/newline-after-import, import/first */
'use strict'; 'use strict';
/** /**

View File

@ -583,8 +583,8 @@ Key.prototype.update = function(key) {
key.users.forEach(function(srcUser) { key.users.forEach(function(srcUser) {
var found = false; var found = false;
for (var i = 0; i < that.users.length; i++) { for (var i = 0; i < that.users.length; i++) {
if (srcUser.userId && (srcUser.userId.userid === that.users[i].userId.userid) || if ((srcUser.userId && (srcUser.userId.userid === that.users[i].userId.userid)) ||
srcUser.userAttribute && (srcUser.userAttribute.equals(that.users[i].userAttribute))) { (srcUser.userAttribute && (srcUser.userAttribute.equals(that.users[i].userAttribute)))) {
that.users[i].update(srcUser, that.primaryKey); that.users[i].update(srcUser, that.primaryKey);
found = true; found = true;
break; break;

View File

@ -5,8 +5,8 @@
* @module keyring * @module keyring
*/ */
import Keyring from './keyring.js'; import Keyring from './keyring.js';
import localstore from './localstore.js'; import localstore from './localstore.js';
Keyring.localstore = localstore; Keyring.localstore = localstore;
export default Keyring; export default Keyring;

View File

@ -184,7 +184,7 @@ Message.prototype.decryptSessionKey = function(privateKey, password) {
*/ */
Message.prototype.getLiteralData = function() { Message.prototype.getLiteralData = function() {
var literal = this.packets.findPacket(enums.packet.literal); var literal = this.packets.findPacket(enums.packet.literal);
return literal && literal.data || null; return (literal && literal.data) || null;
}; };
/** /**
@ -193,7 +193,7 @@ Message.prototype.getLiteralData = function() {
*/ */
Message.prototype.getFilename = function() { Message.prototype.getFilename = function() {
var literal = this.packets.findPacket(enums.packet.literal); var literal = this.packets.findPacket(enums.packet.literal);
return literal && literal.getFilename() || null; return (literal && literal.getFilename()) || null;
}; };
/** /**

View File

@ -32,13 +32,15 @@
'use strict'; 'use strict';
import es6Promise from 'es6-promise';
import * as messageLib from './message.js'; import * as messageLib from './message.js';
import * as cleartext from './cleartext.js'; import * as cleartext from './cleartext.js';
import * as key from './key.js'; import * as key from './key.js';
import config from './config/config.js'; import config from './config/config.js';
import util from './util'; import util from './util';
import AsyncProxy from './worker/async_proxy.js'; import AsyncProxy from './worker/async_proxy.js';
import es6Promise from 'es6-promise';
es6Promise.polyfill(); // load ES6 Promises polyfill es6Promise.polyfill(); // load ES6 Promises polyfill
@ -57,7 +59,7 @@ let asyncProxy; // instance of the asyncproxy
* @param {Object} worker alternative to path parameter: web worker initialized with 'openpgp.worker.js' * @param {Object} worker alternative to path parameter: web worker initialized with 'openpgp.worker.js'
*/ */
export function initWorker({ path='openpgp.worker.js', worker } = {}) { export function initWorker({ path='openpgp.worker.js', worker } = {}) {
if (worker || typeof window !== 'undefined' && window.Worker) { if (worker || (typeof window !== 'undefined' && window.Worker)) {
asyncProxy = new AsyncProxy({ path, worker, config }); asyncProxy = new AsyncProxy({ path, worker, config });
return true; return true;
} }

View File

@ -79,7 +79,6 @@ Compressed.prototype.read = function (bytes) {
}; };
/** /**
* Return the compressed packet. * Return the compressed packet.
* @return {String} binary compressed packet * @return {String} binary compressed packet

View File

@ -45,7 +45,10 @@ Packetlist.prototype.read = function (bytes) {
pushed = true; pushed = true;
packet.read(parsed.packet); packet.read(parsed.packet);
} catch(e) { } catch(e) {
if (!config.tolerant || parsed.tag == enums.packet.symmetricallyEncrypted || parsed.tag == enums.packet.literal || parsed.tag == enums.packet.compressed) { if (!config.tolerant ||
parsed.tag === enums.packet.symmetricallyEncrypted ||
parsed.tag === enums.packet.literal ||
parsed.tag === enums.packet.compressed) {
throw e; throw e;
} }
if (pushed) { if (pushed) {

View File

@ -170,8 +170,6 @@ SecretKey.prototype.write = function () {
}; };
/** Encrypt the payload. By default, we use aes256 and iterated, salted string /** Encrypt the payload. By default, we use aes256 and iterated, salted string
* to key specifier. If the key is in a decrypted state (isDecrypted === true) * to key specifier. If the key is in a decrypted state (isDecrypted === true)
* and the passphrase is empty or undefined, the key will be set as not encrypted. * and the passphrase is empty or undefined, the key will be set as not encrypted.

View File

@ -97,6 +97,28 @@ export default function Signature() {
Signature.prototype.read = function (bytes) { Signature.prototype.read = function (bytes) {
var i = 0; var i = 0;
this.version = bytes[i++]; this.version = bytes[i++];
function subpackets(bytes) {
// Two-octet scalar octet count for following subpacket data.
var subpacket_length = util.readNumber(
bytes.subarray(0, 2));
var i = 2;
// subpacket data set (zero or more subpackets)
while (i < 2 + subpacket_length) {
var len = packet.readSimpleLength(bytes.subarray(i, bytes.length));
i += len.offset;
this.read_sub_packet(bytes.subarray(i, i + len.len));
i += len.len;
}
return i;
}
// switch on version (3 and 4) // switch on version (3 and 4)
switch (this.version) { switch (this.version) {
case 3: case 3:
@ -133,27 +155,6 @@ Signature.prototype.read = function (bytes) {
this.publicKeyAlgorithm = bytes[i++]; this.publicKeyAlgorithm = bytes[i++];
this.hashAlgorithm = bytes[i++]; this.hashAlgorithm = bytes[i++];
function subpackets(bytes) {
// Two-octet scalar octet count for following subpacket data.
var subpacket_length = util.readNumber(
bytes.subarray(0, 2));
var i = 2;
// subpacket data set (zero or more subpackets)
while (i < 2 + subpacket_length) {
var len = packet.readSimpleLength(bytes.subarray(i, bytes.length));
i += len.offset;
this.read_sub_packet(bytes.subarray(i, i + len.len));
i += len.len;
}
return i;
}
// hashed subpackets // hashed subpackets
i += subpackets.call(this, bytes.subarray(i, bytes.length), true); i += subpackets.call(this, bytes.subarray(i, bytes.length), true);

View File

@ -34,10 +34,11 @@
'use strict'; 'use strict';
import asmCrypto from 'asmcrypto-lite';
import util from '../util.js'; import util from '../util.js';
import crypto from '../crypto'; import crypto from '../crypto';
import enums from '../enums.js'; import enums from '../enums.js';
import asmCrypto from 'asmcrypto-lite';
const nodeCrypto = util.getNodeCrypto(); const nodeCrypto = util.getNodeCrypto();
const Buffer = util.getNodeBuffer(); const Buffer = util.getNodeBuffer();

View File

@ -139,8 +139,7 @@ SymEncryptedSessionKey.prototype.encrypt = function(passphrase) {
var length = crypto.cipher[algo].keySize; var length = crypto.cipher[algo].keySize;
var key = this.s2k.produce_key(passphrase, length); var key = this.s2k.produce_key(passphrase, length);
var algo_enum = new Uint8Array([ var algo_enum = new Uint8Array([enums.write(enums.symmetric, this.sessionKeyAlgorithm)]);
enums.write(enums.symmetric, this.sessionKeyAlgorithm)]);
var private_key; var private_key;
if(this.sessionKey === null) { if(this.sessionKey === null) {

View File

@ -65,7 +65,5 @@ ECDHSymmetricKey.prototype.read = function (input) {
* @return {Uint8Array} An array containing the value * @return {Uint8Array} An array containing the value
*/ */
ECDHSymmetricKey.prototype.write = function () { ECDHSymmetricKey.prototype.write = function () {
return util.concatUint8Array([ return util.concatUint8Array([new Uint8Array([this.data.length]), this.data]);
new Uint8Array([this.data.length]),
this.data]);
}; };

View File

@ -15,7 +15,7 @@
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
/* globals self: true */ /* eslint-disable no-restricted-globals */
self.window = {}; // to make UMD bundles work self.window = {}; // to make UMD bundles work