@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.
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 +31375 -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 +43943 -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 +43880 -0
  26. package/dist/openpgp.js +41077 -41609
  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 +43868 -0
  32. package/lightweight/package.json +5 -0
  33. package/openpgp.d.ts +889 -0
  34. package/package.json +63 -57
  35. package/dist/compat/openpgp.js +0 -61152
  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 -40071
  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 -232
  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 -378
  88. package/src/key/index.js +0 -32
  89. package/src/key/key.js +0 -888
  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 -161
  109. package/src/packet/public_subkey.js +0 -44
  110. package/src/packet/secret_key.js +0 -468
  111. package/src/packet/secret_subkey.js +0 -41
  112. package/src/packet/signature.js +0 -786
  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 -84
  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 -3491
  163. package/test/general/keyring.js +0 -336
  164. package/test/general/oid.js +0 -39
  165. package/test/general/openpgp.js +0 -2577
  166. package/test/general/packet.js +0 -950
  167. package/test/general/signature.js +0 -1715
  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,145 +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
- // The GPG4Browsers crypto interface
19
-
20
- /**
21
- * @fileoverview Provides tools for retrieving secure randomness from browsers or Node.js
22
- * @requires bn.js
23
- * @requires util
24
- * @module crypto/random
25
- */
26
-
27
- import BN from 'bn.js';
28
- import util from '../util';
29
-
30
- // Do not use util.getNodeCrypto because we need this regardless of use_native setting
31
- const nodeCrypto = util.detectNode() && require('crypto');
32
-
33
- export default {
34
- /**
35
- * Retrieve secure random byte array of the specified length
36
- * @param {Integer} length Length in bytes to generate
37
- * @returns {Uint8Array} Random byte array
38
- * @async
39
- */
40
- getRandomBytes: async function(length) {
41
- const buf = new Uint8Array(length);
42
- if (typeof crypto !== 'undefined' && crypto.getRandomValues) {
43
- crypto.getRandomValues(buf);
44
- } else if (typeof global !== 'undefined' && typeof global.msCrypto === 'object' && typeof global.msCrypto.getRandomValues === 'function') {
45
- global.msCrypto.getRandomValues(buf);
46
- } else if (nodeCrypto) {
47
- const bytes = nodeCrypto.randomBytes(buf.length);
48
- buf.set(bytes);
49
- } else if (this.randomBuffer.buffer) {
50
- await this.randomBuffer.get(buf);
51
- } else {
52
- throw new Error('No secure random number generator available.');
53
- }
54
- return buf;
55
- },
56
-
57
- /**
58
- * Create a secure random MPI that is greater than or equal to min and less than max.
59
- * @param {module:type/mpi} min Lower bound, included
60
- * @param {module:type/mpi} max Upper bound, excluded
61
- * @returns {module:BN} Random MPI
62
- * @async
63
- */
64
- getRandomBN: async function(min, max) {
65
- if (max.cmp(min) <= 0) {
66
- throw new Error('Illegal parameter value: max <= min');
67
- }
68
-
69
- const modulus = max.sub(min);
70
- const bytes = modulus.byteLength();
71
-
72
- // Using a while loop is necessary to avoid bias introduced by the mod operation.
73
- // However, we request 64 extra random bits so that the bias is negligible.
74
- // Section B.1.1 here: https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.186-4.pdf
75
- const r = new BN(await this.getRandomBytes(bytes + 8));
76
- return r.mod(modulus).add(min);
77
- },
78
-
79
- randomBuffer: new RandomBuffer()
80
- };
81
-
82
- /**
83
- * Buffer for secure random numbers
84
- */
85
- function RandomBuffer() {
86
- this.buffer = null;
87
- this.size = null;
88
- this.callback = null;
89
- }
90
-
91
- /**
92
- * Initialize buffer
93
- * @param {Integer} size size of buffer
94
- */
95
- RandomBuffer.prototype.init = function(size, callback) {
96
- this.buffer = new Uint8Array(size);
97
- this.size = 0;
98
- this.callback = callback;
99
- };
100
-
101
- /**
102
- * Concat array of secure random numbers to buffer
103
- * @param {Uint8Array} buf
104
- */
105
- RandomBuffer.prototype.set = function(buf) {
106
- if (!this.buffer) {
107
- throw new Error('RandomBuffer is not initialized');
108
- }
109
- if (!(buf instanceof Uint8Array)) {
110
- throw new Error('Invalid type: buf not an Uint8Array');
111
- }
112
- const freeSpace = this.buffer.length - this.size;
113
- if (buf.length > freeSpace) {
114
- buf = buf.subarray(0, freeSpace);
115
- }
116
- // set buf with offset old size of buffer
117
- this.buffer.set(buf, this.size);
118
- this.size += buf.length;
119
- };
120
-
121
- /**
122
- * Take numbers out of buffer and copy to array
123
- * @param {Uint8Array} buf the destination array
124
- */
125
- RandomBuffer.prototype.get = async function(buf) {
126
- if (!this.buffer) {
127
- throw new Error('RandomBuffer is not initialized');
128
- }
129
- if (!(buf instanceof Uint8Array)) {
130
- throw new Error('Invalid type: buf not an Uint8Array');
131
- }
132
- if (this.size < buf.length) {
133
- if (!this.callback) {
134
- throw new Error('Random number buffer depleted');
135
- }
136
- // Wait for random bytes from main context, then try again
137
- await this.callback();
138
- return this.get(buf);
139
- }
140
- for (let i = 0; i < buf.length; i++) {
141
- buf[i] = this.buffer[--this.size];
142
- // clear buffer value
143
- this.buffer[this.size] = 0;
144
- }
145
- };
@@ -1,137 +0,0 @@
1
- /**
2
- * @fileoverview Provides functions for asymmetric signing and signature verification
3
- * @requires crypto/crypto
4
- * @requires crypto/public_key
5
- * @requires enums
6
- * @requires util
7
- * @module crypto/signature
8
- */
9
-
10
- import crypto from './crypto';
11
- import publicKey from './public_key';
12
- import enums from '../enums';
13
- import util from '../util';
14
-
15
- export default {
16
- /**
17
- * Verifies the signature provided for data using specified algorithms and public key parameters.
18
- * See {@link https://tools.ietf.org/html/rfc4880#section-9.1|RFC 4880 9.1}
19
- * and {@link https://tools.ietf.org/html/rfc4880#section-9.4|RFC 4880 9.4}
20
- * for public key and hash algorithms.
21
- * @param {module:enums.publicKey} algo Public key algorithm
22
- * @param {module:enums.hash} hash_algo Hash algorithm
23
- * @param {Array<module:type/mpi>} msg_MPIs Algorithm-specific signature parameters
24
- * @param {Array<module:type/mpi>} pub_MPIs Algorithm-specific public key parameters
25
- * @param {Uint8Array} data Data for which the signature was created
26
- * @param {Uint8Array} hashed The hashed data
27
- * @returns {Boolean} True if signature is valid
28
- * @async
29
- */
30
- verify: async function(algo, hash_algo, msg_MPIs, pub_MPIs, data, hashed) {
31
- const types = crypto.getPubKeyParamTypes(algo);
32
- if (pub_MPIs.length < types.length) {
33
- throw new Error('Missing public key parameters');
34
- }
35
- switch (algo) {
36
- case enums.publicKey.rsa_encrypt_sign:
37
- case enums.publicKey.rsa_encrypt:
38
- case enums.publicKey.rsa_sign: {
39
- const n = pub_MPIs[0].toUint8Array();
40
- const e = pub_MPIs[1].toUint8Array();
41
- const m = msg_MPIs[0].toUint8Array('be', n.length);
42
- return publicKey.rsa.verify(hash_algo, data, m, n, e, hashed);
43
- }
44
- case enums.publicKey.dsa: {
45
- const r = msg_MPIs[0].toBN();
46
- const s = msg_MPIs[1].toBN();
47
- const p = pub_MPIs[0].toBN();
48
- const q = pub_MPIs[1].toBN();
49
- const g = pub_MPIs[2].toBN();
50
- const y = pub_MPIs[3].toBN();
51
- return publicKey.dsa.verify(hash_algo, r, s, hashed, g, p, q, y);
52
- }
53
- case enums.publicKey.ecdsa: {
54
- const { oid, Q } = publicKey.elliptic.ecdsa.parseParams(pub_MPIs);
55
- const signature = { r: msg_MPIs[0].toUint8Array(), s: msg_MPIs[1].toUint8Array() };
56
- return publicKey.elliptic.ecdsa.verify(oid, hash_algo, signature, data, Q, hashed);
57
- }
58
- case enums.publicKey.eddsa: {
59
- const { oid, Q } = publicKey.elliptic.eddsa.parseParams(pub_MPIs);
60
- // EdDSA signature params are expected in little-endian format
61
- const signature = {
62
- R: msg_MPIs[0].toUint8Array('le', 32),
63
- S: msg_MPIs[1].toUint8Array('le', 32)
64
- };
65
- return publicKey.elliptic.eddsa.verify(oid, hash_algo, signature, data, Q, hashed);
66
- }
67
- default:
68
- throw new Error('Invalid signature algorithm.');
69
- }
70
- },
71
-
72
- /**
73
- * Creates a signature on data using specified algorithms and private key parameters.
74
- * See {@link https://tools.ietf.org/html/rfc4880#section-9.1|RFC 4880 9.1}
75
- * and {@link https://tools.ietf.org/html/rfc4880#section-9.4|RFC 4880 9.4}
76
- * for public key and hash algorithms.
77
- * @param {module:enums.publicKey} algo Public key algorithm
78
- * @param {module:enums.hash} hash_algo Hash algorithm
79
- * @param {Array<module:type/mpi>} key_params Algorithm-specific public and private key parameters
80
- * @param {Uint8Array} data Data to be signed
81
- * @param {Uint8Array} hashed The hashed data
82
- * @returns {Uint8Array} Signature
83
- * @async
84
- */
85
- sign: async function(algo, hash_algo, key_params, data, hashed) {
86
- const types = [].concat(crypto.getPubKeyParamTypes(algo), crypto.getPrivKeyParamTypes(algo));
87
- if (key_params.length < types.length) {
88
- throw new Error('Missing private key parameters');
89
- }
90
- switch (algo) {
91
- case enums.publicKey.rsa_encrypt_sign:
92
- case enums.publicKey.rsa_encrypt:
93
- case enums.publicKey.rsa_sign: {
94
- const n = key_params[0].toUint8Array();
95
- const e = key_params[1].toUint8Array();
96
- const d = key_params[2].toUint8Array();
97
- const p = key_params[3].toUint8Array();
98
- const q = key_params[4].toUint8Array();
99
- const u = key_params[5].toUint8Array();
100
- const signature = await publicKey.rsa.sign(hash_algo, data, n, e, d, p, q, u, hashed);
101
- return util.Uint8Array_to_MPI(signature);
102
- }
103
- case enums.publicKey.dsa: {
104
- const p = key_params[0].toBN();
105
- const q = key_params[1].toBN();
106
- const g = key_params[2].toBN();
107
- const x = key_params[4].toBN();
108
- const signature = await publicKey.dsa.sign(hash_algo, hashed, g, p, q, x);
109
- return util.concatUint8Array([
110
- util.Uint8Array_to_MPI(signature.r),
111
- util.Uint8Array_to_MPI(signature.s)
112
- ]);
113
- }
114
- case enums.publicKey.elgamal: {
115
- throw new Error('Signing with Elgamal is not defined in the OpenPGP standard.');
116
- }
117
- case enums.publicKey.ecdsa: {
118
- const { oid, Q, d } = publicKey.elliptic.ecdsa.parseParams(key_params);
119
- const signature = await publicKey.elliptic.ecdsa.sign(oid, hash_algo, data, Q, d, hashed);
120
- return util.concatUint8Array([
121
- util.Uint8Array_to_MPI(signature.r),
122
- util.Uint8Array_to_MPI(signature.s)
123
- ]);
124
- }
125
- case enums.publicKey.eddsa: {
126
- const { oid, Q, seed } = publicKey.elliptic.eddsa.parseParams(key_params);
127
- const signature = await publicKey.elliptic.eddsa.sign(oid, hash_algo, data, Q, seed, hashed);
128
- return util.concatUint8Array([
129
- util.Uint8Array_to_MPI(signature.R),
130
- util.Uint8Array_to_MPI(signature.S)
131
- ]);
132
- }
133
- default:
134
- throw new Error('Invalid signature algorithm.');
135
- }
136
- }
137
- };