orion-design 0.1.49 → 0.1.50
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/base64-KVpG-D_n.js +103 -0
- package/dist/base64-KVpG-D_n.js.map +1 -0
- package/dist/components/Button/index.d.ts +2 -41
- package/dist/components/Card/index.d.ts +1 -3
- package/dist/components/Form/FileInput/FileInput.vue.d.ts +3 -100
- package/dist/components/Form/Form.vue.d.ts +2 -70
- package/dist/components/Form/LovInput/LovInput.vue.d.ts +21526 -1248
- package/dist/components/Form/TableSelect/TableSelect.vue.d.ts +21526 -1248
- package/dist/components/Form/index.d.ts +2 -38
- package/dist/components/Form/index.js +126 -127
- package/dist/components/Form/index.js.map +1 -1
- package/dist/components/LovTable/LovPagetable.vue.d.ts +2 -262
- package/dist/components/LovTable/LovQuerytable.vue.d.ts +2 -178
- package/dist/components/LovTable/index.d.ts +4 -233
- package/dist/components/Space/index.d.ts +1 -10
- package/dist/components/TableSelectPagetable/TableSelectPagetable.vue.d.ts +2 -262
- package/dist/components/TableSelectPagetable/index.d.ts +2 -136
- package/dist/components/Tabs/index.js +1 -1
- package/dist/components/Tree/Tree.vue.d.ts +2 -160
- package/dist/components/Tree/index.d.ts +2 -84
- package/dist/components/_util/dom/element.js +1 -1
- package/dist/components/_util/dom/style.js +1 -1
- package/dist/components/_util/error.js +1 -1
- package/dist/components/_util/functions.js +1 -1
- package/dist/components/_util/index.js +1 -1
- package/dist/components/_util/objects.js +1 -1
- package/dist/components/_util/strings.js +2 -2
- package/dist/components/_util/types.js +2 -2
- package/dist/components/_util/vue/install.js +1 -1
- package/dist/components/_util/vue/props/runtime.js +1 -1
- package/dist/components/_util/vue/refs.js +1 -1
- package/dist/components/_util/vue/vnode.js +1 -1
- package/dist/{functions-DzLqXvGt.js → functions-LOH6x_02.js} +2 -2
- package/dist/functions-LOH6x_02.js.map +1 -0
- package/dist/index-BW3nOBfD.js +714 -0
- package/dist/index-BW3nOBfD.js.map +1 -0
- package/dist/request/disivion/DivisionErrorHandler.d.ts +0 -2
- package/dist/request/disivion/DivisionErrorHandler.js +18 -28
- package/dist/request/disivion/DivisionErrorHandler.js.map +1 -1
- package/dist/request/disivion/index.d.ts +1 -0
- package/dist/request/disivion/index.js +73 -168
- package/dist/request/disivion/index.js.map +1 -1
- package/dist/request/error/ResponseError404.d.ts +7 -0
- package/dist/request/error/ResponseError404.js +10 -0
- package/dist/request/error/ResponseError404.js.map +1 -0
- package/dist/request/error/ResponseError500.d.ts +6 -0
- package/dist/request/error/ResponseError500.js +10 -0
- package/dist/request/error/ResponseError500.js.map +1 -0
- package/dist/request/error/{BizExceptionResponseError.d.ts → ResponseErrorBizException.d.ts} +1 -1
- package/dist/request/error/{BizExceptionResponseError.js → ResponseErrorBizException.js} +2 -2
- package/dist/request/error/ResponseErrorBizException.js.map +1 -0
- package/dist/request/error/{ExceptionResponseError.d.ts → ResponseErrorException.d.ts} +1 -1
- package/dist/request/error/{ExceptionResponseError.js → ResponseErrorException.js} +2 -2
- package/dist/request/error/ResponseErrorException.js.map +1 -0
- package/dist/request/error/{SessionExceptionResponseError.d.ts → ResponseErrorSessionException.d.ts} +1 -1
- package/dist/request/error/{SessionExceptionResponseError.js → ResponseErrorSessionException.js} +2 -2
- package/dist/request/error/{SessionExceptionResponseError.js.map → ResponseErrorSessionException.js.map} +1 -1
- package/dist/request/index.d.ts +12 -3
- package/dist/request/index.js +35 -11
- package/dist/request/index.js.map +1 -1
- package/dist/request/leaf7/Leaf7EncryptRequestParser.d.ts +8 -0
- package/dist/request/leaf7/Leaf7EncryptRequestParser.js +28 -0
- package/dist/request/leaf7/Leaf7EncryptRequestParser.js.map +1 -0
- package/dist/request/leaf7/Leaf7EncryptResponseParser.d.ts +8 -0
- package/dist/request/leaf7/Leaf7EncryptResponseParser.js +42 -0
- package/dist/request/leaf7/Leaf7EncryptResponseParser.js.map +1 -0
- package/dist/request/leaf7/Leaf7ErrorHandler.d.ts +7 -0
- package/dist/request/leaf7/Leaf7ErrorHandler.js +51 -0
- package/dist/request/leaf7/Leaf7ErrorHandler.js.map +1 -0
- package/dist/request/leaf7/Leaf7ResponseParser.d.ts +5 -0
- package/dist/request/leaf7/Leaf7ResponseParser.js +17 -0
- package/dist/request/leaf7/Leaf7ResponseParser.js.map +1 -0
- package/dist/request/leaf7/index.d.ts +20 -0
- package/dist/request/leaf7/index.js +130 -0
- package/dist/request/leaf7/index.js.map +1 -0
- package/dist/request/leaf7/smCrypto/sm2/asn1.d.ts +14 -0
- package/dist/request/leaf7/smCrypto/sm2/asn1.js +81 -0
- package/dist/request/leaf7/smCrypto/sm2/asn1.js.map +1 -0
- package/dist/request/leaf7/smCrypto/sm2/ec.d.ts +119 -0
- package/dist/request/leaf7/smCrypto/sm2/ec.js +199 -0
- package/dist/request/leaf7/smCrypto/sm2/ec.js.map +1 -0
- package/dist/request/leaf7/smCrypto/sm2/index.d.ts +45 -0
- package/dist/request/leaf7/smCrypto/sm2/index.js +102 -0
- package/dist/request/leaf7/smCrypto/sm2/index.js.map +1 -0
- package/dist/request/leaf7/smCrypto/sm2/sm3.d.ts +10 -0
- package/dist/request/leaf7/smCrypto/sm2/sm3.js +69 -0
- package/dist/request/leaf7/smCrypto/sm2/sm3.js.map +1 -0
- package/dist/request/leaf7/smCrypto/sm2/utils.d.ts +66 -0
- package/dist/request/leaf7/smCrypto/sm2/utils.js +91 -0
- package/dist/request/leaf7/smCrypto/sm2/utils.js.map +1 -0
- package/dist/request/leaf7/smCrypto/sm3/index.d.ts +1 -0
- package/dist/request/leaf7/smCrypto/sm3/index.js +45 -0
- package/dist/request/leaf7/smCrypto/sm3/index.js.map +1 -0
- package/dist/request/leaf7/smCrypto/sm4/index.d.ts +5 -0
- package/dist/request/leaf7/smCrypto/sm4/index.js +399 -0
- package/dist/request/leaf7/smCrypto/sm4/index.js.map +1 -0
- package/dist/request/leaf7/smCrypto/smCrypto.d.ts +3 -0
- package/dist/request/leaf7/smCrypto/smCrypto.js +9 -0
- package/dist/request/leaf7/smCrypto/smCrypto.js.map +1 -0
- package/dist/request/leaf7/types.d.ts +11 -0
- package/dist/request/leaf7/types.js +2 -0
- package/dist/request/leaf7/types.js.map +1 -0
- package/dist/request/utils/readBlob.d.ts +1 -0
- package/dist/request/utils/readBlob.js +12 -0
- package/dist/request/utils/readBlob.js.map +1 -0
- package/dist/utils/functions.js +1 -1
- package/dist/version/version.d.ts +1 -1
- package/dist/version/version.js +1 -1
- package/dist/version/version.js.map +1 -1
- package/package.json +2 -1
- package/dist/functions-DzLqXvGt.js.map +0 -1
- package/dist/request/error/BizExceptionResponseError.js.map +0 -1
- package/dist/request/error/ExceptionResponseError.js.map +0 -1
@@ -0,0 +1,130 @@
|
|
1
|
+
import E from "axios";
|
2
|
+
import { g as O } from "../../base64-KVpG-D_n.js";
|
3
|
+
import { cloneDeep as y } from "lodash-es";
|
4
|
+
import "dayjs";
|
5
|
+
import "../../utils/md5.js";
|
6
|
+
import "decimal.js";
|
7
|
+
import F from "../ResponseParserChain.js";
|
8
|
+
import h from "../ErrorHandlerChain.js";
|
9
|
+
import k from "../RequestFilterChain.js";
|
10
|
+
import { ElLoading as w } from "element-plus";
|
11
|
+
import S from "../error/ResponseError.js";
|
12
|
+
let g = [], R = [], f = [], m = "/", u = 1e3 * 30, b = "json";
|
13
|
+
const d = E.create();
|
14
|
+
d.interceptors.request.use(function(e) {
|
15
|
+
const t = new k(g);
|
16
|
+
return t.doFilter(e, t), e;
|
17
|
+
});
|
18
|
+
d.interceptors.response.use(function(e) {
|
19
|
+
try {
|
20
|
+
const t = new F(R);
|
21
|
+
return t.doParse(e, t);
|
22
|
+
} catch (t) {
|
23
|
+
throw new S(t.message, { cause: t }, e);
|
24
|
+
}
|
25
|
+
});
|
26
|
+
function T(e, t = {}, l = { loading: !0, mask: !1, timeout: u }) {
|
27
|
+
let r = t;
|
28
|
+
t instanceof FormData || (r = y(t));
|
29
|
+
let n;
|
30
|
+
return l.loading === !0 && (n = w.service({ fullscreen: !0, background: "transparent" })), d.request({
|
31
|
+
baseURL: m,
|
32
|
+
method: "POST",
|
33
|
+
timeout: u,
|
34
|
+
withCredentials: !0,
|
35
|
+
url: e,
|
36
|
+
data: r,
|
37
|
+
responseType: b,
|
38
|
+
...l
|
39
|
+
}).then((s) => (n && n.close(), s)).catch(function(s) {
|
40
|
+
n && n.close();
|
41
|
+
const i = new h(f);
|
42
|
+
return i.handle(s, i);
|
43
|
+
});
|
44
|
+
}
|
45
|
+
function x(e, t = {}, l = { loading: !0, mask: !1, timeout: u }) {
|
46
|
+
let r;
|
47
|
+
return l.loading === !0 && (r = w.service({ fullscreen: !0, background: "transparent" })), d.request({
|
48
|
+
baseURL: m,
|
49
|
+
method: "POST",
|
50
|
+
timeout: u,
|
51
|
+
withCredentials: !0,
|
52
|
+
url: e,
|
53
|
+
data: t,
|
54
|
+
responseType: "blob",
|
55
|
+
...l
|
56
|
+
}).then((n) => (r && r.close(), n)).then((n) => {
|
57
|
+
const s = n.headers["content-disposition"], i = n.data, a = s.match(/attachment; filename=\"(.*?)\"/)[1], c = O.decode(a);
|
58
|
+
if (window.navigator && window.navigator.msSaveOrOpenBlob)
|
59
|
+
window.navigator.msSaveOrOpenBlob(i, c);
|
60
|
+
else {
|
61
|
+
const o = document.createElement("a"), p = URL.createObjectURL(i);
|
62
|
+
o.href = p, o.download = c, document.body.appendChild(o), o.click(), document.body.removeChild(o), URL.revokeObjectURL(p);
|
63
|
+
}
|
64
|
+
}).catch(function(n) {
|
65
|
+
r && r.close();
|
66
|
+
const s = new h(f);
|
67
|
+
return s.handle(n, s);
|
68
|
+
});
|
69
|
+
}
|
70
|
+
function A(e, t, l) {
|
71
|
+
const r = new FormData();
|
72
|
+
if (t) {
|
73
|
+
const n = Object.keys(t);
|
74
|
+
for (let s = 0; s < n.length; s++) {
|
75
|
+
const i = n[s], a = t[i];
|
76
|
+
if (a instanceof File)
|
77
|
+
r.append(i, a);
|
78
|
+
else if (a instanceof Array) {
|
79
|
+
let c = !1;
|
80
|
+
for (let o = 0; o < a.length; o++)
|
81
|
+
if (a[o] instanceof File) {
|
82
|
+
c = !0;
|
83
|
+
break;
|
84
|
+
}
|
85
|
+
if (c)
|
86
|
+
for (let o = 0; o < a.length; o++)
|
87
|
+
r.append(i, a[o]);
|
88
|
+
else
|
89
|
+
r.append(i, JSON.stringify(a));
|
90
|
+
} else
|
91
|
+
r.append(i, JSON.stringify(a));
|
92
|
+
}
|
93
|
+
}
|
94
|
+
return T(e, r, l);
|
95
|
+
}
|
96
|
+
const H = {
|
97
|
+
setBaseUrl: (e) => {
|
98
|
+
if (!e)
|
99
|
+
throw new Error("pBaseUrl is null!");
|
100
|
+
m = e;
|
101
|
+
},
|
102
|
+
setRequestTimeout: (e) => {
|
103
|
+
u = e;
|
104
|
+
},
|
105
|
+
setResponseType: (e) => {
|
106
|
+
b = e;
|
107
|
+
},
|
108
|
+
setRequestFilters: (...e) => {
|
109
|
+
if (e == null)
|
110
|
+
throw new Error("filters is null!");
|
111
|
+
g = e;
|
112
|
+
},
|
113
|
+
setResponseParsers: (...e) => {
|
114
|
+
if (e == null)
|
115
|
+
throw new Error("parsers is null!");
|
116
|
+
R = e;
|
117
|
+
},
|
118
|
+
setErrorHandlers: (...e) => {
|
119
|
+
if (e == null)
|
120
|
+
throw new Error("handlers should not null!");
|
121
|
+
f = e;
|
122
|
+
}
|
123
|
+
};
|
124
|
+
export {
|
125
|
+
H as config,
|
126
|
+
x as download,
|
127
|
+
T as request,
|
128
|
+
A as upload
|
129
|
+
};
|
130
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/request/leaf7/index.ts"],"sourcesContent":["import axios from 'axios'\r\nimport { Base64 } from 'js-base64'\r\nimport { cloneDeep } from '../../utils'\r\nimport ResponseParserChain, { type ResponseParser } from '../ResponseParserChain'\r\nimport ErrorHandlerChain, { type ErrorHandler } from '../ErrorHandlerChain'\r\nimport RequestFilterChain, { type RequestFilter } from '../RequestFilterChain'\r\nimport { ElLoading } from 'element-plus'\r\n\r\nimport ResponseError from '../error/ResponseError'\r\n\r\nexport type RequestParams = Record<string, unknown>\r\n\r\nexport interface RequestOptionsI {\r\n loading?: boolean\r\n mask?: boolean\r\n timeout?: number\r\n}\r\n\r\n//////////////////////////////////// Chain\r\nlet gRequestFilters: RequestFilter[] = []\r\nlet gResponseParsers: ResponseParser[] = []\r\nlet gErrorHandlers: ErrorHandler[] = []\r\n\r\n//////////////////////////////////// GLOBAL VARS\r\n\r\nlet BASE_URL = '/'\r\nlet REQUEST_TIMEOUT = 1000 * 30\r\nconst LOADING_DELAY = 1500\r\nlet RESPONSE_TYPE: 'json' | 'text' = 'json'\r\n\r\n//////////////////////////////////// AXIOS\r\n\r\nconst g_AxiosInstance = axios.create()\r\ng_AxiosInstance.interceptors.request.use(function (config) {\r\n const chain = new RequestFilterChain(gRequestFilters)\r\n chain.doFilter(config, chain)\r\n return config\r\n})\r\ng_AxiosInstance.interceptors.response.use(function (response) {\r\n try {\r\n const chain = new ResponseParserChain(gResponseParsers)\r\n return chain.doParse(response, chain)\r\n } catch (e) {\r\n throw new ResponseError((e as Error).message, { cause: e }, response)\r\n }\r\n})\r\n\r\nexport function request<T>(\r\n url: string,\r\n data: RequestParams | FormData = {},\r\n options: RequestOptionsI = { loading: true, mask: false, timeout: REQUEST_TIMEOUT }\r\n): Promise<T> {\r\n let newData = data\r\n if (!(data instanceof FormData)) {\r\n newData = cloneDeep(data)\r\n }\r\n\r\n // loading\r\n let loading: any\r\n\r\n if (options.loading === true) {\r\n loading = ElLoading.service({ fullscreen: true, background: 'transparent' })\r\n }\r\n\r\n return g_AxiosInstance\r\n .request({\r\n baseURL: BASE_URL,\r\n method: 'POST',\r\n timeout: REQUEST_TIMEOUT,\r\n withCredentials: true,\r\n url,\r\n data: newData,\r\n responseType: RESPONSE_TYPE,\r\n ...options,\r\n })\r\n .then((data) => {\r\n if (loading) {\r\n loading.close()\r\n }\r\n\r\n return data\r\n })\r\n .catch(function (error) {\r\n if (loading) {\r\n loading.close()\r\n }\r\n\r\n const chain = new ErrorHandlerChain(gErrorHandlers)\r\n return chain.handle(error, chain)\r\n }) as Promise<T>\r\n}\r\n\r\nexport function download(url: string, data: RequestParams = {}, options: RequestOptionsI = { loading: true, mask: false, timeout: REQUEST_TIMEOUT }) {\r\n let loading: any\r\n\r\n if (options.loading === true) {\r\n loading = ElLoading.service({ fullscreen: true, background: 'transparent' })\r\n }\r\n\r\n return g_AxiosInstance\r\n .request({\r\n baseURL: BASE_URL,\r\n method: 'POST',\r\n timeout: REQUEST_TIMEOUT,\r\n withCredentials: true,\r\n url,\r\n data,\r\n responseType: 'blob',\r\n ...options,\r\n })\r\n .then((data) => {\r\n if (loading) {\r\n loading.close()\r\n }\r\n\r\n return data\r\n })\r\n .then((response) => {\r\n const contentDisposition = response.headers['content-disposition']\r\n const blob = response.data\r\n\r\n const base64FileName = contentDisposition.match(/attachment; filename=\\\"(.*?)\\\"/)[1]\r\n const decodedFileName = Base64.decode(base64FileName)\r\n // for IE\r\n //@ts-ignore\r\n if (window.navigator && window.navigator.msSaveOrOpenBlob) {\r\n //@ts-ignore\r\n window.navigator.msSaveOrOpenBlob(blob, decodedFileName)\r\n } else {\r\n const a = document.createElement('a')\r\n const url = URL.createObjectURL(blob)\r\n a.href = url\r\n a.download = decodedFileName\r\n document.body.appendChild(a)\r\n a.click()\r\n document.body.removeChild(a)\r\n URL.revokeObjectURL(url)\r\n }\r\n })\r\n .catch(function (error) {\r\n if (loading) {\r\n loading.close()\r\n }\r\n\r\n const chain = new ErrorHandlerChain(gErrorHandlers)\r\n return chain.handle(error, chain)\r\n })\r\n}\r\n\r\nexport function upload(url: string, params: RequestParams, options: RequestOptionsI) {\r\n const formdata = new FormData()\r\n if (params) {\r\n const keys = Object.keys(params)\r\n const normalParams: Record<string, unknown> = {}\r\n\r\n for (let i = 0; i < keys.length; i++) {\r\n const key = keys[i]\r\n const itemValue = params[key]\r\n if (itemValue instanceof File) {\r\n formdata.append(key, itemValue)\r\n } else if (itemValue instanceof Array) {\r\n let isFile = false\r\n for (let j = 0; j < itemValue.length; j++) {\r\n if (itemValue[j] instanceof File) {\r\n isFile = true\r\n break\r\n }\r\n }\r\n if (isFile) {\r\n for (let j = 0; j < itemValue.length; j++) {\r\n formdata.append(key, itemValue[j])\r\n }\r\n } else {\r\n formdata.append(key, JSON.stringify(itemValue))\r\n }\r\n } else {\r\n formdata.append(key, JSON.stringify(itemValue))\r\n }\r\n }\r\n }\r\n\r\n return request(url, formdata, options)\r\n}\r\n\r\n// config\r\nexport const config = {\r\n setBaseUrl: (pBaseUrl: string) => {\r\n if (!pBaseUrl) {\r\n throw new Error(`pBaseUrl is null!`)\r\n }\r\n BASE_URL = pBaseUrl\r\n },\r\n setRequestTimeout: (pTimeout: number) => {\r\n REQUEST_TIMEOUT = pTimeout\r\n },\r\n setResponseType: (pType: 'json' | 'text') => {\r\n RESPONSE_TYPE = pType\r\n },\r\n setRequestFilters: (...filters: RequestFilter[]) => {\r\n if (filters == null) {\r\n throw new Error(`filters is null!`)\r\n }\r\n gRequestFilters = filters\r\n },\r\n setResponseParsers: (...parsers: ResponseParser[]) => {\r\n if (parsers == null) {\r\n throw new Error(`parsers is null!`)\r\n }\r\n gResponseParsers = parsers\r\n },\r\n setErrorHandlers: (...handlers: ErrorHandler[]) => {\r\n if (handlers == null) {\r\n throw new Error(`handlers should not null!`)\r\n }\r\n gErrorHandlers = handlers\r\n },\r\n}\r\n"],"names":["gRequestFilters","gResponseParsers","gErrorHandlers","BASE_URL","REQUEST_TIMEOUT","RESPONSE_TYPE","g_AxiosInstance","axios","config","chain","RequestFilterChain","response","ResponseParserChain","e","ResponseError","request","url","data","options","newData","cloneDeep","loading","ElLoading","error","ErrorHandlerChain","download","contentDisposition","blob","base64FileName","decodedFileName","Base64","a","upload","params","formdata","keys","i","key","itemValue","isFile","j","pBaseUrl","pTimeout","pType","filters","parsers","handlers"],"mappings":";;;;;;;;;;;AAmBA,IAAIA,IAAmC,CAAA,GACnCC,IAAqC,CAAA,GACr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C,IAAA4C;AAAA,EACnB;AACF;"}
|
@@ -0,0 +1,81 @@
|
|
1
|
+
import { j as i } from "../../../../index-BW3nOBfD.js";
|
2
|
+
function x(e) {
|
3
|
+
let t = e.toString(16);
|
4
|
+
if (t[0] !== "-")
|
5
|
+
t.length % 2 === 1 ? t = "0" + t : t.match(/^[0-7]/) || (t = "00" + t);
|
6
|
+
else {
|
7
|
+
t = t.substr(1);
|
8
|
+
let n = t.length;
|
9
|
+
n % 2 === 1 ? n += 1 : t.match(/^[0-7]/) || (n += 2);
|
10
|
+
let s = "";
|
11
|
+
for (let r = 0; r < n; r++) s += "f";
|
12
|
+
s = new i.BigInteger(s, 16), t = s.xor(e).add(i.BigInteger.ONE), t = t.toString(16).replace(/^-/, "");
|
13
|
+
}
|
14
|
+
return t;
|
15
|
+
}
|
16
|
+
class h {
|
17
|
+
constructor() {
|
18
|
+
this.tlv = null, this.t = "00", this.l = "00", this.v = "";
|
19
|
+
}
|
20
|
+
/**
|
21
|
+
* 获取 der 编码比特流16进制串
|
22
|
+
*/
|
23
|
+
getEncodedHex() {
|
24
|
+
return this.tlv || (this.v = this.getValue(), this.l = this.getLength(), this.tlv = this.t + this.l + this.v), this.tlv;
|
25
|
+
}
|
26
|
+
getLength() {
|
27
|
+
const t = this.v.length / 2;
|
28
|
+
let n = t.toString(16);
|
29
|
+
return n.length % 2 === 1 && (n = "0" + n), t < 128 ? n : (128 + n.length / 2).toString(16) + n;
|
30
|
+
}
|
31
|
+
getValue() {
|
32
|
+
return "";
|
33
|
+
}
|
34
|
+
}
|
35
|
+
class l extends h {
|
36
|
+
constructor(t) {
|
37
|
+
super(), this.t = "02", t && (this.v = x(t));
|
38
|
+
}
|
39
|
+
getValue() {
|
40
|
+
return this.v;
|
41
|
+
}
|
42
|
+
}
|
43
|
+
class b extends h {
|
44
|
+
constructor(t) {
|
45
|
+
super(), this.t = "30", this.asn1Array = t;
|
46
|
+
}
|
47
|
+
getValue() {
|
48
|
+
return this.v = this.asn1Array.map((t) => t.getEncodedHex()).join(""), this.v;
|
49
|
+
}
|
50
|
+
}
|
51
|
+
function u(e, t) {
|
52
|
+
return +e[t + 2] < 8 ? 1 : +e.substr(t + 2, 2) & 128;
|
53
|
+
}
|
54
|
+
function g(e, t) {
|
55
|
+
const n = u(e, t), s = e.substr(t + 2, n * 2);
|
56
|
+
return s ? (+s[0] < 8 ? new i.BigInteger(s, 16) : new i.BigInteger(s.substr(2), 16)).intValue() : -1;
|
57
|
+
}
|
58
|
+
function o(e, t) {
|
59
|
+
const n = u(e, t);
|
60
|
+
return t + (n + 1) * 2;
|
61
|
+
}
|
62
|
+
const w = {
|
63
|
+
/**
|
64
|
+
* ASN.1 der 编码,针对 sm2 签名
|
65
|
+
*/
|
66
|
+
encodeDer(e, t) {
|
67
|
+
const n = new l(e), s = new l(t);
|
68
|
+
return new b([n, s]).getEncodedHex();
|
69
|
+
},
|
70
|
+
/**
|
71
|
+
* 解析 ASN.1 der,针对 sm2 验签
|
72
|
+
*/
|
73
|
+
decodeDer(e) {
|
74
|
+
const t = o(e, 0), n = o(e, t), s = g(e, t), r = e.substr(n, s * 2), c = n + r.length, a = o(e, c), d = g(e, c), f = e.substr(a, d * 2), v = new i.BigInteger(r, 16), S = new i.BigInteger(f, 16);
|
75
|
+
return { r: v, s: S };
|
76
|
+
}
|
77
|
+
};
|
78
|
+
export {
|
79
|
+
w as default
|
80
|
+
};
|
81
|
+
//# sourceMappingURL=asn1.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"asn1.js","sources":["../../../../../src/request/leaf7/smCrypto/sm2/asn1.ts"],"sourcesContent":["import { BigInteger } from 'jsbn'\r\n\r\nfunction bigintToValue(bigint) {\r\n let h = bigint.toString(16)\r\n if (h[0] !== '-') {\r\n // 正数\r\n if (h.length % 2 === 1) h = '0' + h // 补齐到整字节\r\n else if (!h.match(/^[0-7]/)) h = '00' + h // 非0开头,则补一个全0字节\r\n } else {\r\n // 负数\r\n h = h.substr(1)\r\n\r\n let len = h.length\r\n if (len % 2 === 1) len += 1 // 补齐到整字节\r\n else if (!h.match(/^[0-7]/)) len += 2 // 非0开头,则补一个全0字节\r\n\r\n let mask = ''\r\n for (let i = 0; i < len; i++) mask += 'f'\r\n mask = new BigInteger(mask, 16)\r\n\r\n // 对绝对值取反,加1\r\n h = mask.xor(bigint).add(BigInteger.ONE)\r\n h = h.toString(16).replace(/^-/, '')\r\n }\r\n return h\r\n}\r\n\r\nclass ASN1Object {\r\n constructor() {\r\n this.tlv = null\r\n this.t = '00'\r\n this.l = '00'\r\n this.v = ''\r\n }\r\n\r\n /**\r\n * 获取 der 编码比特流16进制串\r\n */\r\n getEncodedHex() {\r\n if (!this.tlv) {\r\n this.v = this.getValue()\r\n this.l = this.getLength()\r\n this.tlv = this.t + this.l + this.v\r\n }\r\n return this.tlv\r\n }\r\n\r\n getLength() {\r\n const n = this.v.length / 2 // 字节数\r\n let nHex = n.toString(16)\r\n if (nHex.length % 2 === 1) nHex = '0' + nHex // 补齐到整字节\r\n\r\n if (n < 128) {\r\n // 短格式,以 0 开头\r\n return nHex\r\n } else {\r\n // 长格式,以 1 开头\r\n const head = 128 + nHex.length / 2 // 1(1位) + 真正的长度占用字节数(7位) + 真正的长度\r\n return head.toString(16) + nHex\r\n }\r\n }\r\n\r\n getValue() {\r\n return ''\r\n }\r\n}\r\n\r\nclass DERInteger extends ASN1Object {\r\n constructor(bigint) {\r\n super()\r\n\r\n this.t = '02' // 整型标签说明\r\n if (bigint) this.v = bigintToValue(bigint)\r\n }\r\n\r\n getValue() {\r\n return this.v\r\n }\r\n}\r\n\r\nclass DERSequence extends ASN1Object {\r\n constructor(asn1Array) {\r\n super()\r\n\r\n this.t = '30' // 序列标签说明\r\n this.asn1Array = asn1Array\r\n }\r\n\r\n getValue() {\r\n this.v = this.asn1Array.map((asn1Object) => asn1Object.getEncodedHex()).join('')\r\n return this.v\r\n }\r\n}\r\n\r\n/**\r\n * 获取 l 占用字节数\r\n */\r\nfunction getLenOfL(str, start) {\r\n if (+str[start + 2] < 8) return 1 // l 以0开头,则表示短格式,只占一个字节\r\n return +str.substr(start + 2, 2) & (0x7f + 1) // 长格式,取第一个字节后7位作为长度真正占用字节数,再加上本身\r\n}\r\n\r\n/**\r\n * 获取 l\r\n */\r\nfunction getL(str, start) {\r\n // 获取 l\r\n const len = getLenOfL(str, start)\r\n const l = str.substr(start + 2, len * 2)\r\n\r\n if (!l) return -1\r\n const bigint = +l[0] < 8 ? new BigInteger(l, 16) : new BigInteger(l.substr(2), 16)\r\n\r\n return bigint.intValue()\r\n}\r\n\r\n/**\r\n * 获取 v 的位置\r\n */\r\nfunction getStartOfV(str, start) {\r\n const len = getLenOfL(str, start)\r\n return start + (len + 1) * 2\r\n}\r\n\r\nexport default {\r\n /**\r\n * ASN.1 der 编码,针对 sm2 签名\r\n */\r\n encodeDer(r, s) {\r\n const derR = new DERInteger(r)\r\n const derS = new DERInteger(s)\r\n const derSeq = new DERSequence([derR, derS])\r\n\r\n return derSeq.getEncodedHex()\r\n },\r\n\r\n /**\r\n * 解析 ASN.1 der,针对 sm2 验签\r\n */\r\n decodeDer(input) {\r\n // 结构:\r\n // input = | tSeq | lSeq | vSeq |\r\n // vSeq = | tR | lR | vR | tS | lS | vS |\r\n const start = getStartOfV(input, 0)\r\n\r\n const vIndexR = getStartOfV(input, start)\r\n const lR = getL(input, start)\r\n const vR = input.substr(vIndexR, lR * 2)\r\n\r\n const nextStart = vIndexR + vR.length\r\n const vIndexS = getStartOfV(input, nextStart)\r\n const lS = getL(input, nextStart)\r\n const vS = input.substr(vIndexS, lS * 2)\r\n\r\n const r = new BigInteger(vR, 16)\r\n const s = new BigInteger(vS, 16)\r\n\r\n return { r, s }\r\n },\r\n}\r\n"],"names":["bigintToValue","bigint","h","len","mask","i","BigInteger","ASN1Object","n","nHex","DERInteger","DERSequence","asn1Array","asn1Object","getLenOfL","str","start","getL","l","getStartOfV","asn1","r","s","derR","derS","input","vIndexR","lR","vR","nextStart","vIndexS","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AOT,CAAK,GAClCW,IAAKV,EAAKQ,GAAOT,CAAK,GACtBY,IAAKH,EAAM,OAAOC,GAASC,IAAK,CAAC,GAEjCE,IAAYH,IAAUE,EAAG,QACzBE,IAAUX,EAAYM,GAAOI,CAAS,GACtCE,IAAKd,EAAKQ,GAAOI,CAAS,GAC1BG,IAAKP,EAAM,OAAOK,GAASC,IAAK,CAAC,GAEjCV,IAAI,IAAIf,EAAAA,WAAWsB,GAAI,EAAE,GACzBN,IAAI,IAAIhB,EAAAA,WAAW0B,GAAI,EAAE;AAExB,WAAA,EAAE,GAAAX,GAAG,GAAAC;EACd;AACF;"}
|
@@ -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,EAAE,IAAI,KAAK,CAAC,CAAC;AAAA,EACnF;AAAA;AAAA;AAAA;AAAA,EAKA,SAASA,GAAG;AACV,WAAO,IAAIJ,EAAiB,KAAK,GAAG,KAAK,EAAE,SAASI,EAAE,aAAc,CAAA,EAAE,IAAI,KAAK,CAAC,CAAC;AAAA,EACnF;AAAA;AAAA;AAAA;AAAA,EAKA,OAAOA,GAAG;AACR,WAAO,IAAIJ,EAAiB,KAAK,GAAG,KAAK,EAA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ACtBE,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;
|