orion-design 0.1.48 → 0.1.50

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. package/dist/base64-KVpG-D_n.js +103 -0
  2. package/dist/base64-KVpG-D_n.js.map +1 -0
  3. package/dist/components/Button/index.d.ts +217 -4
  4. package/dist/components/Button/index.js +17 -25
  5. package/dist/components/Button/index.js.map +1 -1
  6. package/dist/components/Card/index.d.ts +1 -3
  7. package/dist/components/Form/FileInput/FileInput.vue.d.ts +3 -100
  8. package/dist/components/Form/Form.vue.d.ts +2 -70
  9. package/dist/components/Form/LovInput/LovInput.vue.d.ts +21526 -1248
  10. package/dist/components/Form/TableSelect/TableSelect.vue.d.ts +21526 -1248
  11. package/dist/components/Form/index.d.ts +2 -38
  12. package/dist/components/Form/index.js +126 -127
  13. package/dist/components/Form/index.js.map +1 -1
  14. package/dist/components/LovTable/LovPagetable.vue.d.ts +2 -262
  15. package/dist/components/LovTable/LovQuerytable.vue.d.ts +2 -178
  16. package/dist/components/LovTable/index.d.ts +4 -233
  17. package/dist/components/Message/index.d.ts +27 -0
  18. package/dist/components/Message/index.js +16 -0
  19. package/dist/components/Message/index.js.map +1 -0
  20. package/dist/components/MessageBox/index.d.ts +13 -0
  21. package/dist/components/MessageBox/index.js +27 -0
  22. package/dist/components/MessageBox/index.js.map +1 -0
  23. package/dist/components/Space/index.d.ts +1 -10
  24. package/dist/components/TableSelectPagetable/TableSelectPagetable.vue.d.ts +2 -262
  25. package/dist/components/TableSelectPagetable/index.d.ts +2 -136
  26. package/dist/components/Tabs/index.js +1 -1
  27. package/dist/components/Tree/Tree.vue.d.ts +2 -160
  28. package/dist/components/Tree/index.d.ts +2 -84
  29. package/dist/components/_util/dom/element.js +1 -1
  30. package/dist/components/_util/dom/style.js +1 -1
  31. package/dist/components/_util/error.js +1 -1
  32. package/dist/components/_util/functions.js +1 -1
  33. package/dist/components/_util/index.js +1 -1
  34. package/dist/components/_util/objects.js +1 -1
  35. package/dist/components/_util/strings.js +2 -2
  36. package/dist/components/_util/types.js +2 -2
  37. package/dist/components/_util/vue/install.js +1 -1
  38. package/dist/components/_util/vue/props/runtime.js +1 -1
  39. package/dist/components/_util/vue/refs.js +1 -1
  40. package/dist/components/_util/vue/vnode.js +1 -1
  41. package/dist/components/index.d.ts +2 -0
  42. package/dist/components/index.js +38 -34
  43. package/dist/components/index.js.map +1 -1
  44. package/dist/{functions-DzLqXvGt.js → functions-LOH6x_02.js} +2 -2
  45. package/dist/functions-LOH6x_02.js.map +1 -0
  46. package/dist/index-BW3nOBfD.js +714 -0
  47. package/dist/index-BW3nOBfD.js.map +1 -0
  48. package/dist/index.js +24 -20
  49. package/dist/index.js.map +1 -1
  50. package/dist/request/disivion/DivisionErrorHandler.d.ts +0 -2
  51. package/dist/request/disivion/DivisionErrorHandler.js +18 -28
  52. package/dist/request/disivion/DivisionErrorHandler.js.map +1 -1
  53. package/dist/request/disivion/index.d.ts +1 -0
  54. package/dist/request/disivion/index.js +73 -168
  55. package/dist/request/disivion/index.js.map +1 -1
  56. package/dist/request/error/ResponseError404.d.ts +7 -0
  57. package/dist/request/error/ResponseError404.js +10 -0
  58. package/dist/request/error/ResponseError404.js.map +1 -0
  59. package/dist/request/error/ResponseError500.d.ts +6 -0
  60. package/dist/request/error/ResponseError500.js +10 -0
  61. package/dist/request/error/ResponseError500.js.map +1 -0
  62. package/dist/request/error/{BizExceptionResponseError.d.ts → ResponseErrorBizException.d.ts} +1 -1
  63. package/dist/request/error/{BizExceptionResponseError.js → ResponseErrorBizException.js} +2 -2
  64. package/dist/request/error/ResponseErrorBizException.js.map +1 -0
  65. package/dist/request/error/{ExceptionResponseError.d.ts → ResponseErrorException.d.ts} +1 -1
  66. package/dist/request/error/{ExceptionResponseError.js → ResponseErrorException.js} +2 -2
  67. package/dist/request/error/ResponseErrorException.js.map +1 -0
  68. package/dist/request/error/{SessionExceptionResponseError.d.ts → ResponseErrorSessionException.d.ts} +1 -1
  69. package/dist/request/error/{SessionExceptionResponseError.js → ResponseErrorSessionException.js} +2 -2
  70. package/dist/request/error/{SessionExceptionResponseError.js.map → ResponseErrorSessionException.js.map} +1 -1
  71. package/dist/request/index.d.ts +12 -3
  72. package/dist/request/index.js +35 -11
  73. package/dist/request/index.js.map +1 -1
  74. package/dist/request/leaf7/Leaf7EncryptRequestParser.d.ts +8 -0
  75. package/dist/request/leaf7/Leaf7EncryptRequestParser.js +28 -0
  76. package/dist/request/leaf7/Leaf7EncryptRequestParser.js.map +1 -0
  77. package/dist/request/leaf7/Leaf7EncryptResponseParser.d.ts +8 -0
  78. package/dist/request/leaf7/Leaf7EncryptResponseParser.js +42 -0
  79. package/dist/request/leaf7/Leaf7EncryptResponseParser.js.map +1 -0
  80. package/dist/request/leaf7/Leaf7ErrorHandler.d.ts +7 -0
  81. package/dist/request/leaf7/Leaf7ErrorHandler.js +51 -0
  82. package/dist/request/leaf7/Leaf7ErrorHandler.js.map +1 -0
  83. package/dist/request/leaf7/Leaf7ResponseParser.d.ts +5 -0
  84. package/dist/request/leaf7/Leaf7ResponseParser.js +17 -0
  85. package/dist/request/leaf7/Leaf7ResponseParser.js.map +1 -0
  86. package/dist/request/leaf7/index.d.ts +20 -0
  87. package/dist/request/leaf7/index.js +130 -0
  88. package/dist/request/leaf7/index.js.map +1 -0
  89. package/dist/request/leaf7/smCrypto/sm2/asn1.d.ts +14 -0
  90. package/dist/request/leaf7/smCrypto/sm2/asn1.js +81 -0
  91. package/dist/request/leaf7/smCrypto/sm2/asn1.js.map +1 -0
  92. package/dist/request/leaf7/smCrypto/sm2/ec.d.ts +119 -0
  93. package/dist/request/leaf7/smCrypto/sm2/ec.js +199 -0
  94. package/dist/request/leaf7/smCrypto/sm2/ec.js.map +1 -0
  95. package/dist/request/leaf7/smCrypto/sm2/index.d.ts +45 -0
  96. package/dist/request/leaf7/smCrypto/sm2/index.js +102 -0
  97. package/dist/request/leaf7/smCrypto/sm2/index.js.map +1 -0
  98. package/dist/request/leaf7/smCrypto/sm2/sm3.d.ts +10 -0
  99. package/dist/request/leaf7/smCrypto/sm2/sm3.js +69 -0
  100. package/dist/request/leaf7/smCrypto/sm2/sm3.js.map +1 -0
  101. package/dist/request/leaf7/smCrypto/sm2/utils.d.ts +66 -0
  102. package/dist/request/leaf7/smCrypto/sm2/utils.js +91 -0
  103. package/dist/request/leaf7/smCrypto/sm2/utils.js.map +1 -0
  104. package/dist/request/leaf7/smCrypto/sm3/index.d.ts +1 -0
  105. package/dist/request/leaf7/smCrypto/sm3/index.js +45 -0
  106. package/dist/request/leaf7/smCrypto/sm3/index.js.map +1 -0
  107. package/dist/request/leaf7/smCrypto/sm4/index.d.ts +5 -0
  108. package/dist/request/leaf7/smCrypto/sm4/index.js +399 -0
  109. package/dist/request/leaf7/smCrypto/sm4/index.js.map +1 -0
  110. package/dist/request/leaf7/smCrypto/smCrypto.d.ts +3 -0
  111. package/dist/request/leaf7/smCrypto/smCrypto.js +9 -0
  112. package/dist/request/leaf7/smCrypto/smCrypto.js.map +1 -0
  113. package/dist/request/leaf7/types.d.ts +11 -0
  114. package/dist/request/leaf7/types.js +2 -0
  115. package/dist/request/leaf7/types.js.map +1 -0
  116. package/dist/request/utils/readBlob.d.ts +1 -0
  117. package/dist/request/utils/readBlob.js +12 -0
  118. package/dist/request/utils/readBlob.js.map +1 -0
  119. package/dist/utils/functions.js +1 -1
  120. package/dist/version/version.d.ts +1 -1
  121. package/dist/version/version.js +1 -1
  122. package/dist/version/version.js.map +1 -1
  123. package/package.json +2 -1
  124. package/dist/components/Button/Button.vue.d.ts +0 -16
  125. package/dist/functions-DzLqXvGt.js.map +0 -1
  126. package/dist/request/error/BizExceptionResponseError.js.map +0 -1
  127. package/dist/request/error/ExceptionResponseError.js.map +0 -1
@@ -0,0 +1,119 @@
1
+ /**
2
+ * 椭圆曲线域元素
3
+ */
4
+ declare class ECFieldElementFp {
5
+ constructor(q: any, x: any);
6
+ /**
7
+ * 判断相等
8
+ */
9
+ equals(other: any): any;
10
+ /**
11
+ * 返回具体数值
12
+ */
13
+ toBigInteger(): any;
14
+ /**
15
+ * 取反
16
+ */
17
+ negate(): ECFieldElementFp;
18
+ /**
19
+ * 相加
20
+ */
21
+ add(b: any): ECFieldElementFp;
22
+ /**
23
+ * 相减
24
+ */
25
+ subtract(b: any): ECFieldElementFp;
26
+ /**
27
+ * 相乘
28
+ */
29
+ multiply(b: any): ECFieldElementFp;
30
+ /**
31
+ * 相除
32
+ */
33
+ divide(b: any): ECFieldElementFp;
34
+ /**
35
+ * 平方
36
+ */
37
+ square(): ECFieldElementFp;
38
+ }
39
+ export declare class ECPointFp {
40
+ constructor(curve: any, x: any, y: any, z: any);
41
+ getX(): any;
42
+ getY(): any;
43
+ /**
44
+ * 判断相等
45
+ */
46
+ equals(other: any): any;
47
+ /**
48
+ * 是否是无穷远点
49
+ */
50
+ isInfinity(): any;
51
+ /**
52
+ * 取反,x 轴对称点
53
+ */
54
+ negate(): ECPointFp;
55
+ /**
56
+ * 相加
57
+ *
58
+ * 标准射影坐标系:
59
+ *
60
+ * λ1 = x1 * z2
61
+ * λ2 = x2 * z1
62
+ * λ3 = λ1 − λ2
63
+ * λ4 = y1 * z2
64
+ * λ5 = y2 * z1
65
+ * λ6 = λ4 − λ5
66
+ * λ7 = λ1 + λ2
67
+ * λ8 = z1 * z2
68
+ * λ9 = λ3^2
69
+ * λ10 = λ3 * λ9
70
+ * λ11 = λ8 * λ6^2 − λ7 * λ9
71
+ * x3 = λ3 * λ11
72
+ * y3 = λ6 * (λ9 * λ1 − λ11) − λ4 * λ10
73
+ * z3 = λ10 * λ8
74
+ */
75
+ add(b: any): any;
76
+ /**
77
+ * 自加
78
+ *
79
+ * 标准射影坐标系:
80
+ *
81
+ * λ1 = 3 * x1^2 + a * z1^2
82
+ * λ2 = 2 * y1 * z1
83
+ * λ3 = y1^2
84
+ * λ4 = λ3 * x1 * z1
85
+ * λ5 = λ2^2
86
+ * λ6 = λ1^2 − 8 * λ4
87
+ * x3 = λ2 * λ6
88
+ * y3 = λ1 * (4 * λ4 − λ6) − 2 * λ5 * λ3
89
+ * z3 = λ2 * λ5
90
+ */
91
+ twice(): any;
92
+ /**
93
+ * 倍点计算
94
+ */
95
+ multiply(k: any): any;
96
+ }
97
+ /**
98
+ * 椭圆曲线 y^2 = x^3 + ax + b
99
+ */
100
+ export declare class ECCurveFp {
101
+ constructor(q: any, a: any, b: any);
102
+ /**
103
+ * 判断两个椭圆曲线是否相等
104
+ */
105
+ equals(other: any): any;
106
+ /**
107
+ * 生成椭圆曲线域元素
108
+ */
109
+ fromBigInteger(x: any): ECFieldElementFp;
110
+ /**
111
+ * 解析 16 进制串为椭圆曲线点
112
+ */
113
+ decodePointHex(s: any): any;
114
+ }
115
+ declare const _default: {
116
+ ECPointFp: typeof ECPointFp;
117
+ ECCurveFp: typeof ECCurveFp;
118
+ };
119
+ export default _default;
@@ -0,0 +1,199 @@
1
+ import { j as n } from "../../../../index-BW3nOBfD.js";
2
+ const v = new n.BigInteger("2"), p = new n.BigInteger("3");
3
+ class h {
4
+ constructor(t, s) {
5
+ this.x = s, this.q = t;
6
+ }
7
+ /**
8
+ * 判断相等
9
+ */
10
+ equals(t) {
11
+ return t === this ? !0 : this.q.equals(t.q) && this.x.equals(t.x);
12
+ }
13
+ /**
14
+ * 返回具体数值
15
+ */
16
+ toBigInteger() {
17
+ return this.x;
18
+ }
19
+ /**
20
+ * 取反
21
+ */
22
+ negate() {
23
+ return new h(this.q, this.x.negate().mod(this.q));
24
+ }
25
+ /**
26
+ * 相加
27
+ */
28
+ add(t) {
29
+ return new h(this.q, this.x.add(t.toBigInteger()).mod(this.q));
30
+ }
31
+ /**
32
+ * 相减
33
+ */
34
+ subtract(t) {
35
+ return new h(this.q, this.x.subtract(t.toBigInteger()).mod(this.q));
36
+ }
37
+ /**
38
+ * 相乘
39
+ */
40
+ multiply(t) {
41
+ return new h(this.q, this.x.multiply(t.toBigInteger()).mod(this.q));
42
+ }
43
+ /**
44
+ * 相除
45
+ */
46
+ divide(t) {
47
+ return new h(this.q, this.x.multiply(t.toBigInteger().modInverse(this.q)).mod(this.q));
48
+ }
49
+ /**
50
+ * 平方
51
+ */
52
+ square() {
53
+ return new h(this.q, this.x.square().mod(this.q));
54
+ }
55
+ }
56
+ class c {
57
+ constructor(t, s, e, i) {
58
+ this.curve = t, this.x = s, this.y = e, this.z = i ?? n.BigInteger.ONE, this.zinv = null;
59
+ }
60
+ getX() {
61
+ 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));
62
+ }
63
+ getY() {
64
+ 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));
65
+ }
66
+ /**
67
+ * 判断相等
68
+ */
69
+ equals(t) {
70
+ 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.BigInteger.ZERO) ? t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(n.BigInteger.ZERO) : !1;
71
+ }
72
+ /**
73
+ * 是否是无穷远点
74
+ */
75
+ isInfinity() {
76
+ return this.x === null && this.y === null ? !0 : this.z.equals(n.BigInteger.ZERO) && !this.y.toBigInteger().equals(n.BigInteger.ZERO);
77
+ }
78
+ /**
79
+ * 取反,x 轴对称点
80
+ */
81
+ negate() {
82
+ return new c(this.curve, this.x, this.y.negate(), this.z);
83
+ }
84
+ /**
85
+ * 相加
86
+ *
87
+ * 标准射影坐标系:
88
+ *
89
+ * λ1 = x1 * z2
90
+ * λ2 = x2 * z1
91
+ * λ3 = λ1 − λ2
92
+ * λ4 = y1 * z2
93
+ * λ5 = y2 * z1
94
+ * λ6 = λ4 − λ5
95
+ * λ7 = λ1 + λ2
96
+ * λ8 = z1 * z2
97
+ * λ9 = λ3^2
98
+ * λ10 = λ3 * λ9
99
+ * λ11 = λ8 * λ6^2 − λ7 * λ9
100
+ * x3 = λ3 * λ11
101
+ * y3 = λ6 * (λ9 * λ1 − λ11) − λ4 * λ10
102
+ * z3 = λ10 * λ8
103
+ */
104
+ add(t) {
105
+ if (this.isInfinity()) return t;
106
+ if (t.isInfinity()) return this;
107
+ const s = this.x.toBigInteger(), e = this.y.toBigInteger(), i = this.z, u = t.x.toBigInteger(), o = t.y.toBigInteger(), g = t.z, r = this.curve.q, m = s.multiply(g).mod(r), a = u.multiply(i).mod(r), l = m.subtract(a), I = e.multiply(g).mod(r), f = o.multiply(i).mod(r), y = I.subtract(f);
108
+ if (n.BigInteger.ZERO.equals(l))
109
+ return n.BigInteger.ZERO.equals(y) ? this.twice() : this.curve.infinity;
110
+ const x = m.add(a), d = i.multiply(g).mod(r), q = l.square().mod(r), B = l.multiply(q).mod(r), w = d.multiply(y.square()).subtract(x.multiply(q)).mod(r), z = l.multiply(w).mod(r), b = y.multiply(q.multiply(m).subtract(w)).subtract(I.multiply(B)).mod(r), O = B.multiply(d).mod(r);
111
+ return new c(this.curve, this.curve.fromBigInteger(z), this.curve.fromBigInteger(b), O);
112
+ }
113
+ /**
114
+ * 自加
115
+ *
116
+ * 标准射影坐标系:
117
+ *
118
+ * λ1 = 3 * x1^2 + a * z1^2
119
+ * λ2 = 2 * y1 * z1
120
+ * λ3 = y1^2
121
+ * λ4 = λ3 * x1 * z1
122
+ * λ5 = λ2^2
123
+ * λ6 = λ1^2 − 8 * λ4
124
+ * x3 = λ2 * λ6
125
+ * y3 = λ1 * (4 * λ4 − λ6) − 2 * λ5 * λ3
126
+ * z3 = λ2 * λ5
127
+ */
128
+ twice() {
129
+ if (this.isInfinity()) return this;
130
+ if (!this.y.toBigInteger().signum()) return this.curve.infinity;
131
+ 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(p).add(u.multiply(e.square())).mod(i), g = s.shiftLeft(1).multiply(e).mod(i), r = s.square().mod(i), m = r.multiply(t).multiply(e).mod(i), a = g.square().mod(i), l = o.square().subtract(m.shiftLeft(3)).mod(i), I = g.multiply(l).mod(i), f = o.multiply(m.shiftLeft(2).subtract(l)).subtract(a.shiftLeft(1).multiply(r)).mod(i), y = g.multiply(a).mod(i);
132
+ return new c(this.curve, this.curve.fromBigInteger(I), this.curve.fromBigInteger(f), y);
133
+ }
134
+ /**
135
+ * 倍点计算
136
+ */
137
+ multiply(t) {
138
+ if (this.isInfinity()) return this;
139
+ if (!t.signum()) return this.curve.infinity;
140
+ const s = t.multiply(p), e = this.negate();
141
+ let i = this;
142
+ for (let u = s.bitLength() - 2; u > 0; u--) {
143
+ i = i.twice();
144
+ const o = s.testBit(u), g = t.testBit(u);
145
+ o !== g && (i = i.add(o ? this : e));
146
+ }
147
+ return i;
148
+ }
149
+ }
150
+ class R {
151
+ constructor(t, s, e) {
152
+ this.q = t, this.a = this.fromBigInteger(s), this.b = this.fromBigInteger(e), this.infinity = new c(this, null, null);
153
+ }
154
+ /**
155
+ * 判断两个椭圆曲线是否相等
156
+ */
157
+ equals(t) {
158
+ return t === this ? !0 : this.q.equals(t.q) && this.a.equals(t.a) && this.b.equals(t.b);
159
+ }
160
+ /**
161
+ * 生成椭圆曲线域元素
162
+ */
163
+ fromBigInteger(t) {
164
+ return new h(this.q, t);
165
+ }
166
+ /**
167
+ * 解析 16 进制串为椭圆曲线点
168
+ */
169
+ decodePointHex(t) {
170
+ switch (parseInt(t.substr(0, 2), 16)) {
171
+ case 0:
172
+ return this.infinity;
173
+ case 2:
174
+ case 3:
175
+ const s = this.fromBigInteger(new n.BigInteger(t.substr(2), 16));
176
+ let e = this.fromBigInteger(
177
+ s.multiply(s.square()).add(s.multiply(this.a)).add(this.b).toBigInteger().modPow(this.q.divide(new n.BigInteger("4")).add(n.BigInteger.ONE), this.q)
178
+ );
179
+ return e.toBigInteger().mod(v).equals(new n.BigInteger(t.substr(0, 2), 16).subtract(v)) || (e = e.negate()), new c(this, s, e);
180
+ case 4:
181
+ case 6:
182
+ case 7:
183
+ const i = (t.length - 2) / 2, u = t.substr(2, i), o = t.substr(i + 2, i);
184
+ return new c(this, this.fromBigInteger(new n.BigInteger(u, 16)), this.fromBigInteger(new n.BigInteger(o, 16)));
185
+ default:
186
+ return null;
187
+ }
188
+ }
189
+ }
190
+ const H = {
191
+ ECPointFp: c,
192
+ ECCurveFp: R
193
+ };
194
+ export {
195
+ R as ECCurveFp,
196
+ c as ECPointFp,
197
+ H as default
198
+ };
199
+ //# sourceMappingURL=ec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ec.js","sources":["../../../../../src/request/leaf7/smCrypto/sm2/ec.ts"],"sourcesContent":["import { BigInteger } from 'jsbn'\r\n\r\n/**\r\n * thanks for Tom Wu : http://www-cs-students.stanford.edu/~tjw/jsbn/\r\n *\r\n * Basic Javascript Elliptic Curve implementation\r\n * Ported loosely from BouncyCastle's Java EC code\r\n * Only Fp curves implemented for now\r\n */\r\n\r\nconst TWO = new BigInteger('2')\r\nconst THREE = new BigInteger('3')\r\n\r\n/**\r\n * 椭圆曲线域元素\r\n */\r\nclass ECFieldElementFp {\r\n constructor(q, x) {\r\n this.x = x\r\n this.q = q\r\n // TODO if (x.compareTo(q) >= 0) error\r\n }\r\n\r\n /**\r\n * 判断相等\r\n */\r\n equals(other) {\r\n if (other === this) return true\r\n return this.q.equals(other.q) && this.x.equals(other.x)\r\n }\r\n\r\n /**\r\n * 返回具体数值\r\n */\r\n toBigInteger() {\r\n return this.x\r\n }\r\n\r\n /**\r\n * 取反\r\n */\r\n negate() {\r\n return new ECFieldElementFp(this.q, this.x.negate().mod(this.q))\r\n }\r\n\r\n /**\r\n * 相加\r\n */\r\n add(b) {\r\n return new ECFieldElementFp(this.q, this.x.add(b.toBigInteger()).mod(this.q))\r\n }\r\n\r\n /**\r\n * 相减\r\n */\r\n subtract(b) {\r\n return new ECFieldElementFp(this.q, this.x.subtract(b.toBigInteger()).mod(this.q))\r\n }\r\n\r\n /**\r\n * 相乘\r\n */\r\n multiply(b) {\r\n return new ECFieldElementFp(this.q, this.x.multiply(b.toBigInteger()).mod(this.q))\r\n }\r\n\r\n /**\r\n * 相除\r\n */\r\n divide(b) {\r\n return new ECFieldElementFp(this.q, this.x.multiply(b.toBigInteger().modInverse(this.q)).mod(this.q))\r\n }\r\n\r\n /**\r\n * 平方\r\n */\r\n square() {\r\n return new ECFieldElementFp(this.q, this.x.square().mod(this.q))\r\n }\r\n}\r\n\r\nexport class ECPointFp {\r\n constructor(curve, x, y, z) {\r\n this.curve = curve\r\n this.x = x\r\n this.y = y\r\n // 标准射影坐标系:zinv == null 或 z * zinv == 1\r\n this.z = z == null ? BigInteger.ONE : z\r\n this.zinv = null\r\n // TODO: compression flag\r\n }\r\n\r\n getX() {\r\n if (this.zinv === null) this.zinv = this.z.modInverse(this.curve.q)\r\n\r\n return this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q))\r\n }\r\n\r\n getY() {\r\n if (this.zinv === null) this.zinv = this.z.modInverse(this.curve.q)\r\n\r\n return this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q))\r\n }\r\n\r\n /**\r\n * 判断相等\r\n */\r\n equals(other) {\r\n if (other === this) return true\r\n if (this.isInfinity()) return other.isInfinity()\r\n if (other.isInfinity()) return this.isInfinity()\r\n\r\n // u = y2 * z1 - y1 * z2\r\n const u = other.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(other.z)).mod(this.curve.q)\r\n if (!u.equals(BigInteger.ZERO)) return false\r\n\r\n // v = x2 * z1 - x1 * z2\r\n const v = other.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(other.z)).mod(this.curve.q)\r\n return v.equals(BigInteger.ZERO)\r\n }\r\n\r\n /**\r\n * 是否是无穷远点\r\n */\r\n isInfinity() {\r\n if (this.x === null && this.y === null) return true\r\n return this.z.equals(BigInteger.ZERO) && !this.y.toBigInteger().equals(BigInteger.ZERO)\r\n }\r\n\r\n /**\r\n * 取反,x 轴对称点\r\n */\r\n negate() {\r\n return new ECPointFp(this.curve, this.x, this.y.negate(), this.z)\r\n }\r\n\r\n /**\r\n * 相加\r\n *\r\n * 标准射影坐标系:\r\n *\r\n * λ1 = x1 * z2\r\n * λ2 = x2 * z1\r\n * λ3 = λ1 − λ2\r\n * λ4 = y1 * z2\r\n * λ5 = y2 * z1\r\n * λ6 = λ4 − λ5\r\n * λ7 = λ1 + λ2\r\n * λ8 = z1 * z2\r\n * λ9 = λ3^2\r\n * λ10 = λ3 * λ9\r\n * λ11 = λ8 * λ6^2 − λ7 * λ9\r\n * x3 = λ3 * λ11\r\n * y3 = λ6 * (λ9 * λ1 − λ11) − λ4 * λ10\r\n * z3 = λ10 * λ8\r\n */\r\n add(b) {\r\n if (this.isInfinity()) return b\r\n if (b.isInfinity()) return this\r\n\r\n const x1 = this.x.toBigInteger()\r\n const y1 = this.y.toBigInteger()\r\n const z1 = this.z\r\n const x2 = b.x.toBigInteger()\r\n const y2 = b.y.toBigInteger()\r\n const z2 = b.z\r\n const q = this.curve.q\r\n\r\n const w1 = x1.multiply(z2).mod(q)\r\n const w2 = x2.multiply(z1).mod(q)\r\n const w3 = w1.subtract(w2)\r\n const w4 = y1.multiply(z2).mod(q)\r\n const w5 = y2.multiply(z1).mod(q)\r\n const w6 = w4.subtract(w5)\r\n\r\n if (BigInteger.ZERO.equals(w3)) {\r\n if (BigInteger.ZERO.equals(w6)) {\r\n return this.twice() // this == b,计算自加\r\n }\r\n return this.curve.infinity // this == -b,则返回无穷远点\r\n }\r\n\r\n const w7 = w1.add(w2)\r\n const w8 = z1.multiply(z2).mod(q)\r\n const w9 = w3.square().mod(q)\r\n const w10 = w3.multiply(w9).mod(q)\r\n const w11 = w8.multiply(w6.square()).subtract(w7.multiply(w9)).mod(q)\r\n\r\n const x3 = w3.multiply(w11).mod(q)\r\n const y3 = w6.multiply(w9.multiply(w1).subtract(w11)).subtract(w4.multiply(w10)).mod(q)\r\n const z3 = w10.multiply(w8).mod(q)\r\n\r\n return new ECPointFp(this.curve, this.curve.fromBigInteger(x3), this.curve.fromBigInteger(y3), z3)\r\n }\r\n\r\n /**\r\n * 自加\r\n *\r\n * 标准射影坐标系:\r\n *\r\n * λ1 = 3 * x1^2 + a * z1^2\r\n * λ2 = 2 * y1 * z1\r\n * λ3 = y1^2\r\n * λ4 = λ3 * x1 * z1\r\n * λ5 = λ2^2\r\n * λ6 = λ1^2 − 8 * λ4\r\n * x3 = λ2 * λ6\r\n * y3 = λ1 * (4 * λ4 − λ6) − 2 * λ5 * λ3\r\n * z3 = λ2 * λ5\r\n */\r\n twice() {\r\n if (this.isInfinity()) return this\r\n if (!this.y.toBigInteger().signum()) return this.curve.infinity\r\n\r\n const x1 = this.x.toBigInteger()\r\n const y1 = this.y.toBigInteger()\r\n const z1 = this.z\r\n const q = this.curve.q\r\n const a = this.curve.a.toBigInteger()\r\n\r\n const w1 = x1.square().multiply(THREE).add(a.multiply(z1.square())).mod(q)\r\n const w2 = y1.shiftLeft(1).multiply(z1).mod(q)\r\n const w3 = y1.square().mod(q)\r\n const w4 = w3.multiply(x1).multiply(z1).mod(q)\r\n const w5 = w2.square().mod(q)\r\n const w6 = w1.square().subtract(w4.shiftLeft(3)).mod(q)\r\n\r\n const x3 = w2.multiply(w6).mod(q)\r\n const y3 = w1.multiply(w4.shiftLeft(2).subtract(w6)).subtract(w5.shiftLeft(1).multiply(w3)).mod(q)\r\n const z3 = w2.multiply(w5).mod(q)\r\n\r\n return new ECPointFp(this.curve, this.curve.fromBigInteger(x3), this.curve.fromBigInteger(y3), z3)\r\n }\r\n\r\n /**\r\n * 倍点计算\r\n */\r\n multiply(k) {\r\n if (this.isInfinity()) return this\r\n if (!k.signum()) return this.curve.infinity\r\n\r\n // 使用加减法\r\n const k3 = k.multiply(THREE)\r\n const neg = this.negate()\r\n let Q = this\r\n\r\n for (let i = k3.bitLength() - 2; i > 0; i--) {\r\n Q = Q.twice()\r\n\r\n const k3Bit = k3.testBit(i)\r\n const kBit = k.testBit(i)\r\n\r\n if (k3Bit !== kBit) {\r\n Q = Q.add(k3Bit ? this : neg)\r\n }\r\n }\r\n\r\n return Q\r\n }\r\n}\r\n\r\n/**\r\n * 椭圆曲线 y^2 = x^3 + ax + b\r\n */\r\nexport class ECCurveFp {\r\n constructor(q, a, b) {\r\n this.q = q\r\n this.a = this.fromBigInteger(a)\r\n this.b = this.fromBigInteger(b)\r\n this.infinity = new ECPointFp(this, null, null) // 无穷远点\r\n }\r\n\r\n /**\r\n * 判断两个椭圆曲线是否相等\r\n */\r\n equals(other) {\r\n if (other === this) return true\r\n return this.q.equals(other.q) && this.a.equals(other.a) && this.b.equals(other.b)\r\n }\r\n\r\n /**\r\n * 生成椭圆曲线域元素\r\n */\r\n fromBigInteger(x) {\r\n return new ECFieldElementFp(this.q, x)\r\n }\r\n\r\n /**\r\n * 解析 16 进制串为椭圆曲线点\r\n */\r\n decodePointHex(s) {\r\n switch (parseInt(s.substr(0, 2), 16)) {\r\n // 第一个字节\r\n case 0:\r\n return this.infinity\r\n case 2:\r\n case 3:\r\n // 压缩\r\n const x = this.fromBigInteger(new BigInteger(s.substr(2), 16))\r\n // 对 p ≡ 3 (mod4),即存在正整数 u,使得 p = 4u + 3\r\n // 计算 y = (√ (x^3 + ax + b) % p)^(u + 1) modp\r\n let y = this.fromBigInteger(\r\n x\r\n .multiply(x.square())\r\n .add(x.multiply(this.a))\r\n .add(this.b)\r\n .toBigInteger()\r\n .modPow(this.q.divide(new BigInteger('4')).add(BigInteger.ONE), this.q)\r\n )\r\n // 算出结果 2 进制最后 1 位不等于第 1 个字节减 2 则取反\r\n if (\r\n !y\r\n .toBigInteger()\r\n .mod(TWO)\r\n .equals(new BigInteger(s.substr(0, 2), 16).subtract(TWO))\r\n ) {\r\n y = y.negate()\r\n }\r\n return new ECPointFp(this, x, y)\r\n case 4:\r\n case 6:\r\n case 7:\r\n const len = (s.length - 2) / 2\r\n const xHex = s.substr(2, len)\r\n const yHex = s.substr(len + 2, len)\r\n\r\n return new ECPointFp(this, this.fromBigInteger(new BigInteger(xHex, 16)), this.fromBigInteger(new BigInteger(yHex, 16)))\r\n default:\r\n // 不支持\r\n return null\r\n }\r\n }\r\n}\r\n\r\nexport default {\r\n ECPointFp,\r\n ECCurveFp,\r\n}\r\n"],"names":["TWO","BigInteger","THREE","ECFieldElementFp","q","x","other","b","ECPointFp","curve","y","z","x1","y1","z1","x2","y2","z2","w1","w2","w3","w4","w5","w6","w7","w8","w9","w10","w11","x3","y3","z3","a","k","k3","neg","Q","i","k3Bit","kBit","ECCurveFp","s","len","xHex","yHex","ec"],"mappings":";AAUA,MAAMA,IAAM,IAAIC,aAAW,GAAG,GACxBC,IAAQ,IAAID,aAAW,GAAG;AAKhC,MAAME,EAAiB;AAAA,EACrB,YAAYC,GAAGC,GAAG;AAChB,SAAK,IAAIA,GACT,KAAK,IAAID;AAAA,EAEX;AAAA;AAAA;AAAA;AAAA,EAKA,OAAOE,GAAO;AACR,WAAAA,MAAU,OAAa,KACpB,KAAK,EAAE,OAAOA,EAAM,CAAC,KAAK,KAAK,EAAE,OAAOA,EAAM,CAAC;AAAA,EACxD;AAAA;AAAA;AAAA;AAAA,EAKA,eAAe;AACb,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKA,SAAS;AACA,WAAA,IAAIH,EAAiB,KAAK,GAAG,KAAK,EAAE,OAAA,EAAS,IAAI,KAAK,CAAC,CAAC;AAAA,EACjE;AAAA;AAAA;AAAA;AAAA,EAKA,IAAII,GAAG;AACL,WAAO,IAAIJ,EAAiB,KAAK,GAAG,KAAK,EAAE,IAAII,EAAE,aAAc,CAAA,EAAE,IAAI,KAAK,CAAC,CAAC;AAAA,EAC9E;AAAA;AAAA;AAAA;AAAA,EAKA,SAASA,GAAG;AACV,WAAO,IAAIJ,EAAiB,KAAK,GAAG,KAAK,EAAE,SAASI,EAAE,aAAc,CAAA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V,CAAG,EACP,OAAO,IAAIC,EAAA,WAAWwC,EAAE,OAAO,GAAG,CAAC,GAAG,EAAE,EAAE,SAASzC,CAAG,CAAC,MAE1DU,IAAIA,EAAE,WAED,IAAIF,EAAU,MAAMH,GAAGK,CAAC;AAAA,MACjC,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AACG,cAAAgC,KAAOD,EAAE,SAAS,KAAK,GACvBE,IAAOF,EAAE,OAAO,GAAGC,CAAG,GACtBE,IAAOH,EAAE,OAAOC,IAAM,GAAGA,CAAG;AAElC,eAAO,IAAIlC,EAAU,MAAM,KAAK,eAAe,IAAIP,aAAW0C,GAAM,EAAE,CAAC,GAAG,KAAK,eAAe,IAAI1C,EAAAA,WAAW2C,GAAM,EAAE,CAAC,CAAC;AAAA,MACzH;AAES,eAAA;AAAA,IACX;AAAA,EACF;AACF;AAEA,MAAeC,IAAA;AAAA,EACb,WAAArC;AAAA,EACA,WAAAgC;AACF;"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * 加密
3
+ */
4
+ declare function _s2EN(msg: any, publicKey: any, cipherMode?: number): string;
5
+ /**
6
+ * 解密
7
+ */
8
+ declare function _s2DE(encryptData: any, privateKey: any, cipherMode?: number, { output }?: {
9
+ output?: string | undefined;
10
+ }): string | never[];
11
+ /**
12
+ * 签名
13
+ */
14
+ declare function _s2DOSIG(msg: any, privateKey: any, { pointPool, der, hash, publicKey, userId }?: {}): any;
15
+ /**
16
+ * 验签
17
+ */
18
+ declare function _s2DOVERSIG(msg: any, signHex: any, publicKey: any, { der, hash, userId }?: {}): any;
19
+ /**
20
+ * 计算公钥
21
+ */
22
+ declare function _s2GETPublicFPrivate(privateKey: any): string;
23
+ /**
24
+ * 获取椭圆曲线点
25
+ */
26
+ declare function getPoint(): {
27
+ privateKey: any;
28
+ publicKey: string;
29
+ };
30
+ declare const _default: {
31
+ generateKeyPairHex: (a: any, b: any, c: any) => {
32
+ privateKey: any;
33
+ publicKey: string;
34
+ };
35
+ compressPublicKeyHex: (s: any) => string;
36
+ comparePublicKeyHex: (publicKey1: any, publicKey2: any) => any;
37
+ _s2EN: typeof _s2EN;
38
+ _s2DE: typeof _s2DE;
39
+ _s2DOSIG: typeof _s2DOSIG;
40
+ _s2DOVERSIG: typeof _s2DOVERSIG;
41
+ _s2GETPublicFPrivate: typeof _s2GETPublicFPrivate;
42
+ getPoint: typeof getPoint;
43
+ verifyPublicKey: (publicKey: any) => any;
44
+ };
45
+ export default _default;
@@ -0,0 +1,102 @@
1
+ import { j as u } from "../../../../index-BW3nOBfD.js";
2
+ import v from "./asn1.js";
3
+ import e from "./utils.js";
4
+ import E from "./sm3.js";
5
+ const { sm3: I } = E, { encodeDer: k, decodeDer: C } = v, { G: h, curve: m, n: B } = e.generateEcparam(), p = 0;
6
+ function O(t, n, r = 1) {
7
+ t = typeof t == "string" ? e.hexToArray(e.utf8ToHex(t)) : Array.prototype.slice.call(t), n = e.getGlobalCurve().decodePointHex(n);
8
+ const d = e.generateKeyPairHex(), y = new u.BigInteger(d.privateKey, 16);
9
+ let i = d.publicKey;
10
+ i.length > 128 && (i = i.substr(i.length - 128));
11
+ const a = n.multiply(y), g = e.hexToArray(e.leftPad(a.getX().toBigInteger().toRadix(16), 64)), s = e.hexToArray(e.leftPad(a.getY().toBigInteger().toRadix(16), 64)), f = e.arrayToHex(I([].concat(g, t, s)));
12
+ let c = 1, o = 0, l = [];
13
+ const x = [].concat(g, s), P = () => {
14
+ l = I([...x, c >> 24 & 255, c >> 16 & 255, c >> 8 & 255, c & 255]), c++, o = 0;
15
+ };
16
+ P();
17
+ for (let b = 0, T = t.length; b < T; b++)
18
+ o === l.length && P(), t[b] ^= l[o++] & 255;
19
+ const H = e.arrayToHex(t);
20
+ return r === p ? i + H + f : i + f + H;
21
+ }
22
+ function S(t, n, r = 1, { output: d = "string" } = {}) {
23
+ n = new u.BigInteger(n, 16);
24
+ let y = t.substr(128, 64), i = t.substr(192);
25
+ r === p && (y = t.substr(t.length - 64), i = t.substr(128, t.length - 128 - 64));
26
+ const a = e.hexToArray(i), s = e.getGlobalCurve().decodePointHex("04" + t.substr(0, 128)).multiply(n), f = e.hexToArray(e.leftPad(s.getX().toBigInteger().toRadix(16), 64)), c = e.hexToArray(e.leftPad(s.getY().toBigInteger().toRadix(16), 64));
27
+ let o = 1, l = 0, x = [];
28
+ const P = [].concat(f, c), H = () => {
29
+ x = I([...P, o >> 24 & 255, o >> 16 & 255, o >> 8 & 255, o & 255]), o++, l = 0;
30
+ };
31
+ H();
32
+ for (let T = 0, w = a.length; T < w; T++)
33
+ l === x.length && H(), a[T] ^= x[l++] & 255;
34
+ return e.arrayToHex(I([].concat(f, a, c))) === y.toLowerCase() ? d === "array" ? a : e.arrayToUtf8(a) : d === "array" ? [] : "";
35
+ }
36
+ function X(t, n, { pointPool: r, der: d, hash: y, publicKey: i, userId: a } = {}) {
37
+ let g = typeof t == "string" ? e.utf8ToHex(t) : e.arrayToHex(t);
38
+ y && (i = i || getPublicKeyFromPrivateKey(n), g = R(g, i, a));
39
+ const s = new u.BigInteger(n, 16), f = new u.BigInteger(g, 16);
40
+ let c = null, o = null, l = null;
41
+ do {
42
+ do {
43
+ let x;
44
+ r && r.length ? x = r.pop() : x = A(), c = x.k, o = f.add(x.x1).mod(B);
45
+ } while (o.equals(u.BigInteger.ZERO) || o.add(c).equals(B));
46
+ l = s.add(u.BigInteger.ONE).modInverse(B).multiply(c.subtract(o.multiply(s))).mod(B);
47
+ } while (l.equals(u.BigInteger.ZERO));
48
+ return d ? k(o, l) : e.leftPad(o.toString(16), 64) + e.leftPad(l.toString(16), 64);
49
+ }
50
+ function G(t, n, r, { der: d, hash: y, userId: i } = {}) {
51
+ let a = typeof t == "string" ? e.utf8ToHex(t) : e.arrayToHex(t);
52
+ y && (a = R(a, r, i));
53
+ let g, s;
54
+ if (d) {
55
+ const P = C(n);
56
+ g = P.r, s = P.s;
57
+ } else
58
+ g = new u.BigInteger(n.substring(0, 64), 16), s = new u.BigInteger(n.substring(64), 16);
59
+ const f = m.decodePointHex(r), c = new u.BigInteger(a, 16), o = g.add(s).mod(B);
60
+ if (o.equals(u.BigInteger.ZERO)) return !1;
61
+ const l = h.multiply(s).add(f.multiply(o)), x = c.add(l.getX().toBigInteger()).mod(B);
62
+ return g.equals(x);
63
+ }
64
+ function R(t, n, r = "1234567812345678") {
65
+ r = e.utf8ToHex(r);
66
+ const d = e.leftPad(h.curve.a.toBigInteger().toRadix(16), 64), y = e.leftPad(h.curve.b.toBigInteger().toRadix(16), 64), i = e.leftPad(h.getX().toBigInteger().toRadix(16), 64), a = e.leftPad(h.getY().toBigInteger().toRadix(16), 64);
67
+ let g, s;
68
+ if (n.length === 128)
69
+ g = n.substr(0, 64), s = n.substr(64, 64);
70
+ else {
71
+ const l = h.curve.decodePointHex(n);
72
+ g = e.leftPad(l.getX().toBigInteger().toRadix(16), 64), s = e.leftPad(l.getY().toBigInteger().toRadix(16), 64);
73
+ }
74
+ const f = e.hexToArray(r + d + y + i + a + g + s), c = r.length * 4;
75
+ f.unshift(c & 255), f.unshift(c >> 8 & 255);
76
+ const o = I(f);
77
+ return e.arrayToHex(I(o.concat(e.hexToArray(t))));
78
+ }
79
+ function _(t) {
80
+ const n = h.multiply(new u.BigInteger(t, 16)), r = e.leftPad(n.getX().toBigInteger().toString(16), 64), d = e.leftPad(n.getY().toBigInteger().toString(16), 64);
81
+ return "04" + r + d;
82
+ }
83
+ function A() {
84
+ const t = e.generateKeyPairHex(), n = m.decodePointHex(t.publicKey);
85
+ return t.k = new u.BigInteger(t.privateKey, 16), t.x1 = n.getX().toBigInteger(), t;
86
+ }
87
+ const z = {
88
+ generateKeyPairHex: e.generateKeyPairHex,
89
+ compressPublicKeyHex: e.compressPublicKeyHex,
90
+ comparePublicKeyHex: e.comparePublicKeyHex,
91
+ _s2EN: O,
92
+ _s2DE: S,
93
+ _s2DOSIG: X,
94
+ _s2DOVERSIG: G,
95
+ _s2GETPublicFPrivate: _,
96
+ getPoint: A,
97
+ verifyPublicKey: e.verifyPublicKey
98
+ };
99
+ export {
100
+ z as default
101
+ };
102
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../../../src/request/leaf7/smCrypto/sm2/index.ts"],"sourcesContent":["import { BigInteger } from 'jsbn'\r\nimport asn1 from './asn1'\r\nimport _ from './utils'\r\nimport SM3 from './sm3'\r\n\r\nconst { sm3 } = SM3\r\nconst { encodeDer, decodeDer } = asn1\r\n\r\nconst { G, curve, n } = _.generateEcparam()\r\nconst C1C2C3 = 0\r\n\r\n/**\r\n * 加密\r\n */\r\nfunction _s2EN(msg, publicKey, cipherMode = 1) {\r\n msg = typeof msg === 'string' ? _.hexToArray(_.utf8ToHex(msg)) : Array.prototype.slice.call(msg)\r\n publicKey = _.getGlobalCurve().decodePointHex(publicKey) // 先将公钥转成点\r\n\r\n const keypair = _.generateKeyPairHex()\r\n const k = new BigInteger(keypair.privateKey, 16) // 随机数 k\r\n\r\n // c1 = k * G\r\n let c1 = keypair.publicKey\r\n if (c1.length > 128) c1 = c1.substr(c1.length - 128)\r\n\r\n // (x2, y2) = k * publicKey\r\n const p = publicKey.multiply(k)\r\n const x2 = _.hexToArray(_.leftPad(p.getX().toBigInteger().toRadix(16), 64))\r\n const y2 = _.hexToArray(_.leftPad(p.getY().toBigInteger().toRadix(16), 64))\r\n\r\n // c3 = hash(x2 || msg || y2)\r\n const c3 = _.arrayToHex(sm3([].concat(x2, msg, y2)))\r\n\r\n let ct = 1\r\n let offset = 0\r\n let t = [] // 256 位\r\n const z = [].concat(x2, y2)\r\n const nextT = () => {\r\n // (1) Hai = hash(z || ct)\r\n // (2) ct++\r\n t = sm3([...z, (ct >> 24) & 0x00ff, (ct >> 16) & 0x00ff, (ct >> 8) & 0x00ff, ct & 0x00ff])\r\n ct++\r\n offset = 0\r\n }\r\n nextT() // 先生成 Ha1\r\n\r\n for (let i = 0, len = msg.length; i < len; i++) {\r\n // t = Ha1 || Ha2 || Ha3 || Ha4\r\n if (offset === t.length) nextT()\r\n\r\n // c2 = msg ^ t\r\n msg[i] ^= t[offset++] & 0xff\r\n }\r\n const c2 = _.arrayToHex(msg)\r\n\r\n return cipherMode === C1C2C3 ? c1 + c2 + c3 : c1 + c3 + c2\r\n}\r\n\r\n/**\r\n * 解密\r\n */\r\nfunction _s2DE(encryptData, privateKey, cipherMode = 1, { output = 'string' } = {}) {\r\n privateKey = new BigInteger(privateKey, 16)\r\n\r\n let c3 = encryptData.substr(128, 64)\r\n let c2 = encryptData.substr(128 + 64)\r\n\r\n if (cipherMode === C1C2C3) {\r\n c3 = encryptData.substr(encryptData.length - 64)\r\n c2 = encryptData.substr(128, encryptData.length - 128 - 64)\r\n }\r\n\r\n const msg = _.hexToArray(c2)\r\n const c1 = _.getGlobalCurve().decodePointHex('04' + encryptData.substr(0, 128))\r\n\r\n const p = c1.multiply(privateKey)\r\n const x2 = _.hexToArray(_.leftPad(p.getX().toBigInteger().toRadix(16), 64))\r\n const y2 = _.hexToArray(_.leftPad(p.getY().toBigInteger().toRadix(16), 64))\r\n\r\n let ct = 1\r\n let offset = 0\r\n let t = [] // 256 位\r\n const z = [].concat(x2, y2)\r\n const nextT = () => {\r\n // (1) Hai = hash(z || ct)\r\n // (2) ct++\r\n t = sm3([...z, (ct >> 24) & 0x00ff, (ct >> 16) & 0x00ff, (ct >> 8) & 0x00ff, ct & 0x00ff])\r\n ct++\r\n offset = 0\r\n }\r\n nextT() // 先生成 Ha1\r\n\r\n for (let i = 0, len = msg.length; i < len; i++) {\r\n // t = Ha1 || Ha2 || Ha3 || Ha4\r\n if (offset === t.length) nextT()\r\n\r\n // c2 = msg ^ t\r\n msg[i] ^= t[offset++] & 0xff\r\n }\r\n\r\n // c3 = hash(x2 || msg || y2)\r\n const checkC3 = _.arrayToHex(sm3([].concat(x2, msg, y2)))\r\n\r\n if (checkC3 === c3.toLowerCase()) {\r\n return output === 'array' ? msg : _.arrayToUtf8(msg)\r\n } else {\r\n return output === 'array' ? [] : ''\r\n }\r\n}\r\n\r\n/**\r\n * 签名\r\n */\r\nfunction _s2DOSIG(msg, privateKey, { pointPool, der, hash, publicKey, userId } = {}) {\r\n let hashHex = typeof msg === 'string' ? _.utf8ToHex(msg) : _.arrayToHex(msg)\r\n\r\n if (hash) {\r\n // sm3杂凑\r\n publicKey = publicKey || getPublicKeyFromPrivateKey(privateKey)\r\n hashHex = getHash(hashHex, publicKey, userId)\r\n }\r\n\r\n const dA = new BigInteger(privateKey, 16)\r\n const e = new BigInteger(hashHex, 16)\r\n\r\n // k\r\n let k = null\r\n let r = null\r\n let s = null\r\n\r\n do {\r\n do {\r\n let point\r\n if (pointPool && pointPool.length) {\r\n point = pointPool.pop()\r\n } else {\r\n point = getPoint()\r\n }\r\n k = point.k\r\n\r\n // r = (e + x1) mod n\r\n r = e.add(point.x1).mod(n)\r\n } while (r.equals(BigInteger.ZERO) || r.add(k).equals(n))\r\n\r\n // s = ((1 + dA)^-1 * (k - r * dA)) mod n\r\n s = dA\r\n .add(BigInteger.ONE)\r\n .modInverse(n)\r\n .multiply(k.subtract(r.multiply(dA)))\r\n .mod(n)\r\n } while (s.equals(BigInteger.ZERO))\r\n\r\n if (der) return encodeDer(r, s) // asn.1 der 编码\r\n\r\n return _.leftPad(r.toString(16), 64) + _.leftPad(s.toString(16), 64)\r\n}\r\n\r\n/**\r\n * 验签\r\n */\r\nfunction _s2DOVERSIG(msg, signHex, publicKey, { der, hash, userId } = {}) {\r\n let hashHex = typeof msg === 'string' ? _.utf8ToHex(msg) : _.arrayToHex(msg)\r\n\r\n if (hash) {\r\n // sm3杂凑\r\n hashHex = getHash(hashHex, publicKey, userId)\r\n }\r\n\r\n let r\r\n let s\r\n if (der) {\r\n const decodeDerObj = decodeDer(signHex) // asn.1 der 解码\r\n r = decodeDerObj.r\r\n s = decodeDerObj.s\r\n } else {\r\n r = new BigInteger(signHex.substring(0, 64), 16)\r\n s = new BigInteger(signHex.substring(64), 16)\r\n }\r\n\r\n const PA = curve.decodePointHex(publicKey)\r\n const e = new BigInteger(hashHex, 16)\r\n\r\n // t = (r + s) mod n\r\n const t = r.add(s).mod(n)\r\n\r\n if (t.equals(BigInteger.ZERO)) return false\r\n\r\n // x1y1 = s * G + t * PA\r\n const x1y1 = G.multiply(s).add(PA.multiply(t))\r\n\r\n // R = (e + x1) mod n\r\n const R = e.add(x1y1.getX().toBigInteger()).mod(n)\r\n\r\n return r.equals(R)\r\n}\r\n\r\n/**\r\n * sm3杂凑算法\r\n */\r\nfunction getHash(hashHex, publicKey, userId = '1234567812345678') {\r\n // z = hash(entl || userId || a || b || gx || gy || px || py)\r\n userId = _.utf8ToHex(userId)\r\n const a = _.leftPad(G.curve.a.toBigInteger().toRadix(16), 64)\r\n const b = _.leftPad(G.curve.b.toBigInteger().toRadix(16), 64)\r\n const gx = _.leftPad(G.getX().toBigInteger().toRadix(16), 64)\r\n const gy = _.leftPad(G.getY().toBigInteger().toRadix(16), 64)\r\n let px\r\n let py\r\n if (publicKey.length === 128) {\r\n px = publicKey.substr(0, 64)\r\n py = publicKey.substr(64, 64)\r\n } else {\r\n const point = G.curve.decodePointHex(publicKey)\r\n px = _.leftPad(point.getX().toBigInteger().toRadix(16), 64)\r\n py = _.leftPad(point.getY().toBigInteger().toRadix(16), 64)\r\n }\r\n const data = _.hexToArray(userId + a + b + gx + gy + px + py)\r\n\r\n const entl = userId.length * 4\r\n data.unshift(entl & 0x00ff)\r\n data.unshift((entl >> 8) & 0x00ff)\r\n\r\n const z = sm3(data)\r\n\r\n // e = hash(z || msg)\r\n return _.arrayToHex(sm3(z.concat(_.hexToArray(hashHex))))\r\n}\r\n\r\n/**\r\n * 计算公钥\r\n */\r\nfunction _s2GETPublicFPrivate(privateKey) {\r\n const PA = G.multiply(new BigInteger(privateKey, 16))\r\n const x = _.leftPad(PA.getX().toBigInteger().toString(16), 64)\r\n const y = _.leftPad(PA.getY().toBigInteger().toString(16), 64)\r\n return '04' + x + y\r\n}\r\n\r\n/**\r\n * 获取椭圆曲线点\r\n */\r\nfunction getPoint() {\r\n const keypair = _.generateKeyPairHex()\r\n const PA = curve.decodePointHex(keypair.publicKey)\r\n\r\n keypair.k = new BigInteger(keypair.privateKey, 16)\r\n keypair.x1 = PA.getX().toBigInteger()\r\n\r\n return keypair\r\n}\r\n\r\nexport default {\r\n generateKeyPairHex: _.generateKeyPairHex,\r\n compressPublicKeyHex: _.compressPublicKeyHex,\r\n comparePublicKeyHex: _.comparePublicKeyHex,\r\n _s2EN,\r\n _s2DE,\r\n _s2DOSIG,\r\n _s2DOVERSIG,\r\n _s2GETPublicFPrivate,\r\n getPoint,\r\n verifyPublicKey: _.verifyPublicKey,\r\n}\r\n"],"names":["sm3","SM3","encodeDer","decodeDer","asn1","G","curve","n","_","C1C2C3","_s2EN","msg","publicKey","cipherMode","keypair","k","BigInteger","c1","p","x2","y2","c3","ct","offset","t","z","nextT","i","len","c2","_s2DE","encryptData","privateKey","output","_s2DOSIG","pointPool","der","hash","userId","hashHex","getHash","dA","e","r","s","point","getPoint","_s2DOVERSIG","signHex","decodeDerObj","PA","x1y1","R","a","b","gx","gy","px","py","data","entl","_s2GETPublicFPrivate","x","y","sm2"],"mappings":";;;;AAKA,MAAM,EAAE,KAAAA,EAAQ,IAAAC,GACV,EAAE,WAAAC,GAAW,WAAAC,EAAc,IAAAC,GAE3B,EAAE,GAAAC,GAAG,OAAAC,GAAO,GAAAC,EAAE,IAAIC,EAAE,gBAAgB,GACpCC,IAAS;AAKf,SAASC,EAAMC,GAAKC,GAAWC,IAAa,GAAG;AAC7C,EAAAF,IAAM,OAAOA,KAAQ,WAAWH,EAAE,WAAWA,EAAE,UAAUG,CAAG,CAAC,IAAI,MAAM,UAAU,MAAM,KAAKA,CAAG,GAC/FC,IAAYJ,EAAE,eAAiB,EAAA,eAAeI,CAAS;AAEjD,QAAAE,IAAUN,EAAE,sBACZO,IAAI,IAAIC,EAAW,WAAAF,EAAQ,YAAY,EAAE;AAG/C,MAAIG,IAAKH,EAAQ;AACb,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EACA,aAAAa;AAAA,EACA,sBAAAc;AAAA,EACA,UAAAf;AAAA,EACA,iBAAiBtC,EAAE;AACrB;"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * sm3 本体
3
+ */
4
+ export declare function sm3(array: any): never[];
5
+ export declare function hmac(input: any, key: any): never[];
6
+ declare const _default: {
7
+ sm3: typeof sm3;
8
+ hmac: typeof hmac;
9
+ };
10
+ export default _default;
@@ -0,0 +1,69 @@
1
+ const i = new Uint32Array(68), j = new Uint32Array(64);
2
+ function s(n, e) {
3
+ const o = e & 31;
4
+ return n << o | n >>> 32 - o;
5
+ }
6
+ function M(n, e) {
7
+ const o = [];
8
+ for (let c = n.length - 1; c >= 0; c--) o[c] = (n[c] ^ e[c]) & 255;
9
+ return o;
10
+ }
11
+ function H(n) {
12
+ return n ^ s(n, 9) ^ s(n, 17);
13
+ }
14
+ function L(n) {
15
+ return n ^ s(n, 15) ^ s(n, 23);
16
+ }
17
+ function P(n) {
18
+ let e = n.length * 8, o = e % 512;
19
+ o = o >= 448 ? 512 - o % 448 - 1 : 448 - o - 1;
20
+ const c = new Array((o - 7) / 8), u = new Array(8);
21
+ for (let r = 0, f = c.length; r < f; r++) c[r] = 0;
22
+ for (let r = 0, f = u.length; r < f; r++) u[r] = 0;
23
+ e = e.toString(2);
24
+ for (let r = 7; r >= 0; r--)
25
+ if (e.length > 8) {
26
+ const f = e.length - 8;
27
+ u[r] = parseInt(e.substr(f), 2), e = e.substr(0, f);
28
+ } else e.length > 0 && (u[r] = parseInt(e, 2), e = "");
29
+ const m = new Uint8Array([...n, 128, ...c, ...u]), E = new DataView(m.buffer, 0), F = m.length / 64, l = new Uint32Array([1937774191, 1226093241, 388252375, 3666478592, 2842636476, 372324522, 3817729613, 2969243214]);
30
+ for (let r = 0; r < F; r++) {
31
+ i.fill(0), j.fill(0);
32
+ const f = 16 * r;
33
+ for (let t = 0; t < 16; t++)
34
+ i[t] = E.getUint32((f + t) * 4, !1);
35
+ for (let t = 16; t < 68; t++)
36
+ i[t] = L(i[t - 16] ^ i[t - 9] ^ s(i[t - 3], 15)) ^ s(i[t - 13], 7) ^ i[t - 6];
37
+ for (let t = 0; t < 64; t++)
38
+ j[t] = i[t] ^ i[t + 4];
39
+ const g = 2043430169, G = 2055708042;
40
+ let a = l[0], w = l[1], A = l[2], S = l[3], h = l[4], d = l[5], T = l[6], p = l[7], b, V, D, I, K;
41
+ for (let t = 0; t < 64; t++)
42
+ K = t >= 0 && t <= 15 ? g : G, b = s(s(a, 12) + h + s(K, t), 7), V = b ^ s(a, 12), D = (t >= 0 && t <= 15 ? a ^ w ^ A : a & w | a & A | w & A) + S + V + j[t], I = (t >= 0 && t <= 15 ? h ^ d ^ T : h & d | ~h & T) + p + b + i[t], S = A, A = s(w, 9), w = a, a = D, p = T, T = s(d, 19), d = h, h = H(I);
43
+ l[0] ^= a, l[1] ^= w, l[2] ^= A, l[3] ^= S, l[4] ^= h, l[5] ^= d, l[6] ^= T, l[7] ^= p;
44
+ }
45
+ const y = [];
46
+ for (let r = 0, f = l.length; r < f; r++) {
47
+ const g = l[r];
48
+ y.push((g & 4278190080) >>> 24, (g & 16711680) >>> 16, (g & 65280) >>> 8, g & 255);
49
+ }
50
+ return y;
51
+ }
52
+ const U = 64, B = new Uint8Array(U), C = new Uint8Array(U);
53
+ for (let n = 0; n < U; n++)
54
+ B[n] = 54, C[n] = 92;
55
+ function W(n, e) {
56
+ for (e.length > U && (e = P(e)); e.length < U; ) e.push(0);
57
+ const o = M(e, B), c = M(e, C), u = P([...o, ...n]);
58
+ return P([...c, ...u]);
59
+ }
60
+ const q = {
61
+ sm3: P,
62
+ hmac: W
63
+ };
64
+ export {
65
+ q as default,
66
+ W as hmac,
67
+ P as sm3
68
+ };
69
+ //# sourceMappingURL=sm3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sm3.js","sources":["../../../../../src/request/leaf7/smCrypto/sm2/sm3.ts"],"sourcesContent":["// 消息扩展\r\nconst W = new Uint32Array(68)\r\nconst M = new Uint32Array(64) // W'\r\n\r\n/**\r\n * 循环左移\r\n */\r\nfunction rotl(x, n) {\r\n const s = n & 31\r\n return (x << s) | (x >>> (32 - s))\r\n}\r\n\r\n/**\r\n * 二进制异或运算\r\n */\r\nfunction xor(x, y) {\r\n const result = []\r\n for (let i = x.length - 1; i >= 0; i--) result[i] = (x[i] ^ y[i]) & 0xff\r\n return result\r\n}\r\n\r\n/**\r\n * 压缩函数中的置换函数 P0(X) = X xor (X <<< 9) xor (X <<< 17)\r\n */\r\nfunction P0(X) {\r\n return X ^ rotl(X, 9) ^ rotl(X, 17)\r\n}\r\n\r\n/**\r\n * 消息扩展中的置换函数 P1(X) = X xor (X <<< 15) xor (X <<< 23)\r\n */\r\nfunction P1(X) {\r\n return X ^ rotl(X, 15) ^ rotl(X, 23)\r\n}\r\n\r\n/**\r\n * sm3 本体\r\n */\r\nexport function sm3(array) {\r\n let len = array.length * 8\r\n\r\n // k 是满足 len + 1 + k = 448mod512 的最小的非负整数\r\n let k = len % 512\r\n // 如果 448 <= (512 % len) < 512,需要多补充 (len % 448) 比特'0'以满足总比特长度为512的倍数\r\n k = k >= 448 ? 512 - (k % 448) - 1 : 448 - k - 1\r\n\r\n // 填充\r\n const kArr = new Array((k - 7) / 8)\r\n const lenArr = new Array(8)\r\n for (let i = 0, len = kArr.length; i < len; i++) kArr[i] = 0\r\n for (let i = 0, len = lenArr.length; i < len; i++) lenArr[i] = 0\r\n len = len.toString(2)\r\n for (let i = 7; i >= 0; i--) {\r\n if (len.length > 8) {\r\n const start = len.length - 8\r\n lenArr[i] = parseInt(len.substr(start), 2)\r\n len = len.substr(0, start)\r\n } else if (len.length > 0) {\r\n lenArr[i] = parseInt(len, 2)\r\n len = ''\r\n }\r\n }\r\n const m = new Uint8Array([...array, 0x80, ...kArr, ...lenArr])\r\n const dataView = new DataView(m.buffer, 0)\r\n\r\n // 迭代压缩\r\n const n = m.length / 64\r\n const V = new Uint32Array([0x7380166f, 0x4914b2b9, 0x172442d7, 0xda8a0600, 0xa96f30bc, 0x163138aa, 0xe38dee4d, 0xb0fb0e4e])\r\n for (let i = 0; i < n; i++) {\r\n W.fill(0)\r\n M.fill(0)\r\n\r\n // 将消息分组B划分为 16 个字 W0, W1,……,W15\r\n const start = 16 * i\r\n for (let j = 0; j < 16; j++) {\r\n W[j] = dataView.getUint32((start + j) * 4, false)\r\n }\r\n\r\n // W16 ~ W67:W[j] <- P1(W[j−16] xor W[j−9] xor (W[j−3] <<< 15)) xor (W[j−13] <<< 7) xor W[j−6]\r\n for (let j = 16; j < 68; j++) {\r\n W[j] = P1(W[j - 16] ^ W[j - 9] ^ rotl(W[j - 3], 15)) ^ rotl(W[j - 13], 7) ^ W[j - 6]\r\n }\r\n\r\n // W′0 ~ W′63:W′[j] = W[j] xor W[j+4]\r\n for (let j = 0; j < 64; j++) {\r\n M[j] = W[j] ^ W[j + 4]\r\n }\r\n\r\n // 压缩\r\n const T1 = 0x79cc4519\r\n const T2 = 0x7a879d8a\r\n // 字寄存器\r\n let A = V[0]\r\n let B = V[1]\r\n let C = V[2]\r\n let D = V[3]\r\n let E = V[4]\r\n let F = V[5]\r\n let G = V[6]\r\n let H = V[7]\r\n // 中间变量\r\n let SS1\r\n let SS2\r\n let TT1\r\n let TT2\r\n let T\r\n for (let j = 0; j < 64; j++) {\r\n T = j >= 0 && j <= 15 ? T1 : T2\r\n SS1 = rotl(rotl(A, 12) + E + rotl(T, j), 7)\r\n SS2 = SS1 ^ rotl(A, 12)\r\n\r\n TT1 = (j >= 0 && j <= 15 ? A ^ B ^ C : (A & B) | (A & C) | (B & C)) + D + SS2 + M[j]\r\n TT2 = (j >= 0 && j <= 15 ? E ^ F ^ G : (E & F) | (~E & G)) + H + SS1 + W[j]\r\n\r\n D = C\r\n C = rotl(B, 9)\r\n B = A\r\n A = TT1\r\n H = G\r\n G = rotl(F, 19)\r\n F = E\r\n E = P0(TT2)\r\n }\r\n\r\n V[0] ^= A\r\n V[1] ^= B\r\n V[2] ^= C\r\n V[3] ^= D\r\n V[4] ^= E\r\n V[5] ^= F\r\n V[6] ^= G\r\n V[7] ^= H\r\n }\r\n\r\n // 转回 uint8\r\n const result = []\r\n for (let i = 0, len = V.length; i < len; i++) {\r\n const word = V[i]\r\n result.push((word & 0xff000000) >>> 24, (word & 0xff0000) >>> 16, (word & 0xff00) >>> 8, word & 0xff)\r\n }\r\n\r\n return result\r\n}\r\n\r\n/**\r\n * hmac 实现\r\n */\r\nconst blockLen = 64\r\nconst iPad = new Uint8Array(blockLen)\r\nconst oPad = new Uint8Array(blockLen)\r\nfor (let i = 0; i < blockLen; i++) {\r\n iPad[i] = 0x36\r\n oPad[i] = 0x5c\r\n}\r\nexport function hmac(input, key) {\r\n // 密钥填充\r\n if (key.length > blockLen) key = sm3(key)\r\n while (key.length < blockLen) key.push(0)\r\n\r\n const iPadKey = xor(key, iPad)\r\n const oPadKey = xor(key, oPad)\r\n\r\n const hash = sm3([...iPadKey, ...input])\r\n return sm3([...oPadKey, ...hash])\r\n}\r\n\r\nexport default {\r\n sm3,\r\n hmac,\r\n}\r\n"],"names":["W","M","rotl","x","n","s","xor","y","result","i","P0","X","P1","sm3","array","len","k","kArr","lenArr","start","dataView","V","j","T1","T2","A","B","C","D","E","F","G","H","SS1","SS2","TT1","TT2","T","word","blockLen","iPad","oPad","hmac","input","key","iPadKey","oPadKey","hash","SM3"],"mappings":"AACA,MAAMA,IAAI,IAAI,YAAY,EAAE,GACtBC,IAAI,IAAI,YAAY,EAAE;AAK5B,SAASC,EAAKC,GAAGC,GAAG;AAClB,QAAMC,IAAID,IAAI;AACN,SAAAD,KAAKE,IAAMF,MAAO,KAAKE;AACjC;AAKA,SAASC,EAAIH,GAAGI,GAAG;AACjB,QAAMC,IAAS,CAAA;AACf,WAASC,IAAIN,EAAE,SAAS,GAAGM,KAAK,GAAGA,IAAY,CAAAD,EAAAC,CAAC,KAAKN,EAAEM,CAAC,IAAIF,EAAEE,CAAC,KAAK;AAC7D,SAAAD;AACT;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