@protontech/openpgp 4.10.8 → 5.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +311 -239
- package/dist/lightweight/bn.interface.min.mjs +3 -0
- package/dist/lightweight/bn.interface.min.mjs.map +1 -0
- package/dist/lightweight/bn.interface.mjs +340 -0
- package/dist/lightweight/bn.min.mjs +3 -0
- package/dist/lightweight/bn.min.mjs.map +1 -0
- package/dist/lightweight/bn.mjs +3434 -0
- package/dist/lightweight/elliptic.min.mjs +3 -0
- package/dist/lightweight/elliptic.min.mjs.map +1 -0
- package/dist/lightweight/elliptic.mjs +4313 -0
- package/dist/lightweight/openpgp.min.mjs +3 -0
- package/dist/lightweight/openpgp.min.mjs.map +1 -0
- package/dist/lightweight/openpgp.mjs +31375 -0
- package/dist/lightweight/ponyfill.es6.min.mjs +3 -0
- package/dist/lightweight/ponyfill.es6.min.mjs.map +1 -0
- package/dist/lightweight/ponyfill.es6.mjs +3831 -0
- package/dist/lightweight/web-streams-adapter.min.mjs +17 -0
- package/dist/lightweight/web-streams-adapter.min.mjs.map +1 -0
- package/dist/lightweight/web-streams-adapter.mjs +561 -0
- package/dist/node/openpgp.js +43943 -0
- package/dist/node/openpgp.min.js +17 -0
- package/dist/node/openpgp.min.js.map +1 -0
- package/dist/node/openpgp.min.mjs +17 -0
- package/dist/node/openpgp.min.mjs.map +1 -0
- package/dist/node/openpgp.mjs +43880 -0
- package/dist/openpgp.js +41077 -41609
- package/dist/openpgp.min.js +17 -2
- package/dist/openpgp.min.js.map +1 -0
- package/dist/openpgp.min.mjs +17 -0
- package/dist/openpgp.min.mjs.map +1 -0
- package/dist/openpgp.mjs +43868 -0
- package/lightweight/package.json +5 -0
- package/openpgp.d.ts +889 -0
- package/package.json +63 -57
- package/dist/compat/openpgp.js +0 -61152
- package/dist/compat/openpgp.min.js +0 -2
- package/dist/compat/openpgp.worker.js +0 -173
- package/dist/compat/openpgp.worker.min.js +0 -2
- package/dist/lightweight/elliptic.min.js +0 -5
- package/dist/lightweight/openpgp.js +0 -40071
- package/dist/lightweight/openpgp.min.js +0 -2
- package/dist/lightweight/openpgp.worker.js +0 -173
- package/dist/lightweight/openpgp.worker.min.js +0 -2
- package/dist/openpgp.worker.js +0 -173
- package/dist/openpgp.worker.min.js +0 -2
- package/src/cleartext.js +0 -220
- package/src/config/config.js +0 -232
- package/src/config/index.js +0 -7
- package/src/config/localStorage.js +0 -35
- package/src/crypto/aes_kw.js +0 -153
- package/src/crypto/cfb.js +0 -169
- package/src/crypto/cipher/aes.js +0 -27
- package/src/crypto/cipher/blowfish.js +0 -398
- package/src/crypto/cipher/cast5.js +0 -610
- package/src/crypto/cipher/des.js +0 -476
- package/src/crypto/cipher/index.js +0 -91
- package/src/crypto/cipher/twofish.js +0 -346
- package/src/crypto/cmac.js +0 -98
- package/src/crypto/crypto.js +0 -394
- package/src/crypto/eax.js +0 -172
- package/src/crypto/gcm.js +0 -141
- package/src/crypto/hash/index.js +0 -163
- package/src/crypto/hash/md5.js +0 -205
- package/src/crypto/index.js +0 -57
- package/src/crypto/ocb.js +0 -274
- package/src/crypto/pkcs1.js +0 -170
- package/src/crypto/pkcs5.js +0 -55
- package/src/crypto/public_key/dsa.js +0 -188
- package/src/crypto/public_key/elgamal.js +0 -137
- package/src/crypto/public_key/elliptic/curves.js +0 -385
- package/src/crypto/public_key/elliptic/ecdh.js +0 -414
- package/src/crypto/public_key/elliptic/ecdsa.js +0 -348
- package/src/crypto/public_key/elliptic/eddsa.js +0 -119
- package/src/crypto/public_key/elliptic/index.js +0 -34
- package/src/crypto/public_key/elliptic/indutnyKey.js +0 -85
- package/src/crypto/public_key/index.js +0 -28
- package/src/crypto/public_key/prime.js +0 -275
- package/src/crypto/public_key/rsa.js +0 -597
- package/src/crypto/random.js +0 -145
- package/src/crypto/signature.js +0 -137
- package/src/encoding/armor.js +0 -433
- package/src/encoding/base64.js +0 -96
- package/src/enums.js +0 -493
- package/src/hkp.js +0 -89
- package/src/index.js +0 -161
- package/src/key/factory.js +0 -326
- package/src/key/helper.js +0 -378
- package/src/key/index.js +0 -32
- package/src/key/key.js +0 -888
- package/src/key/subkey.js +0 -187
- package/src/key/user.js +0 -230
- package/src/keyring/index.js +0 -12
- package/src/keyring/keyring.js +0 -229
- package/src/keyring/localstore.js +0 -119
- package/src/lightweight_helper.js +0 -26
- package/src/message.js +0 -825
- package/src/openpgp.js +0 -717
- package/src/packet/all_packets.js +0 -116
- package/src/packet/clone.js +0 -189
- package/src/packet/compressed.js +0 -194
- package/src/packet/index.js +0 -20
- package/src/packet/literal.js +0 -168
- package/src/packet/marker.js +0 -62
- package/src/packet/one_pass_signature.js +0 -156
- package/src/packet/packet.js +0 -300
- package/src/packet/packetlist.js +0 -232
- package/src/packet/public_key.js +0 -280
- package/src/packet/public_key_encrypted_session_key.js +0 -161
- package/src/packet/public_subkey.js +0 -44
- package/src/packet/secret_key.js +0 -468
- package/src/packet/secret_subkey.js +0 -41
- package/src/packet/signature.js +0 -786
- package/src/packet/sym_encrypted_aead_protected.js +0 -189
- package/src/packet/sym_encrypted_integrity_protected.js +0 -139
- package/src/packet/sym_encrypted_session_key.js +0 -204
- package/src/packet/symmetrically_encrypted.js +0 -118
- package/src/packet/trust.js +0 -35
- package/src/packet/user_attribute.js +0 -94
- package/src/packet/userid.js +0 -87
- package/src/polyfills.js +0 -64
- package/src/signature.js +0 -73
- package/src/type/ecdh_symkey.js +0 -69
- package/src/type/kdf_params.js +0 -114
- package/src/type/keyid.js +0 -110
- package/src/type/mpi.js +0 -138
- package/src/type/oid.js +0 -110
- package/src/type/s2k.js +0 -203
- package/src/util.js +0 -836
- package/src/wkd.js +0 -84
- package/src/worker/async_proxy.js +0 -190
- package/src/worker/worker.js +0 -167
- package/test/crypto/aes_kw.js +0 -57
- package/test/crypto/cipher/aes.js +0 -86
- package/test/crypto/cipher/blowfish.js +0 -58
- package/test/crypto/cipher/cast5.js +0 -25
- package/test/crypto/cipher/des.js +0 -143
- package/test/crypto/cipher/index.js +0 -7
- package/test/crypto/cipher/twofish.js +0 -71
- package/test/crypto/crypto.js +0 -383
- package/test/crypto/eax.js +0 -150
- package/test/crypto/ecdh.js +0 -359
- package/test/crypto/elliptic.js +0 -251
- package/test/crypto/elliptic_data.js +0 -102
- package/test/crypto/hash/index.js +0 -5
- package/test/crypto/hash/md5.js +0 -16
- package/test/crypto/hash/ripemd.js +0 -14
- package/test/crypto/hash/sha.js +0 -20
- package/test/crypto/index.js +0 -14
- package/test/crypto/ocb.js +0 -183
- package/test/crypto/pkcs5.js +0 -39
- package/test/crypto/random.js +0 -79
- package/test/crypto/rsa.js +0 -180
- package/test/crypto/validate.js +0 -387
- package/test/general/armor.js +0 -408
- package/test/general/brainpool.js +0 -360
- package/test/general/decompression.js +0 -60
- package/test/general/ecc_nist.js +0 -115
- package/test/general/ecc_secp256k1.js +0 -242
- package/test/general/forwarding.js +0 -43
- package/test/general/hkp.js +0 -165
- package/test/general/index.js +0 -20
- package/test/general/key.js +0 -3491
- package/test/general/keyring.js +0 -336
- package/test/general/oid.js +0 -39
- package/test/general/openpgp.js +0 -2577
- package/test/general/packet.js +0 -950
- package/test/general/signature.js +0 -1715
- package/test/general/streaming.js +0 -944
- package/test/general/testInputs.js +0 -18
- package/test/general/util.js +0 -183
- package/test/general/wkd.js +0 -48
- package/test/general/x25519.js +0 -556
- package/test/unittests.js +0 -64
package/src/wkd.js
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
// OpenPGP.js - An OpenPGP implementation in javascript
|
|
2
|
-
// Copyright (C) 2018 Wiktor Kwapisiewicz
|
|
3
|
-
//
|
|
4
|
-
// This library is free software; you can redistribute it and/or
|
|
5
|
-
// modify it under the terms of the GNU Lesser General Public
|
|
6
|
-
// License as published by the Free Software Foundation; either
|
|
7
|
-
// version 3.0 of the License, or (at your option) any later version.
|
|
8
|
-
//
|
|
9
|
-
// This library is distributed in the hope that it will be useful,
|
|
10
|
-
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
-
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
12
|
-
// Lesser General Public License for more details.
|
|
13
|
-
//
|
|
14
|
-
// You should have received a copy of the GNU Lesser General Public
|
|
15
|
-
// License along with this library; if not, write to the Free Software
|
|
16
|
-
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @fileoverview This class implements a client for the Web Key Directory (wkd) protocol
|
|
20
|
-
* in order to lookup keys on designated servers.
|
|
21
|
-
* See: https://datatracker.ietf.org/doc/draft-koch-openpgp-webkey-service/
|
|
22
|
-
* @module wkd
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
import util from './util';
|
|
26
|
-
import crypto from './crypto';
|
|
27
|
-
import * as keyMod from './key';
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Initialize the WKD client
|
|
31
|
-
* @constructor
|
|
32
|
-
*/
|
|
33
|
-
function WKD() {
|
|
34
|
-
this._fetch = typeof global !== 'undefined' ? global.fetch : require('node-fetch');
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Search for a public key using Web Key Directory protocol.
|
|
39
|
-
* @param {String} options.email User's email.
|
|
40
|
-
* @param {Boolean} options.rawBytes Returns Uint8Array instead of parsed key.
|
|
41
|
-
* @returns {Promise<Uint8Array|
|
|
42
|
-
* {keys: Array<module:key.Key>,
|
|
43
|
-
* err: (Array<Error>|null)}>} The public key.
|
|
44
|
-
* @async
|
|
45
|
-
*/
|
|
46
|
-
WKD.prototype.lookup = async function(options) {
|
|
47
|
-
const fetch = this._fetch;
|
|
48
|
-
|
|
49
|
-
if (!options.email) {
|
|
50
|
-
throw new Error('You must provide an email parameter!');
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (!util.isEmailAddress(options.email)) {
|
|
54
|
-
throw new Error('Invalid e-mail address.');
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const [, localPart, domain] = /(.*)@(.*)/.exec(options.email);
|
|
58
|
-
const localEncoded = util.encodeZBase32(await crypto.hash.sha1(util.str_to_Uint8Array(localPart.toLowerCase())));
|
|
59
|
-
|
|
60
|
-
const urlAdvanced = `https://openpgpkey.${domain}/.well-known/openpgpkey/${domain}/hu/${localEncoded}`;
|
|
61
|
-
const urlDirect = `https://${domain}/.well-known/openpgpkey/hu/${localEncoded}`;
|
|
62
|
-
|
|
63
|
-
let response;
|
|
64
|
-
try {
|
|
65
|
-
response = await fetch(urlAdvanced);
|
|
66
|
-
if (response.status !== 200) {
|
|
67
|
-
throw new Error('Advanced WKD lookup failed: ' + response.statusText);
|
|
68
|
-
}
|
|
69
|
-
} catch (err) {
|
|
70
|
-
util.print_debug_error(err);
|
|
71
|
-
response = await fetch(urlDirect);
|
|
72
|
-
if (response.status !== 200) {
|
|
73
|
-
throw new Error('Direct WKD lookup failed: ' + response.statusText);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const rawBytes = new Uint8Array(await response.arrayBuffer());
|
|
78
|
-
if (options.rawBytes) {
|
|
79
|
-
return rawBytes;
|
|
80
|
-
}
|
|
81
|
-
return keyMod.read(rawBytes);
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
export default WKD;
|
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
// GPG4Browsers - An OpenPGP implementation in javascript
|
|
2
|
-
// Copyright (C) 2011 Recurity Labs GmbH
|
|
3
|
-
//
|
|
4
|
-
// This library is free software; you can redistribute it and/or
|
|
5
|
-
// modify it under the terms of the GNU Lesser General Public
|
|
6
|
-
// License as published by the Free Software Foundation; either
|
|
7
|
-
// version 3.0 of the License, or (at your option) any later version.
|
|
8
|
-
//
|
|
9
|
-
// This library is distributed in the hope that it will be useful,
|
|
10
|
-
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
-
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
12
|
-
// Lesser General Public License for more details.
|
|
13
|
-
//
|
|
14
|
-
// You should have received a copy of the GNU Lesser General Public
|
|
15
|
-
// License along with this library; if not, write to the Free Software
|
|
16
|
-
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @fileoverview Provides functions for maintaining browser workers
|
|
20
|
-
* @see module:openpgp.initWorker
|
|
21
|
-
* @see module:openpgp.getWorker
|
|
22
|
-
* @see module:openpgp.destroyWorker
|
|
23
|
-
* @see module:worker/worker
|
|
24
|
-
* @requires util
|
|
25
|
-
* @requires config
|
|
26
|
-
* @requires crypto
|
|
27
|
-
* @requires packet
|
|
28
|
-
* @module worker/async_proxy
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
import util from '../util.js';
|
|
32
|
-
import config from '../config';
|
|
33
|
-
import crypto from '../crypto';
|
|
34
|
-
import packet from '../packet';
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Initializes a new proxy and loads the web worker
|
|
39
|
-
* @param {String} path The path to the worker or 'openpgp.worker.js' by default
|
|
40
|
-
* @param {Number} n number of workers to initialize if path given
|
|
41
|
-
* @param {Object} config config The worker configuration
|
|
42
|
-
* @param {Array<Object>} worker alternative to path parameter: web worker initialized with 'openpgp.worker.js'
|
|
43
|
-
* @constructor
|
|
44
|
-
*/
|
|
45
|
-
function AsyncProxy({ path = 'openpgp.worker.js', n = 1, workers = [], config } = {}) {
|
|
46
|
-
/**
|
|
47
|
-
* Message handling
|
|
48
|
-
*/
|
|
49
|
-
const handleMessage = workerId => event => {
|
|
50
|
-
const msg = event.data;
|
|
51
|
-
switch (msg.event) {
|
|
52
|
-
case 'loaded':
|
|
53
|
-
this.workers[workerId].loadedResolve(true);
|
|
54
|
-
break;
|
|
55
|
-
case 'method-return':
|
|
56
|
-
if (msg.err) {
|
|
57
|
-
// fail
|
|
58
|
-
const err = new Error(msg.err);
|
|
59
|
-
// add worker stack
|
|
60
|
-
err.workerStack = msg.stack;
|
|
61
|
-
this.tasks[msg.id].reject(err);
|
|
62
|
-
} else {
|
|
63
|
-
// success
|
|
64
|
-
this.tasks[msg.id].resolve(msg.data);
|
|
65
|
-
}
|
|
66
|
-
delete this.tasks[msg.id];
|
|
67
|
-
this.workers[workerId].requests--;
|
|
68
|
-
break;
|
|
69
|
-
case 'request-seed':
|
|
70
|
-
this.seedRandom(workerId, msg.amount);
|
|
71
|
-
break;
|
|
72
|
-
default:
|
|
73
|
-
throw new Error('Unknown Worker Event.');
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
if (workers.length) {
|
|
78
|
-
this.workers = workers;
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
this.workers = [];
|
|
82
|
-
while (this.workers.length < n) {
|
|
83
|
-
this.workers.push(new Worker(path));
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
let workerId = 0;
|
|
88
|
-
this.workers.forEach(worker => {
|
|
89
|
-
worker.loadedPromise = new Promise(resolve => {
|
|
90
|
-
worker.loadedResolve = resolve;
|
|
91
|
-
});
|
|
92
|
-
worker.requests = 0;
|
|
93
|
-
worker.onmessage = handleMessage(workerId++);
|
|
94
|
-
worker.onerror = e => {
|
|
95
|
-
worker.loadedResolve(false);
|
|
96
|
-
// eslint-disable-next-line no-console
|
|
97
|
-
console.error('Unhandled error in openpgp worker: ' + e.message + ' (' + e.filename + ':' + e.lineno + ')');
|
|
98
|
-
return false;
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
if (config) {
|
|
102
|
-
worker.postMessage({ event:'configure', config });
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
// Cannot rely on task order being maintained, use object keyed by request ID to track tasks
|
|
107
|
-
this.tasks = {};
|
|
108
|
-
this.currentID = 0;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Returns a promise that resolves when all workers have finished loading
|
|
113
|
-
* @returns {Promise<Boolean>} Resolves to true if all workers have loaded succesfully; false otherwise
|
|
114
|
-
*/
|
|
115
|
-
AsyncProxy.prototype.loaded = async function() {
|
|
116
|
-
const loaded = await Promise.all(this.workers.map(worker => worker.loadedPromise));
|
|
117
|
-
return loaded.every(Boolean);
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Get new request ID
|
|
122
|
-
* @returns {integer} New unique request ID
|
|
123
|
-
*/
|
|
124
|
-
AsyncProxy.prototype.getID = function() {
|
|
125
|
-
return this.currentID++;
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Send message to worker with random data
|
|
130
|
-
* @param {Integer} size Number of bytes to send
|
|
131
|
-
* @async
|
|
132
|
-
*/
|
|
133
|
-
AsyncProxy.prototype.seedRandom = async function(workerId, size) {
|
|
134
|
-
const buf = await crypto.random.getRandomBytes(size);
|
|
135
|
-
this.workers[workerId].postMessage({ event:'seed-random', buf }, util.getTransferables(buf, true));
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Clear key caches
|
|
140
|
-
* @async
|
|
141
|
-
*/
|
|
142
|
-
AsyncProxy.prototype.clearKeyCache = async function() {
|
|
143
|
-
await Promise.all(this.workers.map(worker => new Promise((resolve, reject) => {
|
|
144
|
-
const id = this.getID();
|
|
145
|
-
|
|
146
|
-
worker.postMessage({ id, event: 'clear-key-cache' });
|
|
147
|
-
|
|
148
|
-
this.tasks[id] = { resolve, reject };
|
|
149
|
-
})));
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Terminates the workers
|
|
154
|
-
*/
|
|
155
|
-
AsyncProxy.prototype.terminate = function() {
|
|
156
|
-
this.workers.forEach(worker => {
|
|
157
|
-
worker.terminate();
|
|
158
|
-
});
|
|
159
|
-
};
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Generic proxy function that handles all commands from the public api.
|
|
163
|
-
* @param {String} method the public api function to be delegated to the worker thread
|
|
164
|
-
* @param {Object} options the api function's options
|
|
165
|
-
* @returns {Promise} see the corresponding public api functions for their return types
|
|
166
|
-
* @async
|
|
167
|
-
*/
|
|
168
|
-
AsyncProxy.prototype.delegate = function(method, options) {
|
|
169
|
-
|
|
170
|
-
const id = this.getID();
|
|
171
|
-
const requests = this.workers.map(worker => worker.requests);
|
|
172
|
-
const minRequests = Math.min(...requests);
|
|
173
|
-
let workerId = 0;
|
|
174
|
-
for (; workerId < this.workers.length; workerId++) {
|
|
175
|
-
if (this.workers[workerId].requests === minRequests) {
|
|
176
|
-
break;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
return new Promise((resolve, reject) => {
|
|
181
|
-
// clone packets (for web worker structured cloning algorithm)
|
|
182
|
-
this.workers[workerId].postMessage({ id:id, event:method, options:packet.clone.clonePackets(options) }, util.getTransferables(options, config.zero_copy));
|
|
183
|
-
this.workers[workerId].requests++;
|
|
184
|
-
|
|
185
|
-
// remember to handle parsing cloned packets from worker
|
|
186
|
-
this.tasks[id] = { resolve: data => resolve(packet.clone.parseClonedPackets(util.restoreStreams(data), method)), reject };
|
|
187
|
-
});
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
export default AsyncProxy;
|
package/src/worker/worker.js
DELETED
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
// GPG4Browsers - An OpenPGP implementation in javascript
|
|
2
|
-
// Copyright (C) 2011 Recurity Labs GmbH
|
|
3
|
-
//
|
|
4
|
-
// This library is free software; you can redistribute it and/or
|
|
5
|
-
// modify it under the terms of the GNU Lesser General Public
|
|
6
|
-
// License as published by the Free Software Foundation; either
|
|
7
|
-
// version 3.0 of the License, or (at your option) any later version.
|
|
8
|
-
//
|
|
9
|
-
// This library is distributed in the hope that it will be useful,
|
|
10
|
-
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
-
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
12
|
-
// Lesser General Public License for more details.
|
|
13
|
-
//
|
|
14
|
-
// You should have received a copy of the GNU Lesser General Public
|
|
15
|
-
// License along with this library; if not, write to the Free Software
|
|
16
|
-
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
17
|
-
|
|
18
|
-
/* eslint-disable no-restricted-globals */
|
|
19
|
-
/* eslint-disable no-var */
|
|
20
|
-
/* eslint-disable vars-on-top */
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* @fileoverview Provides functions for communicating with workers
|
|
24
|
-
* @see module:openpgp.initWorker
|
|
25
|
-
* @see module:openpgp.getWorker
|
|
26
|
-
* @see module:openpgp.destroyWorker
|
|
27
|
-
* @see module:worker/async_proxy
|
|
28
|
-
* @module worker/worker
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
importScripts('openpgp.js');
|
|
32
|
-
var openpgp = global.openpgp;
|
|
33
|
-
|
|
34
|
-
var randomQueue = [];
|
|
35
|
-
var MAX_SIZE_RANDOM_BUFFER = 60000;
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Handle random buffer exhaustion by requesting more random bytes from the main window
|
|
39
|
-
* @returns {Promise<Object>} Empty promise whose resolution indicates that the buffer has been refilled
|
|
40
|
-
*/
|
|
41
|
-
function randomCallback() {
|
|
42
|
-
|
|
43
|
-
if (!randomQueue.length) {
|
|
44
|
-
self.postMessage({ event: 'request-seed', amount: MAX_SIZE_RANDOM_BUFFER });
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return new Promise(function(resolve) {
|
|
48
|
-
randomQueue.push(resolve);
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
openpgp.crypto.random.randomBuffer.init(MAX_SIZE_RANDOM_BUFFER, randomCallback);
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Handle messages from the main window.
|
|
56
|
-
* @param {Object} event Contains event type and data
|
|
57
|
-
*/
|
|
58
|
-
self.onmessage = function(event) {
|
|
59
|
-
var msg = event.data || {};
|
|
60
|
-
|
|
61
|
-
switch (msg.event) {
|
|
62
|
-
case 'configure':
|
|
63
|
-
configure(msg.config);
|
|
64
|
-
break;
|
|
65
|
-
|
|
66
|
-
case 'seed-random':
|
|
67
|
-
seedRandom(msg.buf);
|
|
68
|
-
|
|
69
|
-
var queueCopy = randomQueue;
|
|
70
|
-
randomQueue = [];
|
|
71
|
-
for (var i = 0; i < queueCopy.length; i++) {
|
|
72
|
-
queueCopy[i]();
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
break;
|
|
76
|
-
|
|
77
|
-
default:
|
|
78
|
-
delegate(msg.id, msg.event, msg.options || {});
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Set config from main context to worker context.
|
|
84
|
-
* @param {Object} config The openpgp configuration
|
|
85
|
-
*/
|
|
86
|
-
function configure(config) {
|
|
87
|
-
Object.keys(config).forEach(function(key) {
|
|
88
|
-
openpgp.config[key] = config[key];
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Seed the library with entropy gathered global.crypto.getRandomValues
|
|
94
|
-
* as this api is only avalible in the main window.
|
|
95
|
-
* @param {ArrayBuffer} buffer Some random bytes
|
|
96
|
-
*/
|
|
97
|
-
function seedRandom(buffer) {
|
|
98
|
-
if (!(buffer instanceof Uint8Array)) {
|
|
99
|
-
buffer = new Uint8Array(buffer);
|
|
100
|
-
}
|
|
101
|
-
openpgp.crypto.random.randomBuffer.set(buffer);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const keyCache = new Map();
|
|
105
|
-
function getCachedKey(key) {
|
|
106
|
-
const armor = key.armor();
|
|
107
|
-
if (keyCache.has(armor)) {
|
|
108
|
-
return keyCache.get(armor);
|
|
109
|
-
}
|
|
110
|
-
keyCache.set(armor, key);
|
|
111
|
-
return key;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Generic proxy function that handles all commands from the public api.
|
|
116
|
-
* @param {String} method The public api function to be delegated to the worker thread
|
|
117
|
-
* @param {Object} options The api function's options
|
|
118
|
-
*/
|
|
119
|
-
function delegate(id, method, options) {
|
|
120
|
-
if (method === 'clear-key-cache') {
|
|
121
|
-
Array.from(keyCache.values()).forEach(key => {
|
|
122
|
-
if (key.isPrivate()) {
|
|
123
|
-
key.clearPrivateParams();
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
keyCache.clear();
|
|
127
|
-
response({ id, event: 'method-return' });
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
if (typeof openpgp[method] !== 'function') {
|
|
131
|
-
response({ id:id, event:'method-return', err:'Unknown Worker Event' });
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
// construct ReadableStreams from MessagePorts
|
|
135
|
-
openpgp.util.restoreStreams(options);
|
|
136
|
-
// parse cloned packets
|
|
137
|
-
options = openpgp.packet.clone.parseClonedPackets(options, method);
|
|
138
|
-
// cache keys by armor, so that we don't have to repeatedly verify self-signatures
|
|
139
|
-
if (options.publicKeys) {
|
|
140
|
-
options.publicKeys = options.publicKeys.map(getCachedKey);
|
|
141
|
-
}
|
|
142
|
-
if (options.privateKeys) {
|
|
143
|
-
options.privateKeys = options.privateKeys.map(getCachedKey);
|
|
144
|
-
}
|
|
145
|
-
openpgp[method](options).then(function(data) {
|
|
146
|
-
// clone packets (for web worker structured cloning algorithm)
|
|
147
|
-
response({ id:id, event:'method-return', data:openpgp.packet.clone.clonePackets(data) });
|
|
148
|
-
}).catch(function(e) {
|
|
149
|
-
openpgp.util.print_debug_error(e);
|
|
150
|
-
response({
|
|
151
|
-
id:id, event:'method-return', err:e.message, stack:e.stack
|
|
152
|
-
});
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Respond to the main window.
|
|
158
|
-
* @param {Object} event Contains event type and data
|
|
159
|
-
*/
|
|
160
|
-
function response(event) {
|
|
161
|
-
self.postMessage(event, openpgp.util.getTransferables(event.data, openpgp.config.zero_copy));
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Let the main window know the worker has loaded.
|
|
166
|
-
*/
|
|
167
|
-
postMessage({ event: 'loaded' });
|
package/test/crypto/aes_kw.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../../dist/openpgp');
|
|
2
|
-
|
|
3
|
-
const expect = require('chai').expect;
|
|
4
|
-
|
|
5
|
-
describe('AES Key Wrap and Unwrap', function () {
|
|
6
|
-
const test_vectors = [
|
|
7
|
-
[
|
|
8
|
-
"128 bits of Key Data with a 128-bit KEK",
|
|
9
|
-
"000102030405060708090A0B0C0D0E0F",
|
|
10
|
-
"00112233445566778899AABBCCDDEEFF",
|
|
11
|
-
"1FA68B0A8112B447 AEF34BD8FB5A7B82 9D3E862371D2CFE5"
|
|
12
|
-
],
|
|
13
|
-
[
|
|
14
|
-
"128 bits of Key Data with a 192-bit KEK",
|
|
15
|
-
"000102030405060708090A0B0C0D0E0F1011121314151617",
|
|
16
|
-
"00112233445566778899AABBCCDDEEFF",
|
|
17
|
-
"96778B25AE6CA435 F92B5B97C050AED2 468AB8A17AD84E5D"
|
|
18
|
-
],
|
|
19
|
-
[
|
|
20
|
-
"128 bits of Key Data with a 256-bit KEK",
|
|
21
|
-
"000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F",
|
|
22
|
-
"00112233445566778899AABBCCDDEEFF",
|
|
23
|
-
"64E8C3F9CE0F5BA2 63E9777905818A2A 93C8191E7D6E8AE7"
|
|
24
|
-
],
|
|
25
|
-
[
|
|
26
|
-
"192 bits of Key Data with a 192-bit KEK",
|
|
27
|
-
"000102030405060708090A0B0C0D0E0F1011121314151617",
|
|
28
|
-
"00112233445566778899AABBCCDDEEFF0001020304050607",
|
|
29
|
-
"031D33264E15D332 68F24EC260743EDC E1C6C7DDEE725A93 6BA814915C6762D2"
|
|
30
|
-
],
|
|
31
|
-
[
|
|
32
|
-
"192 bits of Key Data with a 256-bit KEK",
|
|
33
|
-
"000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F",
|
|
34
|
-
"00112233445566778899AABBCCDDEEFF0001020304050607",
|
|
35
|
-
"A8F9BC1612C68B3F F6E6F4FBE30E71E4 769C8B80A32CB895 8CD5D17D6B254DA1"
|
|
36
|
-
],
|
|
37
|
-
[
|
|
38
|
-
"256 bits of Key Data with a 256-bit KEK",
|
|
39
|
-
"000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F",
|
|
40
|
-
"00112233445566778899AABBCCDDEEFF000102030405060708090A0B0C0D0E0F",
|
|
41
|
-
"28C9F404C4B810F4 CBCCB35CFB87F826 3F5786E2D80ED326 CBC7F0E71A99F43B FB988B9B7A02DD21"
|
|
42
|
-
]
|
|
43
|
-
];
|
|
44
|
-
|
|
45
|
-
test_vectors.forEach(function(test) {
|
|
46
|
-
it(test[0], function(done) {
|
|
47
|
-
const kek = openpgp.util.hex_to_Uint8Array(test[1]);
|
|
48
|
-
const input = test[2].replace(/\s/g, "");
|
|
49
|
-
const input_bin = openpgp.util.hex_to_str(input);
|
|
50
|
-
const output = test[3].replace(/\s/g, "");
|
|
51
|
-
const output_bin = openpgp.util.hex_to_str(output);
|
|
52
|
-
expect(openpgp.util.Uint8Array_to_hex(openpgp.crypto.aes_kw.wrap(kek, input_bin)).toUpperCase()).to.equal(output);
|
|
53
|
-
expect(openpgp.util.Uint8Array_to_hex(openpgp.crypto.aes_kw.unwrap(kek, output_bin)).toUpperCase()).to.equal(input);
|
|
54
|
-
done();
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
});
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../../../dist/openpgp');
|
|
2
|
-
|
|
3
|
-
const chai = require('chai');
|
|
4
|
-
|
|
5
|
-
const { expect } = chai;
|
|
6
|
-
|
|
7
|
-
describe('AES Rijndael cipher test with test vectors from ecb_tbl.txt', function() {
|
|
8
|
-
function test_aes(input, key, output) {
|
|
9
|
-
const aes = new openpgp.crypto.cipher.aes128(new Uint8Array(key));
|
|
10
|
-
|
|
11
|
-
const encrypted = aes.encrypt(new Uint8Array(input));
|
|
12
|
-
expect(encrypted).to.deep.equal(new Uint8Array(output));
|
|
13
|
-
|
|
14
|
-
const decrypted = aes.decrypt(new Uint8Array(output));
|
|
15
|
-
expect(decrypted).to.deep.equal(new Uint8Array(input));
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const testvectors128 = [[[0x00,0x01,0x02,0x03,0x05,0x06,0x07,0x08,0x0A,0x0B,0x0C,0x0D,0x0F,0x10,0x11,0x12],[0x50,0x68,0x12,0xA4,0x5F,0x08,0xC8,0x89,0xB9,0x7F,0x59,0x80,0x03,0x8B,0x83,0x59],[0xD8,0xF5,0x32,0x53,0x82,0x89,0xEF,0x7D,0x06,0xB5,0x06,0xA4,0xFD,0x5B,0xE9,0xC9]],
|
|
19
|
-
[[0x14,0x15,0x16,0x17,0x19,0x1A,0x1B,0x1C,0x1E,0x1F,0x20,0x21,0x23,0x24,0x25,0x26],[0x5C,0x6D,0x71,0xCA,0x30,0xDE,0x8B,0x8B,0x00,0x54,0x99,0x84,0xD2,0xEC,0x7D,0x4B],[0x59,0xAB,0x30,0xF4,0xD4,0xEE,0x6E,0x4F,0xF9,0x90,0x7E,0xF6,0x5B,0x1F,0xB6,0x8C]],
|
|
20
|
-
[[0x28,0x29,0x2A,0x2B,0x2D,0x2E,0x2F,0x30,0x32,0x33,0x34,0x35,0x37,0x38,0x39,0x3A],[0x53,0xF3,0xF4,0xC6,0x4F,0x86,0x16,0xE4,0xE7,0xC5,0x61,0x99,0xF4,0x8F,0x21,0xF6],[0xBF,0x1E,0xD2,0xFC,0xB2,0xAF,0x3F,0xD4,0x14,0x43,0xB5,0x6D,0x85,0x02,0x5C,0xB1]],
|
|
21
|
-
[[0x3C,0x3D,0x3E,0x3F,0x41,0x42,0x43,0x44,0x46,0x47,0x48,0x49,0x4B,0x4C,0x4D,0x4E],[0xA1,0xEB,0x65,0xA3,0x48,0x71,0x65,0xFB,0x0F,0x1C,0x27,0xFF,0x99,0x59,0xF7,0x03],[0x73,0x16,0x63,0x2D,0x5C,0x32,0x23,0x3E,0xDC,0xB0,0x78,0x05,0x60,0xEA,0xE8,0xB2]],
|
|
22
|
-
[[0x50,0x51,0x52,0x53,0x55,0x56,0x57,0x58,0x5A,0x5B,0x5C,0x5D,0x5F,0x60,0x61,0x62],[0x35,0x53,0xEC,0xF0,0xB1,0x73,0x95,0x58,0xB0,0x8E,0x35,0x0A,0x98,0xA3,0x9B,0xFA],[0x40,0x8C,0x07,0x3E,0x3E,0x25,0x38,0x07,0x2B,0x72,0x62,0x5E,0x68,0xB8,0x36,0x4B]],
|
|
23
|
-
[[0x64,0x65,0x66,0x67,0x69,0x6A,0x6B,0x6C,0x6E,0x6F,0x70,0x71,0x73,0x74,0x75,0x76],[0x67,0x42,0x99,0x69,0x49,0x0B,0x97,0x11,0xAE,0x2B,0x01,0xDC,0x49,0x7A,0xFD,0xE8],[0xE1,0xF9,0x4D,0xFA,0x77,0x65,0x97,0xBE,0xAC,0xA2,0x62,0xF2,0xF6,0x36,0x6F,0xEA]],
|
|
24
|
-
[[0x78,0x79,0x7A,0x7B,0x7D,0x7E,0x7F,0x80,0x82,0x83,0x84,0x85,0x87,0x88,0x89,0x8A],[0x93,0x38,0x5C,0x1F,0x2A,0xEC,0x8B,0xED,0x19,0x2F,0x5A,0x8E,0x16,0x1D,0xD5,0x08],[0xF2,0x9E,0x98,0x6C,0x6A,0x1C,0x27,0xD7,0xB2,0x9F,0xFD,0x7E,0xE9,0x2B,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0xE4,0xE6,0xE7,0xE8,0xE9,0xEB,0xEC,0xED,0xEE],[0x23,0x60,0x5A,0x82,0x43,0xD0,0x77,0x64,0x54,0x1B,0xC5,0xAD,0x35,0x5B,0x31,0x29],[0x6D,0x96,0xFE,0xF7,0xD6,0x65,0x90,0xA7,0x7A,0x77,0xBB,0x20,0x56,0x66,0x7F,0x7F]],
|
|
30
|
-
[[0xF0,0xF1,0xF2,0xF3,0xF5,0xF6,0xF7,0xF8,0xFA,0xFB,0xFC,0xFD,0xFE,0x01,0x00,0x02],[0x12,0xA8,0xCF,0xA2,0x3E,0xA7,0x64,0xFD,0x87,0x62,0x32,0xB4,0xE8,0x42,0xBC,0x44],[0x31,0x6F,0xB6,0x8E,0xDB,0xA7,0x36,0xC5,0x3E,0x78,0x47,0x7B,0xF9,0x13,0x72,0x5C]],
|
|
31
|
-
[[0x04,0x05,0x06,0x07,0x09,0x0A,0x0B,0x0C,0x0E,0x0F,0x10,0x11,0x13,0x14,0x15,0x16],[0xBC,0xAF,0x32,0x41,0x5E,0x83,0x08,0xB3,0x72,0x3E,0x5F,0xDD,0x85,0x3C,0xCC,0x80],[0x69,0x36,0xF2,0xB9,0x3A,0xF8,0x39,0x7F,0xD3,0xA7,0x71,0xFC,0x01,0x1C,0x8C,0x37]],
|
|
32
|
-
[[0x2C,0x2D,0x2E,0x2F,0x31,0x32,0x33,0x34,0x36,0x37,0x38,0x39,0x3B,0x3C,0x3D,0x3E],[0x89,0xAF,0xAE,0x68,0x5D,0x80,0x1A,0xD7,0x47,0xAC,0xE9,0x1F,0xC4,0x9A,0xDD,0xE0],[0xF3,0xF9,0x2F,0x7A,0x9C,0x59,0x17,0x9C,0x1F,0xCC,0x2C,0x2B,0xA0,0xB0,0x82,0xCD]]];
|
|
33
|
-
|
|
34
|
-
const testvectors192 = [[[0x00,0x01,0x02,0x03,0x05,0x06,0x07,0x08,0x0A,0x0B,0x0C,0x0D,0x0F,0x10,0x11,0x12,0x14,0x15,0x16,0x17,0x19,0x1A,0x1B,0x1C],[0x2D,0x33,0xEE,0xF2,0xC0,0x43,0x0A,0x8A,0x9E,0xBF,0x45,0xE8,0x09,0xC4,0x0B,0xB6],[0xDF,0xF4,0x94,0x5E,0x03,0x36,0xDF,0x4C,0x1C,0x56,0xBC,0x70,0x0E,0xFF,0x83,0x7F]],
|
|
35
|
-
[[0x1E,0x1F,0x20,0x21,0x23,0x24,0x25,0x26,0x28,0x29,0x2A,0x2B,0x2D,0x2E,0x2F,0x30,0x32,0x33,0x34,0x35,0x37,0x38,0x39,0x3A],[0x6A,0xA3,0x75,0xD1,0xFA,0x15,0x5A,0x61,0xFB,0x72,0x35,0x3E,0x0A,0x5A,0x87,0x56],[0xB6,0xFD,0xDE,0xF4,0x75,0x27,0x65,0xE3,0x47,0xD5,0xD2,0xDC,0x19,0x6D,0x12,0x52]],
|
|
36
|
-
[[0x3C,0x3D,0x3E,0x3F,0x41,0x42,0x43,0x44,0x46,0x47,0x48,0x49,0x4B,0x4C,0x4D,0x4E,0x50,0x51,0x52,0x53,0x55,0x56,0x57,0x58],[0xBC,0x37,0x36,0x51,0x8B,0x94,0x90,0xDC,0xB8,0xED,0x60,0xEB,0x26,0x75,0x8E,0xD4],[0xD2,0x36,0x84,0xE3,0xD9,0x63,0xB3,0xAF,0xCF,0x1A,0x11,0x4A,0xCA,0x90,0xCB,0xD6]],
|
|
37
|
-
[[0x5A,0x5B,0x5C,0x5D,0x5F,0x60,0x61,0x62,0x64,0x65,0x66,0x67,0x69,0x6A,0x6B,0x6C,0x6E,0x6F,0x70,0x71,0x73,0x74,0x75,0x76],[0xAA,0x21,0x44,0x02,0xB4,0x6C,0xFF,0xB9,0xF7,0x61,0xEC,0x11,0x26,0x3A,0x31,0x1E],[0x3A,0x7A,0xC0,0x27,0x75,0x3E,0x2A,0x18,0xC2,0xCE,0xAB,0x9E,0x17,0xC1,0x1F,0xD0]],
|
|
38
|
-
[[0x78,0x79,0x7A,0x7B,0x7D,0x7E,0x7F,0x80,0x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,0xB6,0xAD,0x26,0xD3,0xD8,0x62,0xFF]],
|
|
42
|
-
[[0xF0,0xF1,0xF2,0xF3,0xF5,0xF6,0xF7,0xF8,0xFA,0xFB,0xFC,0xFD,0xFE,0x01,0x00,0x02,0x04,0x05,0x06,0x07,0x09,0x0A,0x0B,0x0C],[0x66,0x20,0x8F,0x6E,0x9D,0x04,0x52,0x5B,0xDE,0xDB,0x27,0x33,0xB6,0xA6,0xBE,0x37],[0x70,0xF9,0xE6,0x7F,0x9F,0x8D,0xF1,0x29,0x41,0x31,0x66,0x2D,0xC6,0xE6,0x93,0x64]],
|
|
43
|
-
[[0x0E,0x0F,0x10,0x11,0x13,0x14,0x15,0x16,0x18,0x19,0x1A,0x1B,0x1D,0x1E,0x1F,0x20,0x22,0x23,0x24,0x25,0x27,0x28,0x29,0x2A],[0x33,0x93,0xF8,0xDF,0xC7,0x29,0xC9,0x7F,0x54,0x80,0xB9,0x50,0xBC,0x96,0x66,0xB0],[0xD1,0x54,0xDC,0xAF,0xAD,0x8B,0x20,0x7F,0xA5,0xCB,0xC9,0x5E,0x99,0x96,0xB5,0x59]],
|
|
44
|
-
[[0x2C,0x2D,0x2E,0x2F,0x31,0x32,0x33,0x34,0x36,0x37,0x38,0x39,0x3B,0x3C,0x3D,0x3E,0x40,0x41,0x42,0x43,0x45,0x46,0x47,0x48],[0x60,0x68,0x34,0xC8,0xCE,0x06,0x3F,0x32,0x34,0xCF,0x11,0x45,0x32,0x5D,0xBD,0x71],[0x49,0x34,0xD5,0x41,0xE8,0xB4,0x6F,0xA3,0x39,0xC8,0x05,0xA7,0xAE,0xB9,0xE5,0xDA]],
|
|
45
|
-
[[0x4A,0x4B,0x4C,0x4D,0x4F,0x50,0x51,0x52,0x54,0x55,0x56,0x57,0x59,0x5A,0x5B,0x5C,0x5E,0x5F,0x60,0x61,0x63,0x64,0x65,0x66],[0xFE,0xC1,0xC0,0x4F,0x52,0x9B,0xBD,0x17,0xD8,0xCE,0xCF,0xCC,0x47,0x18,0xB1,0x7F],[0x62,0x56,0x4C,0x73,0x8F,0x3E,0xFE,0x18,0x6E,0x1A,0x12,0x7A,0x0C,0x4D,0x3C,0x61]],
|
|
46
|
-
[[0x68,0x69,0x6A,0x6B,0x6D,0x6E,0x6F,0x70,0x72,0x73,0x74,0x75,0x77,0x78,0x79,0x7A,0x7C,0x7D,0x7E,0x7F,0x81,0x82,0x83,0x84],[0x32,0xDF,0x99,0xB4,0x31,0xED,0x5D,0xC5,0xAC,0xF8,0xCA,0xF6,0xDC,0x6C,0xE4,0x75],[0x07,0x80,0x5A,0xA0,0x43,0x98,0x6E,0xB2,0x36,0x93,0xE2,0x3B,0xEF,0x8F,0x34,0x38]],
|
|
47
|
-
[[0x86,0x87,0x88,0x89,0x8B,0x8C,0x8D,0x8E,0x90,0x91,0x92,0x93,0x95,0x96,0x97,0x98,0x9A,0x9B,0x9C,0x9D,0x9F,0xA0,0xA1,0xA2],[0x7F,0xDC,0x2B,0x74,0x6F,0x3F,0x66,0x52,0x96,0x94,0x3B,0x83,0x71,0x0D,0x1F,0x82],[0xDF,0x0B,0x49,0x31,0x03,0x8B,0xAD,0xE8,0x48,0xDE,0xE3,0xB4,0xB8,0x5A,0xA4,0x4B]],
|
|
48
|
-
[[0xA4,0xA5,0xA6,0xA7,0xA9,0xAA,0xAB,0xAC,0xAE,0xAF,0xB0,0xB1,0xB3,0xB4,0xB5,0xB6,0xB8,0xB9,0xBA,0xBB,0xBD,0xBE,0xBF,0xC0],[0x8F,0xBA,0x15,0x10,0xA3,0xC5,0xB8,0x7E,0x2E,0xAA,0x3F,0x7A,0x91,0x45,0x5C,0xA2],[0x59,0x2D,0x5F,0xDE,0xD7,0x65,0x82,0xE4,0x14,0x3C,0x65,0x09,0x93,0x09,0x47,0x7C]]];
|
|
49
|
-
|
|
50
|
-
const testvectors256 = [[[0x00,0x01,0x02,0x03,0x05,0x06,0x07,0x08,0x0A,0x0B,0x0C,0x0D,0x0F,0x10,0x11,0x12,0x14,0x15,0x16,0x17,0x19,0x1A,0x1B,0x1C,0x1E,0x1F,0x20,0x21,0x23,0x24,0x25,0x26],[0x83,0x4E,0xAD,0xFC,0xCA,0xC7,0xE1,0xB3,0x06,0x64,0xB1,0xAB,0xA4,0x48,0x15,0xAB],[0x19,0x46,0xDA,0xBF,0x6A,0x03,0xA2,0xA2,0xC3,0xD0,0xB0,0x50,0x80,0xAE,0xD6,0xFC]],
|
|
51
|
-
[[0x28,0x29,0x2A,0x2B,0x2D,0x2E,0x2F,0x30,0x32,0x33,0x34,0x35,0x37,0x38,0x39,0x3A,0x3C,0x3D,0x3E,0x3F,0x41,0x42,0x43,0x44,0x46,0x47,0x48,0x49,0x4B,0x4C,0x4D,0x4E],[0xD9,0xDC,0x4D,0xBA,0x30,0x21,0xB0,0x5D,0x67,0xC0,0x51,0x8F,0x72,0xB6,0x2B,0xF1],[0x5E,0xD3,0x01,0xD7,0x47,0xD3,0xCC,0x71,0x54,0x45,0xEB,0xDE,0xC6,0x2F,0x2F,0xB4]],
|
|
52
|
-
[[0x50,0x51,0x52,0x53,0x55,0x56,0x57,0x58,0x5A,0x5B,0x5C,0x5D,0x5F,0x60,0x61,0x62,0x64,0x65,0x66,0x67,0x69,0x6A,0x6B,0x6C,0x6E,0x6F,0x70,0x71,0x73,0x74,0x75,0x76],[0xA2,0x91,0xD8,0x63,0x01,0xA4,0xA7,0x39,0xF7,0x39,0x21,0x73,0xAA,0x3C,0x60,0x4C],[0x65,0x85,0xC8,0xF4,0x3D,0x13,0xA6,0xBE,0xAB,0x64,0x19,0xFC,0x59,0x35,0xB9,0xD0]],
|
|
53
|
-
[[0x78,0x79,0x7A,0x7B,0x7D,0x7E,0x7F,0x80,0x82,0x83,0x84,0x85,0x87,0x88,0x89,0x8A,0x8C,0x8D,0x8E,0x8F,0x91,0x92,0x93,0x94,0x96,0x97,0x98,0x99,0x9B,0x9C,0x9D,0x9E],[0x42,0x64,0xB2,0x69,0x64,0x98,0xDE,0x4D,0xF7,0x97,0x88,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81,0x44,0xBC,0x8D,0x22,0xE8,0xE7]],
|
|
57
|
-
[[0x18,0x19,0x1A,0x1B,0x1D,0x1E,0x1F,0x20,0x22,0x23,0x24,0x25,0x27,0x28,0x29,0x2A,0x2C,0x2D,0x2E,0x2F,0x31,0x32,0x33,0x34,0x36,0x37,0x38,0x39,0x3B,0x3C,0x3D,0x3E],[0xF0,0xE2,0xD7,0x22,0x60,0xAF,0x58,0xE2,0x1E,0x01,0x5A,0xB3,0xA4,0xC0,0xD9,0x06],[0x89,0xBD,0x5B,0x73,0xB3,0x56,0xAB,0x41,0x2A,0xEF,0x9F,0x76,0xCE,0xA2,0xD6,0x5C]],
|
|
58
|
-
[[0x40,0x41,0x42,0x43,0x45,0x46,0x47,0x48,0x4A,0x4B,0x4C,0x4D,0x4F,0x50,0x51,0x52,0x54,0x55,0x56,0x57,0x59,0x5A,0x5B,0x5C,0x5E,0x5F,0x60,0x61,0x63,0x64,0x65,0x66],[0x47,0x5B,0x8B,0x82,0x3C,0xE8,0x89,0x3D,0xB3,0xC4,0x4A,0x9F,0x2A,0x37,0x9F,0xF7],[0x25,0x36,0x96,0x90,0x93,0xC5,0x5F,0xF9,0x45,0x46,0x92,0xF2,0xFA,0xC2,0xF5,0x30]],
|
|
59
|
-
[[0x68,0x69,0x6A,0x6B,0x6D,0x6E,0x6F,0x70,0x72,0x73,0x74,0x75,0x77,0x78,0x79,0x7A,0x7C,0x7D,0x7E,0x7F,0x81,0x82,0x83,0x84,0x86,0x87,0x88,0x89,0x8B,0x8C,0x8D,0x8E],[0x68,0x8F,0x52,0x81,0x94,0x58,0x12,0x86,0x2F,0x5F,0x30,0x76,0xCF,0x80,0x41,0x2F],[0x07,0xFC,0x76,0xA8,0x72,0x84,0x3F,0x3F,0x6E,0x00,0x81,0xEE,0x93,0x96,0xD6,0x37]],
|
|
60
|
-
[[0x90,0x91,0x92,0x93,0x95,0x96,0x97,0x98,0x9A,0x9B,0x9C,0x9D,0x9F,0xA0,0xA1,0xA2,0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E],[0x06,0x9A,0x00,0x7F,0xC7,0x6A,0x45,0x9F,0x98,0xBA,0xF9,0x17,0xFE,0xDF,0x95,0x21],[0x08,0x0E,0x95,0x17,0xEB,0x16,0x77,0x71,0x9A,0xCF,0x72,0x80,0x86,0x04,0x0A,0xE3]],
|
|
64
|
-
[[0x30,0x31,0x32,0x33,0x35,0x36,0x37,0x38,0x3A,0x3B,0x3C,0x3D,0x3F,0x40,0x41,0x42,0x44,0x45,0x46,0x47,0x49,0x4A,0x4B,0x4C,0x4E,0x4F,0x50,0x51,0x53,0x54,0x55,0x56],[0x72,0x61,0x65,0xC1,0x72,0x3F,0xBC,0xF6,0xC0,0x26,0xD7,0xD0,0x0B,0x09,0x10,0x27],[0x7C,0x17,0x00,0x21,0x1A,0x39,0x91,0xFC,0x0E,0xCD,0xED,0x0A,0xB3,0xE5,0x76,0xB0]]];
|
|
65
|
-
|
|
66
|
-
it('128 bit key', function (done) {
|
|
67
|
-
for (let i = 0; i < testvectors128.length; i++) {
|
|
68
|
-
test_aes(testvectors128[i][1],testvectors128[i][0],testvectors128[i][2]);
|
|
69
|
-
}
|
|
70
|
-
done();
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it('192 bit key', function (done) {
|
|
74
|
-
for (let i = 0; i < testvectors192.length; i++) {
|
|
75
|
-
test_aes(testvectors192[i][1],testvectors192[i][0],testvectors192[i][2]);
|
|
76
|
-
}
|
|
77
|
-
done();
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it('256 bit key', function (done) {
|
|
81
|
-
for (let i = 0; i < testvectors256.length; i++) {
|
|
82
|
-
test_aes(testvectors256[i][1],testvectors256[i][0],testvectors256[i][2]);
|
|
83
|
-
}
|
|
84
|
-
done();
|
|
85
|
-
});
|
|
86
|
-
});
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../../../dist/openpgp');
|
|
2
|
-
|
|
3
|
-
const chai = require('chai');
|
|
4
|
-
|
|
5
|
-
const { util } = openpgp;
|
|
6
|
-
const { expect } = chai;
|
|
7
|
-
|
|
8
|
-
it('Blowfish cipher test with test vectors from https://www.schneier.com/code/vectors.txt', function(done) {
|
|
9
|
-
function test_bf(input, key, output) {
|
|
10
|
-
const blowfish = new openpgp.crypto.cipher.blowfish(util.Uint8Array_to_str(key));
|
|
11
|
-
const result = util.Uint8Array_to_str(blowfish.encrypt(input));
|
|
12
|
-
|
|
13
|
-
return (util.str_to_hex(result) === util.str_to_hex(util.Uint8Array_to_str(output)));
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const testvectors = [[[0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00],[0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00],[0x4E,0xF9,0x97,0x45,0x61,0x98,0xDD,0x78]],
|
|
17
|
-
[[0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF],[0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF],[0x51,0x86,0x6F,0xD5,0xB8,0x5E,0xCB,0x8A]],
|
|
18
|
-
[[0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00],[0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x01],[0x7D,0x85,0x6F,0x9A,0x61,0x30,0x63,0xF2]],
|
|
19
|
-
[[0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11],[0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11],[0x24,0x66,0xDD,0x87,0x8B,0x96,0x3C,0x9D]],
|
|
20
|
-
[[0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF],[0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11],[0x61,0xF9,0xC3,0x80,0x22,0x81,0xB0,0x96]],
|
|
21
|
-
[[0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11],[0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF],[0x7D,0x0C,0xC6,0x30,0xAF,0xDA,0x1E,0xC7]],
|
|
22
|
-
[[0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00],[0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00],[0x4E,0xF9,0x97,0x45,0x61,0x98,0xDD,0x78]],
|
|
23
|
-
[[0xFE,0xDC,0xBA,0x98,0x76,0x54,0x32,0x10],[0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF],[0x0A,0xCE,0xAB,0x0F,0xC6,0xA0,0xA2,0x8D]],
|
|
24
|
-
[[0x7C,0xA1,0x10,0x45,0x4A,0x1A,0x6E,0x57],[0x01,0xA1,0xD6,0xD0,0x39,0x77,0x67,0x42],[0x59,0xC6,0x82,0x45,0xEB,0x05,0x28,0x2B]],
|
|
25
|
-
[[0x01,0x31,0xD9,0x61,0x9D,0xC1,0x37,0x6E],[0x5C,0xD5,0x4C,0xA8,0x3D,0xEF,0x57,0xDA],[0xB1,0xB8,0xCC,0x0B,0x25,0x0F,0x09,0xA0]],
|
|
26
|
-
[[0x07,0xA1,0x13,0x3E,0x4A,0x0B,0x26,0x86],[0x02,0x48,0xD4,0x38,0x06,0xF6,0x71,0x72],[0x17,0x30,0xE5,0x77,0x8B,0xEA,0x1D,0xA4]],
|
|
27
|
-
[[0x38,0x49,0x67,0x4C,0x26,0x02,0x31,0x9E],[0x51,0x45,0x4B,0x58,0x2D,0xDF,0x44,0x0A],[0xA2,0x5E,0x78,0x56,0xCF,0x26,0x51,0xEB]],
|
|
28
|
-
[[0x04,0xB9,0x15,0xBA,0x43,0xFE,0xB5,0xB6],[0x42,0xFD,0x44,0x30,0x59,0x57,0x7F,0xA2],[0x35,0x38,0x82,0xB1,0x09,0xCE,0x8F,0x1A]],
|
|
29
|
-
[[0x01,0x13,0xB9,0x70,0xFD,0x34,0xF2,0xCE],[0x05,0x9B,0x5E,0x08,0x51,0xCF,0x14,0x3A],[0x48,0xF4,0xD0,0x88,0x4C,0x37,0x99,0x18]],
|
|
30
|
-
[[0x01,0x70,0xF1,0x75,0x46,0x8F,0xB5,0xE6],[0x07,0x56,0xD8,0xE0,0x77,0x47,0x61,0xD2],[0x43,0x21,0x93,0xB7,0x89,0x51,0xFC,0x98]],
|
|
31
|
-
[[0x43,0x29,0x7F,0xAD,0x38,0xE3,0x73,0xFE],[0x76,0x25,0x14,0xB8,0x29,0xBF,0x48,0x6A],[0x13,0xF0,0x41,0x54,0xD6,0x9D,0x1A,0xE5]],
|
|
32
|
-
[[0x07,0xA7,0x13,0x70,0x45,0xDA,0x2A,0x16],[0x3B,0xDD,0x11,0x90,0x49,0x37,0x28,0x02],[0x2E,0xED,0xDA,0x93,0xFF,0xD3,0x9C,0x79]],
|
|
33
|
-
[[0x04,0x68,0x91,0x04,0xC2,0xFD,0x3B,0x2F],[0x26,0x95,0x5F,0x68,0x35,0xAF,0x60,0x9A],[0xD8,0x87,0xE0,0x39,0x3C,0x2D,0xA6,0xE3]],
|
|
34
|
-
[[0x37,0xD0,0x6B,0xB5,0x16,0xCB,0x75,0x46],[0x16,0x4D,0x5E,0x40,0x4F,0x27,0x52,0x32],[0x5F,0x99,0xD0,0x4F,0x5B,0x16,0x39,0x69]],
|
|
35
|
-
[[0x1F,0x08,0x26,0x0D,0x1A,0xC2,0x46,0x5E],[0x6B,0x05,0x6E,0x18,0x75,0x9F,0x5C,0xCA],[0x4A,0x05,0x7A,0x3B,0x24,0xD3,0x97,0x7B]],
|
|
36
|
-
[[0x58,0x40,0x23,0x64,0x1A,0xBA,0x61,0x76],[0x00,0x4B,0xD6,0xEF,0x09,0x17,0x60,0x62],[0x45,0x20,0x31,0xC1,0xE4,0xFA,0xDA,0x8E]],
|
|
37
|
-
[[0x02,0x58,0x16,0x16,0x46,0x29,0xB0,0x07],[0x48,0x0D,0x39,0x00,0x6E,0xE7,0x62,0xF2],[0x75,0x55,0xAE,0x39,0xF5,0x9B,0x87,0xBD]],
|
|
38
|
-
[[0x49,0x79,0x3E,0xBC,0x79,0xB3,0x25,0x8F],[0x43,0x75,0x40,0xC8,0x69,0x8F,0x3C,0xFA],[0x53,0xC5,0x5F,0x9C,0xB4,0x9F,0xC0,0x19]],
|
|
39
|
-
[[0x4F,0xB0,0x5E,0x15,0x15,0xAB,0x73,0xA7],[0x07,0x2D,0x43,0xA0,0x77,0x07,0x52,0x92],[0x7A,0x8E,0x7B,0xFA,0x93,0x7E,0x89,0xA3]],
|
|
40
|
-
[[0x49,0xE9,0x5D,0x6D,0x4C,0xA2,0x29,0xBF],[0x02,0xFE,0x55,0x77,0x81,0x17,0xF1,0x2A],[0xCF,0x9C,0x5D,0x7A,0x49,0x86,0xAD,0xB5]],
|
|
41
|
-
[[0x01,0x83,0x10,0xDC,0x40,0x9B,0x26,0xD6],[0x1D,0x9D,0x5C,0x50,0x18,0xF7,0x28,0xC2],[0xD1,0xAB,0xB2,0x90,0x65,0x8B,0xC7,0x78]],
|
|
42
|
-
[[0x1C,0x58,0x7F,0x1C,0x13,0x92,0x4F,0xEF],[0x30,0x55,0x32,0x28,0x6D,0x6F,0x29,0x5A],[0x55,0xCB,0x37,0x74,0xD1,0x3E,0xF2,0x01]],
|
|
43
|
-
[[0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01],[0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF],[0xFA,0x34,0xEC,0x48,0x47,0xB2,0x68,0xB2]],
|
|
44
|
-
[[0x1F,0x1F,0x1F,0x1F,0x0E,0x0E,0x0E,0x0E],[0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF],[0xA7,0x90,0x79,0x51,0x08,0xEA,0x3C,0xAE]],
|
|
45
|
-
[[0xE0,0xFE,0xE0,0xFE,0xF1,0xFE,0xF1,0xFE],[0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF],[0xC3,0x9E,0x07,0x2D,0x9F,0xAC,0x63,0x1D]],
|
|
46
|
-
[[0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00],[0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF],[0x01,0x49,0x33,0xE0,0xCD,0xAF,0xF6,0xE4]],
|
|
47
|
-
[[0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF],[0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00],[0xF2,0x1E,0x9A,0x77,0xB7,0x1C,0x49,0xBC]],
|
|
48
|
-
[[0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF],[0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00],[0x24,0x59,0x46,0x88,0x57,0x54,0x36,0x9A]],
|
|
49
|
-
[[0xFE,0xDC,0xBA,0x98,0x76,0x54,0x32,0x10],[0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF],[0x6B,0x5C,0x5A,0x9C,0x5D,0x9E,0x0A,0x5A]]];
|
|
50
|
-
|
|
51
|
-
for (let i = 0; i < testvectors.length; i++) {
|
|
52
|
-
const res = test_bf(testvectors[i][1],testvectors[i][0],testvectors[i][2]);
|
|
53
|
-
expect(res, 'vector ' + i + '" with block ' + util.Uint8Array_to_hex(testvectors[i][0]) +
|
|
54
|
-
' and key ' + util.Uint8Array_to_hex(testvectors[i][1]) +
|
|
55
|
-
' should be ' + util.Uint8Array_to_hex(testvectors[i][2]), false);
|
|
56
|
-
}
|
|
57
|
-
done();
|
|
58
|
-
});
|