module-develop-kit 1.4.0 → 1.4.2

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 (37) hide show
  1. package/dist/commonjs-virtual-dir/browser.js +2 -5
  2. package/dist/commonjs-virtual-dir/browser2.js +5 -2
  3. package/dist/commonjs-virtual-dir/index2.js +2 -5
  4. package/dist/commonjs-virtual-dir/index3.js +4 -2
  5. package/dist/commonjs-virtual-dir/index4.js +2 -2
  6. package/dist/main.d.ts +60 -14
  7. package/dist/main.js +19 -19
  8. package/dist/src/shield/gcm-crypto/axios-adapter.js +82 -0
  9. package/dist/src/shield/gcm-crypto/constants.js +4 -0
  10. package/dist/src/shield/gcm-crypto/gcm.config.js +60 -0
  11. package/dist/src/shield/gcm-crypto/index.js +22 -19
  12. package/dist/src/shield/gcm-crypto/utils.js +40 -0
  13. package/dist/types/axios.d.ts +20 -4
  14. package/dist/vendor/@tokenizer/inflate/lib/ZipHandler.js +1 -1
  15. package/dist/vendor/debug/src/browser.js +1 -1
  16. package/dist/vendor/ieee754/index.js +1 -1
  17. package/dist/vendor/sdp-transform/lib/index.js +1 -1
  18. package/dist/vendor/token-types/lib/index.js +1 -1
  19. package/package.json +1 -1
  20. package/dist/commonjs-virtual-dir/index5.js +0 -4
  21. package/dist/commonjs-virtual-dir/index6.js +0 -4
  22. package/dist/src/shield/crypto/const.js +0 -4
  23. package/dist/src/shield/crypto/sm2.js +0 -7
  24. package/dist/src/shield/crypto/util.js +0 -17
  25. package/dist/src/shield/gcm-crypto/gcm.service.js +0 -29
  26. package/dist/src/shield/gcm-crypto/hex.js +0 -18
  27. package/dist/src/shield/gcm-crypto/init.js +0 -61
  28. package/dist/src/shield/gcm-crypto/string.js +0 -10
  29. package/dist/vendor/jsbn/index.js +0 -714
  30. package/dist/vendor/sm-crypto/src/index.js +0 -14
  31. package/dist/vendor/sm-crypto/src/sm2/asn1.js +0 -86
  32. package/dist/vendor/sm-crypto/src/sm2/ec.js +0 -205
  33. package/dist/vendor/sm-crypto/src/sm2/index.js +0 -114
  34. package/dist/vendor/sm-crypto/src/sm2/sm3.js +0 -71
  35. package/dist/vendor/sm-crypto/src/sm2/utils.js +0 -95
  36. package/dist/vendor/sm-crypto/src/sm3/index.js +0 -50
  37. package/dist/vendor/sm-crypto/src/sm4/index.js +0 -408
@@ -1,14 +0,0 @@
1
- import { __require as i } from "./sm2/index.js";
2
- import { __require as m } from "./sm3/index.js";
3
- import { __require as u } from "./sm4/index.js";
4
- var r, e;
5
- function _() {
6
- return e || (e = 1, r = {
7
- sm2: i(),
8
- sm3: m(),
9
- sm4: u()
10
- }), r;
11
- }
12
- export {
13
- _ as __require
14
- };
@@ -1,86 +0,0 @@
1
- import { __require as R } from "../../../jsbn/index.js";
2
- var c, f;
3
- function m() {
4
- if (f) return c;
5
- f = 1;
6
- const { BigInteger: i } = R();
7
- function d(e) {
8
- let t = e.toString(16);
9
- if (t[0] !== "-")
10
- t.length % 2 === 1 ? t = "0" + t : t.match(/^[0-7]/) || (t = "00" + t);
11
- else {
12
- t = t.substr(1);
13
- let n = t.length;
14
- n % 2 === 1 ? n += 1 : t.match(/^[0-7]/) || (n += 2);
15
- let s = "";
16
- for (let r = 0; r < n; r++) s += "f";
17
- s = new i(s, 16), t = s.xor(e).add(i.ONE), t = t.toString(16).replace(/^-/, "");
18
- }
19
- return t;
20
- }
21
- class l {
22
- constructor() {
23
- this.tlv = null, this.t = "00", this.l = "00", this.v = "";
24
- }
25
- /**
26
- * 获取 der 编码比特流16进制串
27
- */
28
- getEncodedHex() {
29
- return this.tlv || (this.v = this.getValue(), this.l = this.getLength(), this.tlv = this.t + this.l + this.v), this.tlv;
30
- }
31
- getLength() {
32
- const t = this.v.length / 2;
33
- let n = t.toString(16);
34
- return n.length % 2 === 1 && (n = "0" + n), t < 128 ? n : (128 + n.length / 2).toString(16) + n;
35
- }
36
- getValue() {
37
- return "";
38
- }
39
- }
40
- class u extends l {
41
- constructor(t) {
42
- super(), this.t = "02", t && (this.v = d(t));
43
- }
44
- getValue() {
45
- return this.v;
46
- }
47
- }
48
- class v extends l {
49
- constructor(t) {
50
- super(), this.t = "30", this.asn1Array = t;
51
- }
52
- getValue() {
53
- return this.v = this.asn1Array.map((t) => t.getEncodedHex()).join(""), this.v;
54
- }
55
- }
56
- function h(e, t) {
57
- return +e[t + 2] < 8 ? 1 : +e.substr(t + 2, 2) & 128;
58
- }
59
- function g(e, t) {
60
- const n = h(e, t), s = e.substr(t + 2, n * 2);
61
- return s ? (+s[0] < 8 ? new i(s, 16) : new i(s.substr(2), 16)).intValue() : -1;
62
- }
63
- function o(e, t) {
64
- const n = h(e, t);
65
- return t + (n + 1) * 2;
66
- }
67
- return c = {
68
- /**
69
- * ASN.1 der 编码,针对 sm2 签名
70
- */
71
- encodeDer(e, t) {
72
- const n = new u(e), s = new u(t);
73
- return new v([n, s]).getEncodedHex();
74
- },
75
- /**
76
- * 解析 ASN.1 der,针对 sm2 验签
77
- */
78
- decodeDer(e) {
79
- const t = o(e, 0), n = o(e, t), s = g(e, t), r = e.substr(n, s * 2), a = n + r.length, S = o(e, a), x = g(e, a), b = e.substr(S, x * 2), q = new i(r, 16), w = new i(b, 16);
80
- return { r: q, s: w };
81
- }
82
- }, c;
83
- }
84
- export {
85
- m as __require
86
- };
@@ -1,205 +0,0 @@
1
- import { __require as H } from "../../../jsbn/index.js";
2
- var I, z;
3
- function k() {
4
- if (z) return I;
5
- z = 1;
6
- const { BigInteger: n } = H(), w = new n("2"), B = new n("3");
7
- class c {
8
- constructor(t, s) {
9
- this.x = s, this.q = t;
10
- }
11
- /**
12
- * 判断相等
13
- */
14
- equals(t) {
15
- return t === this ? !0 : this.q.equals(t.q) && this.x.equals(t.x);
16
- }
17
- /**
18
- * 返回具体数值
19
- */
20
- toBigInteger() {
21
- return this.x;
22
- }
23
- /**
24
- * 取反
25
- */
26
- negate() {
27
- return new c(this.q, this.x.negate().mod(this.q));
28
- }
29
- /**
30
- * 相加
31
- */
32
- add(t) {
33
- return new c(this.q, this.x.add(t.toBigInteger()).mod(this.q));
34
- }
35
- /**
36
- * 相减
37
- */
38
- subtract(t) {
39
- return new c(this.q, this.x.subtract(t.toBigInteger()).mod(this.q));
40
- }
41
- /**
42
- * 相乘
43
- */
44
- multiply(t) {
45
- return new c(this.q, this.x.multiply(t.toBigInteger()).mod(this.q));
46
- }
47
- /**
48
- * 相除
49
- */
50
- divide(t) {
51
- return new c(this.q, this.x.multiply(t.toBigInteger().modInverse(this.q)).mod(this.q));
52
- }
53
- /**
54
- * 平方
55
- */
56
- square() {
57
- return new c(this.q, this.x.square().mod(this.q));
58
- }
59
- }
60
- class l {
61
- constructor(t, s, e, i) {
62
- this.curve = t, this.x = s, this.y = e, this.z = i ?? n.ONE, this.zinv = null;
63
- }
64
- getX() {
65
- return this.zinv === null && (this.zinv = this.z.modInverse(this.curve.q)), this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q));
66
- }
67
- getY() {
68
- return this.zinv === null && (this.zinv = this.z.modInverse(this.curve.q)), this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q));
69
- }
70
- /**
71
- * 判断相等
72
- */
73
- equals(t) {
74
- return t === this ? !0 : this.isInfinity() ? t.isInfinity() : t.isInfinity() ? this.isInfinity() : t.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(n.ZERO) ? t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(n.ZERO) : !1;
75
- }
76
- /**
77
- * 是否是无穷远点
78
- */
79
- isInfinity() {
80
- return this.x === null && this.y === null ? !0 : this.z.equals(n.ZERO) && !this.y.toBigInteger().equals(n.ZERO);
81
- }
82
- /**
83
- * 取反,x 轴对称点
84
- */
85
- negate() {
86
- return new l(this.curve, this.x, this.y.negate(), this.z);
87
- }
88
- /**
89
- * 相加
90
- *
91
- * 标准射影坐标系:
92
- *
93
- * λ1 = x1 * z2
94
- * λ2 = x2 * z1
95
- * λ3 = λ1 − λ2
96
- * λ4 = y1 * z2
97
- * λ5 = y2 * z1
98
- * λ6 = λ4 − λ5
99
- * λ7 = λ1 + λ2
100
- * λ8 = z1 * z2
101
- * λ9 = λ3^2
102
- * λ10 = λ3 * λ9
103
- * λ11 = λ8 * λ6^2 − λ7 * λ9
104
- * x3 = λ3 * λ11
105
- * y3 = λ6 * (λ9 * λ1 − λ11) − λ4 * λ10
106
- * z3 = λ10 * λ8
107
- */
108
- add(t) {
109
- if (this.isInfinity()) return t;
110
- if (t.isInfinity()) return this;
111
- const s = this.x.toBigInteger(), e = this.y.toBigInteger(), i = this.z, u = t.x.toBigInteger(), o = t.y.toBigInteger(), h = t.z, r = this.curve.q, m = s.multiply(h).mod(r), a = u.multiply(i).mod(r), g = m.subtract(a), q = e.multiply(h).mod(r), f = o.multiply(i).mod(r), y = q.subtract(f);
112
- if (n.ZERO.equals(g))
113
- return n.ZERO.equals(y) ? this.twice() : this.curve.infinity;
114
- const O = m.add(a), v = i.multiply(h).mod(r), d = g.square().mod(r), p = g.multiply(d).mod(r), x = v.multiply(y.square()).subtract(O.multiply(d)).mod(r), R = g.multiply(x).mod(r), Z = y.multiply(d.multiply(m).subtract(x)).subtract(q.multiply(p)).mod(r), L = p.multiply(v).mod(r);
115
- return new l(this.curve, this.curve.fromBigInteger(R), this.curve.fromBigInteger(Z), L);
116
- }
117
- /**
118
- * 自加
119
- *
120
- * 标准射影坐标系:
121
- *
122
- * λ1 = 3 * x1^2 + a * z1^2
123
- * λ2 = 2 * y1 * z1
124
- * λ3 = y1^2
125
- * λ4 = λ3 * x1 * z1
126
- * λ5 = λ2^2
127
- * λ6 = λ1^2 − 8 * λ4
128
- * x3 = λ2 * λ6
129
- * y3 = λ1 * (4 * λ4 − λ6) − 2 * λ5 * λ3
130
- * z3 = λ2 * λ5
131
- */
132
- twice() {
133
- if (this.isInfinity()) return this;
134
- if (!this.y.toBigInteger().signum()) return this.curve.infinity;
135
- const t = this.x.toBigInteger(), s = this.y.toBigInteger(), e = this.z, i = this.curve.q, u = this.curve.a.toBigInteger(), o = t.square().multiply(B).add(u.multiply(e.square())).mod(i), h = s.shiftLeft(1).multiply(e).mod(i), r = s.square().mod(i), m = r.multiply(t).multiply(e).mod(i), a = h.square().mod(i), g = o.square().subtract(m.shiftLeft(3)).mod(i), q = h.multiply(g).mod(i), f = o.multiply(m.shiftLeft(2).subtract(g)).subtract(a.shiftLeft(1).multiply(r)).mod(i), y = h.multiply(a).mod(i);
136
- return new l(this.curve, this.curve.fromBigInteger(q), this.curve.fromBigInteger(f), y);
137
- }
138
- /**
139
- * 倍点计算
140
- */
141
- multiply(t) {
142
- if (this.isInfinity()) return this;
143
- if (!t.signum()) return this.curve.infinity;
144
- const s = t.multiply(B), e = this.negate();
145
- let i = this;
146
- for (let u = s.bitLength() - 2; u > 0; u--) {
147
- i = i.twice();
148
- const o = s.testBit(u), h = t.testBit(u);
149
- o !== h && (i = i.add(o ? this : e));
150
- }
151
- return i;
152
- }
153
- }
154
- class b {
155
- constructor(t, s, e) {
156
- this.q = t, this.a = this.fromBigInteger(s), this.b = this.fromBigInteger(e), this.infinity = new l(this, null, null);
157
- }
158
- /**
159
- * 判断两个椭圆曲线是否相等
160
- */
161
- equals(t) {
162
- return t === this ? !0 : this.q.equals(t.q) && this.a.equals(t.a) && this.b.equals(t.b);
163
- }
164
- /**
165
- * 生成椭圆曲线域元素
166
- */
167
- fromBigInteger(t) {
168
- return new c(this.q, t);
169
- }
170
- /**
171
- * 解析 16 进制串为椭圆曲线点
172
- */
173
- decodePointHex(t) {
174
- switch (parseInt(t.substr(0, 2), 16)) {
175
- // 第一个字节
176
- case 0:
177
- return this.infinity;
178
- case 2:
179
- case 3:
180
- const s = this.fromBigInteger(new n(t.substr(2), 16));
181
- let e = this.fromBigInteger(s.multiply(s.square()).add(
182
- s.multiply(this.a)
183
- ).add(this.b).toBigInteger().modPow(
184
- this.q.divide(new n("4")).add(n.ONE),
185
- this.q
186
- ));
187
- return e.toBigInteger().mod(w).equals(new n(t.substr(0, 2), 16).subtract(w)) || (e = e.negate()), new l(this, s, e);
188
- case 4:
189
- case 6:
190
- case 7:
191
- const i = (t.length - 2) / 2, u = t.substr(2, i), o = t.substr(i + 2, i);
192
- return new l(this, this.fromBigInteger(new n(u, 16)), this.fromBigInteger(new n(o, 16)));
193
- default:
194
- return null;
195
- }
196
- }
197
- }
198
- return I = {
199
- ECPointFp: l,
200
- ECCurveFp: b
201
- }, I;
202
- }
203
- export {
204
- k as __require
205
- };
@@ -1,114 +0,0 @@
1
- import { __require as O } from "../../../jsbn/index.js";
2
- import { __require as Y } from "./asn1.js";
3
- import { __require as z } from "./utils.js";
4
- import { __require as G } from "./sm3.js";
5
- var q, v;
6
- function J() {
7
- if (v) return q;
8
- v = 1;
9
- const { BigInteger: u } = O(), { encodeDer: _, decodeDer: S } = Y(), e = z(), H = G().sm3, { G: P, curve: B, n: m } = e.generateEcparam(), R = 0;
10
- function k(t, r, n = 1) {
11
- t = typeof t == "string" ? e.hexToArray(e.utf8ToHex(t)) : Array.prototype.slice.call(t), r = e.getGlobalCurve().decodePointHex(r);
12
- const g = e.generateKeyPairHex(), y = new u(g.privateKey, 16);
13
- let i = g.publicKey;
14
- i.length > 128 && (i = i.substr(i.length - 128));
15
- const l = r.multiply(y), f = e.hexToArray(e.leftPad(l.getX().toBigInteger().toRadix(16), 64)), a = e.hexToArray(e.leftPad(l.getY().toBigInteger().toRadix(16), 64)), x = e.arrayToHex(H([].concat(f, t, a)));
16
- let s = 1, o = 0, c = [];
17
- const d = [].concat(f, a), h = () => {
18
- c = H([...d, s >> 24 & 255, s >> 16 & 255, s >> 8 & 255, s & 255]), s++, o = 0;
19
- };
20
- h();
21
- for (let p = 0, b = t.length; p < b; p++)
22
- o === c.length && h(), t[p] ^= c[o++] & 255;
23
- const T = e.arrayToHex(t);
24
- return n === R ? i + T + x : i + x + T;
25
- }
26
- function C(t, r, n = 1, {
27
- output: g = "string"
28
- } = {}) {
29
- r = new u(r, 16);
30
- let y = t.substr(128, 64), i = t.substr(192);
31
- n === R && (y = t.substr(t.length - 64), i = t.substr(128, t.length - 128 - 64));
32
- const l = e.hexToArray(i), a = e.getGlobalCurve().decodePointHex("04" + t.substr(0, 128)).multiply(r), x = e.hexToArray(e.leftPad(a.getX().toBigInteger().toRadix(16), 64)), s = e.hexToArray(e.leftPad(a.getY().toBigInteger().toRadix(16), 64));
33
- let o = 1, c = 0, d = [];
34
- const h = [].concat(x, s), T = () => {
35
- d = H([...h, o >> 24 & 255, o >> 16 & 255, o >> 8 & 255, o & 255]), o++, c = 0;
36
- };
37
- T();
38
- for (let b = 0, K = l.length; b < K; b++)
39
- c === d.length && T(), l[b] ^= d[c++] & 255;
40
- return e.arrayToHex(H([].concat(x, l, s))) === y.toLowerCase() ? g === "array" ? l : e.arrayToUtf8(l) : g === "array" ? [] : "";
41
- }
42
- function X(t, r, {
43
- pointPool: n,
44
- der: g,
45
- hash: y,
46
- publicKey: i,
47
- userId: l
48
- } = {}) {
49
- let f = typeof t == "string" ? e.utf8ToHex(t) : e.arrayToHex(t);
50
- y && (i = i || I(r), f = A(f, i, l));
51
- const a = new u(r, 16), x = new u(f, 16);
52
- let s = null, o = null, c = null;
53
- do {
54
- do {
55
- let d;
56
- n && n.length ? d = n.pop() : d = w(), s = d.k, o = x.add(d.x1).mod(m);
57
- } while (o.equals(u.ZERO) || o.add(s).equals(m));
58
- c = a.add(u.ONE).modInverse(m).multiply(s.subtract(o.multiply(a))).mod(m);
59
- } while (c.equals(u.ZERO));
60
- return g ? _(o, c) : e.leftPad(o.toString(16), 64) + e.leftPad(c.toString(16), 64);
61
- }
62
- function E(t, r, n, { der: g, hash: y, userId: i } = {}) {
63
- let l = typeof t == "string" ? e.utf8ToHex(t) : e.arrayToHex(t);
64
- y && (l = A(l, n, i));
65
- let f, a;
66
- if (g) {
67
- const h = S(r);
68
- f = h.r, a = h.s;
69
- } else
70
- f = new u(r.substring(0, 64), 16), a = new u(r.substring(64), 16);
71
- const x = B.decodePointHex(n), s = new u(l, 16), o = f.add(a).mod(m);
72
- if (o.equals(u.ZERO)) return !1;
73
- const c = P.multiply(a).add(x.multiply(o)), d = s.add(c.getX().toBigInteger()).mod(m);
74
- return f.equals(d);
75
- }
76
- function A(t, r, n = "1234567812345678") {
77
- n = e.utf8ToHex(n);
78
- const g = e.leftPad(P.curve.a.toBigInteger().toRadix(16), 64), y = e.leftPad(P.curve.b.toBigInteger().toRadix(16), 64), i = e.leftPad(P.getX().toBigInteger().toRadix(16), 64), l = e.leftPad(P.getY().toBigInteger().toRadix(16), 64);
79
- let f, a;
80
- if (r.length === 128)
81
- f = r.substr(0, 64), a = r.substr(64, 64);
82
- else {
83
- const c = P.curve.decodePointHex(r);
84
- f = e.leftPad(c.getX().toBigInteger().toRadix(16), 64), a = e.leftPad(c.getY().toBigInteger().toRadix(16), 64);
85
- }
86
- const x = e.hexToArray(n + g + y + i + l + f + a), s = n.length * 4;
87
- x.unshift(s & 255), x.unshift(s >> 8 & 255);
88
- const o = H(x);
89
- return e.arrayToHex(H(o.concat(e.hexToArray(t))));
90
- }
91
- function I(t) {
92
- const r = P.multiply(new u(t, 16)), n = e.leftPad(r.getX().toBigInteger().toString(16), 64), g = e.leftPad(r.getY().toBigInteger().toString(16), 64);
93
- return "04" + n + g;
94
- }
95
- function w() {
96
- const t = e.generateKeyPairHex(), r = B.decodePointHex(t.publicKey);
97
- return t.k = new u(t.privateKey, 16), t.x1 = r.getX().toBigInteger(), t;
98
- }
99
- return q = {
100
- generateKeyPairHex: e.generateKeyPairHex,
101
- compressPublicKeyHex: e.compressPublicKeyHex,
102
- comparePublicKeyHex: e.comparePublicKeyHex,
103
- doEncrypt: k,
104
- doDecrypt: C,
105
- doSignature: X,
106
- doVerifySignature: E,
107
- getPublicKeyFromPrivateKey: I,
108
- getPoint: w,
109
- verifyPublicKey: e.verifyPublicKey
110
- }, q;
111
- }
112
- export {
113
- J as __require
114
- };
@@ -1,71 +0,0 @@
1
- var p, B;
2
- function M() {
3
- if (B) return p;
4
- B = 1;
5
- const f = new Uint32Array(68), T = new Uint32Array(64);
6
- function s(n, e) {
7
- const o = e & 31;
8
- return n << o | n >>> 32 - o;
9
- }
10
- function j(n, e) {
11
- const o = [];
12
- for (let i = n.length - 1; i >= 0; i--) o[i] = (n[i] ^ e[i]) & 255;
13
- return o;
14
- }
15
- function C(n) {
16
- return n ^ s(n, 9) ^ s(n, 17);
17
- }
18
- function E(n) {
19
- return n ^ s(n, 15) ^ s(n, 23);
20
- }
21
- function S(n) {
22
- let e = n.length * 8, o = e % 512;
23
- o = o >= 448 ? 512 - o % 448 - 1 : 448 - o - 1;
24
- const i = new Array((o - 7) / 8), u = new Array(8);
25
- for (let r = 0, c = i.length; r < c; r++) i[r] = 0;
26
- for (let r = 0, c = u.length; r < c; r++) u[r] = 0;
27
- e = e.toString(2);
28
- for (let r = 7; r >= 0; r--)
29
- if (e.length > 8) {
30
- const c = e.length - 8;
31
- u[r] = parseInt(e.substr(c), 2), e = e.substr(0, c);
32
- } else e.length > 0 && (u[r] = parseInt(e, 2), e = "");
33
- const V = new Uint8Array([...n, 128, ...i, ...u]), G = new DataView(V.buffer, 0), H = V.length / 64, l = new Uint32Array([1937774191, 1226093241, 388252375, 3666478592, 2842636476, 372324522, 3817729613, 2969243214]);
34
- for (let r = 0; r < H; r++) {
35
- f.fill(0), T.fill(0);
36
- const c = 16 * r;
37
- for (let t = 0; t < 16; t++)
38
- f[t] = G.getUint32((c + t) * 4, !1);
39
- for (let t = 16; t < 68; t++)
40
- f[t] = E(f[t - 16] ^ f[t - 9] ^ s(f[t - 3], 15)) ^ s(f[t - 13], 7) ^ f[t - 6];
41
- for (let t = 0; t < 64; t++)
42
- T[t] = f[t] ^ f[t + 4];
43
- const x = 2043430169, L = 2055708042;
44
- let a = l[0], g = l[1], w = l[2], U = l[3], h = l[4], A = l[5], b = l[6], m = l[7], P, v, D, I, K;
45
- for (let t = 0; t < 64; t++)
46
- K = t >= 0 && t <= 15 ? x : L, P = s(s(a, 12) + h + s(K, t), 7), v = P ^ s(a, 12), D = (t >= 0 && t <= 15 ? a ^ g ^ w : a & g | a & w | g & w) + U + v + T[t], I = (t >= 0 && t <= 15 ? h ^ A ^ b : h & A | ~h & b) + m + P + f[t], U = w, w = s(g, 9), g = a, a = D, m = b, b = s(A, 19), A = h, h = C(I);
47
- l[0] ^= a, l[1] ^= g, l[2] ^= w, l[3] ^= U, l[4] ^= h, l[5] ^= A, l[6] ^= b, l[7] ^= m;
48
- }
49
- const _ = [];
50
- for (let r = 0, c = l.length; r < c; r++) {
51
- const x = l[r];
52
- _.push((x & 4278190080) >>> 24, (x & 16711680) >>> 16, (x & 65280) >>> 8, x & 255);
53
- }
54
- return _;
55
- }
56
- const d = 64, q = new Uint8Array(d), y = new Uint8Array(d);
57
- for (let n = 0; n < d; n++)
58
- q[n] = 54, y[n] = 92;
59
- function F(n, e) {
60
- for (e.length > d && (e = S(e)); e.length < d; ) e.push(0);
61
- const o = j(e, q), i = j(e, y), u = S([...o, ...n]);
62
- return S([...i, ...u]);
63
- }
64
- return p = {
65
- sm3: S,
66
- hmac: F
67
- }, p;
68
- }
69
- export {
70
- M as __require
71
- };
@@ -1,95 +0,0 @@
1
- import { __require as v } from "../../../jsbn/index.js";
2
- import { __require as I } from "./ec.js";
3
- var l, d;
4
- function _() {
5
- if (d) return l;
6
- d = 1;
7
- const { BigInteger: o, SecureRandom: h } = v(), { ECCurveFp: p } = I(), x = new h(), { curve: s, G: C, n: f } = g();
8
- function y() {
9
- return s;
10
- }
11
- function g() {
12
- const F = new o("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFF", 16), e = new o("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFC", 16), n = new o("28E9FA9E9D9F5E344D5A9E4BCF6509A7F39789F515AB8F92DDBCBD414D940E93", 16), t = new p(F, e, n), u = t.decodePointHex("04" + "32C4AE2C1F1981195F9904466A39C9948FE30BBFF2660BE1715A4589334C74C7" + "BC3736A2F4F6779C59BDCEE36B692153D0A9877CC62A474002DF32E52139F0A0"), a = new o("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFF7203DF6B21C6052B53BBF40939D54123", 16);
13
- return { curve: t, G: u, n: a };
14
- }
15
- function E(F, e, n) {
16
- const r = (F ? new o(F, e, n) : new o(f.bitLength(), x)).mod(f.subtract(o.ONE)).add(o.ONE), c = i(r.toString(16), 64), u = C.multiply(r), a = i(u.getX().toBigInteger().toString(16), 64), P = i(u.getY().toBigInteger().toString(16), 64), D = "04" + a + P;
17
- return { privateKey: c, publicKey: D };
18
- }
19
- function w(F) {
20
- if (F.length !== 130) throw new Error("Invalid public key to compress");
21
- const e = (F.length - 2) / 2, n = F.substr(2, e), t = new o(F.substr(e + 2, e), 16);
22
- let r = "03";
23
- return t.mod(new o("2")).equals(o.ZERO) && (r = "02"), r + n;
24
- }
25
- function B(F) {
26
- F = unescape(encodeURIComponent(F));
27
- const e = F.length, n = [];
28
- for (let r = 0; r < e; r++)
29
- n[r >>> 2] |= (F.charCodeAt(r) & 255) << 24 - r % 4 * 8;
30
- const t = [];
31
- for (let r = 0; r < e; r++) {
32
- const c = n[r >>> 2] >>> 24 - r % 4 * 8 & 255;
33
- t.push((c >>> 4).toString(16)), t.push((c & 15).toString(16));
34
- }
35
- return t.join("");
36
- }
37
- function i(F, e) {
38
- return F.length >= e ? F : new Array(e - F.length + 1).join("0") + F;
39
- }
40
- function b(F) {
41
- return F.map((e) => (e = e.toString(16), e.length === 1 ? "0" + e : e)).join("");
42
- }
43
- function m(F) {
44
- const e = [];
45
- let n = 0;
46
- for (let t = 0; t < F.length * 2; t += 2)
47
- e[t >>> 3] |= parseInt(F[n], 10) << 24 - t % 8 * 4, n++;
48
- try {
49
- const t = [];
50
- for (let r = 0; r < F.length; r++) {
51
- const c = e[r >>> 2] >>> 24 - r % 4 * 8 & 255;
52
- t.push(String.fromCharCode(c));
53
- }
54
- return decodeURIComponent(escape(t.join("")));
55
- } catch {
56
- throw new Error("Malformed UTF-8 data");
57
- }
58
- }
59
- function A(F) {
60
- const e = [];
61
- let n = F.length;
62
- n % 2 !== 0 && (F = i(F, n + 1)), n = F.length;
63
- for (let t = 0; t < n; t += 2)
64
- e.push(parseInt(F.substr(t, 2), 16));
65
- return e;
66
- }
67
- function H(F) {
68
- const e = s.decodePointHex(F);
69
- if (!e) return !1;
70
- const n = e.getX();
71
- return e.getY().square().equals(n.multiply(n.square()).add(n.multiply(s.a)).add(s.b));
72
- }
73
- function q(F, e) {
74
- const n = s.decodePointHex(F);
75
- if (!n) return !1;
76
- const t = s.decodePointHex(e);
77
- return t ? n.equals(t) : !1;
78
- }
79
- return l = {
80
- getGlobalCurve: y,
81
- generateEcparam: g,
82
- generateKeyPairHex: E,
83
- compressPublicKeyHex: w,
84
- utf8ToHex: B,
85
- leftPad: i,
86
- arrayToHex: b,
87
- arrayToUtf8: m,
88
- hexToArray: A,
89
- verifyPublicKey: H,
90
- comparePublicKeyHex: q
91
- }, l;
92
- }
93
- export {
94
- _ as __require
95
- };
@@ -1,50 +0,0 @@
1
- import { __require as c } from "../sm2/sm3.js";
2
- var f, u;
3
- function y() {
4
- if (u) return f;
5
- u = 1;
6
- const { sm3: i, hmac: h } = c();
7
- function l(e, r) {
8
- return e.length >= r ? e : new Array(r - e.length + 1).join("0") + e;
9
- }
10
- function s(e) {
11
- return e.map((r) => (r = r.toString(16), r.length === 1 ? "0" + r : r)).join("");
12
- }
13
- function x(e) {
14
- const r = [];
15
- let t = e.length;
16
- t % 2 !== 0 && (e = l(e, t + 1)), t = e.length;
17
- for (let o = 0; o < t; o += 2)
18
- r.push(parseInt(e.substr(o, 2), 16));
19
- return r;
20
- }
21
- function a(e) {
22
- const r = [];
23
- for (let t = 0, o = e.length; t < o; t++) {
24
- const n = e.codePointAt(t);
25
- if (n <= 127)
26
- r.push(n);
27
- else if (n <= 2047)
28
- r.push(192 | n >>> 6), r.push(128 | n & 63);
29
- else if (n <= 55295 || n >= 57344 && n <= 65535)
30
- r.push(224 | n >>> 12), r.push(128 | n >>> 6 & 63), r.push(128 | n & 63);
31
- else if (n >= 65536 && n <= 1114111)
32
- t++, r.push(240 | n >>> 18 & 28), r.push(128 | n >>> 12 & 63), r.push(128 | n >>> 6 & 63), r.push(128 | n & 63);
33
- else
34
- throw r.push(n), new Error("input is not supported");
35
- }
36
- return r;
37
- }
38
- return f = function(e, r) {
39
- if (e = typeof e == "string" ? a(e) : Array.prototype.slice.call(e), r) {
40
- if ((r.mode || "hmac") !== "hmac") throw new Error("invalid mode");
41
- let o = r.key;
42
- if (!o) throw new Error("invalid key");
43
- return o = typeof o == "string" ? x(o) : Array.prototype.slice.call(o), s(h(e, o));
44
- }
45
- return s(i(e));
46
- }, f;
47
- }
48
- export {
49
- y as __require
50
- };