@novnc/novnc 1.6.0 → 1.7.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 (103) hide show
  1. package/core/base64.js +104 -0
  2. package/core/crypto/aes.js +178 -0
  3. package/core/crypto/bigint.js +34 -0
  4. package/core/crypto/crypto.js +90 -0
  5. package/core/crypto/des.js +330 -0
  6. package/core/crypto/dh.js +55 -0
  7. package/core/crypto/md5.js +82 -0
  8. package/core/crypto/rsa.js +132 -0
  9. package/core/decoders/copyrect.js +27 -0
  10. package/core/decoders/h264.js +321 -0
  11. package/core/decoders/hextile.js +181 -0
  12. package/core/decoders/jpeg.js +161 -0
  13. package/core/decoders/raw.js +59 -0
  14. package/core/decoders/rre.js +44 -0
  15. package/core/decoders/tight.js +393 -0
  16. package/core/decoders/tightpng.js +27 -0
  17. package/core/decoders/zlib.js +51 -0
  18. package/core/decoders/zrle.js +185 -0
  19. package/core/deflator.js +84 -0
  20. package/core/display.js +578 -0
  21. package/core/encodings.js +54 -0
  22. package/core/inflator.js +65 -0
  23. package/core/input/domkeytable.js +311 -0
  24. package/core/input/fixedkeys.js +129 -0
  25. package/core/input/gesturehandler.js +567 -0
  26. package/core/input/keyboard.js +294 -0
  27. package/core/input/keysym.js +616 -0
  28. package/core/input/keysymdef.js +688 -0
  29. package/core/input/util.js +191 -0
  30. package/core/input/vkeys.js +116 -0
  31. package/core/input/xtscancodes.js +173 -0
  32. package/core/ra2.js +312 -0
  33. package/core/rfb.js +3411 -0
  34. package/core/util/browser.js +233 -0
  35. package/core/util/cursor.js +249 -0
  36. package/core/util/element.js +32 -0
  37. package/core/util/events.js +138 -0
  38. package/core/util/eventtarget.js +35 -0
  39. package/core/util/int.js +15 -0
  40. package/core/util/logging.js +56 -0
  41. package/core/util/strings.js +28 -0
  42. package/core/websock.js +369 -0
  43. package/docs/API.md +0 -5
  44. package/package.json +6 -10
  45. package/vendor/pako/LICENSE +21 -0
  46. package/vendor/pako/README.md +6 -0
  47. package/{lib/vendor → vendor}/pako/lib/utils/common.js +13 -23
  48. package/{lib/vendor → vendor}/pako/lib/zlib/adler32.js +12 -14
  49. package/vendor/pako/lib/zlib/constants.js +47 -0
  50. package/{lib/vendor → vendor}/pako/lib/zlib/crc32.js +15 -14
  51. package/{lib/vendor → vendor}/pako/lib/zlib/deflate.js +459 -334
  52. package/{lib/vendor → vendor}/pako/lib/zlib/gzheader.js +13 -19
  53. package/{lib/vendor → vendor}/pako/lib/zlib/inffast.js +116 -119
  54. package/vendor/pako/lib/zlib/inflate.js +1527 -0
  55. package/{lib/vendor → vendor}/pako/lib/zlib/inftrees.js +103 -91
  56. package/vendor/pako/lib/zlib/messages.js +11 -0
  57. package/{lib/vendor → vendor}/pako/lib/zlib/trees.js +313 -268
  58. package/{lib/vendor → vendor}/pako/lib/zlib/zstream.js +4 -10
  59. package/lib/base64.js +0 -100
  60. package/lib/crypto/aes.js +0 -481
  61. package/lib/crypto/bigint.js +0 -41
  62. package/lib/crypto/crypto.js +0 -109
  63. package/lib/crypto/des.js +0 -374
  64. package/lib/crypto/dh.js +0 -81
  65. package/lib/crypto/md5.js +0 -97
  66. package/lib/crypto/rsa.js +0 -312
  67. package/lib/decoders/copyrect.js +0 -40
  68. package/lib/decoders/h264.js +0 -349
  69. package/lib/decoders/hextile.js +0 -195
  70. package/lib/decoders/jpeg.js +0 -175
  71. package/lib/decoders/raw.js +0 -66
  72. package/lib/decoders/rre.js +0 -52
  73. package/lib/decoders/tight.js +0 -363
  74. package/lib/decoders/tightpng.js +0 -51
  75. package/lib/decoders/zlib.js +0 -57
  76. package/lib/decoders/zrle.js +0 -192
  77. package/lib/deflator.js +0 -88
  78. package/lib/display.js +0 -588
  79. package/lib/encodings.js +0 -70
  80. package/lib/inflator.js +0 -77
  81. package/lib/input/domkeytable.js +0 -313
  82. package/lib/input/fixedkeys.js +0 -127
  83. package/lib/input/gesturehandler.js +0 -573
  84. package/lib/input/keyboard.js +0 -293
  85. package/lib/input/keysym.js +0 -878
  86. package/lib/input/keysymdef.js +0 -1351
  87. package/lib/input/util.js +0 -217
  88. package/lib/input/vkeys.js +0 -121
  89. package/lib/input/xtscancodes.js +0 -343
  90. package/lib/ra2.js +0 -535
  91. package/lib/rfb.js +0 -3398
  92. package/lib/util/browser.js +0 -239
  93. package/lib/util/cursor.js +0 -269
  94. package/lib/util/element.js +0 -41
  95. package/lib/util/events.js +0 -133
  96. package/lib/util/eventtarget.js +0 -53
  97. package/lib/util/int.js +0 -21
  98. package/lib/util/logging.js +0 -56
  99. package/lib/util/strings.js +0 -36
  100. package/lib/vendor/pako/lib/zlib/constants.js +0 -47
  101. package/lib/vendor/pako/lib/zlib/inflate.js +0 -1602
  102. package/lib/vendor/pako/lib/zlib/messages.js +0 -25
  103. package/lib/websock.js +0 -395
@@ -1,109 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
- var _aes = require("./aes.js");
8
- var _des = require("./des.js");
9
- var _rsa = require("./rsa.js");
10
- var _dh = require("./dh.js");
11
- var _md = require("./md5.js");
12
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
13
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
14
- function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
15
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
16
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
17
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
18
- // A single interface for the cryptographic algorithms not supported by SubtleCrypto.
19
- // Both synchronous and asynchronous implmentations are allowed.
20
- var LegacyCrypto = /*#__PURE__*/function () {
21
- function LegacyCrypto() {
22
- _classCallCheck(this, LegacyCrypto);
23
- this._algorithms = {
24
- "AES-ECB": _aes.AESECBCipher,
25
- "AES-EAX": _aes.AESEAXCipher,
26
- "DES-ECB": _des.DESECBCipher,
27
- "DES-CBC": _des.DESCBCCipher,
28
- "RSA-PKCS1-v1_5": _rsa.RSACipher,
29
- "DH": _dh.DHCipher,
30
- "MD5": _md.MD5
31
- };
32
- }
33
- return _createClass(LegacyCrypto, [{
34
- key: "encrypt",
35
- value: function encrypt(algorithm, key, data) {
36
- if (key.algorithm.name !== algorithm.name) {
37
- throw new Error("algorithm does not match");
38
- }
39
- if (typeof key.encrypt !== "function") {
40
- throw new Error("key does not support encryption");
41
- }
42
- return key.encrypt(algorithm, data);
43
- }
44
- }, {
45
- key: "decrypt",
46
- value: function decrypt(algorithm, key, data) {
47
- if (key.algorithm.name !== algorithm.name) {
48
- throw new Error("algorithm does not match");
49
- }
50
- if (typeof key.decrypt !== "function") {
51
- throw new Error("key does not support encryption");
52
- }
53
- return key.decrypt(algorithm, data);
54
- }
55
- }, {
56
- key: "importKey",
57
- value: function importKey(format, keyData, algorithm, extractable, keyUsages) {
58
- if (format !== "raw") {
59
- throw new Error("key format is not supported");
60
- }
61
- var alg = this._algorithms[algorithm.name];
62
- if (typeof alg === "undefined" || typeof alg.importKey !== "function") {
63
- throw new Error("algorithm is not supported");
64
- }
65
- return alg.importKey(keyData, algorithm, extractable, keyUsages);
66
- }
67
- }, {
68
- key: "generateKey",
69
- value: function generateKey(algorithm, extractable, keyUsages) {
70
- var alg = this._algorithms[algorithm.name];
71
- if (typeof alg === "undefined" || typeof alg.generateKey !== "function") {
72
- throw new Error("algorithm is not supported");
73
- }
74
- return alg.generateKey(algorithm, extractable, keyUsages);
75
- }
76
- }, {
77
- key: "exportKey",
78
- value: function exportKey(format, key) {
79
- if (format !== "raw") {
80
- throw new Error("key format is not supported");
81
- }
82
- if (typeof key.exportKey !== "function") {
83
- throw new Error("key does not support exportKey");
84
- }
85
- return key.exportKey();
86
- }
87
- }, {
88
- key: "digest",
89
- value: function digest(algorithm, data) {
90
- var alg = this._algorithms[algorithm];
91
- if (typeof alg !== "function") {
92
- throw new Error("algorithm is not supported");
93
- }
94
- return alg(data);
95
- }
96
- }, {
97
- key: "deriveBits",
98
- value: function deriveBits(algorithm, key, length) {
99
- if (key.algorithm.name !== algorithm.name) {
100
- throw new Error("algorithm does not match");
101
- }
102
- if (typeof key.deriveBits !== "function") {
103
- throw new Error("key does not support deriveBits");
104
- }
105
- return key.deriveBits(algorithm, length);
106
- }
107
- }]);
108
- }();
109
- var _default = exports["default"] = new LegacyCrypto();
package/lib/crypto/des.js DELETED
@@ -1,374 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.DESECBCipher = exports.DESCBCCipher = void 0;
7
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
8
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
9
- function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
10
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
11
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
12
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
13
- /*
14
- * Ported from Flashlight VNC ActionScript implementation:
15
- * http://www.wizhelp.com/flashlight-vnc/
16
- *
17
- * Full attribution follows:
18
- *
19
- * -------------------------------------------------------------------------
20
- *
21
- * This DES class has been extracted from package Acme.Crypto for use in VNC.
22
- * The unnecessary odd parity code has been removed.
23
- *
24
- * These changes are:
25
- * Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved.
26
- *
27
- * This software is distributed in the hope that it will be useful,
28
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
29
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
30
- *
31
-
32
- * DesCipher - the DES encryption method
33
- *
34
- * The meat of this code is by Dave Zimmerman <dzimm@widget.com>, and is:
35
- *
36
- * Copyright (c) 1996 Widget Workshop, Inc. All Rights Reserved.
37
- *
38
- * Permission to use, copy, modify, and distribute this software
39
- * and its documentation for NON-COMMERCIAL or COMMERCIAL purposes and
40
- * without fee is hereby granted, provided that this copyright notice is kept
41
- * intact.
42
- *
43
- * WIDGET WORKSHOP MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY
44
- * OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
45
- * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
46
- * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. WIDGET WORKSHOP SHALL NOT BE LIABLE
47
- * FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
48
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
49
- *
50
- * THIS SOFTWARE IS NOT DESIGNED OR INTENDED FOR USE OR RESALE AS ON-LINE
51
- * CONTROL EQUIPMENT IN HAZARDOUS ENVIRONMENTS REQUIRING FAIL-SAFE
52
- * PERFORMANCE, SUCH AS IN THE OPERATION OF NUCLEAR FACILITIES, AIRCRAFT
53
- * NAVIGATION OR COMMUNICATION SYSTEMS, AIR TRAFFIC CONTROL, DIRECT LIFE
54
- * SUPPORT MACHINES, OR WEAPONS SYSTEMS, IN WHICH THE FAILURE OF THE
55
- * SOFTWARE COULD LEAD DIRECTLY TO DEATH, PERSONAL INJURY, OR SEVERE
56
- * PHYSICAL OR ENVIRONMENTAL DAMAGE ("HIGH RISK ACTIVITIES"). WIDGET WORKSHOP
57
- * SPECIFICALLY DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY OF FITNESS FOR
58
- * HIGH RISK ACTIVITIES.
59
- *
60
- *
61
- * The rest is:
62
- *
63
- * Copyright (C) 1996 by Jef Poskanzer <jef@acme.com>. All rights reserved.
64
- *
65
- * Redistribution and use in source and binary forms, with or without
66
- * modification, are permitted provided that the following conditions
67
- * are met:
68
- * 1. Redistributions of source code must retain the above copyright
69
- * notice, this list of conditions and the following disclaimer.
70
- * 2. Redistributions in binary form must reproduce the above copyright
71
- * notice, this list of conditions and the following disclaimer in the
72
- * documentation and/or other materials provided with the distribution.
73
- *
74
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
75
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
76
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
77
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
78
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
79
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
80
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
81
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
82
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
83
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
84
- * SUCH DAMAGE.
85
- *
86
- * Visit the ACME Labs Java page for up-to-date versions of this and other
87
- * fine Java utilities: http://www.acme.com/java/
88
- */
89
-
90
- /* eslint-disable comma-spacing */
91
-
92
- // Tables, permutations, S-boxes, etc.
93
- var PC2 = [13, 16, 10, 23, 0, 4, 2, 27, 14, 5, 20, 9, 22, 18, 11, 3, 25, 7, 15, 6, 26, 19, 12, 1, 40, 51, 30, 36, 46, 54, 29, 39, 50, 44, 32, 47, 43, 48, 38, 55, 33, 52, 45, 41, 49, 35, 28, 31],
94
- totrot = [1, 2, 4, 6, 8, 10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28];
95
- var z = 0x0;
96
- var a, b, c, d, e, f;
97
- a = 1 << 16;
98
- b = 1 << 24;
99
- c = a | b;
100
- d = 1 << 2;
101
- e = 1 << 10;
102
- f = d | e;
103
- var SP1 = [c | e, z | z, a | z, c | f, c | d, a | f, z | d, a | z, z | e, c | e, c | f, z | e, b | f, c | d, b | z, z | d, z | f, b | e, b | e, a | e, a | e, c | z, c | z, b | f, a | d, b | d, b | d, a | d, z | z, z | f, a | f, b | z, a | z, c | f, z | d, c | z, c | e, b | z, b | z, z | e, c | d, a | z, a | e, b | d, z | e, z | d, b | f, a | f, c | f, a | d, c | z, b | f, b | d, z | f, a | f, c | e, z | f, b | e, b | e, z | z, a | d, a | e, z | z, c | d];
104
- a = 1 << 20;
105
- b = 1 << 31;
106
- c = a | b;
107
- d = 1 << 5;
108
- e = 1 << 15;
109
- f = d | e;
110
- var SP2 = [c | f, b | e, z | e, a | f, a | z, z | d, c | d, b | f, b | d, c | f, c | e, b | z, b | e, a | z, z | d, c | d, a | e, a | d, b | f, z | z, b | z, z | e, a | f, c | z, a | d, b | d, z | z, a | e, z | f, c | e, c | z, z | f, z | z, a | f, c | d, a | z, b | f, c | z, c | e, z | e, c | z, b | e, z | d, c | f, a | f, z | d, z | e, b | z, z | f, c | e, a | z, b | d, a | d, b | f, b | d, a | d, a | e, z | z, b | e, z | f, b | z, c | d, c | f, a | e];
111
- a = 1 << 17;
112
- b = 1 << 27;
113
- c = a | b;
114
- d = 1 << 3;
115
- e = 1 << 9;
116
- f = d | e;
117
- var SP3 = [z | f, c | e, z | z, c | d, b | e, z | z, a | f, b | e, a | d, b | d, b | d, a | z, c | f, a | d, c | z, z | f, b | z, z | d, c | e, z | e, a | e, c | z, c | d, a | f, b | f, a | e, a | z, b | f, z | d, c | f, z | e, b | z, c | e, b | z, a | d, z | f, a | z, c | e, b | e, z | z, z | e, a | d, c | f, b | e, b | d, z | e, z | z, c | d, b | f, a | z, b | z, c | f, z | d, a | f, a | e, b | d, c | z, b | f, z | f, c | z, a | f, z | d, c | d, a | e];
118
- a = 1 << 13;
119
- b = 1 << 23;
120
- c = a | b;
121
- d = 1 << 0;
122
- e = 1 << 7;
123
- f = d | e;
124
- var SP4 = [c | d, a | f, a | f, z | e, c | e, b | f, b | d, a | d, z | z, c | z, c | z, c | f, z | f, z | z, b | e, b | d, z | d, a | z, b | z, c | d, z | e, b | z, a | d, a | e, b | f, z | d, a | e, b | e, a | z, c | e, c | f, z | f, b | e, b | d, c | z, c | f, z | f, z | z, z | z, c | z, a | e, b | e, b | f, z | d, c | d, a | f, a | f, z | e, c | f, z | f, z | d, a | z, b | d, a | d, c | e, b | f, a | d, a | e, b | z, c | d, z | e, b | z, a | z, c | e];
125
- a = 1 << 25;
126
- b = 1 << 30;
127
- c = a | b;
128
- d = 1 << 8;
129
- e = 1 << 19;
130
- f = d | e;
131
- var SP5 = [z | d, a | f, a | e, c | d, z | e, z | d, b | z, a | e, b | f, z | e, a | d, b | f, c | d, c | e, z | f, b | z, a | z, b | e, b | e, z | z, b | d, c | f, c | f, a | d, c | e, b | d, z | z, c | z, a | f, a | z, c | z, z | f, z | e, c | d, z | d, a | z, b | z, a | e, c | d, b | f, a | d, b | z, c | e, a | f, b | f, z | d, a | z, c | e, c | f, z | f, c | z, c | f, a | e, z | z, b | e, c | z, z | f, a | d, b | d, z | e, z | z, b | e, a | f, b | d];
132
- a = 1 << 22;
133
- b = 1 << 29;
134
- c = a | b;
135
- d = 1 << 4;
136
- e = 1 << 14;
137
- f = d | e;
138
- var SP6 = [b | d, c | z, z | e, c | f, c | z, z | d, c | f, a | z, b | e, a | f, a | z, b | d, a | d, b | e, b | z, z | f, z | z, a | d, b | f, z | e, a | e, b | f, z | d, c | d, c | d, z | z, a | f, c | e, z | f, a | e, c | e, b | z, b | e, z | d, c | d, a | e, c | f, a | z, z | f, b | d, a | z, b | e, b | z, z | f, b | d, c | f, a | e, c | z, a | f, c | e, z | z, c | d, z | d, z | e, c | z, a | f, z | e, a | d, b | f, z | z, c | e, b | z, a | d, b | f];
139
- a = 1 << 21;
140
- b = 1 << 26;
141
- c = a | b;
142
- d = 1 << 1;
143
- e = 1 << 11;
144
- f = d | e;
145
- var SP7 = [a | z, c | d, b | f, z | z, z | e, b | f, a | f, c | e, c | f, a | z, z | z, b | d, z | d, b | z, c | d, z | f, b | e, a | f, a | d, b | e, b | d, c | z, c | e, a | d, c | z, z | e, z | f, c | f, a | e, z | d, b | z, a | e, b | z, a | e, a | z, b | f, b | f, c | d, c | d, z | d, a | d, b | z, b | e, a | z, c | e, z | f, a | f, c | e, z | f, b | d, c | f, c | z, a | e, z | z, z | d, c | f, z | z, a | f, c | z, z | e, b | d, b | e, z | e, a | d];
146
- a = 1 << 18;
147
- b = 1 << 28;
148
- c = a | b;
149
- d = 1 << 6;
150
- e = 1 << 12;
151
- f = d | e;
152
- var SP8 = [b | f, z | e, a | z, c | f, b | z, b | f, z | d, b | z, a | d, c | z, c | f, a | e, c | e, a | f, z | e, z | d, c | z, b | d, b | e, z | f, a | e, a | d, c | d, c | e, z | f, z | z, z | z, c | d, b | d, b | e, a | f, a | z, a | f, a | z, c | e, z | e, z | d, c | d, z | e, a | f, b | e, z | d, b | d, c | z, c | d, b | z, a | z, b | f, z | z, c | f, a | d, b | d, c | z, b | e, b | f, z | z, c | f, a | e, a | e, z | f, z | f, a | d, b | z, c | e];
153
-
154
- /* eslint-enable comma-spacing */
155
- var DES = /*#__PURE__*/function () {
156
- function DES(password) {
157
- _classCallCheck(this, DES);
158
- this.keys = [];
159
-
160
- // Set the key.
161
- var pc1m = [],
162
- pcr = [],
163
- kn = [];
164
- for (var j = 0, l = 56; j < 56; ++j, l -= 8) {
165
- l += l < -5 ? 65 : l < -3 ? 31 : l < -1 ? 63 : l === 27 ? 35 : 0; // PC1
166
- var m = l & 0x7;
167
- pc1m[j] = (password[l >>> 3] & 1 << m) !== 0 ? 1 : 0;
168
- }
169
- for (var i = 0; i < 16; ++i) {
170
- var _m = i << 1;
171
- var n = _m + 1;
172
- kn[_m] = kn[n] = 0;
173
- for (var o = 28; o < 59; o += 28) {
174
- for (var _j = o - 28; _j < o; ++_j) {
175
- var _l = _j + totrot[i];
176
- pcr[_j] = _l < o ? pc1m[_l] : pc1m[_l - 28];
177
- }
178
- }
179
- for (var _j2 = 0; _j2 < 24; ++_j2) {
180
- if (pcr[PC2[_j2]] !== 0) {
181
- kn[_m] |= 1 << 23 - _j2;
182
- }
183
- if (pcr[PC2[_j2 + 24]] !== 0) {
184
- kn[n] |= 1 << 23 - _j2;
185
- }
186
- }
187
- }
188
-
189
- // cookey
190
- for (var _i = 0, rawi = 0, KnLi = 0; _i < 16; ++_i) {
191
- var raw0 = kn[rawi++];
192
- var raw1 = kn[rawi++];
193
- this.keys[KnLi] = (raw0 & 0x00fc0000) << 6;
194
- this.keys[KnLi] |= (raw0 & 0x00000fc0) << 10;
195
- this.keys[KnLi] |= (raw1 & 0x00fc0000) >>> 10;
196
- this.keys[KnLi] |= (raw1 & 0x00000fc0) >>> 6;
197
- ++KnLi;
198
- this.keys[KnLi] = (raw0 & 0x0003f000) << 12;
199
- this.keys[KnLi] |= (raw0 & 0x0000003f) << 16;
200
- this.keys[KnLi] |= (raw1 & 0x0003f000) >>> 4;
201
- this.keys[KnLi] |= raw1 & 0x0000003f;
202
- ++KnLi;
203
- }
204
- }
205
-
206
- // Encrypt 8 bytes of text
207
- return _createClass(DES, [{
208
- key: "enc8",
209
- value: function enc8(text) {
210
- var b = text.slice();
211
- var i = 0,
212
- l,
213
- r,
214
- x; // left, right, accumulator
215
-
216
- // Squash 8 bytes to 2 ints
217
- l = b[i++] << 24 | b[i++] << 16 | b[i++] << 8 | b[i++];
218
- r = b[i++] << 24 | b[i++] << 16 | b[i++] << 8 | b[i++];
219
- x = (l >>> 4 ^ r) & 0x0f0f0f0f;
220
- r ^= x;
221
- l ^= x << 4;
222
- x = (l >>> 16 ^ r) & 0x0000ffff;
223
- r ^= x;
224
- l ^= x << 16;
225
- x = (r >>> 2 ^ l) & 0x33333333;
226
- l ^= x;
227
- r ^= x << 2;
228
- x = (r >>> 8 ^ l) & 0x00ff00ff;
229
- l ^= x;
230
- r ^= x << 8;
231
- r = r << 1 | r >>> 31 & 1;
232
- x = (l ^ r) & 0xaaaaaaaa;
233
- l ^= x;
234
- r ^= x;
235
- l = l << 1 | l >>> 31 & 1;
236
- for (var _i2 = 0, keysi = 0; _i2 < 8; ++_i2) {
237
- x = r << 28 | r >>> 4;
238
- x ^= this.keys[keysi++];
239
- var fval = SP7[x & 0x3f];
240
- fval |= SP5[x >>> 8 & 0x3f];
241
- fval |= SP3[x >>> 16 & 0x3f];
242
- fval |= SP1[x >>> 24 & 0x3f];
243
- x = r ^ this.keys[keysi++];
244
- fval |= SP8[x & 0x3f];
245
- fval |= SP6[x >>> 8 & 0x3f];
246
- fval |= SP4[x >>> 16 & 0x3f];
247
- fval |= SP2[x >>> 24 & 0x3f];
248
- l ^= fval;
249
- x = l << 28 | l >>> 4;
250
- x ^= this.keys[keysi++];
251
- fval = SP7[x & 0x3f];
252
- fval |= SP5[x >>> 8 & 0x3f];
253
- fval |= SP3[x >>> 16 & 0x3f];
254
- fval |= SP1[x >>> 24 & 0x3f];
255
- x = l ^ this.keys[keysi++];
256
- fval |= SP8[x & 0x0000003f];
257
- fval |= SP6[x >>> 8 & 0x3f];
258
- fval |= SP4[x >>> 16 & 0x3f];
259
- fval |= SP2[x >>> 24 & 0x3f];
260
- r ^= fval;
261
- }
262
- r = r << 31 | r >>> 1;
263
- x = (l ^ r) & 0xaaaaaaaa;
264
- l ^= x;
265
- r ^= x;
266
- l = l << 31 | l >>> 1;
267
- x = (l >>> 8 ^ r) & 0x00ff00ff;
268
- r ^= x;
269
- l ^= x << 8;
270
- x = (l >>> 2 ^ r) & 0x33333333;
271
- r ^= x;
272
- l ^= x << 2;
273
- x = (r >>> 16 ^ l) & 0x0000ffff;
274
- l ^= x;
275
- r ^= x << 16;
276
- x = (r >>> 4 ^ l) & 0x0f0f0f0f;
277
- l ^= x;
278
- r ^= x << 4;
279
-
280
- // Spread ints to bytes
281
- x = [r, l];
282
- for (i = 0; i < 8; i++) {
283
- b[i] = (x[i >>> 2] >>> 8 * (3 - i % 4)) % 256;
284
- if (b[i] < 0) {
285
- b[i] += 256;
286
- } // unsigned
287
- }
288
- return b;
289
- }
290
- }]);
291
- }();
292
- var DESECBCipher = exports.DESECBCipher = /*#__PURE__*/function () {
293
- function DESECBCipher() {
294
- _classCallCheck(this, DESECBCipher);
295
- this._cipher = null;
296
- }
297
- return _createClass(DESECBCipher, [{
298
- key: "algorithm",
299
- get: function get() {
300
- return {
301
- name: "DES-ECB"
302
- };
303
- }
304
- }, {
305
- key: "_importKey",
306
- value: function _importKey(key, _extractable, _keyUsages) {
307
- this._cipher = new DES(key);
308
- }
309
- }, {
310
- key: "encrypt",
311
- value: function encrypt(_algorithm, plaintext) {
312
- var x = new Uint8Array(plaintext);
313
- if (x.length % 8 !== 0 || this._cipher === null) {
314
- return null;
315
- }
316
- var n = x.length / 8;
317
- for (var i = 0; i < n; i++) {
318
- x.set(this._cipher.enc8(x.slice(i * 8, i * 8 + 8)), i * 8);
319
- }
320
- return x;
321
- }
322
- }], [{
323
- key: "importKey",
324
- value: function importKey(key, _algorithm, _extractable, _keyUsages) {
325
- var cipher = new DESECBCipher();
326
- cipher._importKey(key);
327
- return cipher;
328
- }
329
- }]);
330
- }();
331
- var DESCBCCipher = exports.DESCBCCipher = /*#__PURE__*/function () {
332
- function DESCBCCipher() {
333
- _classCallCheck(this, DESCBCCipher);
334
- this._cipher = null;
335
- }
336
- return _createClass(DESCBCCipher, [{
337
- key: "algorithm",
338
- get: function get() {
339
- return {
340
- name: "DES-CBC"
341
- };
342
- }
343
- }, {
344
- key: "_importKey",
345
- value: function _importKey(key) {
346
- this._cipher = new DES(key);
347
- }
348
- }, {
349
- key: "encrypt",
350
- value: function encrypt(algorithm, plaintext) {
351
- var x = new Uint8Array(plaintext);
352
- var y = new Uint8Array(algorithm.iv);
353
- if (x.length % 8 !== 0 || this._cipher === null) {
354
- return null;
355
- }
356
- var n = x.length / 8;
357
- for (var i = 0; i < n; i++) {
358
- for (var j = 0; j < 8; j++) {
359
- y[j] ^= plaintext[i * 8 + j];
360
- }
361
- y = this._cipher.enc8(y);
362
- x.set(y, i * 8);
363
- }
364
- return x;
365
- }
366
- }], [{
367
- key: "importKey",
368
- value: function importKey(key, _algorithm, _extractable, _keyUsages) {
369
- var cipher = new DESCBCCipher();
370
- cipher._importKey(key);
371
- return cipher;
372
- }
373
- }]);
374
- }();
package/lib/crypto/dh.js DELETED
@@ -1,81 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.DHCipher = void 0;
7
- var _bigint = require("./bigint.js");
8
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
9
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
10
- function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
11
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
12
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
13
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
14
- var DHPublicKey = /*#__PURE__*/function () {
15
- function DHPublicKey(key) {
16
- _classCallCheck(this, DHPublicKey);
17
- this._key = key;
18
- }
19
- return _createClass(DHPublicKey, [{
20
- key: "algorithm",
21
- get: function get() {
22
- return {
23
- name: "DH"
24
- };
25
- }
26
- }, {
27
- key: "exportKey",
28
- value: function exportKey() {
29
- return this._key;
30
- }
31
- }]);
32
- }();
33
- var DHCipher = exports.DHCipher = /*#__PURE__*/function () {
34
- function DHCipher() {
35
- _classCallCheck(this, DHCipher);
36
- this._g = null;
37
- this._p = null;
38
- this._gBigInt = null;
39
- this._pBigInt = null;
40
- this._privateKey = null;
41
- }
42
- return _createClass(DHCipher, [{
43
- key: "algorithm",
44
- get: function get() {
45
- return {
46
- name: "DH"
47
- };
48
- }
49
- }, {
50
- key: "_generateKey",
51
- value: function _generateKey(algorithm) {
52
- var g = algorithm.g;
53
- var p = algorithm.p;
54
- this._keyBytes = p.length;
55
- this._gBigInt = (0, _bigint.u8ArrayToBigInt)(g);
56
- this._pBigInt = (0, _bigint.u8ArrayToBigInt)(p);
57
- this._privateKey = window.crypto.getRandomValues(new Uint8Array(this._keyBytes));
58
- this._privateKeyBigInt = (0, _bigint.u8ArrayToBigInt)(this._privateKey);
59
- this._publicKey = (0, _bigint.bigIntToU8Array)((0, _bigint.modPow)(this._gBigInt, this._privateKeyBigInt, this._pBigInt), this._keyBytes);
60
- }
61
- }, {
62
- key: "deriveBits",
63
- value: function deriveBits(algorithm, length) {
64
- var bytes = Math.ceil(length / 8);
65
- var pkey = new Uint8Array(algorithm["public"]);
66
- var len = bytes > this._keyBytes ? bytes : this._keyBytes;
67
- var secret = (0, _bigint.modPow)((0, _bigint.u8ArrayToBigInt)(pkey), this._privateKeyBigInt, this._pBigInt);
68
- return (0, _bigint.bigIntToU8Array)(secret, len).slice(0, len);
69
- }
70
- }], [{
71
- key: "generateKey",
72
- value: function generateKey(algorithm, _extractable) {
73
- var cipher = new DHCipher();
74
- cipher._generateKey(algorithm);
75
- return {
76
- privateKey: cipher,
77
- publicKey: new DHPublicKey(cipher._publicKey)
78
- };
79
- }
80
- }]);
81
- }();