sm-crypto-v2 1.9.0 → 1.9.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [1.9.2](https://github.com/Cubelrti/sm-crypto-v2/compare/v1.9.1...v1.9.2) (2024-08-16)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * **sm4:** string type return ([406fa5a](https://github.com/Cubelrti/sm-crypto-v2/commit/406fa5a848015e3a02339f109f60ec1e8ec3fe8b))
11
+
12
+ ### [1.9.1](https://github.com/Cubelrti/sm-crypto-v2/compare/v1.9.0...v1.9.1) (2024-07-09)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * **asn1:** correct the implementation of the long version of L encoding in asn.1 ([55569c5](https://github.com/Cubelrti/sm-crypto-v2/commit/55569c55235c0a82525b142ea9a4f8a2669654ce))
18
+
5
19
  ## [1.9.0](https://github.com/Cubelrti/sm-crypto-v2/compare/v1.7.0...v1.9.0) (2023-12-27)
6
20
 
7
21
 
package/README.md CHANGED
@@ -8,6 +8,8 @@
8
8
 
9
9
  参数支持 TypedArray,导出 esm/cjs。
10
10
 
11
+ For WebAssembly-supported platform, see [sm-crypto-wasm](https://github.com/Cubelrti/sm-crypto-wasm) and its [Online Playground](https://cubelrti.github.io/sm-crypto-wasm/)
12
+
11
13
  ## 特性
12
14
 
13
15
  - ⚡ 基于 [`noble-curves` Abstract API](https://github.com/paulmillr/noble-curves#abstract-api) 重构 SM2,性能提升近4倍。详见 [noble-curves 文档](https://paulmillr.com/posts/noble-secp256k1-fast-ecc/)
package/dist/index.d.mts CHANGED
@@ -153,16 +153,16 @@ interface SM4Options {
153
153
  declare function sm4(inArray: Uint8Array | string, key: Uint8Array | string, cryptFlag: 0 | 1, options?: SM4Options): string | Uint8Array;
154
154
  declare function encrypt(inArray: Uint8Array | string, key: Uint8Array | string, options?: {
155
155
  output: 'array';
156
- } | SM4Options): Uint8Array;
156
+ } & SM4Options): Uint8Array;
157
157
  declare function encrypt(inArray: Uint8Array | string, key: Uint8Array | string, options?: {
158
158
  output: 'string';
159
- } | SM4Options): string;
159
+ } & SM4Options): string;
160
160
  declare function decrypt(inArray: Uint8Array | string, key: Uint8Array | string, options?: {
161
161
  output: 'array';
162
- } | SM4Options): Uint8Array;
162
+ } & SM4Options): Uint8Array;
163
163
  declare function decrypt(inArray: Uint8Array | string, key: Uint8Array | string, options?: {
164
164
  output: 'string';
165
- } | SM4Options): string;
165
+ } & SM4Options): string;
166
166
 
167
167
  type index_SM4Options = SM4Options;
168
168
  declare const index_decrypt: typeof decrypt;
package/dist/index.d.ts CHANGED
@@ -153,16 +153,16 @@ interface SM4Options {
153
153
  declare function sm4(inArray: Uint8Array | string, key: Uint8Array | string, cryptFlag: 0 | 1, options?: SM4Options): string | Uint8Array;
154
154
  declare function encrypt(inArray: Uint8Array | string, key: Uint8Array | string, options?: {
155
155
  output: 'array';
156
- } | SM4Options): Uint8Array;
156
+ } & SM4Options): Uint8Array;
157
157
  declare function encrypt(inArray: Uint8Array | string, key: Uint8Array | string, options?: {
158
158
  output: 'string';
159
- } | SM4Options): string;
159
+ } & SM4Options): string;
160
160
  declare function decrypt(inArray: Uint8Array | string, key: Uint8Array | string, options?: {
161
161
  output: 'array';
162
- } | SM4Options): Uint8Array;
162
+ } & SM4Options): Uint8Array;
163
163
  declare function decrypt(inArray: Uint8Array | string, key: Uint8Array | string, options?: {
164
164
  output: 'string';
165
- } | SM4Options): string;
165
+ } & SM4Options): string;
166
166
 
167
167
  type index_SM4Options = SM4Options;
168
168
  declare const index_decrypt: typeof decrypt;
package/dist/index.js CHANGED
@@ -167,7 +167,11 @@ var DERSequence = class extends ASN1Object {
167
167
  function getLenOfL(str, start) {
168
168
  if (+str[start + 2] < 8)
169
169
  return 1;
170
- return +str.substring(start + 2, start + 4) & 127 + 1;
170
+ const encoded = str.slice(start + 2, start + 6);
171
+ const headHex = encoded.slice(0, 2);
172
+ const head = parseInt(headHex, 16);
173
+ const nHexLength = (head - 128) * 2;
174
+ return nHexLength;
171
175
  }
172
176
  function getL(str, start) {
173
177
  const len = getLenOfL(str, start);
package/dist/index.mjs CHANGED
@@ -135,7 +135,11 @@ var DERSequence = class extends ASN1Object {
135
135
  function getLenOfL(str, start) {
136
136
  if (+str[start + 2] < 8)
137
137
  return 1;
138
- return +str.substring(start + 2, start + 4) & 127 + 1;
138
+ const encoded = str.slice(start + 2, start + 6);
139
+ const headHex = encoded.slice(0, 2);
140
+ const head = parseInt(headHex, 16);
141
+ const nHexLength = (head - 128) * 2;
142
+ return nHexLength;
139
143
  }
140
144
  function getL(str, start) {
141
145
  const len = getLenOfL(str, start);
@@ -153,16 +153,16 @@ interface SM4Options {
153
153
  declare function sm4(inArray: Uint8Array | string, key: Uint8Array | string, cryptFlag: 0 | 1, options?: SM4Options): string | Uint8Array;
154
154
  declare function encrypt(inArray: Uint8Array | string, key: Uint8Array | string, options?: {
155
155
  output: 'array';
156
- } | SM4Options): Uint8Array;
156
+ } & SM4Options): Uint8Array;
157
157
  declare function encrypt(inArray: Uint8Array | string, key: Uint8Array | string, options?: {
158
158
  output: 'string';
159
- } | SM4Options): string;
159
+ } & SM4Options): string;
160
160
  declare function decrypt(inArray: Uint8Array | string, key: Uint8Array | string, options?: {
161
161
  output: 'array';
162
- } | SM4Options): Uint8Array;
162
+ } & SM4Options): Uint8Array;
163
163
  declare function decrypt(inArray: Uint8Array | string, key: Uint8Array | string, options?: {
164
164
  output: 'string';
165
- } | SM4Options): string;
165
+ } & SM4Options): string;
166
166
 
167
167
  type index_SM4Options = SM4Options;
168
168
  declare const index_decrypt: typeof decrypt;
@@ -975,7 +975,11 @@ var DERSequence = /*#__PURE__*/ function(ASN1Object) {
975
975
  }(ASN1Object);
976
976
  function getLenOfL(str, start) {
977
977
  if (+str[start + 2] < 8) return 1;
978
- return +str.substring(start + 2, start + 4) & 127 + 1;
978
+ var encoded = str.slice(start + 2, start + 6);
979
+ var headHex = encoded.slice(0, 2);
980
+ var head = parseInt(headHex, 16);
981
+ var nHexLength = (head - 128) * 2;
982
+ return nHexLength;
979
983
  }
980
984
  function getL(str, start) {
981
985
  var len = getLenOfL(str, start);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sm-crypto-v2",
3
- "version": "1.9.0",
3
+ "version": "1.9.2",
4
4
  "description": "sm-crypto-v2",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",