ESLint is happy!
This commit is contained in:
parent
370a15e2a1
commit
11a2d0070b
366
.eslintrc.js
Normal file
366
.eslintrc.js
Normal 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
|
||||||
|
}
|
||||||
|
};
|
36
.jshintrc
36
.jshintrc
|
@ -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
|
|
||||||
}
|
|
||||||
}
|
|
27
Gruntfile.js
27
Gruntfile.js
|
@ -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');
|
||||||
|
@ -310,10 +299,10 @@ module.exports = function(grunt) {
|
||||||
// Build tasks
|
// Build tasks
|
||||||
grunt.registerTask('version', ['replace:openpgp', 'replace:openpgp_debug']);
|
grunt.registerTask('version', ['replace:openpgp', 'replace:openpgp_debug']);
|
||||||
grunt.registerTask('replace_min', ['replace:openpgp_min', 'replace:worker_min']);
|
grunt.registerTask('replace_min', ['replace:openpgp_min', 'replace:worker_min']);
|
||||||
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']);
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
import cipher from './cipher';
|
import cipher from './cipher';
|
||||||
|
|
||||||
function wrap(key, data) {
|
function wrap(key, data) {
|
||||||
var aes = new cipher["aes" + (key.length*8)](key);
|
var aes = new cipher["aes" + (key.length*8)](key);
|
||||||
var IV = new Uint32Array([0xA6A6A6A6, 0xA6A6A6A6]);
|
var IV = new Uint32Array([0xA6A6A6A6, 0xA6A6A6A6]);
|
||||||
var P = unpack(data);
|
var P = unpack(data);
|
||||||
var A = IV;
|
var A = IV;
|
||||||
|
@ -52,7 +52,7 @@ function wrap(key, data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function unwrap(key, data) {
|
function unwrap(key, data) {
|
||||||
var aes = new cipher["aes" + (key.length*8)](key);
|
var aes = new cipher["aes" + (key.length*8)](key);
|
||||||
var IV = new Uint32Array([0xA6A6A6A6, 0xA6A6A6A6]);
|
var IV = new Uint32Array([0xA6A6A6A6, 0xA6A6A6A6]);
|
||||||
var C = unpack(data);
|
var C = unpack(data);
|
||||||
var A = C.subarray(0, 2);
|
var A = C.subarray(0, 2);
|
||||||
|
|
|
@ -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([
|
||||||
|
|
|
@ -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 );
|
||||||
}
|
}
|
||||||
|
|
|
@ -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];
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -73,7 +73,7 @@ export default {
|
||||||
* @return {Array<module:type/mpi|module:type/oid|module:type/kdf|module:type/ecdh_symkey>} encrypted session key parameters
|
* @return {Array<module:type/mpi|module:type/oid|module:type/kdf|module:type/ecdh_symkey>} encrypted session key parameters
|
||||||
*/
|
*/
|
||||||
publicKeyEncrypt: function(algo, publicParams, data, fingerprint) {
|
publicKeyEncrypt: function(algo, publicParams, data, fingerprint) {
|
||||||
var types = this.getEncSessionKeyParamTypes(algo);
|
var types = this.getEncSessionKeyParamTypes(algo);
|
||||||
var result = (function() {
|
var result = (function() {
|
||||||
var m;
|
var m;
|
||||||
switch (algo) {
|
switch (algo) {
|
||||||
|
@ -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;
|
||||||
|
@ -270,7 +270,7 @@ export default {
|
||||||
* @return {Array} The array of parameters
|
* @return {Array} The array of parameters
|
||||||
*/
|
*/
|
||||||
generateParams: function(algo, bits, curve) {
|
generateParams: function(algo, bits, curve) {
|
||||||
var types = this.getPubKeyParamTypes(algo).concat(this.getPrivKeyParamTypes(algo));
|
var types = this.getPubKeyParamTypes(algo).concat(this.getPrivKeyParamTypes(algo));
|
||||||
switch (algo) {
|
switch (algo) {
|
||||||
case 'rsa_encrypt':
|
case 'rsa_encrypt':
|
||||||
case 'rsa_encrypt_sign':
|
case 'rsa_encrypt_sign':
|
||||||
|
|
|
@ -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();
|
||||||
|
@ -49,7 +50,7 @@ export function encrypt(cipher, plaintext, key, iv) {
|
||||||
if (webCrypto && config.use_native && key.length !== 24) { // WebCrypto (no 192 bit support) see: https://www.chromium.org/blink/webcrypto#TOC-AES-support
|
if (webCrypto && config.use_native && key.length !== 24) { // WebCrypto (no 192 bit support) see: https://www.chromium.org/blink/webcrypto#TOC-AES-support
|
||||||
return webEncrypt(plaintext, key, iv);
|
return webEncrypt(plaintext, key, iv);
|
||||||
} else if (nodeCrypto && config.use_native) { // Node crypto library
|
} else if (nodeCrypto && config.use_native) { // Node crypto library
|
||||||
return nodeEncrypt(plaintext, key, iv) ;
|
return nodeEncrypt(plaintext, key, iv);
|
||||||
} else { // asm.js fallback
|
} else { // asm.js fallback
|
||||||
return Promise.resolve(asmCrypto.AES_GCM.encrypt(plaintext, key, iv));
|
return Promise.resolve(asmCrypto.AES_GCM.encrypt(plaintext, key, iv));
|
||||||
}
|
}
|
||||||
|
|
|
@ -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';
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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";
|
||||||
}
|
}
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,7 +114,7 @@ function am3(i, x, w, j, c, n) {
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
/*if(j_lm && (navigator != undefined &&
|
/*if(j_lm && (navigator != undefined &&
|
||||||
navigator.appName == "Microsoft Internet Explorer")) {
|
navigator.appName == "Microsoft Internet Explorer")) {
|
||||||
BigInteger.prototype.am = am2;
|
BigInteger.prototype.am = am2;
|
||||||
dbits = 30;
|
dbits = 30;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
/* eslint-disable import/newline-after-import, import/first */
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -323,7 +323,7 @@ Message.prototype.sign = function(privateKeys=[], signature=null) {
|
||||||
|
|
||||||
var literalFormat = enums.write(enums.literal, literalDataPacket.format);
|
var literalFormat = enums.write(enums.literal, literalDataPacket.format);
|
||||||
var signatureType = literalFormat === enums.literal.binary ?
|
var signatureType = literalFormat === enums.literal.binary ?
|
||||||
enums.signature.binary : enums.signature.text;
|
enums.signature.binary : enums.signature.text;
|
||||||
var i, signingKeyPacket, existingSigPacketlist, onePassSig;
|
var i, signingKeyPacket, existingSigPacketlist, onePassSig;
|
||||||
|
|
||||||
if (signature) {
|
if (signature) {
|
||||||
|
@ -401,7 +401,7 @@ Message.prototype.signDetached = function(privateKeys=[], signature=null) {
|
||||||
|
|
||||||
var literalFormat = enums.write(enums.literal, literalDataPacket.format);
|
var literalFormat = enums.write(enums.literal, literalDataPacket.format);
|
||||||
var signatureType = literalFormat === enums.literal.binary ?
|
var signatureType = literalFormat === enums.literal.binary ?
|
||||||
enums.signature.binary : enums.signature.text;
|
enums.signature.binary : enums.signature.text;
|
||||||
|
|
||||||
for (var i = 0; i < privateKeys.length; i++) {
|
for (var i = 0; i < privateKeys.length; i++) {
|
||||||
var signingKeyPacket = privateKeys[i].getSigningKeyPacket();
|
var signingKeyPacket = privateKeys[i].getSigningKeyPacket();
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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) {
|
||||||
|
@ -127,7 +130,7 @@ Packetlist.prototype.filterByTag = function () {
|
||||||
var filtered = new Packetlist();
|
var filtered = new Packetlist();
|
||||||
var that = this;
|
var that = this;
|
||||||
|
|
||||||
function handle(packetType) {return that[i].tag === packetType;}
|
function handle(packetType) { return that[i].tag === packetType; }
|
||||||
for (var i = 0; i < this.length; i++) {
|
for (var i = 0; i < this.length; i++) {
|
||||||
if (args.some(handle)) {
|
if (args.some(handle)) {
|
||||||
filtered.push(this[i]);
|
filtered.push(this[i]);
|
||||||
|
@ -177,7 +180,7 @@ Packetlist.prototype.indexOfTag = function () {
|
||||||
var tagIndex = [];
|
var tagIndex = [];
|
||||||
var that = this;
|
var that = this;
|
||||||
|
|
||||||
function handle(packetType) {return that[i].tag === packetType;}
|
function handle(packetType) { return that[i].tag === packetType; }
|
||||||
for (var i = 0; i < this.length; i++) {
|
for (var i = 0; i < this.length; i++) {
|
||||||
if (args.some(handle)) {
|
if (args.some(handle)) {
|
||||||
tagIndex.push(i);
|
tagIndex.push(i);
|
||||||
|
|
|
@ -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.
|
||||||
|
@ -193,7 +191,7 @@ SecretKey.prototype.encrypt = function (passphrase) {
|
||||||
blockLen = crypto.cipher[symmetric].blockSize,
|
blockLen = crypto.cipher[symmetric].blockSize,
|
||||||
iv = crypto.random.getRandomBytes(blockLen);
|
iv = crypto.random.getRandomBytes(blockLen);
|
||||||
|
|
||||||
var arr = [ new Uint8Array([254, enums.write(enums.symmetric, symmetric)]) ];
|
var arr = [new Uint8Array([254, enums.write(enums.symmetric, symmetric)])];
|
||||||
arr.push(s2k.write());
|
arr.push(s2k.write());
|
||||||
arr.push(iv);
|
arr.push(iv);
|
||||||
arr.push(crypto.cfb.normalEncrypt(symmetric, key, cleartext, iv));
|
arr.push(crypto.cfb.normalEncrypt(symmetric, key, cleartext, iv));
|
||||||
|
|
|
@ -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);
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ export default function SymEncryptedAEADProtected() {
|
||||||
this.version = VERSION;
|
this.version = VERSION;
|
||||||
this.iv = null;
|
this.iv = null;
|
||||||
this.encrypted = null;
|
this.encrypted = null;
|
||||||
this.packets = null;
|
this.packets = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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();
|
||||||
|
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
|
@ -42,7 +42,7 @@ export default function SymmetricallyEncrypted() {
|
||||||
this.encrypted = null;
|
this.encrypted = null;
|
||||||
/** Decrypted packets contained within.
|
/** Decrypted packets contained within.
|
||||||
* @type {module:packet/packetlist} */
|
* @type {module:packet/packetlist} */
|
||||||
this.packets = null;
|
this.packets = null;
|
||||||
this.ignore_mdc_error = config.ignore_mdc_error;
|
this.ignore_mdc_error = config.ignore_mdc_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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]);
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user