@protontech/openpgp 4.10.6 → 5.4.0

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.
Files changed (173) hide show
  1. package/README.md +311 -239
  2. package/dist/lightweight/bn.interface.min.mjs +3 -0
  3. package/dist/lightweight/bn.interface.min.mjs.map +1 -0
  4. package/dist/lightweight/bn.interface.mjs +340 -0
  5. package/dist/lightweight/bn.min.mjs +3 -0
  6. package/dist/lightweight/bn.min.mjs.map +1 -0
  7. package/dist/lightweight/bn.mjs +3434 -0
  8. package/dist/lightweight/elliptic.min.mjs +3 -0
  9. package/dist/lightweight/elliptic.min.mjs.map +1 -0
  10. package/dist/lightweight/elliptic.mjs +4313 -0
  11. package/dist/lightweight/openpgp.min.mjs +3 -0
  12. package/dist/lightweight/openpgp.min.mjs.map +1 -0
  13. package/dist/lightweight/openpgp.mjs +31379 -0
  14. package/dist/lightweight/ponyfill.es6.min.mjs +3 -0
  15. package/dist/lightweight/ponyfill.es6.min.mjs.map +1 -0
  16. package/dist/lightweight/ponyfill.es6.mjs +3831 -0
  17. package/dist/lightweight/web-streams-adapter.min.mjs +17 -0
  18. package/dist/lightweight/web-streams-adapter.min.mjs.map +1 -0
  19. package/dist/lightweight/web-streams-adapter.mjs +561 -0
  20. package/dist/node/openpgp.js +43947 -0
  21. package/dist/node/openpgp.min.js +17 -0
  22. package/dist/node/openpgp.min.js.map +1 -0
  23. package/dist/node/openpgp.min.mjs +17 -0
  24. package/dist/node/openpgp.min.mjs.map +1 -0
  25. package/dist/node/openpgp.mjs +43884 -0
  26. package/dist/openpgp.js +41082 -41563
  27. package/dist/openpgp.min.js +17 -2
  28. package/dist/openpgp.min.js.map +1 -0
  29. package/dist/openpgp.min.mjs +17 -0
  30. package/dist/openpgp.min.mjs.map +1 -0
  31. package/dist/openpgp.mjs +43872 -0
  32. package/lightweight/package.json +5 -0
  33. package/openpgp.d.ts +890 -0
  34. package/package.json +63 -57
  35. package/dist/compat/openpgp.js +0 -61067
  36. package/dist/compat/openpgp.min.js +0 -2
  37. package/dist/compat/openpgp.worker.js +0 -173
  38. package/dist/compat/openpgp.worker.min.js +0 -2
  39. package/dist/lightweight/elliptic.min.js +0 -5
  40. package/dist/lightweight/openpgp.js +0 -40024
  41. package/dist/lightweight/openpgp.min.js +0 -2
  42. package/dist/lightweight/openpgp.worker.js +0 -173
  43. package/dist/lightweight/openpgp.worker.min.js +0 -2
  44. package/dist/openpgp.worker.js +0 -173
  45. package/dist/openpgp.worker.min.js +0 -2
  46. package/src/cleartext.js +0 -220
  47. package/src/config/config.js +0 -224
  48. package/src/config/index.js +0 -7
  49. package/src/config/localStorage.js +0 -35
  50. package/src/crypto/aes_kw.js +0 -153
  51. package/src/crypto/cfb.js +0 -169
  52. package/src/crypto/cipher/aes.js +0 -27
  53. package/src/crypto/cipher/blowfish.js +0 -398
  54. package/src/crypto/cipher/cast5.js +0 -610
  55. package/src/crypto/cipher/des.js +0 -476
  56. package/src/crypto/cipher/index.js +0 -91
  57. package/src/crypto/cipher/twofish.js +0 -346
  58. package/src/crypto/cmac.js +0 -98
  59. package/src/crypto/crypto.js +0 -394
  60. package/src/crypto/eax.js +0 -172
  61. package/src/crypto/gcm.js +0 -141
  62. package/src/crypto/hash/index.js +0 -163
  63. package/src/crypto/hash/md5.js +0 -205
  64. package/src/crypto/index.js +0 -57
  65. package/src/crypto/ocb.js +0 -274
  66. package/src/crypto/pkcs1.js +0 -170
  67. package/src/crypto/pkcs5.js +0 -55
  68. package/src/crypto/public_key/dsa.js +0 -188
  69. package/src/crypto/public_key/elgamal.js +0 -137
  70. package/src/crypto/public_key/elliptic/curves.js +0 -385
  71. package/src/crypto/public_key/elliptic/ecdh.js +0 -414
  72. package/src/crypto/public_key/elliptic/ecdsa.js +0 -348
  73. package/src/crypto/public_key/elliptic/eddsa.js +0 -119
  74. package/src/crypto/public_key/elliptic/index.js +0 -34
  75. package/src/crypto/public_key/elliptic/indutnyKey.js +0 -85
  76. package/src/crypto/public_key/index.js +0 -28
  77. package/src/crypto/public_key/prime.js +0 -275
  78. package/src/crypto/public_key/rsa.js +0 -597
  79. package/src/crypto/random.js +0 -145
  80. package/src/crypto/signature.js +0 -137
  81. package/src/encoding/armor.js +0 -433
  82. package/src/encoding/base64.js +0 -96
  83. package/src/enums.js +0 -493
  84. package/src/hkp.js +0 -89
  85. package/src/index.js +0 -161
  86. package/src/key/factory.js +0 -326
  87. package/src/key/helper.js +0 -363
  88. package/src/key/index.js +0 -32
  89. package/src/key/key.js +0 -890
  90. package/src/key/subkey.js +0 -187
  91. package/src/key/user.js +0 -230
  92. package/src/keyring/index.js +0 -12
  93. package/src/keyring/keyring.js +0 -229
  94. package/src/keyring/localstore.js +0 -119
  95. package/src/lightweight_helper.js +0 -26
  96. package/src/message.js +0 -825
  97. package/src/openpgp.js +0 -717
  98. package/src/packet/all_packets.js +0 -116
  99. package/src/packet/clone.js +0 -189
  100. package/src/packet/compressed.js +0 -194
  101. package/src/packet/index.js +0 -20
  102. package/src/packet/literal.js +0 -168
  103. package/src/packet/marker.js +0 -62
  104. package/src/packet/one_pass_signature.js +0 -156
  105. package/src/packet/packet.js +0 -300
  106. package/src/packet/packetlist.js +0 -232
  107. package/src/packet/public_key.js +0 -280
  108. package/src/packet/public_key_encrypted_session_key.js +0 -156
  109. package/src/packet/public_subkey.js +0 -44
  110. package/src/packet/secret_key.js +0 -448
  111. package/src/packet/secret_subkey.js +0 -41
  112. package/src/packet/signature.js +0 -782
  113. package/src/packet/sym_encrypted_aead_protected.js +0 -189
  114. package/src/packet/sym_encrypted_integrity_protected.js +0 -139
  115. package/src/packet/sym_encrypted_session_key.js +0 -204
  116. package/src/packet/symmetrically_encrypted.js +0 -118
  117. package/src/packet/trust.js +0 -35
  118. package/src/packet/user_attribute.js +0 -94
  119. package/src/packet/userid.js +0 -87
  120. package/src/polyfills.js +0 -64
  121. package/src/signature.js +0 -73
  122. package/src/type/ecdh_symkey.js +0 -69
  123. package/src/type/kdf_params.js +0 -114
  124. package/src/type/keyid.js +0 -110
  125. package/src/type/mpi.js +0 -138
  126. package/src/type/oid.js +0 -110
  127. package/src/type/s2k.js +0 -203
  128. package/src/util.js +0 -836
  129. package/src/wkd.js +0 -88
  130. package/src/worker/async_proxy.js +0 -190
  131. package/src/worker/worker.js +0 -167
  132. package/test/crypto/aes_kw.js +0 -57
  133. package/test/crypto/cipher/aes.js +0 -86
  134. package/test/crypto/cipher/blowfish.js +0 -58
  135. package/test/crypto/cipher/cast5.js +0 -25
  136. package/test/crypto/cipher/des.js +0 -143
  137. package/test/crypto/cipher/index.js +0 -7
  138. package/test/crypto/cipher/twofish.js +0 -71
  139. package/test/crypto/crypto.js +0 -383
  140. package/test/crypto/eax.js +0 -150
  141. package/test/crypto/ecdh.js +0 -359
  142. package/test/crypto/elliptic.js +0 -251
  143. package/test/crypto/elliptic_data.js +0 -102
  144. package/test/crypto/hash/index.js +0 -5
  145. package/test/crypto/hash/md5.js +0 -16
  146. package/test/crypto/hash/ripemd.js +0 -14
  147. package/test/crypto/hash/sha.js +0 -20
  148. package/test/crypto/index.js +0 -14
  149. package/test/crypto/ocb.js +0 -183
  150. package/test/crypto/pkcs5.js +0 -39
  151. package/test/crypto/random.js +0 -79
  152. package/test/crypto/rsa.js +0 -180
  153. package/test/crypto/validate.js +0 -387
  154. package/test/general/armor.js +0 -408
  155. package/test/general/brainpool.js +0 -360
  156. package/test/general/decompression.js +0 -60
  157. package/test/general/ecc_nist.js +0 -115
  158. package/test/general/ecc_secp256k1.js +0 -242
  159. package/test/general/forwarding.js +0 -43
  160. package/test/general/hkp.js +0 -165
  161. package/test/general/index.js +0 -20
  162. package/test/general/key.js +0 -3402
  163. package/test/general/keyring.js +0 -336
  164. package/test/general/oid.js +0 -39
  165. package/test/general/openpgp.js +0 -2542
  166. package/test/general/packet.js +0 -937
  167. package/test/general/signature.js +0 -1665
  168. package/test/general/streaming.js +0 -944
  169. package/test/general/testInputs.js +0 -18
  170. package/test/general/util.js +0 -183
  171. package/test/general/wkd.js +0 -48
  172. package/test/general/x25519.js +0 -556
  173. package/test/unittests.js +0 -64
@@ -1,173 +0,0 @@
1
- /*! OpenPGP.js v4.10.6 - 2020-07-14 - this is LGPL licensed code, see LICENSE/our website https://openpgpjs.org/ for more information. */
2
- (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
3
- (function (global){
4
- // GPG4Browsers - An OpenPGP implementation in javascript
5
- // Copyright (C) 2011 Recurity Labs GmbH
6
- //
7
- // This library is free software; you can redistribute it and/or
8
- // modify it under the terms of the GNU Lesser General Public
9
- // License as published by the Free Software Foundation; either
10
- // version 3.0 of the License, or (at your option) any later version.
11
- //
12
- // This library is distributed in the hope that it will be useful,
13
- // but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
- // Lesser General Public License for more details.
16
- //
17
- // You should have received a copy of the GNU Lesser General Public
18
- // License along with this library; if not, write to the Free Software
19
- // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
-
21
- /* eslint-disable no-restricted-globals */
22
- /* eslint-disable no-var */
23
- /* eslint-disable vars-on-top */
24
-
25
- /**
26
- * @fileoverview Provides functions for communicating with workers
27
- * @see module:openpgp.initWorker
28
- * @see module:openpgp.getWorker
29
- * @see module:openpgp.destroyWorker
30
- * @see module:worker/async_proxy
31
- * @module worker/worker
32
- */
33
-
34
- importScripts('openpgp.js');
35
- var openpgp = global.openpgp;
36
-
37
- var randomQueue = [];
38
- var MAX_SIZE_RANDOM_BUFFER = 60000;
39
-
40
- /**
41
- * Handle random buffer exhaustion by requesting more random bytes from the main window
42
- * @returns {Promise<Object>} Empty promise whose resolution indicates that the buffer has been refilled
43
- */
44
- function randomCallback() {
45
-
46
- if (!randomQueue.length) {
47
- self.postMessage({ event: 'request-seed', amount: MAX_SIZE_RANDOM_BUFFER });
48
- }
49
-
50
- return new Promise(function(resolve) {
51
- randomQueue.push(resolve);
52
- });
53
- }
54
-
55
- openpgp.crypto.random.randomBuffer.init(MAX_SIZE_RANDOM_BUFFER, randomCallback);
56
-
57
- /**
58
- * Handle messages from the main window.
59
- * @param {Object} event Contains event type and data
60
- */
61
- self.onmessage = function(event) {
62
- var msg = event.data || {};
63
-
64
- switch (msg.event) {
65
- case 'configure':
66
- configure(msg.config);
67
- break;
68
-
69
- case 'seed-random':
70
- seedRandom(msg.buf);
71
-
72
- var queueCopy = randomQueue;
73
- randomQueue = [];
74
- for (var i = 0; i < queueCopy.length; i++) {
75
- queueCopy[i]();
76
- }
77
-
78
- break;
79
-
80
- default:
81
- delegate(msg.id, msg.event, msg.options || {});
82
- }
83
- };
84
-
85
- /**
86
- * Set config from main context to worker context.
87
- * @param {Object} config The openpgp configuration
88
- */
89
- function configure(config) {
90
- Object.keys(config).forEach(function(key) {
91
- openpgp.config[key] = config[key];
92
- });
93
- }
94
-
95
- /**
96
- * Seed the library with entropy gathered global.crypto.getRandomValues
97
- * as this api is only avalible in the main window.
98
- * @param {ArrayBuffer} buffer Some random bytes
99
- */
100
- function seedRandom(buffer) {
101
- if (!(buffer instanceof Uint8Array)) {
102
- buffer = new Uint8Array(buffer);
103
- }
104
- openpgp.crypto.random.randomBuffer.set(buffer);
105
- }
106
-
107
- const keyCache = new Map();
108
- function getCachedKey(key) {
109
- const armor = key.armor();
110
- if (keyCache.has(armor)) {
111
- return keyCache.get(armor);
112
- }
113
- keyCache.set(armor, key);
114
- return key;
115
- }
116
-
117
- /**
118
- * Generic proxy function that handles all commands from the public api.
119
- * @param {String} method The public api function to be delegated to the worker thread
120
- * @param {Object} options The api function's options
121
- */
122
- function delegate(id, method, options) {
123
- if (method === 'clear-key-cache') {
124
- Array.from(keyCache.values()).forEach(key => {
125
- if (key.isPrivate()) {
126
- key.clearPrivateParams();
127
- }
128
- });
129
- keyCache.clear();
130
- response({ id, event: 'method-return' });
131
- return;
132
- }
133
- if (typeof openpgp[method] !== 'function') {
134
- response({ id:id, event:'method-return', err:'Unknown Worker Event' });
135
- return;
136
- }
137
- // construct ReadableStreams from MessagePorts
138
- openpgp.util.restoreStreams(options);
139
- // parse cloned packets
140
- options = openpgp.packet.clone.parseClonedPackets(options, method);
141
- // cache keys by armor, so that we don't have to repeatedly verify self-signatures
142
- if (options.publicKeys) {
143
- options.publicKeys = options.publicKeys.map(getCachedKey);
144
- }
145
- if (options.privateKeys) {
146
- options.privateKeys = options.privateKeys.map(getCachedKey);
147
- }
148
- openpgp[method](options).then(function(data) {
149
- // clone packets (for web worker structured cloning algorithm)
150
- response({ id:id, event:'method-return', data:openpgp.packet.clone.clonePackets(data) });
151
- }).catch(function(e) {
152
- openpgp.util.print_debug_error(e);
153
- response({
154
- id:id, event:'method-return', err:e.message, stack:e.stack
155
- });
156
- });
157
- }
158
-
159
- /**
160
- * Respond to the main window.
161
- * @param {Object} event Contains event type and data
162
- */
163
- function response(event) {
164
- self.postMessage(event, openpgp.util.getTransferables(event.data, openpgp.config.zero_copy));
165
- }
166
-
167
- /**
168
- * Let the main window know the worker has loaded.
169
- */
170
- postMessage({ event: 'loaded' });
171
-
172
- }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
173
- },{}]},{},[1]);
@@ -1,2 +0,0 @@
1
- /*! OpenPGP.js v4.10.6 - 2020-07-14 - this is LGPL licensed code, see LICENSE/our website https://openpgpjs.org/ for more information. */
2
- !function(){return function e(n,r,t){function o(i,s){if(!r[i]){if(!n[i]){var c="function"==typeof require&&require;if(!s&&c)return c(i,!0);if(a)return a(i,!0);var f=new Error("Cannot find module '"+i+"'");throw f.code="MODULE_NOT_FOUND",f}var u=r[i]={exports:{}};n[i][0].call(u.exports,function(e){return o(n[i][1][e]||e)},u,u.exports,e,n,r,t)}return r[i].exports}for(var a="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}}()({1:[function(e,n,r){(function(e){importScripts("openpgp.min.js");var n=e.openpgp,r=[],t=6e4;n.crypto.random.randomBuffer.init(t,function(){return r.length||self.postMessage({event:"request-seed",amount:t}),new Promise(function(e){r.push(e)})}),self.onmessage=function(e){var t,s=e.data||{};switch(s.event){case"configure":t=s.config,Object.keys(t).forEach(function(e){n.config[e]=t[e]});break;case"seed-random":!function(e){e instanceof Uint8Array||(e=new Uint8Array(e));n.crypto.random.randomBuffer.set(e)}(s.buf);var c=r;r=[];for(var f=0;f<c.length;f++)c[f]();break;default:!function(e,r,t){if("clear-key-cache"===r)return Array.from(o.values()).forEach(e=>{e.isPrivate()&&e.clearPrivateParams()}),o.clear(),void i({id:e,event:"method-return"});if("function"!=typeof n[r])return void i({id:e,event:"method-return",err:"Unknown Worker Event"});n.util.restoreStreams(t),(t=n.packet.clone.parseClonedPackets(t,r)).publicKeys&&(t.publicKeys=t.publicKeys.map(a));t.privateKeys&&(t.privateKeys=t.privateKeys.map(a));n[r](t).then(function(r){i({id:e,event:"method-return",data:n.packet.clone.clonePackets(r)})}).catch(function(r){n.util.print_debug_error(r),i({id:e,event:"method-return",err:r.message,stack:r.stack})})}(s.id,s.event,s.options||{})}};const o=new Map;function a(e){const n=e.armor();return o.has(n)?o.get(n):(o.set(n,e),e)}function i(e){self.postMessage(e,n.util.getTransferables(e.data,n.config.zero_copy))}postMessage({event:"loaded"})}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1]);
@@ -1,173 +0,0 @@
1
- /*! OpenPGP.js v4.10.6 - 2020-07-14 - this is LGPL licensed code, see LICENSE/our website https://openpgpjs.org/ for more information. */
2
- (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
3
- (function (global){
4
- // GPG4Browsers - An OpenPGP implementation in javascript
5
- // Copyright (C) 2011 Recurity Labs GmbH
6
- //
7
- // This library is free software; you can redistribute it and/or
8
- // modify it under the terms of the GNU Lesser General Public
9
- // License as published by the Free Software Foundation; either
10
- // version 3.0 of the License, or (at your option) any later version.
11
- //
12
- // This library is distributed in the hope that it will be useful,
13
- // but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
- // Lesser General Public License for more details.
16
- //
17
- // You should have received a copy of the GNU Lesser General Public
18
- // License along with this library; if not, write to the Free Software
19
- // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
-
21
- /* eslint-disable no-restricted-globals */
22
- /* eslint-disable no-var */
23
- /* eslint-disable vars-on-top */
24
-
25
- /**
26
- * @fileoverview Provides functions for communicating with workers
27
- * @see module:openpgp.initWorker
28
- * @see module:openpgp.getWorker
29
- * @see module:openpgp.destroyWorker
30
- * @see module:worker/async_proxy
31
- * @module worker/worker
32
- */
33
-
34
- importScripts('openpgp.js');
35
- var openpgp = global.openpgp;
36
-
37
- var randomQueue = [];
38
- var MAX_SIZE_RANDOM_BUFFER = 60000;
39
-
40
- /**
41
- * Handle random buffer exhaustion by requesting more random bytes from the main window
42
- * @returns {Promise<Object>} Empty promise whose resolution indicates that the buffer has been refilled
43
- */
44
- function randomCallback() {
45
-
46
- if (!randomQueue.length) {
47
- self.postMessage({ event: 'request-seed', amount: MAX_SIZE_RANDOM_BUFFER });
48
- }
49
-
50
- return new Promise(function(resolve) {
51
- randomQueue.push(resolve);
52
- });
53
- }
54
-
55
- openpgp.crypto.random.randomBuffer.init(MAX_SIZE_RANDOM_BUFFER, randomCallback);
56
-
57
- /**
58
- * Handle messages from the main window.
59
- * @param {Object} event Contains event type and data
60
- */
61
- self.onmessage = function(event) {
62
- var msg = event.data || {};
63
-
64
- switch (msg.event) {
65
- case 'configure':
66
- configure(msg.config);
67
- break;
68
-
69
- case 'seed-random':
70
- seedRandom(msg.buf);
71
-
72
- var queueCopy = randomQueue;
73
- randomQueue = [];
74
- for (var i = 0; i < queueCopy.length; i++) {
75
- queueCopy[i]();
76
- }
77
-
78
- break;
79
-
80
- default:
81
- delegate(msg.id, msg.event, msg.options || {});
82
- }
83
- };
84
-
85
- /**
86
- * Set config from main context to worker context.
87
- * @param {Object} config The openpgp configuration
88
- */
89
- function configure(config) {
90
- Object.keys(config).forEach(function(key) {
91
- openpgp.config[key] = config[key];
92
- });
93
- }
94
-
95
- /**
96
- * Seed the library with entropy gathered global.crypto.getRandomValues
97
- * as this api is only avalible in the main window.
98
- * @param {ArrayBuffer} buffer Some random bytes
99
- */
100
- function seedRandom(buffer) {
101
- if (!(buffer instanceof Uint8Array)) {
102
- buffer = new Uint8Array(buffer);
103
- }
104
- openpgp.crypto.random.randomBuffer.set(buffer);
105
- }
106
-
107
- const keyCache = new Map();
108
- function getCachedKey(key) {
109
- const armor = key.armor();
110
- if (keyCache.has(armor)) {
111
- return keyCache.get(armor);
112
- }
113
- keyCache.set(armor, key);
114
- return key;
115
- }
116
-
117
- /**
118
- * Generic proxy function that handles all commands from the public api.
119
- * @param {String} method The public api function to be delegated to the worker thread
120
- * @param {Object} options The api function's options
121
- */
122
- function delegate(id, method, options) {
123
- if (method === 'clear-key-cache') {
124
- Array.from(keyCache.values()).forEach(key => {
125
- if (key.isPrivate()) {
126
- key.clearPrivateParams();
127
- }
128
- });
129
- keyCache.clear();
130
- response({ id, event: 'method-return' });
131
- return;
132
- }
133
- if (typeof openpgp[method] !== 'function') {
134
- response({ id:id, event:'method-return', err:'Unknown Worker Event' });
135
- return;
136
- }
137
- // construct ReadableStreams from MessagePorts
138
- openpgp.util.restoreStreams(options);
139
- // parse cloned packets
140
- options = openpgp.packet.clone.parseClonedPackets(options, method);
141
- // cache keys by armor, so that we don't have to repeatedly verify self-signatures
142
- if (options.publicKeys) {
143
- options.publicKeys = options.publicKeys.map(getCachedKey);
144
- }
145
- if (options.privateKeys) {
146
- options.privateKeys = options.privateKeys.map(getCachedKey);
147
- }
148
- openpgp[method](options).then(function(data) {
149
- // clone packets (for web worker structured cloning algorithm)
150
- response({ id:id, event:'method-return', data:openpgp.packet.clone.clonePackets(data) });
151
- }).catch(function(e) {
152
- openpgp.util.print_debug_error(e);
153
- response({
154
- id:id, event:'method-return', err:e.message, stack:e.stack
155
- });
156
- });
157
- }
158
-
159
- /**
160
- * Respond to the main window.
161
- * @param {Object} event Contains event type and data
162
- */
163
- function response(event) {
164
- self.postMessage(event, openpgp.util.getTransferables(event.data, openpgp.config.zero_copy));
165
- }
166
-
167
- /**
168
- * Let the main window know the worker has loaded.
169
- */
170
- postMessage({ event: 'loaded' });
171
-
172
- }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
173
- },{}]},{},[1]);
@@ -1,2 +0,0 @@
1
- /*! OpenPGP.js v4.10.6 - 2020-07-14 - this is LGPL licensed code, see LICENSE/our website https://openpgpjs.org/ for more information. */
2
- !function(){return function e(n,r,t){function o(i,s){if(!r[i]){if(!n[i]){var c="function"==typeof require&&require;if(!s&&c)return c(i,!0);if(a)return a(i,!0);var f=new Error("Cannot find module '"+i+"'");throw f.code="MODULE_NOT_FOUND",f}var u=r[i]={exports:{}};n[i][0].call(u.exports,function(e){return o(n[i][1][e]||e)},u,u.exports,e,n,r,t)}return r[i].exports}for(var a="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}}()({1:[function(e,n,r){(function(e){importScripts("openpgp.min.js");var n=e.openpgp,r=[],t=6e4;n.crypto.random.randomBuffer.init(t,function(){return r.length||self.postMessage({event:"request-seed",amount:t}),new Promise(function(e){r.push(e)})}),self.onmessage=function(e){var t,s=e.data||{};switch(s.event){case"configure":t=s.config,Object.keys(t).forEach(function(e){n.config[e]=t[e]});break;case"seed-random":!function(e){e instanceof Uint8Array||(e=new Uint8Array(e));n.crypto.random.randomBuffer.set(e)}(s.buf);var c=r;r=[];for(var f=0;f<c.length;f++)c[f]();break;default:!function(e,r,t){if("clear-key-cache"===r)return Array.from(o.values()).forEach(e=>{e.isPrivate()&&e.clearPrivateParams()}),o.clear(),void i({id:e,event:"method-return"});if("function"!=typeof n[r])return void i({id:e,event:"method-return",err:"Unknown Worker Event"});n.util.restoreStreams(t),(t=n.packet.clone.parseClonedPackets(t,r)).publicKeys&&(t.publicKeys=t.publicKeys.map(a));t.privateKeys&&(t.privateKeys=t.privateKeys.map(a));n[r](t).then(function(r){i({id:e,event:"method-return",data:n.packet.clone.clonePackets(r)})}).catch(function(r){n.util.print_debug_error(r),i({id:e,event:"method-return",err:r.message,stack:r.stack})})}(s.id,s.event,s.options||{})}};const o=new Map;function a(e){const n=e.armor();return o.has(n)?o.get(n):(o.set(n,e),e)}function i(e){self.postMessage(e,n.util.getTransferables(e.data,n.config.zero_copy))}postMessage({event:"loaded"})}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1]);
package/src/cleartext.js DELETED
@@ -1,220 +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
- * @requires encoding/armor
20
- * @requires enums
21
- * @requires util
22
- * @requires packet
23
- * @requires signature
24
- * @module cleartext
25
- */
26
-
27
- import armor from './encoding/armor';
28
- import enums from './enums';
29
- import util from './util';
30
- import packet from './packet';
31
- import { Signature } from './signature';
32
- import { createVerificationObjects, createSignaturePackets } from './message';
33
-
34
- /**
35
- * @class
36
- * @classdesc Class that represents an OpenPGP cleartext signed message.
37
- * See {@link https://tools.ietf.org/html/rfc4880#section-7}
38
- * @param {String} text The cleartext of the signed message
39
- * @param {module:signature.Signature} signature The detached signature or an empty signature for unsigned messages
40
- */
41
- export function CleartextMessage(text, signature) {
42
- if (!(this instanceof CleartextMessage)) {
43
- return new CleartextMessage(text, signature);
44
- }
45
- // normalize EOL to canonical form <CR><LF>
46
- this.text = util.removeTrailingSpaces(text).replace(/\r?\n/g, '\r\n');
47
- if (signature && !(signature instanceof Signature)) {
48
- throw new Error('Invalid signature input');
49
- }
50
- this.signature = signature || new Signature(new packet.List());
51
- }
52
-
53
- /**
54
- * Returns the key IDs of the keys that signed the cleartext message
55
- * @returns {Array<module:type/keyid>} array of keyid objects
56
- */
57
- CleartextMessage.prototype.getSigningKeyIds = function() {
58
- const keyIds = [];
59
- const signatureList = this.signature.packets;
60
- signatureList.forEach(function(packet) {
61
- keyIds.push(packet.issuerKeyId);
62
- });
63
- return keyIds;
64
- };
65
-
66
- /**
67
- * Sign the cleartext message
68
- * @param {Array<module:key.Key>} privateKeys private keys with decrypted secret key data for signing
69
- * @param {Signature} signature (optional) any existing detached signature
70
- * @param {Date} date (optional) The creation time of the signature that should be created
71
- * @param {Array} userIds (optional) user IDs to sign with, e.g. [{ name:'Steve Sender', email:'steve@openpgp.org' }]
72
- * @returns {Promise<module:cleartext.CleartextMessage>} new cleartext message with signed content
73
- * @async
74
- */
75
- CleartextMessage.prototype.sign = async function(privateKeys, signature = null, date = new Date(), userIds = []) {
76
- return new CleartextMessage(this.text, await this.signDetached(privateKeys, signature, date, userIds));
77
- };
78
-
79
- /**
80
- * Sign the cleartext message
81
- * @param {Array<module:key.Key>} privateKeys private keys with decrypted secret key data for signing
82
- * @param {Signature} signature (optional) any existing detached signature
83
- * @param {Date} date (optional) The creation time of the signature that should be created
84
- * @param {Array} userIds (optional) user IDs to sign with, e.g. [{ name:'Steve Sender', email:'steve@openpgp.org' }]
85
- * @returns {Promise<module:signature.Signature>} new detached signature of message content
86
- * @async
87
- */
88
- CleartextMessage.prototype.signDetached = async function(privateKeys, signature = null, date = new Date(), userIds = []) {
89
- const literalDataPacket = new packet.Literal();
90
- literalDataPacket.setText(this.text);
91
-
92
- return new Signature(await createSignaturePackets(literalDataPacket, privateKeys, signature, date, userIds, true));
93
- };
94
-
95
- /**
96
- * Verify signatures of cleartext signed message
97
- * @param {Array<module:key.Key>} keys array of keys to verify signatures
98
- * @param {Date} date (optional) Verify the signature against the given date, i.e. check signature creation time < date < expiration time
99
- * @returns {Promise<Array<{keyid: module:type/keyid, valid: Boolean}>>} list of signer's keyid and validity of signature
100
- * @async
101
- */
102
- CleartextMessage.prototype.verify = function(keys, date = new Date()) {
103
- return this.verifyDetached(this.signature, keys, date);
104
- };
105
-
106
- /**
107
- * Verify signatures of cleartext signed message
108
- * @param {Array<module:key.Key>} keys array of keys to verify signatures
109
- * @param {Date} date (optional) Verify the signature against the given date, i.e. check signature creation time < date < expiration time
110
- * @returns {Promise<Array<{keyid: module:type/keyid, valid: Boolean}>>} list of signer's keyid and validity of signature
111
- * @async
112
- */
113
- CleartextMessage.prototype.verifyDetached = function(signature, keys, date = new Date()) {
114
- const signatureList = signature.packets;
115
- const literalDataPacket = new packet.Literal();
116
- // we assume that cleartext signature is generated based on UTF8 cleartext
117
- literalDataPacket.setText(this.text);
118
- return createVerificationObjects(signatureList, [literalDataPacket], keys, date, true);
119
- };
120
-
121
- /**
122
- * Get cleartext
123
- * @returns {String} cleartext of message
124
- */
125
- CleartextMessage.prototype.getText = function() {
126
- // normalize end of line to \n
127
- return this.text.replace(/\r\n/g, '\n');
128
- };
129
-
130
- /**
131
- * Returns ASCII armored text of cleartext signed message
132
- * @returns {String | ReadableStream<String>} ASCII armor
133
- */
134
- CleartextMessage.prototype.armor = function() {
135
- let hashes = this.signature.packets.map(function(packet) {
136
- return enums.read(enums.hash, packet.hashAlgorithm).toUpperCase();
137
- });
138
- hashes = hashes.filter(function(item, i, ar) { return ar.indexOf(item) === i; });
139
- const body = {
140
- hash: hashes.join(),
141
- text: this.text,
142
- data: this.signature.packets.write()
143
- };
144
- return armor.encode(enums.armor.signed, body);
145
- };
146
-
147
-
148
- /**
149
- * reads an OpenPGP cleartext signed message and returns a CleartextMessage object
150
- * @param {String | ReadableStream<String>} armoredText text to be parsed
151
- * @returns {module:cleartext.CleartextMessage} new cleartext message object
152
- * @async
153
- * @static
154
- */
155
- export async function readArmored(armoredText) {
156
- const input = await armor.decode(armoredText);
157
- if (input.type !== enums.armor.signed) {
158
- throw new Error('No cleartext signed message.');
159
- }
160
- const packetlist = new packet.List();
161
- await packetlist.read(input.data);
162
- verifyHeaders(input.headers, packetlist);
163
- const signature = new Signature(packetlist);
164
- return new CleartextMessage(input.text, signature);
165
- }
166
-
167
- /**
168
- * Compare hash algorithm specified in the armor header with signatures
169
- * @param {Array<String>} headers Armor headers
170
- * @param {module:packet.List} packetlist The packetlist with signature packets
171
- * @private
172
- */
173
- function verifyHeaders(headers, packetlist) {
174
- const checkHashAlgos = function(hashAlgos) {
175
- const check = packet => algo => packet.hashAlgorithm === algo;
176
-
177
- for (let i = 0; i < packetlist.length; i++) {
178
- if (packetlist[i].tag === enums.packet.signature && !hashAlgos.some(check(packetlist[i]))) {
179
- return false;
180
- }
181
- }
182
- return true;
183
- };
184
-
185
- let oneHeader = null;
186
- let hashAlgos = [];
187
- headers.forEach(function(header) {
188
- oneHeader = header.match(/Hash: (.+)/); // get header value
189
- if (oneHeader) {
190
- oneHeader = oneHeader[1].replace(/\s/g, ''); // remove whitespace
191
- oneHeader = oneHeader.split(',');
192
- oneHeader = oneHeader.map(function(hash) {
193
- hash = hash.toLowerCase();
194
- try {
195
- return enums.write(enums.hash, hash);
196
- } catch (e) {
197
- throw new Error('Unknown hash algorithm in armor header: ' + hash);
198
- }
199
- });
200
- hashAlgos = hashAlgos.concat(oneHeader);
201
- } else {
202
- throw new Error('Only "Hash" header allowed in cleartext signed message');
203
- }
204
- });
205
-
206
- if (!hashAlgos.length && !checkHashAlgos([enums.hash.md5])) {
207
- throw new Error('If no "Hash" header in cleartext signed message, then only MD5 signatures allowed');
208
- } else if (hashAlgos.length && !checkHashAlgos(hashAlgos)) {
209
- throw new Error('Hash algorithm mismatch in armor header and signature');
210
- }
211
- }
212
-
213
- /**
214
- * Creates a new CleartextMessage object from text
215
- * @param {String} text
216
- * @static
217
- */
218
- export function fromText(text) {
219
- return new CleartextMessage(text);
220
- }