@protontech/openpgp 4.10.5 → 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 +41080 -41565
  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 -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
package/src/crypto/gcm.js DELETED
@@ -1,141 +0,0 @@
1
- // OpenPGP.js - An OpenPGP implementation in javascript
2
- // Copyright (C) 2016 Tankred Hase
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 module wraps native AES-GCM en/decryption for both
20
- * the WebCrypto api as well as node.js' crypto api.
21
- * @requires asmcrypto.js
22
- * @requires util
23
- * @module crypto/gcm
24
- */
25
-
26
- import { AES_GCM } from 'asmcrypto.js/dist_es5/aes/gcm';
27
- import util from '../util';
28
-
29
- const webCrypto = util.getWebCrypto(); // no GCM support in IE11, Safari 9
30
- const nodeCrypto = util.getNodeCrypto();
31
- const Buffer = util.getNodeBuffer();
32
-
33
- const blockLength = 16;
34
- const ivLength = 12; // size of the IV in bytes
35
- const tagLength = 16; // size of the tag in bytes
36
- const ALGO = 'AES-GCM';
37
-
38
- /**
39
- * Class to en/decrypt using GCM mode.
40
- * @param {String} cipher The symmetric cipher algorithm to use e.g. 'aes128'
41
- * @param {Uint8Array} key The encryption key
42
- */
43
- async function GCM(cipher, key) {
44
- if (cipher.substr(0, 3) !== 'aes') {
45
- throw new Error('GCM mode supports only AES cipher');
46
- }
47
-
48
- if (util.getWebCrypto() && key.length !== 24) { // WebCrypto (no 192 bit support) see: https://www.chromium.org/blink/webcrypto#TOC-AES-support
49
- const _key = await webCrypto.importKey('raw', key, { name: ALGO }, false, ['encrypt', 'decrypt']);
50
-
51
- return {
52
- encrypt: async function(pt, iv, adata = new Uint8Array()) {
53
- if (
54
- !pt.length ||
55
- // iOS does not support GCM-en/decrypting empty messages
56
- // Also, synchronous en/decryption might be faster in this case.
57
- (!adata.length && navigator.userAgent.indexOf('Edge') !== -1)
58
- // Edge does not support GCM-en/decrypting without ADATA
59
- ) {
60
- return AES_GCM.encrypt(pt, key, iv, adata);
61
- }
62
- const ct = await webCrypto.encrypt({ name: ALGO, iv, additionalData: adata, tagLength: tagLength * 8 }, _key, pt);
63
- return new Uint8Array(ct);
64
- },
65
-
66
- decrypt: async function(ct, iv, adata = new Uint8Array()) {
67
- if (
68
- ct.length === tagLength ||
69
- // iOS does not support GCM-en/decrypting empty messages
70
- // Also, synchronous en/decryption might be faster in this case.
71
- (!adata.length && navigator.userAgent.indexOf('Edge') !== -1)
72
- // Edge does not support GCM-en/decrypting without ADATA
73
- ) {
74
- return AES_GCM.decrypt(ct, key, iv, adata);
75
- }
76
- const pt = await webCrypto.decrypt({ name: ALGO, iv, additionalData: adata, tagLength: tagLength * 8 }, _key, ct);
77
- return new Uint8Array(pt);
78
- }
79
- };
80
- }
81
-
82
- if (util.getNodeCrypto()) { // Node crypto library
83
- key = Buffer.from(key);
84
-
85
- return {
86
- encrypt: async function(pt, iv, adata = new Uint8Array()) {
87
- pt = Buffer.from(pt);
88
- iv = Buffer.from(iv);
89
- adata = Buffer.from(adata);
90
- const en = new nodeCrypto.createCipheriv('aes-' + (key.length * 8) + '-gcm', key, iv);
91
- en.setAAD(adata);
92
- const ct = Buffer.concat([en.update(pt), en.final(), en.getAuthTag()]); // append auth tag to ciphertext
93
- return new Uint8Array(ct);
94
- },
95
-
96
- decrypt: async function(ct, iv, adata = new Uint8Array()) {
97
- ct = Buffer.from(ct);
98
- iv = Buffer.from(iv);
99
- adata = Buffer.from(adata);
100
- const de = new nodeCrypto.createDecipheriv('aes-' + (key.length * 8) + '-gcm', key, iv);
101
- de.setAAD(adata);
102
- de.setAuthTag(ct.slice(ct.length - tagLength, ct.length)); // read auth tag at end of ciphertext
103
- const pt = Buffer.concat([de.update(ct.slice(0, ct.length - tagLength)), de.final()]);
104
- return new Uint8Array(pt);
105
- }
106
- };
107
- }
108
-
109
- return {
110
- encrypt: async function(pt, iv, adata) {
111
- return AES_GCM.encrypt(pt, key, iv, adata);
112
- },
113
-
114
- decrypt: async function(ct, iv, adata) {
115
- return AES_GCM.decrypt(ct, key, iv, adata);
116
- }
117
- };
118
- }
119
-
120
-
121
- /**
122
- * Get GCM nonce. Note: this operation is not defined by the standard.
123
- * A future version of the standard may define GCM mode differently,
124
- * hopefully under a different ID (we use Private/Experimental algorithm
125
- * ID 100) so that we can maintain backwards compatibility.
126
- * @param {Uint8Array} iv The initialization vector (12 bytes)
127
- * @param {Uint8Array} chunkIndex The chunk index (8 bytes)
128
- */
129
- GCM.getNonce = function(iv, chunkIndex) {
130
- const nonce = iv.slice();
131
- for (let i = 0; i < chunkIndex.length; i++) {
132
- nonce[4 + i] ^= chunkIndex[i];
133
- }
134
- return nonce;
135
- };
136
-
137
- GCM.blockLength = blockLength;
138
- GCM.ivLength = ivLength;
139
- GCM.tagLength = tagLength;
140
-
141
- export default GCM;
@@ -1,163 +0,0 @@
1
- /**
2
- * @fileoverview Provides an interface to hashing functions available in Node.js or external libraries.
3
- * @see {@link https://github.com/asmcrypto/asmcrypto.js|asmCrypto}
4
- * @see {@link https://github.com/indutny/hash.js|hash.js}
5
- * @requires asmcrypto.js
6
- * @requires hash.js
7
- * @requires web-stream-tools
8
- * @requires crypto/hash/md5
9
- * @requires config
10
- * @requires util
11
- * @module crypto/hash
12
- */
13
-
14
- import { Sha1 } from 'asmcrypto.js/dist_es5/hash/sha1/sha1';
15
- import { Sha256 } from 'asmcrypto.js/dist_es5/hash/sha256/sha256';
16
- import sha224 from 'hash.js/lib/hash/sha/224';
17
- import sha384 from 'hash.js/lib/hash/sha/384';
18
- import sha512 from 'hash.js/lib/hash/sha/512';
19
- import { ripemd160 } from 'hash.js/lib/hash/ripemd';
20
- import stream from 'web-stream-tools';
21
- import md5 from './md5';
22
- import config from '../../config';
23
- import util from '../../util';
24
-
25
- const webCrypto = util.getWebCrypto();
26
- const nodeCrypto = util.getNodeCrypto();
27
- const Buffer = util.getNodeBuffer();
28
-
29
- function node_hash(type) {
30
- return async function (data) {
31
- const shasum = nodeCrypto.createHash(type);
32
- return stream.transform(data, value => {
33
- shasum.update(Buffer.from(value));
34
- }, () => new Uint8Array(shasum.digest()));
35
- };
36
- }
37
-
38
- function hashjs_hash(hash, webCryptoHash) {
39
- return async function(data) {
40
- if (!util.isStream(data) && webCrypto && webCryptoHash && data.length >= config.min_bytes_for_web_crypto) {
41
- return new Uint8Array(await webCrypto.digest(webCryptoHash, data));
42
- }
43
- const hashInstance = hash();
44
- return stream.transform(data, value => {
45
- hashInstance.update(value);
46
- }, () => new Uint8Array(hashInstance.digest()));
47
- };
48
- }
49
-
50
- function asmcrypto_hash(hash, webCryptoHash) {
51
- return async function(data) {
52
- if (util.isStream(data)) {
53
- const hashInstance = new hash();
54
- return stream.transform(data, value => {
55
- hashInstance.process(value);
56
- }, () => hashInstance.finish().result);
57
- } else if (webCrypto && webCryptoHash && data.length >= config.min_bytes_for_web_crypto) {
58
- return new Uint8Array(await webCrypto.digest(webCryptoHash, data));
59
- } else {
60
- return hash.bytes(data);
61
- }
62
- };
63
- }
64
-
65
- let hash_fns;
66
- if (nodeCrypto) { // Use Node native crypto for all hash functions
67
- hash_fns = {
68
- md5: node_hash('md5'),
69
- sha1: node_hash('sha1'),
70
- sha224: node_hash('sha224'),
71
- sha256: node_hash('sha256'),
72
- sha384: node_hash('sha384'),
73
- sha512: node_hash('sha512'),
74
- ripemd: node_hash('ripemd160')
75
- };
76
- } else { // Use JS fallbacks
77
- hash_fns = {
78
- md5: md5,
79
- sha1: asmcrypto_hash(Sha1, navigator.userAgent.indexOf('Edge') === -1 && 'SHA-1'),
80
- sha224: hashjs_hash(sha224),
81
- sha256: asmcrypto_hash(Sha256, 'SHA-256'),
82
- sha384: hashjs_hash(sha384, 'SHA-384'),
83
- sha512: hashjs_hash(sha512, 'SHA-512'), // asmcrypto sha512 is huge.
84
- ripemd: hashjs_hash(ripemd160)
85
- };
86
- }
87
-
88
- export default {
89
-
90
- /** @see module:md5 */
91
- md5: hash_fns.md5,
92
- /** @see asmCrypto */
93
- sha1: hash_fns.sha1,
94
- /** @see hash.js */
95
- sha224: hash_fns.sha224,
96
- /** @see asmCrypto */
97
- sha256: hash_fns.sha256,
98
- /** @see hash.js */
99
- sha384: hash_fns.sha384,
100
- /** @see asmCrypto */
101
- sha512: hash_fns.sha512,
102
- /** @see hash.js */
103
- ripemd: hash_fns.ripemd,
104
-
105
- /**
106
- * Create a hash on the specified data using the specified algorithm
107
- * @param {module:enums.hash} algo Hash algorithm type (see {@link https://tools.ietf.org/html/rfc4880#section-9.4|RFC 4880 9.4})
108
- * @param {Uint8Array} data Data to be hashed
109
- * @returns {Promise<Uint8Array>} hash value
110
- */
111
- digest: function(algo, data) {
112
- switch (algo) {
113
- case 1:
114
- // - MD5 [HAC]
115
- return this.md5(data);
116
- case 2:
117
- // - SHA-1 [FIPS180]
118
- return this.sha1(data);
119
- case 3:
120
- // - RIPE-MD/160 [HAC]
121
- return this.ripemd(data);
122
- case 8:
123
- // - SHA256 [FIPS180]
124
- return this.sha256(data);
125
- case 9:
126
- // - SHA384 [FIPS180]
127
- return this.sha384(data);
128
- case 10:
129
- // - SHA512 [FIPS180]
130
- return this.sha512(data);
131
- case 11:
132
- // - SHA224 [FIPS180]
133
- return this.sha224(data);
134
- default:
135
- throw new Error('Invalid hash function.');
136
- }
137
- },
138
-
139
- /**
140
- * Returns the hash size in bytes of the specified hash algorithm type
141
- * @param {module:enums.hash} algo Hash algorithm type (See {@link https://tools.ietf.org/html/rfc4880#section-9.4|RFC 4880 9.4})
142
- * @returns {Integer} Size in bytes of the resulting hash
143
- */
144
- getHashByteLength: function(algo) {
145
- switch (algo) {
146
- case 1: // - MD5 [HAC]
147
- return 16;
148
- case 2: // - SHA-1 [FIPS180]
149
- case 3: // - RIPE-MD/160 [HAC]
150
- return 20;
151
- case 8: // - SHA256 [FIPS180]
152
- return 32;
153
- case 9: // - SHA384 [FIPS180]
154
- return 48;
155
- case 10: // - SHA512 [FIPS180]
156
- return 64;
157
- case 11: // - SHA224 [FIPS180]
158
- return 28;
159
- default:
160
- throw new Error('Invalid hash algorithm.');
161
- }
162
- }
163
- };
@@ -1,205 +0,0 @@
1
- /**
2
- * A fast MD5 JavaScript implementation
3
- * Copyright (c) 2012 Joseph Myers
4
- * http://www.myersdaily.org/joseph/javascript/md5-text.html
5
- *
6
- * Permission to use, copy, modify, and distribute this software
7
- * and its documentation for any purposes and without
8
- * fee is hereby granted provided that this copyright notice
9
- * appears in all copies.
10
- *
11
- * Of course, this soft is provided "as is" without express or implied
12
- * warranty of any kind.
13
- */
14
-
15
- /**
16
- * @requires util
17
- */
18
-
19
- import util from '../../util';
20
-
21
- // MD5 Digest
22
- async function md5(entree) {
23
- const digest = md51(util.Uint8Array_to_str(entree));
24
- return util.hex_to_Uint8Array(hex(digest));
25
- }
26
-
27
- function md5cycle(x, k) {
28
- let a = x[0];
29
- let b = x[1];
30
- let c = x[2];
31
- let d = x[3];
32
-
33
- a = ff(a, b, c, d, k[0], 7, -680876936);
34
- d = ff(d, a, b, c, k[1], 12, -389564586);
35
- c = ff(c, d, a, b, k[2], 17, 606105819);
36
- b = ff(b, c, d, a, k[3], 22, -1044525330);
37
- a = ff(a, b, c, d, k[4], 7, -176418897);
38
- d = ff(d, a, b, c, k[5], 12, 1200080426);
39
- c = ff(c, d, a, b, k[6], 17, -1473231341);
40
- b = ff(b, c, d, a, k[7], 22, -45705983);
41
- a = ff(a, b, c, d, k[8], 7, 1770035416);
42
- d = ff(d, a, b, c, k[9], 12, -1958414417);
43
- c = ff(c, d, a, b, k[10], 17, -42063);
44
- b = ff(b, c, d, a, k[11], 22, -1990404162);
45
- a = ff(a, b, c, d, k[12], 7, 1804603682);
46
- d = ff(d, a, b, c, k[13], 12, -40341101);
47
- c = ff(c, d, a, b, k[14], 17, -1502002290);
48
- b = ff(b, c, d, a, k[15], 22, 1236535329);
49
-
50
- a = gg(a, b, c, d, k[1], 5, -165796510);
51
- d = gg(d, a, b, c, k[6], 9, -1069501632);
52
- c = gg(c, d, a, b, k[11], 14, 643717713);
53
- b = gg(b, c, d, a, k[0], 20, -373897302);
54
- a = gg(a, b, c, d, k[5], 5, -701558691);
55
- d = gg(d, a, b, c, k[10], 9, 38016083);
56
- c = gg(c, d, a, b, k[15], 14, -660478335);
57
- b = gg(b, c, d, a, k[4], 20, -405537848);
58
- a = gg(a, b, c, d, k[9], 5, 568446438);
59
- d = gg(d, a, b, c, k[14], 9, -1019803690);
60
- c = gg(c, d, a, b, k[3], 14, -187363961);
61
- b = gg(b, c, d, a, k[8], 20, 1163531501);
62
- a = gg(a, b, c, d, k[13], 5, -1444681467);
63
- d = gg(d, a, b, c, k[2], 9, -51403784);
64
- c = gg(c, d, a, b, k[7], 14, 1735328473);
65
- b = gg(b, c, d, a, k[12], 20, -1926607734);
66
-
67
- a = hh(a, b, c, d, k[5], 4, -378558);
68
- d = hh(d, a, b, c, k[8], 11, -2022574463);
69
- c = hh(c, d, a, b, k[11], 16, 1839030562);
70
- b = hh(b, c, d, a, k[14], 23, -35309556);
71
- a = hh(a, b, c, d, k[1], 4, -1530992060);
72
- d = hh(d, a, b, c, k[4], 11, 1272893353);
73
- c = hh(c, d, a, b, k[7], 16, -155497632);
74
- b = hh(b, c, d, a, k[10], 23, -1094730640);
75
- a = hh(a, b, c, d, k[13], 4, 681279174);
76
- d = hh(d, a, b, c, k[0], 11, -358537222);
77
- c = hh(c, d, a, b, k[3], 16, -722521979);
78
- b = hh(b, c, d, a, k[6], 23, 76029189);
79
- a = hh(a, b, c, d, k[9], 4, -640364487);
80
- d = hh(d, a, b, c, k[12], 11, -421815835);
81
- c = hh(c, d, a, b, k[15], 16, 530742520);
82
- b = hh(b, c, d, a, k[2], 23, -995338651);
83
-
84
- a = ii(a, b, c, d, k[0], 6, -198630844);
85
- d = ii(d, a, b, c, k[7], 10, 1126891415);
86
- c = ii(c, d, a, b, k[14], 15, -1416354905);
87
- b = ii(b, c, d, a, k[5], 21, -57434055);
88
- a = ii(a, b, c, d, k[12], 6, 1700485571);
89
- d = ii(d, a, b, c, k[3], 10, -1894986606);
90
- c = ii(c, d, a, b, k[10], 15, -1051523);
91
- b = ii(b, c, d, a, k[1], 21, -2054922799);
92
- a = ii(a, b, c, d, k[8], 6, 1873313359);
93
- d = ii(d, a, b, c, k[15], 10, -30611744);
94
- c = ii(c, d, a, b, k[6], 15, -1560198380);
95
- b = ii(b, c, d, a, k[13], 21, 1309151649);
96
- a = ii(a, b, c, d, k[4], 6, -145523070);
97
- d = ii(d, a, b, c, k[11], 10, -1120210379);
98
- c = ii(c, d, a, b, k[2], 15, 718787259);
99
- b = ii(b, c, d, a, k[9], 21, -343485551);
100
-
101
- x[0] = add32(a, x[0]);
102
- x[1] = add32(b, x[1]);
103
- x[2] = add32(c, x[2]);
104
- x[3] = add32(d, x[3]);
105
- }
106
-
107
- function cmn(q, a, b, x, s, t) {
108
- a = add32(add32(a, q), add32(x, t));
109
- return add32((a << s) | (a >>> (32 - s)), b);
110
- }
111
-
112
- function ff(a, b, c, d, x, s, t) {
113
- return cmn((b & c) | ((~b) & d), a, b, x, s, t);
114
- }
115
-
116
- function gg(a, b, c, d, x, s, t) {
117
- return cmn((b & d) | (c & (~d)), a, b, x, s, t);
118
- }
119
-
120
- function hh(a, b, c, d, x, s, t) {
121
- return cmn(b ^ c ^ d, a, b, x, s, t);
122
- }
123
-
124
- function ii(a, b, c, d, x, s, t) {
125
- return cmn(c ^ (b | (~d)), a, b, x, s, t);
126
- }
127
-
128
- function md51(s) {
129
- const n = s.length;
130
- const state = [1732584193, -271733879, -1732584194, 271733878];
131
- let i;
132
- for (i = 64; i <= s.length; i += 64) {
133
- md5cycle(state, md5blk(s.substring(i - 64, i)));
134
- }
135
- s = s.substring(i - 64);
136
- const tail = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
137
- for (i = 0; i < s.length; i++) {
138
- tail[i >> 2] |= s.charCodeAt(i) << ((i % 4) << 3);
139
- }
140
- tail[i >> 2] |= 0x80 << ((i % 4) << 3);
141
- if (i > 55) {
142
- md5cycle(state, tail);
143
- for (i = 0; i < 16; i++) {
144
- tail[i] = 0;
145
- }
146
- }
147
- tail[14] = n * 8;
148
- md5cycle(state, tail);
149
- return state;
150
- }
151
-
152
- /* there needs to be support for Unicode here,
153
- * unless we pretend that we can redefine the MD-5
154
- * algorithm for multi-byte characters (perhaps
155
- * by adding every four 16-bit characters and
156
- * shortening the sum to 32 bits). Otherwise
157
- * I suggest performing MD-5 as if every character
158
- * was two bytes--e.g., 0040 0025 = @%--but then
159
- * how will an ordinary MD-5 sum be matched?
160
- * There is no way to standardize text to something
161
- * like UTF-8 before transformation; speed cost is
162
- * utterly prohibitive. The JavaScript standard
163
- * itself needs to look at this: it should start
164
- * providing access to strings as preformed UTF-8
165
- * 8-bit unsigned value arrays.
166
- */
167
- function md5blk(s) { /* I figured global was faster. */
168
- const md5blks = [];
169
- let i; /* Andy King said do it this way. */
170
- for (i = 0; i < 64; i += 4) {
171
- md5blks[i >> 2] = s.charCodeAt(i) + (s.charCodeAt(i + 1) << 8) + (s.charCodeAt(i + 2) << 16) + (s.charCodeAt(i + 3) <<
172
- 24);
173
- }
174
- return md5blks;
175
- }
176
-
177
- const hex_chr = '0123456789abcdef'.split('');
178
-
179
- function rhex(n) {
180
- let s = '';
181
- let j = 0;
182
- for (; j < 4; j++) {
183
- s += hex_chr[(n >> (j * 8 + 4)) & 0x0F] + hex_chr[(n >> (j * 8)) & 0x0F];
184
- }
185
- return s;
186
- }
187
-
188
- function hex(x) {
189
- for (let i = 0; i < x.length; i++) {
190
- x[i] = rhex(x[i]);
191
- }
192
- return x.join('');
193
- }
194
-
195
- /* this function is much faster,
196
- so if possible we use it. Some IEs
197
- are the only ones I know of that
198
- need the idiotic second function,
199
- generated by an if clause. */
200
-
201
- function add32(a, b) {
202
- return (a + b) & 0xFFFFFFFF;
203
- }
204
-
205
- export default md5;
@@ -1,57 +0,0 @@
1
- /**
2
- * @fileoverview Provides access to all cryptographic primitives used in OpenPGP.js
3
- * @see module:crypto/crypto
4
- * @see module:crypto/signature
5
- * @see module:crypto/public_key
6
- * @see module:crypto/cipher
7
- * @see module:crypto/random
8
- * @see module:crypto/hash
9
- * @module crypto
10
- */
11
-
12
- import cipher from './cipher';
13
- import hash from './hash';
14
- import cfb from './cfb';
15
- import gcm from './gcm';
16
- import eax from './eax';
17
- import ocb from './ocb';
18
- import publicKey from './public_key';
19
- import signature from './signature';
20
- import random from './random';
21
- import pkcs1 from './pkcs1';
22
- import pkcs5 from './pkcs5';
23
- import crypto from './crypto';
24
- import aes_kw from './aes_kw';
25
-
26
- // TODO move cfb and gcm to cipher
27
- const mod = {
28
- /** @see module:crypto/cipher */
29
- cipher: cipher,
30
- /** @see module:crypto/hash */
31
- hash: hash,
32
- /** @see module:crypto/cfb */
33
- cfb: cfb,
34
- /** @see module:crypto/gcm */
35
- gcm: gcm,
36
- experimental_gcm: gcm,
37
- /** @see module:crypto/eax */
38
- eax: eax,
39
- /** @see module:crypto/ocb */
40
- ocb: ocb,
41
- /** @see module:crypto/public_key */
42
- publicKey: publicKey,
43
- /** @see module:crypto/signature */
44
- signature: signature,
45
- /** @see module:crypto/random */
46
- random: random,
47
- /** @see module:crypto/pkcs1 */
48
- pkcs1: pkcs1,
49
- /** @see module:crypto/pkcs5 */
50
- pkcs5: pkcs5,
51
- /** @see module:crypto/aes_kw */
52
- aes_kw: aes_kw
53
- };
54
-
55
- Object.assign(mod, crypto);
56
-
57
- export default mod;