yc-ui2 0.1.2-beta18 → 0.1.2-beta20

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,3211 @@
1
+ /*******************************************************
2
+ *
3
+ * 使用此JS脚本之前请先仔细阅读帮助文档!
4
+ *
5
+ * @author Fuly
6
+ * @version 3.2.3
7
+ * @date 2020/12/23
8
+ *
9
+ **********************************************************/
10
+
11
+
12
+
13
+ var split;
14
+
15
+ // Avoid running twice; that would break the `nativeSplit` reference
16
+ // eslint-disable-next-line no-unused-vars
17
+ split = split || function (undef) {
18
+
19
+ var nativeSplit = String.prototype.split,
20
+ compliantExecNpcg = /()??/.exec("")[1] === undef, // NPCG: nonparticipating capturing group
21
+ self;
22
+
23
+ self = function (str, separator, limit) {
24
+ // If `separator` is not a regex, use `nativeSplit`
25
+ if (Object.prototype.toString.call(separator) !== "[object RegExp]") {
26
+ return nativeSplit.call(str, separator, limit);
27
+ }
28
+ var output = [],
29
+ flags = (separator.ignoreCase ? "i" : "") +
30
+ (separator.multiline ? "m" : "") +
31
+ (separator.extended ? "x" : "") + // Proposed for ES6
32
+ (separator.sticky ? "y" : ""), // Firefox 3+
33
+ lastLastIndex = 0,
34
+ // Make `global` and avoid `lastIndex` issues by working with a copy
35
+ // eslint-disable-next-line no-redeclare
36
+ separator = new RegExp(separator.source, flags + "g"),
37
+ separator2, match, lastIndex, lastLength;
38
+ str += ""; // Type-convert
39
+ if (!compliantExecNpcg) {
40
+ // Doesn't need flags gy, but they don't hurt
41
+ separator2 = new RegExp("^" + separator.source + "$(?!\\s)", flags);
42
+ }
43
+ /* Values for `limit`, per the spec:
44
+ * If undefined: 4294967295 // Math.pow(2, 32) - 1
45
+ * If 0, Infinity, or NaN: 0
46
+ * If positive number: limit = Math.floor(limit); if (limit > 4294967295) limit -= 4294967296;
47
+ * If negative number: 4294967296 - Math.floor(Math.abs(limit))
48
+ * If other: Type-convert, then use the above rules
49
+ */
50
+ limit = limit === undef ?
51
+ -1 >>> 0 : // Math.pow(2, 32) - 1
52
+ limit >>> 0; // ToUint32(limit)
53
+ // eslint-disable-next-line no-cond-assign
54
+ while (match = separator.exec(str)) {
55
+ // `separator.lastIndex` is not reliable cross-browser
56
+ lastIndex = match.index + match[0].length;
57
+ if (lastIndex > lastLastIndex) {
58
+ output.push(str.slice(lastLastIndex, match.index));
59
+ // Fix browsers whose `exec` methods don't consistently return `undefined` for
60
+ // nonparticipating capturing groups
61
+ if (!compliantExecNpcg && match.length > 1) {
62
+ match[0].replace(separator2, function () {
63
+ for (var i = 1; i < arguments.length - 2; i++) {
64
+ if (arguments[i] === undef) {
65
+ match[i] = undef;
66
+ }
67
+ }
68
+ });
69
+ }
70
+ if (match.length > 1 && match.index < str.length) {
71
+ Array.prototype.push.apply(output, match.slice(1));
72
+ }
73
+ lastLength = match[0].length;
74
+ lastLastIndex = lastIndex;
75
+ if (output.length >= limit) {
76
+ break;
77
+ }
78
+ }
79
+ if (separator.lastIndex === match.index) {
80
+ separator.lastIndex++; // Avoid an infinite loop
81
+ }
82
+ }
83
+ if (lastLastIndex === str.length) {
84
+ if (lastLength || !separator.test("")) {
85
+ output.push("");
86
+ }
87
+ } else {
88
+ output.push(str.slice(lastLastIndex));
89
+ }
90
+ return output.length > limit ? output.slice(0, limit) : output;
91
+ };
92
+
93
+ // For convenience
94
+ String.prototype.split = function (separator, limit) {
95
+ return self(this, separator, limit);
96
+ };
97
+
98
+ return self;
99
+
100
+ }();
101
+
102
+
103
+ export function mToken (obj) {
104
+ this.obj = obj;
105
+
106
+ this.SAR_OK = 0;
107
+ this.SAR_FALSE = 1;
108
+
109
+ //分组加密算法标识
110
+ this.SGD_SM1_ECB = 0x00000101;
111
+ this.SGD_SM1_CBC = 0x00000102;
112
+ this.SGD_SM1_CFB = 0x00000104;
113
+ this.SGD_SM1_OFB = 0x00000108;
114
+ this.SGD_SM1_MAC = 0x00000110;
115
+ this.SGD_SSF33_ECB = 0x00000201;
116
+ this.SGD_SSF33_CBC = 0x00000202;
117
+ this.SGD_SSF33_CFB = 0x00000204;
118
+ this.SGD_SSF33_OFB = 0x00000208;
119
+ this.SGD_SSF33_MAC = 0x00000210;
120
+ this.SGD_SM4_ECB = 0x00000401;
121
+ this.SGD_SM4_CBC = 0x00000402;
122
+ this.SGD_SM4_CFB = 0x00000404;
123
+ this.SGD_SM4_OFB = 0x00000408;
124
+ this.SGD_SM4_MAC = 0x00000410;
125
+
126
+ this.SGD_VENDOR_DEFINED = 0x80000000;
127
+ this.SGD_DES_ECB = this.SGD_VENDOR_DEFINED + 0x00000211
128
+ this.SGD_DES_CBC = this.SGD_VENDOR_DEFINED + 0x00000212
129
+
130
+ this.SGD_3DES168_ECB = this.SGD_VENDOR_DEFINED + 0x00000241
131
+ this.SGD_3DES168_CBC = this.SGD_VENDOR_DEFINED + 0x00000242
132
+
133
+ this.SGD_3DES112_ECB = this.SGD_VENDOR_DEFINED + 0x00000221
134
+ this.SGD_3DES112_CBC = this.SGD_VENDOR_DEFINED + 0x00000222
135
+
136
+ this.SGD_AES128_ECB = this.SGD_VENDOR_DEFINED + 0x00000111
137
+ this.SGD_AES128_CBC = this.SGD_VENDOR_DEFINED + 0x00000112
138
+
139
+ this.SGD_AES192_ECB = this.SGD_VENDOR_DEFINED + 0x00000121
140
+ this.SGD_AES192_CBC = this.SGD_VENDOR_DEFINED + 0x00000122
141
+
142
+ this.SGD_AES256_ECB = this.SGD_VENDOR_DEFINED + 0x00000141
143
+ this.SGD_AES256_CBC = this.SGD_VENDOR_DEFINED + 0x00000142
144
+
145
+
146
+ //非对称密码算法标识
147
+ this.SGD_RSA = 0x00010000;
148
+ this.SGD_SM2_1 = 0x00020100; //ECC签名
149
+ this.SGD_SM2_2 = 0x00020200; //ECC密钥交换
150
+ this.SGD_SM2_3 = 0x00020400; //ECC加密
151
+
152
+ //密码杂凑算法标识
153
+ this.SGD_SM3 = 0x00000001;
154
+ this.SGD_SHA1 = 0x00000002;
155
+ this.SGD_SHA256 = 0x00000004;
156
+ this.SGD_RAW = 0x00000080;
157
+ this.SGD_MD5 = 0x00000081;
158
+ this.SGD_SHA384 = 0x00000082;
159
+ this.SGD_SHA512 = 0x00000083;
160
+
161
+
162
+ this.SGD_CERT_VERSION = 0x00000001;
163
+ this.SGD_CERT_SERIAL = 0x00000002;
164
+ this.SGD_CERT_ISSUE = 0x00000005;
165
+ this.SGD_CERT_VALID_TIME = 0x00000006;
166
+ this.SGD_CERT_SUBJECT = 0x00000007;
167
+ this.SGD_CERT_DER_PUBLIC_KEY = 0x00000008;
168
+ this.SGD_CERT_DER_EXTENSIONS = 0x00000009;
169
+ this.SGD_CERT_NOT_BEFORE = 0x00000010;
170
+ this.SGD_CERT_ISSUER_CN = 0x00000021;
171
+ this.SGD_CERT_ISSUER_O = 0x00000022;
172
+ this.SGD_CERT_ISSUER_OU = 0x00000023;
173
+ this.SGD_CERT_ISSUER_C = 0x00000024;
174
+ this.SGD_CERT_ISSUER_P = 0x00000025;
175
+ this.SGD_CERT_ISSUER_L = 0x00000026;
176
+ this.SGD_CERT_ISSUER_S = 0x00000027;
177
+ this.SGD_CERT_ISSUER_EMAIL = 0x00000028;
178
+
179
+ this.SGD_CERT_SUBJECT_CN = 0x00000031;
180
+ this.SGD_CERT_SUBJECT_O = 0x00000032;
181
+ this.SGD_CERT_SUBJECT_OU = 0x00000033;
182
+ this.SGD_CERT_SUBJECT_EMALL = 0x00000034;
183
+ this.SGD_REMAIN_TIME = 0x00000035;
184
+ this.SGD_SIGNATURE_ALG = 0x00000036;
185
+ this.SGD_CERT_SUBJECT_C = 0x00000037;
186
+ this.SGD_CERT_SUBJECT_P = 0x00000038;
187
+ this.SGD_CERT_SUBJECT_L = 0x00000039;
188
+ this.SGD_CERT_SUBJECT_S = 0x0000003A;
189
+
190
+ this.SGD_CERT_CRL = 0x00000041;
191
+
192
+
193
+ this.SGD_DEVICE_SORT = 0x00000201;
194
+ this.SGD_DEVICE_TYPE = 0x00000202;
195
+ this.SGD_DEVICE_NAME = 0x00000203;
196
+ this.SGD_DEVICE_MANUFACTURER = 0x00000204;
197
+ this.SGD_DEVICE_HARDWARE_VERSION = 0x00000205;
198
+ this.SGD_DEVICE_SOFTWARE_VERSION = 0x00000206;
199
+ this.SGD_DEVICE_STANDARD_VERSION = 0x00000207;
200
+ this.SGD_DEVICE_SERIAL_NUMBER = 0x00000208;
201
+ this.SGD_DEVICE_SUPPORT_SYM_ALG = 0x00000209;
202
+ this.SGD_DEVICE_SUPPORT_ASYM_ALG = 0x0000020A;
203
+ this.SGD_DEVICE_SUPPORT_HASH_ALG = 0x0000020B;
204
+ this.SGD_DEVICE_SUPPORT_STORANGE_SPACE = 0x0000020C;
205
+ this.SGD_DEVICE_SUPPORT_FREE_SAPCE = 0x0000020D;
206
+ this.SGD_DEVICE_RUNTIME = 0x0000020E;
207
+ this.SGD_DEVICE_USED_TIMES = 0x0000020F;
208
+ this.SGD_DEVICE_LOCATION = 0x00000210;
209
+ this.SGD_DEVICE_DESCRIPTION = 0x00000211;
210
+ this.SGD_DEVICE_MANAGER_INFO = 0x00000212;
211
+ this.SGD_DEVICE_MAX_DATA_SIZE = 0x00000213;
212
+
213
+ this.TRUE = 1;
214
+ this.FALSE = 0;
215
+
216
+ this.GM3000 = 1;
217
+ this.K5 = 3;
218
+ this.TF = 4;
219
+ this.HT = 5;
220
+ this.SJK1137 = 2;
221
+
222
+ this.TYPE_UKEY = 1; //普通UKEY
223
+ this.TYPE_FPKEY = 2; //指纹UKEY
224
+
225
+ var g_mTokenPlugin = null;
226
+
227
+
228
+ this.SOF_GetLastError = function () {
229
+ if (g_mTokenPlugin == null) {
230
+ return -1;
231
+ }
232
+
233
+ return g_mTokenPlugin.SOF_GetLastError();
234
+ }
235
+
236
+ // eslint-disable-next-line no-unused-vars
237
+ function isIe () {
238
+ return ("ActiveXObject" in window);
239
+ }
240
+
241
+ function isMobile () {
242
+ var browser = {
243
+ versions: function () {
244
+ // eslint-disable-next-line no-unused-vars
245
+ var u = navigator.userAgent, app = navigator.appVersion;
246
+ return {//移动终端浏览器版本信息
247
+ trident: u.indexOf('Trident') > -1, //IE内核
248
+ presto: u.indexOf('Presto') > -1, //opera内核
249
+ webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
250
+ gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1, //火狐内核
251
+ mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端
252
+ ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端
253
+ android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //android终端或者uc浏览器
254
+ iPhone: u.indexOf('iPhone') > -1, //是否为iPhone或者QQHD浏览器
255
+ iPad: u.indexOf('iPad') > -1, //是否iPad
256
+ webApp: u.indexOf('Safari') == -1
257
+ //是否web应该程序,没有头部与底部
258
+ };
259
+ }(),
260
+ language: (navigator.browserLanguage || navigator.language).toLowerCase()
261
+ }
262
+
263
+ if ((browser.versions.mobile) && (browser.versions.ios || browser.versions.android || browser.versions.iPhone || browser.versions.iPad)) {
264
+ return true;
265
+ }
266
+ else {
267
+ return false;
268
+ }
269
+ }
270
+
271
+ this.SOF_LoadLibrary = function (type) {
272
+ os = check_os();
273
+ var ret;
274
+ if (g_mTokenPlugin == null) {
275
+ g_mTokenPlugin = new mTokenPlugin();
276
+ }
277
+
278
+ if (type == this.GM3000) {
279
+ if (isMobile()) {
280
+ ret = g_mTokenPlugin.SOF_LoadLibrary("1", "mToken OTG", "com.longmai.security.plugin.driver.otg.OTGDriver");
281
+ }
282
+ else {
283
+ ret = g_mTokenPlugin.SOF_LoadLibrary("mtoken_gm3000_hnca.dll", "libgm3000.1.0.so", "libgm3000.1.0.dylib");
284
+ }
285
+ }
286
+ else if (type == this.SJK1137) {
287
+ ret = g_mTokenPlugin.SOF_LoadLibrary("SKF_APP.dll", "libhunca_hsic_skf.so", "libhunca_hsic_skf.dylib");
288
+ }
289
+ else if (type == this.HT) {
290
+ ret = g_mTokenPlugin.SOF_LoadLibrary("HUNCA_HT_20522_SKF.dll", "libhunca_ht_h2070f63_skf.so", "libhunca_ht_h2070f63_skf.dylib");
291
+ }
292
+ else if (type == this.K5) {
293
+ if (isMobile()) {
294
+ ret = g_mTokenPlugin.SOF_LoadLibrary("2", "mToken K5 Bluetooth", "com.longmai.security.plugin.driver.ble.BLEDriver");
295
+ }
296
+ else {
297
+ ret = g_mTokenPlugin.SOF_LoadLibrary("mtoken_k5.dll", "libgm3000.1.0.so", "libk5.1.0.dylib");
298
+ }
299
+ }
300
+ else if (type == this.TF) {
301
+ if (isMobile()) {
302
+ ret = g_mTokenPlugin.SOF_LoadLibrary("0", "mToken TF/SD Card", "com.longmai.security.plugin.driver.tf.TFDriver");
303
+ } else {
304
+ ret = g_mTokenPlugin.SOF_LoadLibrary("mtoken_tf.dll", "libgm3000.1.0.so", "libtf.dylib");
305
+ }
306
+ }
307
+ else {
308
+ return -1;
309
+ }
310
+
311
+ if (ret != 0) {
312
+ return -2;
313
+ }
314
+ return this.SAR_OK;
315
+ };
316
+
317
+
318
+ this.SOF_EnumDevice = function () {
319
+ if (g_mTokenPlugin == null) {
320
+ return null;
321
+ }
322
+
323
+ var array = g_mTokenPlugin.SOF_EnumDevice();
324
+ if (array == null || array.length <= 0) {
325
+ return null;
326
+ }
327
+
328
+ return array.split("||");
329
+
330
+ };
331
+
332
+
333
+ this.SOF_GetVersion = function () {
334
+ if (g_mTokenPlugin == null) {
335
+ return null;
336
+ }
337
+
338
+ return g_mTokenPlugin.SOF_GetVersion();
339
+ };
340
+
341
+
342
+ this.SOF_GetDeviceInstance = function (DeviceName, ApplicationName) {
343
+ if (g_mTokenPlugin == null) {
344
+ return -1;
345
+ }
346
+
347
+ return g_mTokenPlugin.SOF_GetDeviceInstance(DeviceName, ApplicationName);
348
+ };
349
+
350
+ this.SOF_ReleaseDeviceInstance = function () {
351
+ if (g_mTokenPlugin == null) {
352
+ return -1;
353
+ }
354
+
355
+ return g_mTokenPlugin.SOF_ReleaseDeviceInstance()
356
+ }
357
+
358
+
359
+ this.SOF_GetUserList = function () {
360
+ if (g_mTokenPlugin == null) {
361
+ return null;
362
+ }
363
+
364
+ var array = g_mTokenPlugin.SOF_GetUserList();
365
+ if (array == null || array.length <= 0)
366
+ return null;
367
+
368
+ var list = new Array();
369
+ var user = array.split("&&&");
370
+ var length = user.length;
371
+ for (var i = 0; i < length; i++) {
372
+ list[i] = user[i].split("||");
373
+ }
374
+
375
+ return list;
376
+ };
377
+
378
+
379
+ this.SOF_ExportUserCert = function (ContainerName, KeySpec) {
380
+ if (g_mTokenPlugin == null) {
381
+ return null;
382
+ }
383
+
384
+ return g_mTokenPlugin.SOF_ExportUserCert(ContainerName, KeySpec);
385
+ };
386
+
387
+
388
+ this.SOF_GetDeviceInfo = function (Type) {
389
+ if (g_mTokenPlugin == null) {
390
+ return null;
391
+ }
392
+
393
+ return g_mTokenPlugin.SOF_GetDeviceInfo(Type);
394
+ };
395
+
396
+
397
+ this.SOF_GetCertInfo = function (Base64EncodeCert, Type) {
398
+ if (g_mTokenPlugin == null) {
399
+ return null;
400
+ }
401
+
402
+ return g_mTokenPlugin.SOF_GetCertInfo(Base64EncodeCert, Type);
403
+ };
404
+
405
+ this.SOF_GetCertInfoByOid = function (Base64EncodeCert, OID) {
406
+ if (g_mTokenPlugin == null) {
407
+ return null;
408
+ }
409
+
410
+ return g_mTokenPlugin.SOF_GetCertInfoByOid(Base64EncodeCert, OID);
411
+ }
412
+
413
+ this.SOF_Login = function (PassWd) {
414
+ if (g_mTokenPlugin == null) {
415
+ return -1;
416
+ }
417
+
418
+ return g_mTokenPlugin.SOF_Login(PassWd);
419
+ };
420
+
421
+
422
+ this.SOF_LogOut = function () {
423
+ if (g_mTokenPlugin == null) {
424
+ return -1;
425
+ }
426
+
427
+ return g_mTokenPlugin.SOF_LogOut();
428
+ };
429
+
430
+
431
+ this.SOF_GetPinRetryCount = function () {
432
+ if (g_mTokenPlugin == null) {
433
+ return -1;
434
+ }
435
+
436
+ return g_mTokenPlugin.SOF_GetPinRetryCount();
437
+ };
438
+
439
+
440
+ this.SOF_ChangePassWd = function (OldPassWd, NewPassWd) {
441
+ if (g_mTokenPlugin == null) {
442
+ return -1;
443
+ }
444
+
445
+ return g_mTokenPlugin.SOF_ChangePassWd(OldPassWd, NewPassWd);
446
+ };
447
+
448
+
449
+ this.SOF_SetDigestMethod = function (DigestMethod) {
450
+ if (g_mTokenPlugin == null) {
451
+ return -1;
452
+ }
453
+
454
+ return g_mTokenPlugin.SOF_SetDigestMethod(DigestMethod);
455
+ };
456
+
457
+
458
+ this.SOF_SetUserID = function (UserID) {
459
+ if (g_mTokenPlugin == null) {
460
+ return -1;
461
+ }
462
+
463
+ return g_mTokenPlugin.SOF_SetUserID(UserID);
464
+ };
465
+
466
+
467
+ this.SOF_SetEncryptMethodAndIV = function (EncryptMethod, EncryptIV) {
468
+ if (g_mTokenPlugin == null) {
469
+ return -1;
470
+ }
471
+
472
+ return g_mTokenPlugin.SOF_SetEncryptMethodAndIV(EncryptMethod, EncryptIV);
473
+ };
474
+
475
+
476
+ this.SOF_EncryptFileToPKCS7 = function (Cert, InFile, OutFile, type) {
477
+ if (g_mTokenPlugin == null) {
478
+ return -1;
479
+ }
480
+
481
+ return g_mTokenPlugin.SOF_EncryptFileToPKCS7(Cert, InFile, OutFile, type);
482
+ };
483
+
484
+
485
+ this.SOF_SignFileToPKCS7 = function (ContainerName, InFile, OutFile) {
486
+ if (g_mTokenPlugin == null) {
487
+ return -1;
488
+ }
489
+
490
+ return g_mTokenPlugin.SOF_SignFileToPKCS7(ContainerName, InFile, OutFile);
491
+ };
492
+
493
+ this.SOF_VerifyFileToPKCS7 = function (strPkcs7Data, InFilePath) {
494
+ if (g_mTokenPlugin == null) {
495
+ return -1;
496
+ }
497
+
498
+ return g_mTokenPlugin.SOF_VerifyFileToPKCS7(strPkcs7Data, InFilePath);
499
+ };
500
+
501
+ this.SOF_DecryptFileToPKCS7 = function (ContainerName, keySpec, Pkcs7Data, InFile, OutFile, type) {
502
+ if (g_mTokenPlugin == null) {
503
+ return -1;
504
+ }
505
+
506
+ return g_mTokenPlugin.SOF_DecryptFileToPKCS7(ContainerName, keySpec, Pkcs7Data, InFile, OutFile, type);
507
+ };
508
+
509
+ this.SOF_DigestData = function (ContainerName, nData, InDataLen) {
510
+ if (g_mTokenPlugin == null) {
511
+ return null;
512
+ }
513
+
514
+ return g_mTokenPlugin.SOF_DigestData(ContainerName, nData, InDataLen);
515
+ };
516
+
517
+ this.SOF_SignData = function (ContainerName, ulKeySpec, InData, InDataLen) {
518
+ if (g_mTokenPlugin == null) {
519
+ return null;
520
+ }
521
+
522
+ return g_mTokenPlugin.SOF_SignData(ContainerName, ulKeySpec, InData, InDataLen);
523
+ };
524
+ //交互式签名
525
+ this.SOF_SignDataInteractive = function (ContainerName, ulKeySpec, InData, InDataLen) {
526
+ if (g_mTokenPlugin == null) {
527
+ return null;
528
+ }
529
+
530
+ return g_mTokenPlugin.SOF_SignDataInteractive(ContainerName, ulKeySpec, InData, InDataLen);
531
+ }
532
+
533
+
534
+ this.SOF_SignDataToPKCS7 = function (ContainerName, ulKeySpec, InData, ulDetached) {
535
+ if (g_mTokenPlugin == null) {
536
+ return null;
537
+ }
538
+
539
+ return g_mTokenPlugin.SOF_SignDataToPKCS7(ContainerName, ulKeySpec, InData, ulDetached);
540
+ };
541
+
542
+
543
+
544
+ this.SOF_VerifyDataToPKCS7 = function (Base64EncodeCert, InData, SignedValue) {
545
+ if (g_mTokenPlugin == null) {
546
+ return -1;
547
+ }
548
+
549
+ return g_mTokenPlugin.SOF_VerifyDataToPKCS7(Base64EncodeCert, InData, SignedValue);
550
+ };
551
+
552
+
553
+ this.SOF_VerifySignedData = function (Base64EncodeCert, digestMethod, InData, SignedValue) {
554
+ if (g_mTokenPlugin == null) {
555
+ return -1;
556
+ }
557
+
558
+ return g_mTokenPlugin.SOF_VerifySignedData(Base64EncodeCert, digestMethod, InData, SignedValue);
559
+ };
560
+
561
+
562
+ this.SOF_EncryptDataPKCS7 = function (Base64EncodeCert, InData, InDataLen) {
563
+ if (g_mTokenPlugin == null) {
564
+ return null;
565
+ }
566
+
567
+ return g_mTokenPlugin.SOF_EncryptDataPKCS7(Base64EncodeCert, InData, InDataLen);
568
+ };
569
+
570
+
571
+ this.SOF_DecryptDataPKCS7 = function (ContainerName, ulKeySpec, InData) {
572
+ if (g_mTokenPlugin == null) {
573
+ return null;
574
+ }
575
+
576
+ return g_mTokenPlugin.SOF_DecryptDataPKCS7(ContainerName, ulKeySpec, InData);
577
+ };
578
+
579
+
580
+ this.SOF_GenRemoteUnblockRequest = function () {
581
+ if (g_mTokenPlugin == null) {
582
+ return null;
583
+ }
584
+
585
+ return g_mTokenPlugin.SOF_GenRemoteUnblockRequest();
586
+ };
587
+
588
+
589
+ this.SOF_GenResetpwdResponse = function (request, soPin, userPin) {
590
+ if (g_mTokenPlugin == null) {
591
+ return null;
592
+ }
593
+
594
+ return g_mTokenPlugin.SOF_GenResetpwdResponse(request, soPin, userPin);
595
+ };
596
+
597
+
598
+ this.SOF_RemoteUnblockPIN = function (request) {
599
+ if (g_mTokenPlugin == null) {
600
+ return null;
601
+ }
602
+
603
+ return g_mTokenPlugin.SOF_RemoteUnblockPIN(request);
604
+ };
605
+
606
+
607
+ this.SOF_SignDataToPKCS7 = function (ContainerName, ulKeySpec, InData, ulDetached) {
608
+ if (g_mTokenPlugin == null) {
609
+ return null;
610
+ }
611
+
612
+ return g_mTokenPlugin.SOF_SignDataToPKCS7(ContainerName, ulKeySpec, InData, ulDetached);
613
+ };
614
+
615
+
616
+ this.SOF_VerifyDataToPKCS7 = function (strPkcs7Data, OriginalText, ulDetached) {
617
+ if (g_mTokenPlugin == null) {
618
+ return null;
619
+ }
620
+
621
+ return g_mTokenPlugin.SOF_VerifyDataToPKCS7(strPkcs7Data, OriginalText, ulDetached);
622
+ };
623
+
624
+ //按expType导出的公钥,格式为国密规范指定的格式或DER格式
625
+ this.SOF_ExportPubKey = function (containerName, cerType, expType) {
626
+ if (g_mTokenPlugin == null) {
627
+ return null;
628
+ }
629
+
630
+ return g_mTokenPlugin.SOF_ExportPubKey(containerName, cerType, expType);
631
+ }
632
+
633
+ this.SOF_EncryptByPubKey = function (strPubKey, strInput, cerType) {
634
+ if (g_mTokenPlugin == null) {
635
+ return null;
636
+ }
637
+
638
+ return g_mTokenPlugin.SOF_EncryptByPubKey(strPubKey, strInput, cerType);
639
+ }
640
+
641
+ this.SOF_DecryptByPrvKey = function (containerName, cerType, strAsymCipher) {
642
+ if (g_mTokenPlugin == null) {
643
+ return null;
644
+ }
645
+
646
+ return g_mTokenPlugin.SOF_DecryptByPrvKey(containerName, cerType, strAsymCipher);
647
+ }
648
+
649
+ //RA客户端相关接口:P10及证书导入等
650
+ this.SOF_GenerateP10Request = function (deviceName, container, dn, asymAlg, keySpec, keyLength) {
651
+ if (g_mTokenPlugin == null) {
652
+ return null;
653
+ }
654
+
655
+ return g_mTokenPlugin.SOF_GenerateP10Request(deviceName, container, dn, asymAlg, keySpec, keyLength);
656
+ }
657
+
658
+ this.SOF_EnumCertContiner = function () {
659
+ if (g_mTokenPlugin == null) {
660
+ return null;
661
+ }
662
+
663
+ return g_mTokenPlugin.SOF_EnumCertContiner();
664
+ }
665
+
666
+ this.SOF_FindContainer = function (certSN) {
667
+ if (g_mTokenPlugin == null) {
668
+ return null;
669
+ }
670
+
671
+ return g_mTokenPlugin.SOF_FindContainer(certSN);
672
+ }
673
+
674
+ this.SOF_DeleteCert = function (certSN) {
675
+ if (g_mTokenPlugin == null) {
676
+ return null;
677
+ }
678
+
679
+ return g_mTokenPlugin.SOF_DeleteCert(certSN);
680
+ }
681
+
682
+ this.SOF_DeleteContainer = function (certSN) {
683
+ if (g_mTokenPlugin == null) {
684
+ return null;
685
+ }
686
+
687
+ return g_mTokenPlugin.SOF_DeleteContainer(certSN);
688
+ }
689
+
690
+ this.SOF_SignByCert = function (certSN, plain) {
691
+ if (g_mTokenPlugin == null) {
692
+ return null;
693
+ }
694
+
695
+ return g_mTokenPlugin.SOF_SignByCert(certSN, plain);
696
+ }
697
+
698
+ this.SOF_VerifyByCert = function (certSN, plain, signature) {
699
+ if (g_mTokenPlugin == null) {
700
+ return null;
701
+ }
702
+
703
+ return g_mTokenPlugin.SOF_VerifyByCert(certSN, plain, signature);
704
+ }
705
+
706
+
707
+ this.SOF_ImportCert = function (container, cert, keySpec) {
708
+ if (g_mTokenPlugin == null) {
709
+ return null;
710
+ }
711
+
712
+ return g_mTokenPlugin.SOF_ImportCert(container, cert, keySpec);
713
+ }
714
+
715
+ this.SOF_ImportCryptoCertAndKey = function (container, cert, nAsymAlg, EncryptedSessionKeyData, symAlg, EncryptedPrivateKeyData, mode) {
716
+ if (g_mTokenPlugin == null) {
717
+ return null;
718
+ }
719
+
720
+ return g_mTokenPlugin.SOF_ImportCryptoCertAndKey(container, cert, nAsymAlg, EncryptedSessionKeyData, symAlg, EncryptedPrivateKeyData, mode);
721
+ }
722
+
723
+ this.SOF_VerifyByExtCert = function (cert, plain, signature, digestMethod) {
724
+ if (g_mTokenPlugin == null) {
725
+ return null;
726
+ }
727
+
728
+ return g_mTokenPlugin.SOF_VerifyByExtCert(cert, plain, signature, digestMethod);
729
+ }
730
+
731
+ this.SOF_GenerateRandom = function (length) {
732
+ if (g_mTokenPlugin == null) {
733
+ return null;
734
+ }
735
+
736
+ return g_mTokenPlugin.SOF_GenerateRandom(length);
737
+ }
738
+
739
+ this.SOF_SymEncryptFile = function (sessionKey, srcfile, destfile, type) {
740
+ if (g_mTokenPlugin == null) {
741
+ return null;
742
+ }
743
+
744
+ return g_mTokenPlugin.SOF_SymEncryptFile(sessionKey, srcfile, destfile, type);
745
+ }
746
+
747
+ this.SOF_SymDecryptFile = function (sessionKey, srcfile, destfile, type) {
748
+ if (g_mTokenPlugin == null) {
749
+ return null;
750
+ }
751
+
752
+ return g_mTokenPlugin.SOF_SymDecryptFile(sessionKey, srcfile, destfile, type);
753
+ }
754
+
755
+ this.SOF_SymEncryptData = function (sessionKey, inData) {
756
+ if (g_mTokenPlugin == null) {
757
+ return null;
758
+ }
759
+
760
+ return g_mTokenPlugin.SOF_SymEncryptData(sessionKey, inData);
761
+ }
762
+
763
+ this.SOF_SymDecryptData = function (sessionKey, inData) {
764
+ if (g_mTokenPlugin == null) {
765
+ return null;
766
+ }
767
+
768
+ return g_mTokenPlugin.SOF_SymDecryptData(sessionKey, inData);
769
+ }
770
+
771
+ this.SOF_GenerateQRCode = function (qrcode_text) {
772
+ if (g_mTokenPlugin == null) {
773
+ return null;
774
+ }
775
+
776
+ return g_mTokenPlugin.SOF_GenerateQRCode(qrcode_text);
777
+ }
778
+
779
+
780
+ this.SOF_VerifyPinMS = function (responseKey) {
781
+ if (g_mTokenPlugin == null) {
782
+ return null;
783
+ }
784
+
785
+ return g_mTokenPlugin.SOF_VerifyPinMS(responseKey);
786
+ }
787
+
788
+ this.SOF_GetHardwareType = function () {
789
+ if (g_mTokenPlugin == null) {
790
+ return null;
791
+ }
792
+
793
+ return g_mTokenPlugin.SOF_GetHardwareType();
794
+ }
795
+
796
+ this.SOF_VerifyFingerprint = function () {
797
+ if (g_mTokenPlugin == null) {
798
+ return null;
799
+ }
800
+
801
+ return g_mTokenPlugin.SOF_VerifyFingerprint();
802
+ }
803
+
804
+
805
+ this.SOF_EnumFiles = function () {
806
+ if (g_mTokenPlugin == null) {
807
+ return null;
808
+ }
809
+
810
+ var array = g_mTokenPlugin.SOF_EnumFiles();
811
+ if (array == null || array.length <= 0) {
812
+ return null;
813
+ }
814
+
815
+ return array.split("||");
816
+ }
817
+
818
+ this.SOF_ReadFile = function (fileName, offset, length) {
819
+ if (g_mTokenPlugin == null) {
820
+ return null;
821
+ }
822
+ return g_mTokenPlugin.SOF_ReadFile(fileName, Number(offset), Number(length));
823
+ }
824
+
825
+ this.SOF_WriteFile = function (fileName, offset, data) {
826
+ if (g_mTokenPlugin == null) {
827
+ return null;
828
+ }
829
+ return g_mTokenPlugin.SOF_WriteFile(fileName, offset, data);
830
+ }
831
+
832
+ this.SOF_CreateFile = function (fileName, length, readRight, writeRight) {
833
+ if (g_mTokenPlugin == null) {
834
+ return null;
835
+ }
836
+ return g_mTokenPlugin.SOF_CreateFile(fileName, length, readRight, writeRight);
837
+ }
838
+
839
+ this.SOF_DeleteFile = function (fileName) {
840
+ if (g_mTokenPlugin == null) {
841
+ return null;
842
+ }
843
+ return g_mTokenPlugin.SOF_DeleteFile(fileName);
844
+ }
845
+
846
+
847
+ }
848
+
849
+ //判断插件名称是否存在
850
+ function hasPlugin (name) {
851
+ name = name.toLowerCase();
852
+ for (var i = 0; i < navigator.plugins.length; i++) {
853
+ if (navigator.plugins[i].name.toLowerCase().indexOf(name) > -1) {
854
+ return true;
855
+ }
856
+ }
857
+ return false;
858
+ }
859
+ //判断系统
860
+ function check_os () {
861
+ var windows = (navigator.userAgent.indexOf("Windows", 0) != -1) ? 1 : 0;
862
+ // eslint-disable-next-line no-unused-vars
863
+ var mac = (navigator.userAgent.indexOf("mac", 0) != -1) ? 1 : 0;
864
+ var linux = (navigator.userAgent.indexOf("Linux", 0) != -1) ? 1 : 0;
865
+ // eslint-disable-next-line no-unused-vars
866
+ var unix = (navigator.userAgent.indexOf("X11", 0) != -1) ? 1 : 0;
867
+ var os_type = "";
868
+ if (windows) os_type = "MS Windows";
869
+ // eslint-disable-next-line no-unused-vars
870
+ else if (linux) os_type = "Lunix";
871
+ if (hasPlugin("mPlugin1.0.0.1")) {
872
+ linuxWin = 2;
873
+ return "id_mPluginV2Router";
874
+ } else {
875
+ linuxWin = 1;
876
+ return "mTokenPlugin";
877
+ }
878
+
879
+
880
+ }
881
+ var linuxWin = 0;
882
+ var os;
883
+
884
+ function mTokenPlugin () {
885
+ var _xmlhttp;
886
+ var retJSON = "";
887
+
888
+ function AjaxIO (json_in) {
889
+ //id_mPluginV2Router mTokenPlugin
890
+ if (os == "id_mPluginV2Router") {
891
+ var router = null;
892
+ //var url = "http://192.168.1.25:51235/alpha";
893
+ var url = "http://127.0.0.1:51235/alpha";
894
+
895
+ router = document.getElementById("id_mPluginV2Router");
896
+ if (null == router) {
897
+ alert("无法获取到插件,请确认已经安装好插件!");
898
+ }
899
+ /*
900
+ if("https:" == document.location.protocol)
901
+ {
902
+ url = "https://127.0.0.1:51245/alpha";
903
+ }
904
+ */
905
+ var json = json_in;
906
+
907
+ retJSON = router.invoke(url, json);
908
+ return retJSON;
909
+ } else {
910
+
911
+ // eslint-disable-next-line no-unused-vars
912
+ var _curDevName = "";
913
+ var _url = "http://127.0.0.1:51235/alpha";
914
+ let json = json_in;
915
+ if (_xmlhttp == null) {
916
+ if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
917
+ _xmlhttp = new XMLHttpRequest();
918
+ } else { // code for IE6, IE5
919
+ // eslint-disable-next-line no-undef
920
+ _xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
921
+ }
922
+ }
923
+
924
+ /***
925
+ if ("https:" == document.location.protocol) {
926
+ _url = "https://127.0.0.1:51245/alpha";
927
+ }
928
+ ***/
929
+ _xmlhttp.open("POST", _url, false);
930
+ _xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
931
+ _xmlhttp.send("json=" + json);
932
+ }
933
+
934
+
935
+
936
+
937
+ }
938
+
939
+ function GetHttpResult () {
940
+ if (_xmlhttp.readyState == 4 && _xmlhttp.status == 200) {
941
+ var obj = eval("(" + _xmlhttp.responseText + ")");
942
+ return obj;
943
+ }
944
+ else {
945
+ return null;
946
+ }
947
+ }
948
+
949
+ this.SOF_GetLastError = function () {
950
+ var json = '{"function":"SOF_GetLastError"}';
951
+ if (linuxWin == 2) {
952
+ var retJSON = "";
953
+ try {
954
+ retJSON = AjaxIO(json);
955
+ } catch (e) {
956
+ return -3;
957
+ }
958
+
959
+
960
+ if (retJSON.length > 3) {
961
+ var obj = eval("(" + retJSON + ")");
962
+ return obj.errorCode;
963
+ } else {
964
+ return -2;
965
+
966
+ }
967
+ } else {
968
+ try {
969
+ AjaxIO(json);
970
+ } catch (e) {
971
+ return -3;
972
+ }
973
+ var ret = GetHttpResult();
974
+ if (ret) {
975
+ return ret.rtn;
976
+ }
977
+
978
+ return -2;
979
+ }
980
+ }
981
+
982
+ this.SOF_LoadLibrary = function (windows, linux, mac) {
983
+ var json = '{"function":"SOF_LoadLibrary", "winDllName":"' + windows + '", "linuxSOName":"' + linux + '", "macDylibName":"' + mac + '"}';
984
+ if (linuxWin == 2) {
985
+ var retJSON = "";
986
+ try {
987
+ retJSON = AjaxIO(json);
988
+ } catch (e) {
989
+ return -3;
990
+ }
991
+
992
+
993
+ if (retJSON.length > 3) {
994
+ var obj = eval("(" + retJSON + ")");
995
+ return obj.rtn;
996
+ } else {
997
+ return -2;
998
+
999
+ }
1000
+ } else {
1001
+ try {
1002
+ AjaxIO(json);
1003
+ } catch (e) {
1004
+ return -3;
1005
+ }
1006
+ var ret = GetHttpResult();
1007
+ if (ret) {
1008
+ return ret.rtn;
1009
+ }
1010
+
1011
+ return -2;
1012
+ }
1013
+ };
1014
+
1015
+
1016
+ this.SOF_EnumDevice = function () {
1017
+ var json = '{"function":"SOF_EnumDevice"}';
1018
+ if (linuxWin == 2) {
1019
+ var retJSON = "";
1020
+ try {
1021
+ retJSON = AjaxIO(json);
1022
+ } catch (e) {
1023
+ return -3;
1024
+ }
1025
+
1026
+
1027
+ if (retJSON.length > 3) {
1028
+ var obj = eval("(" + retJSON + ")");
1029
+ return obj.array;
1030
+ } else {
1031
+ return -2;
1032
+
1033
+ }
1034
+ } else {
1035
+ try {
1036
+ AjaxIO(json);
1037
+ } catch (e) {
1038
+ return -3;
1039
+ }
1040
+ var ret = GetHttpResult();
1041
+ if (ret) {
1042
+ return ret.array;
1043
+ }
1044
+
1045
+ return -2;
1046
+ }
1047
+ };
1048
+
1049
+
1050
+ this.SOF_GetVersion = function () {
1051
+ var json = '{"function":"SOF_GetVersion"}';
1052
+ if (linuxWin == 2) {
1053
+ var retJSON = "";
1054
+ try {
1055
+ retJSON = AjaxIO(json);
1056
+ } catch (e) {
1057
+ return -3;
1058
+ }
1059
+
1060
+
1061
+ if (retJSON.length > 3) {
1062
+ var obj = eval("(" + retJSON + ")");
1063
+ return obj.version;
1064
+ } else {
1065
+ return -2;
1066
+
1067
+ }
1068
+ } else {
1069
+ try {
1070
+ AjaxIO(json);
1071
+ } catch (e) {
1072
+ return -3;
1073
+ }
1074
+ var ret = GetHttpResult();
1075
+ if (ret) {
1076
+ return ret.version;
1077
+ }
1078
+
1079
+ return -2;
1080
+ }
1081
+ };
1082
+
1083
+ var _curDevName;
1084
+ this.SOF_GetDeviceInstance = function (DeviceName, ApplicationName) {
1085
+ var json = '{"function":"SOF_GetDeviceInstance", "deviceName":"' + DeviceName + '", "applicationName":"' + ApplicationName + '"}';
1086
+ if (linuxWin == 2) {
1087
+ var retJSON = "";
1088
+ try {
1089
+ _curDevName = DeviceName;
1090
+ retJSON = AjaxIO(json);
1091
+ } catch (e) {
1092
+ return -3;
1093
+ }
1094
+
1095
+
1096
+ if (retJSON.length > 3) {
1097
+ var obj = eval("(" + retJSON + ")");
1098
+ return obj.rtn;
1099
+ } else {
1100
+ return -2;
1101
+
1102
+ }
1103
+ } else {
1104
+ try {
1105
+ AjaxIO(json);
1106
+ } catch (e) {
1107
+ return -3;
1108
+ }
1109
+ var ret = GetHttpResult();
1110
+ if (ret) {
1111
+ if (ret.rtn == 0) {
1112
+ _curDevName = DeviceName;
1113
+ }
1114
+ return ret.rtn;
1115
+ }
1116
+
1117
+ return -2;
1118
+ }
1119
+ };
1120
+
1121
+ this.SOF_ReleaseDeviceInstance = function () {
1122
+ var json = '{"function":"SOF_ReleaseDeviceInstance", "deviceName":"' + _curDevName + '"}';
1123
+ if (linuxWin == 2) {
1124
+ var retJSON = "";
1125
+ try {
1126
+ retJSON = AjaxIO(json);
1127
+ }
1128
+ catch (e) {
1129
+ return -3;
1130
+ }
1131
+
1132
+ if (retJSON.length > 3) {
1133
+ var obj = eval("(" + retJSON + ")");
1134
+ return obj.array;
1135
+ } else {
1136
+ return -2;
1137
+
1138
+ }
1139
+ } else {
1140
+ try {
1141
+ AjaxIO(json);
1142
+ } catch (e) {
1143
+ return -3;
1144
+ }
1145
+ var ret = GetHttpResult();
1146
+ if (ret) {
1147
+ return ret.rtn;
1148
+ }
1149
+
1150
+ return -2;
1151
+ }
1152
+ };
1153
+
1154
+ this.SOF_GetUserList = function () {
1155
+ var json = '{"function":"SOF_GetUserList", "deviceName":"' + _curDevName + '"}';
1156
+ if (linuxWin == 2) {
1157
+ var retJSON = "";
1158
+ try {
1159
+ retJSON = AjaxIO(json);
1160
+ } catch (e) {
1161
+ return -3;
1162
+ }
1163
+
1164
+
1165
+ if (retJSON.length > 3) {
1166
+ var obj = eval("(" + retJSON + ")");
1167
+ return obj.array;
1168
+ } else {
1169
+ return -2;
1170
+
1171
+ }
1172
+ } else {
1173
+ try {
1174
+ AjaxIO(json);
1175
+ } catch (e) {
1176
+ return -3;
1177
+ }
1178
+ var ret = GetHttpResult();
1179
+ if (ret) {
1180
+ return ret.array;
1181
+ }
1182
+
1183
+ return -2;
1184
+ }
1185
+ };
1186
+
1187
+
1188
+ this.SOF_ExportUserCert = function (ContainerName, KeySpec) {
1189
+
1190
+ var json = '{"function":"SOF_ExportUserCert", "deviceName":"' + _curDevName + '", "containerName":"' + ContainerName + '", "keySpec":' + KeySpec + '}';
1191
+ if (linuxWin == 2) {
1192
+ var retJSON = "";
1193
+ try {
1194
+ retJSON = AjaxIO(json);
1195
+ } catch (e) {
1196
+ return -3;
1197
+ }
1198
+
1199
+
1200
+ if (retJSON.length > 3) {
1201
+ var obj = eval("(" + retJSON + ")");
1202
+ return obj.cert;
1203
+ } else {
1204
+ return -2;
1205
+
1206
+ }
1207
+ } else {
1208
+ try {
1209
+ AjaxIO(json);
1210
+ } catch (e) {
1211
+ return -3;
1212
+ }
1213
+ var ret = GetHttpResult();
1214
+ if (ret) {
1215
+ return ret.cert;
1216
+ }
1217
+
1218
+ return -2;
1219
+ }
1220
+ };
1221
+
1222
+
1223
+ this.SOF_GetDeviceInfo = function (Type) {
1224
+ var json = '{"function":"SOF_GetDeviceInfo", "deviceName":"' + _curDevName + '", "type":' + Type + '}';
1225
+ if (linuxWin == 2) {
1226
+ var retJSON = "";
1227
+ try {
1228
+ retJSON = AjaxIO(json);
1229
+ } catch (e) {
1230
+ return -3;
1231
+ }
1232
+
1233
+
1234
+ if (retJSON.length > 3) {
1235
+ var obj = eval("(" + retJSON + ")");
1236
+ return obj.info;
1237
+ } else {
1238
+ return -2;
1239
+
1240
+ }
1241
+ } else {
1242
+ try {
1243
+ AjaxIO(json);
1244
+ } catch (e) {
1245
+ return -3;
1246
+ }
1247
+ var ret = GetHttpResult();
1248
+ if (ret) {
1249
+ return ret.info;
1250
+ }
1251
+
1252
+ return -2;
1253
+ }
1254
+
1255
+ };
1256
+
1257
+
1258
+ this.SOF_GetCertInfo = function (Base64EncodeCert, Type) {
1259
+ var json = '{"function":"SOF_GetCertInfo", "base64EncodeCert":"' + Base64EncodeCert + '", "type":' + Type + '}';
1260
+ if (linuxWin == 2) {
1261
+ var retJSON = "";
1262
+ try {
1263
+ retJSON = AjaxIO(json);
1264
+ } catch (e) {
1265
+ return -3;
1266
+ }
1267
+
1268
+
1269
+ if (retJSON.length > 3) {
1270
+ var obj = eval("(" + retJSON + ")");
1271
+ return obj.info;
1272
+ } else {
1273
+ return -2;
1274
+
1275
+ }
1276
+ } else {
1277
+ try {
1278
+ AjaxIO(json);
1279
+ } catch (e) {
1280
+ return -3;
1281
+ }
1282
+ var ret = GetHttpResult();
1283
+ if (ret) {
1284
+ return ret.info;
1285
+ }
1286
+
1287
+ return -2;
1288
+ }
1289
+
1290
+ };
1291
+
1292
+
1293
+ this.SOF_GetCertInfoByOid = function (Base64EncodeCert, OID) {
1294
+ var json = '{"function":"SOF_GetCertInfoByOid", "base64EncodeCert":"' + Base64EncodeCert + '", "oid":"' + OID + '"}';
1295
+ if (linuxWin == 2) {
1296
+ var retJSON = "";
1297
+ try {
1298
+ retJSON = AjaxIO(json);
1299
+ } catch (e) {
1300
+ return -3;
1301
+ }
1302
+
1303
+
1304
+ if (retJSON.length > 3) {
1305
+ var obj = eval("(" + retJSON + ")");
1306
+ return obj.info;
1307
+ } else {
1308
+ return -2;
1309
+
1310
+ }
1311
+ } else {
1312
+ try {
1313
+ AjaxIO(json);
1314
+ }
1315
+ catch (e) {
1316
+ return -3;
1317
+ }
1318
+
1319
+ var ret = GetHttpResult();
1320
+ if (ret) {
1321
+ return ret.info;
1322
+ }
1323
+
1324
+ return null;
1325
+ }
1326
+
1327
+ };
1328
+
1329
+
1330
+
1331
+ this.SOF_Login = function (PassWd) {
1332
+
1333
+ var json = '{"function":"SOF_Login", "deviceName":"' + _curDevName + '", "passWd":"' + PassWd + '"}';
1334
+ if (linuxWin == 2) {
1335
+ var retJSON = "";
1336
+ try {
1337
+ retJSON = AjaxIO(json);
1338
+ } catch (e) {
1339
+ return -3;
1340
+ }
1341
+
1342
+
1343
+ if (retJSON.length > 3) {
1344
+ var obj = eval("(" + retJSON + ")");
1345
+ return obj.rtn;
1346
+ } else {
1347
+ return -2;
1348
+
1349
+ }
1350
+ } else {
1351
+ try {
1352
+ AjaxIO(json);
1353
+ } catch (e) {
1354
+ return -3;
1355
+ }
1356
+ var ret = GetHttpResult();
1357
+ if (ret) {
1358
+ return ret.rtn;
1359
+ }
1360
+
1361
+ return -2;
1362
+ }
1363
+ };
1364
+
1365
+
1366
+ this.SOF_LogOut = function () {
1367
+
1368
+ var json = '{"function":"SOF_LogOut", "deviceName":"' + _curDevName + '"}';
1369
+ if (linuxWin == 2) {
1370
+ var retJSON = "";
1371
+ try {
1372
+ retJSON = AjaxIO(json);
1373
+ } catch (e) {
1374
+ return -3;
1375
+ }
1376
+
1377
+
1378
+ if (retJSON.length > 3) {
1379
+ var obj = eval("(" + retJSON + ")");
1380
+ return obj.rtn;
1381
+ } else {
1382
+ return -2;
1383
+
1384
+ }
1385
+ } else {
1386
+ try {
1387
+ AjaxIO(json);
1388
+ } catch (e) {
1389
+ return -3;
1390
+ }
1391
+ var ret = GetHttpResult();
1392
+ if (ret) {
1393
+ return ret.rtn;
1394
+ }
1395
+
1396
+ return -2;
1397
+ }
1398
+ };
1399
+
1400
+
1401
+ this.SOF_GetPinRetryCount = function () {
1402
+
1403
+ var json = '{"function":"SOF_GetPinRetryCount", "deviceName":"' + _curDevName + '"}';
1404
+ if (linuxWin == 2) {
1405
+ var retJSON = "";
1406
+ try {
1407
+ retJSON = AjaxIO(json);
1408
+ } catch (e) {
1409
+ return -3;
1410
+ }
1411
+
1412
+
1413
+ if (retJSON.length > 3) {
1414
+ var obj = eval("(" + retJSON + ")");
1415
+ return obj.retryCount;
1416
+ } else {
1417
+ return -2;
1418
+
1419
+ }
1420
+ } else {
1421
+ try {
1422
+ AjaxIO(json);
1423
+ } catch (e) {
1424
+ return -3;
1425
+ }
1426
+ var ret = GetHttpResult();
1427
+ if (ret) {
1428
+ return ret.retryCount;
1429
+ }
1430
+
1431
+ return -2;
1432
+ }
1433
+ };
1434
+
1435
+
1436
+ this.SOF_ChangePassWd = function (OldPassWd, NewPassWd) {
1437
+
1438
+ var json = '{"function":"SOF_ChangePassWd", "deviceName":"' + _curDevName + '", "oldUpin":"' + OldPassWd + '", "newUpin":"' + NewPassWd + '"}';
1439
+ if (linuxWin == 2) {
1440
+ var retJSON = "";
1441
+ try {
1442
+ retJSON = AjaxIO(json);
1443
+ } catch (e) {
1444
+ return -3;
1445
+ }
1446
+
1447
+
1448
+ if (retJSON.length > 3) {
1449
+ var obj = eval("(" + retJSON + ")");
1450
+ return obj.rtn;
1451
+ } else {
1452
+ return -2;
1453
+
1454
+ }
1455
+ } else {
1456
+ try {
1457
+ AjaxIO(json);
1458
+ } catch (e) {
1459
+ return -3;
1460
+ }
1461
+ var ret = GetHttpResult();
1462
+ if (ret) {
1463
+ return ret.rtn;
1464
+ }
1465
+
1466
+ return -2;
1467
+ }
1468
+ };
1469
+
1470
+
1471
+ this.SOF_SetDigestMethod = function (DigestMethod) {
1472
+
1473
+ var json = '{"function":"SOF_SetDigestMethod","deviceName":"' + _curDevName + '", "digestMethod":' + DigestMethod + '}';
1474
+ if (linuxWin == 2) {
1475
+ var retJSON = "";
1476
+ try {
1477
+ retJSON = AjaxIO(json);
1478
+ } catch (e) {
1479
+ return -3;
1480
+ }
1481
+
1482
+
1483
+ if (retJSON.length > 3) {
1484
+ var obj = eval("(" + retJSON + ")");
1485
+ return obj.rtn;
1486
+ } else {
1487
+ return -2;
1488
+
1489
+ }
1490
+ } else {
1491
+ try {
1492
+ AjaxIO(json);
1493
+ } catch (e) {
1494
+ return -3;
1495
+ }
1496
+ var ret = GetHttpResult();
1497
+ if (ret) {
1498
+ return ret.rtn;
1499
+ }
1500
+
1501
+ return -2;
1502
+ }
1503
+ };
1504
+
1505
+
1506
+ this.SOF_SetUserID = function (UserID) {
1507
+
1508
+ var json = '{"function":"SOF_SetUserID","deviceName":"' + _curDevName + '", "userID":"' + UserID + '"}';
1509
+ if (linuxWin == 2) {
1510
+ var retJSON = "";
1511
+ try {
1512
+ retJSON = AjaxIO(json);
1513
+ } catch (e) {
1514
+ return -3;
1515
+ }
1516
+
1517
+
1518
+ if (retJSON.length > 3) {
1519
+ var obj = eval("(" + retJSON + ")");
1520
+ return obj.rtn;
1521
+ } else {
1522
+ return -2;
1523
+
1524
+ }
1525
+ } else {
1526
+ try {
1527
+ AjaxIO(json);
1528
+ } catch (e) {
1529
+ return -3;
1530
+ }
1531
+ var ret = GetHttpResult();
1532
+ if (ret) {
1533
+ return ret.rtn;
1534
+ }
1535
+
1536
+ return -2;
1537
+ }
1538
+ };
1539
+
1540
+
1541
+ this.SOF_SetEncryptMethodAndIV = function (EncryptMethod, EncryptIV) {
1542
+
1543
+ var json = '{"function":"SOF_SetEncryptMethodAndIV","deviceName":"' + _curDevName + '", "encryptMethod":' + EncryptMethod + ', "encryptIV":"' + EncryptIV + '"}';
1544
+ if (linuxWin == 2) {
1545
+ var retJSON = "";
1546
+ try {
1547
+ retJSON = AjaxIO(json);
1548
+ } catch (e) {
1549
+ return -3;
1550
+ }
1551
+
1552
+
1553
+ if (retJSON.length > 3) {
1554
+ var obj = eval("(" + retJSON + ")");
1555
+ return obj.rtn;
1556
+ } else {
1557
+ return -2;
1558
+
1559
+ }
1560
+ } else {
1561
+ try {
1562
+ AjaxIO(json);
1563
+ } catch (e) {
1564
+ return -3;
1565
+ }
1566
+ var ret = GetHttpResult();
1567
+ if (ret) {
1568
+ return ret.rtn;
1569
+ }
1570
+
1571
+ return -2;
1572
+ }
1573
+ };
1574
+
1575
+
1576
+ this.SOF_EncryptFileToPKCS7 = function (Cert, InFile, OutFile, type) {
1577
+
1578
+ var json = '{"function":"SOF_EncryptFileToPKCS7", "deviceName":"' + _curDevName + '", "cert":"' + Cert + '", "inFile":"' + InFile.replace(/\\/g, '\\\\') + '", "outFile":"' + OutFile.replace(/\\/g, '\\\\') + '", "type":' + type + '}';
1579
+ if (linuxWin == 2) {
1580
+ var retJSON = "";
1581
+ try {
1582
+ retJSON = AjaxIO(json);
1583
+ } catch (e) {
1584
+ return -3;
1585
+ }
1586
+
1587
+
1588
+ if (retJSON.length > 3) {
1589
+ var obj = eval("(" + retJSON + ")");
1590
+ return obj.envelopData;
1591
+ } else {
1592
+ return -2;
1593
+
1594
+ }
1595
+ } else {
1596
+ try {
1597
+ AjaxIO(json);
1598
+ } catch (e) {
1599
+ return -3;
1600
+ }
1601
+ var ret = GetHttpResult();
1602
+ if (ret) {
1603
+ return ret.envelopData;
1604
+ }
1605
+
1606
+ return -2;
1607
+ }
1608
+ };
1609
+
1610
+
1611
+ this.SOF_SignFileToPKCS7 = function (ContainerName, KeySpec, InFile) {
1612
+
1613
+ var json = '{"function":"SOF_SignFileToPKCS7", "deviceName":"' + _curDevName + '", "containerName":"' + ContainerName + '", "KeySpec":' + KeySpec + ', "inFile":"' + InFile.replace(/\\/g, '\\\\') + '"}';
1614
+ if (linuxWin == 2) {
1615
+ var retJSON = "";
1616
+ try {
1617
+ retJSON = AjaxIO(json);
1618
+ } catch (e) {
1619
+ return -3;
1620
+ }
1621
+
1622
+
1623
+ if (retJSON.length > 3) {
1624
+ var obj = eval("(" + retJSON + ")");
1625
+ return obj.signed;
1626
+ } else {
1627
+ return -2;
1628
+
1629
+ }
1630
+ } else {
1631
+ try {
1632
+ AjaxIO(json);
1633
+ } catch (e) {
1634
+ return -3;
1635
+ }
1636
+ var ret = GetHttpResult();
1637
+ if (ret) {
1638
+ return ret.signed;
1639
+ }
1640
+
1641
+ return -2;
1642
+ }
1643
+ };
1644
+
1645
+
1646
+ this.SOF_VerifyFileToPKCS7 = function (strPkcs7Data, InFilePath) {
1647
+ var json = '{"function":"SOF_VerifyFileToPKCS7", "deviceName":"' + _curDevName + '","strPkcs7Data":"' + strPkcs7Data + '", "inFile":"' + InFilePath.replace(/\\/g, '\\\\') + '"}';
1648
+ if (linuxWin == 2) {
1649
+ var retJSON = "";
1650
+ try {
1651
+ retJSON = AjaxIO(json);
1652
+ } catch (e) {
1653
+ return -3;
1654
+ }
1655
+
1656
+
1657
+ if (retJSON.length > 3) {
1658
+ var obj = eval("(" + retJSON + ")");
1659
+ return obj.rtn;
1660
+ } else {
1661
+ return -2;
1662
+
1663
+ }
1664
+ } else {
1665
+ try {
1666
+ AjaxIO(json);
1667
+ } catch (e) {
1668
+ return -3;
1669
+ }
1670
+ var ret = GetHttpResult();
1671
+ if (ret) {
1672
+ return ret.rtn;
1673
+ }
1674
+
1675
+ return -2;
1676
+ }
1677
+ };
1678
+
1679
+
1680
+ this.SOF_DecryptFileToPKCS7 = function (ContainerName, keySpec, Pkcs7Data, InFile, OutFile, type) {
1681
+
1682
+ var json = '{"function":"SOF_DecryptFileToPKCS7", "deviceName":"' + _curDevName + '", "containerName":"' + ContainerName + '", "keySpec":' + keySpec + ', "pkcs7Data":"' + Pkcs7Data + '", "inFile":"' + InFile.replace(/\\/g, '\\\\') + '", "outFile":"' + OutFile.replace(/\\/g, '\\\\') + '", "type":' + type + '}';
1683
+ if (linuxWin == 2) {
1684
+ var retJSON = "";
1685
+ try {
1686
+ retJSON = AjaxIO(json);
1687
+ } catch (e) {
1688
+ return -3;
1689
+ }
1690
+
1691
+
1692
+ if (retJSON.length > 3) {
1693
+ var obj = eval("(" + retJSON + ")");
1694
+ return obj.rtn;
1695
+ } else {
1696
+ return -2;
1697
+
1698
+ }
1699
+ } else {
1700
+ try {
1701
+ AjaxIO(json);
1702
+ } catch (e) {
1703
+ return -3;
1704
+ }
1705
+ var ret = GetHttpResult();
1706
+ if (ret) {
1707
+ return ret.rtn;
1708
+ }
1709
+
1710
+ return -2;
1711
+ }
1712
+ };
1713
+
1714
+
1715
+ this.SOF_DigestData = function (ContainerName, InData, InDataLen) {
1716
+
1717
+ var json = '{"function":"SOF_DigestData","deviceName":"' + _curDevName + '", "containerName":"' + ContainerName + '", "inData":"' + InData + '", "inDataLen":' + InDataLen + '}';
1718
+ if (linuxWin == 2) {
1719
+ var retJSON = "";
1720
+ try {
1721
+ retJSON = AjaxIO(json);
1722
+ } catch (e) {
1723
+ return -3;
1724
+ }
1725
+
1726
+
1727
+ if (retJSON.length > 3) {
1728
+ var obj = eval("(" + retJSON + ")");
1729
+ return obj.digest;
1730
+ } else {
1731
+ return -2;
1732
+
1733
+ }
1734
+ } else {
1735
+ try {
1736
+ AjaxIO(json);
1737
+ } catch (e) {
1738
+ return -3;
1739
+ }
1740
+ var ret = GetHttpResult();
1741
+ if (ret) {
1742
+ return ret.digest;
1743
+ }
1744
+
1745
+ return -2;
1746
+ }
1747
+ };
1748
+
1749
+ //交互式签名
1750
+ this.SOF_SignDataInteractive = function (ContainerName, ulKeySpec, inData, InDataLen) {
1751
+ var InDataBase64 = inData; //对报文进行Base64编码
1752
+ var json = '{"function":"SOF_SignDataInteractive", "deviceName":"' + _curDevName + '", "containerName":"' + ContainerName + '", "keySpec":' + ulKeySpec + ', "inData":"' + InDataBase64 + '", "inDataLen":' + InDataLen + '}';
1753
+
1754
+ if (linuxWin == 2) {
1755
+ var retJSON = "";
1756
+ try {
1757
+ retJSON = AjaxIO(json);
1758
+ } catch (e) {
1759
+ return -3;
1760
+ }
1761
+
1762
+
1763
+ if (retJSON.length > 3) {
1764
+ var obj = eval("(" + retJSON + ")");
1765
+ return obj.signed;
1766
+ } else {
1767
+ return -2;
1768
+
1769
+ }
1770
+ } else {
1771
+ try {
1772
+ AjaxIO(json);
1773
+ }
1774
+ catch (e) {
1775
+ return -3;
1776
+ }
1777
+
1778
+
1779
+ var ret = GetHttpResult();
1780
+ if (ret) {
1781
+ return ret.signed;
1782
+ }
1783
+
1784
+ return null;
1785
+ }
1786
+ };
1787
+
1788
+ this.SOF_SignData = function (ContainerName, ulKeySpec, InData, InDataLen) {
1789
+
1790
+ var json = '{"function":"SOF_SignDataEx", "deviceName":"' + _curDevName + '", "containerName":"' + ContainerName + '", "keySpec":' + ulKeySpec + ', "inData":"' + InData + '", "inDataLen":' + InDataLen + '}';
1791
+ if (linuxWin == 2) {
1792
+ var retJSON = "";
1793
+ try {
1794
+ retJSON = AjaxIO(json);
1795
+ } catch (e) {
1796
+ return -3;
1797
+ }
1798
+
1799
+
1800
+ if (retJSON.length > 3) {
1801
+ var obj = eval("(" + retJSON + ")");
1802
+ return obj.signed;
1803
+ } else {
1804
+ return -2;
1805
+
1806
+ }
1807
+ } else {
1808
+ try {
1809
+ AjaxIO(json);
1810
+ } catch (e) {
1811
+ return -3;
1812
+ }
1813
+ var ret = GetHttpResult();
1814
+ if (ret) {
1815
+ return ret.signed;
1816
+ }
1817
+
1818
+ return -2;
1819
+ }
1820
+ };
1821
+
1822
+
1823
+ this.SOF_VerifySignedData = function (Base64EncodeCert, digestMethod, InData, SignedValue) {
1824
+ var json = '{"function":"SOF_VerifySignedDataEx","deviceName":"' + _curDevName + '", "base64EncodeCert":"' + Base64EncodeCert + '", "digestMethod":' + digestMethod + ', "inData":"' + InData + '", "signedValue":"' + SignedValue + '"}';
1825
+ if (linuxWin == 2) {
1826
+ var retJSON = "";
1827
+ try {
1828
+ retJSON = AjaxIO(json);
1829
+ } catch (e) {
1830
+ return -3;
1831
+ }
1832
+
1833
+
1834
+ if (retJSON.length > 3) {
1835
+ var obj = eval("(" + retJSON + ")");
1836
+ return obj.rtn;
1837
+ } else {
1838
+ return -2;
1839
+
1840
+ }
1841
+ } else {
1842
+ try {
1843
+ AjaxIO(json);
1844
+ } catch (e) {
1845
+ return -3;
1846
+ }
1847
+ var ret = GetHttpResult();
1848
+ if (ret) {
1849
+ return ret.rtn;
1850
+ }
1851
+
1852
+ return -2;
1853
+ }
1854
+ };
1855
+
1856
+
1857
+ this.SOF_EncryptDataPKCS7 = function (Base64EncodeCert, InData, InDataLen) {
1858
+
1859
+ var json = '{"function":"SOF_EncryptDataPKCS7", "deviceName":"' + _curDevName + '", "base64EncodeCert":"' + Base64EncodeCert + '", "inData":"' + InData + '", "inDataLen":' + InDataLen + '}';
1860
+ if (linuxWin == 2) {
1861
+ var retJSON = "";
1862
+ try {
1863
+ retJSON = AjaxIO(json);
1864
+ } catch (e) {
1865
+ return -3;
1866
+ }
1867
+
1868
+
1869
+ if (retJSON.length > 3) {
1870
+ var obj = eval("(" + retJSON + ")");
1871
+ return obj.encrypedData;
1872
+ } else {
1873
+ return -2;
1874
+
1875
+ }
1876
+ } else {
1877
+ try {
1878
+ AjaxIO(json);
1879
+ } catch (e) {
1880
+ return -3;
1881
+ }
1882
+ var ret = GetHttpResult();
1883
+ if (ret) {
1884
+ return ret.encrypedData;
1885
+ }
1886
+
1887
+ return -2;
1888
+ }
1889
+
1890
+ };
1891
+
1892
+
1893
+ this.SOF_DecryptDataPKCS7 = function (ContainerName, ulKeySpec, InData) {
1894
+
1895
+ var json = '{"function":"SOF_DecryptDataPKCS7", "deviceName":"' + _curDevName + '", "containerName":"' + ContainerName + '", "keySpec":' + ulKeySpec + ', "inData":"' + InData + '"}';
1896
+ if (linuxWin == 2) {
1897
+ var retJSON = "";
1898
+ try {
1899
+ retJSON = AjaxIO(json);
1900
+ } catch (e) {
1901
+ return -3;
1902
+ }
1903
+
1904
+
1905
+ if (retJSON.length > 3) {
1906
+ var obj = eval("(" + retJSON + ")");
1907
+ return obj.decryptedData;
1908
+ } else {
1909
+ return -2;
1910
+
1911
+ }
1912
+ } else {
1913
+ try {
1914
+ AjaxIO(json);
1915
+ } catch (e) {
1916
+ return -3;
1917
+ }
1918
+ var ret = GetHttpResult();
1919
+ if (ret) {
1920
+ return ret.decryptedData;
1921
+ }
1922
+
1923
+ return -2;
1924
+ }
1925
+ };
1926
+
1927
+
1928
+ this.SOF_GenRemoteUnblockRequest = function () {
1929
+
1930
+ var json = '{"function":"SOF_GenRemoteUnblockRequest", "deviceName":"' + _curDevName + '"}';
1931
+ if (linuxWin == 2) {
1932
+ var retJSON = "";
1933
+ try {
1934
+ retJSON = AjaxIO(json);
1935
+ } catch (e) {
1936
+ return -3;
1937
+ }
1938
+
1939
+
1940
+ if (retJSON.length > 3) {
1941
+ var obj = eval("(" + retJSON + ")");
1942
+ return obj.request;
1943
+ } else {
1944
+ return -2;
1945
+
1946
+ }
1947
+ } else {
1948
+ try {
1949
+ AjaxIO(json);
1950
+ } catch (e) {
1951
+ return -3;
1952
+ }
1953
+ var ret = GetHttpResult();
1954
+ if (ret) {
1955
+ return ret.request;
1956
+ }
1957
+
1958
+ return -2;
1959
+ }
1960
+ };
1961
+
1962
+
1963
+ this.SOF_GenResetpwdResponse = function (request, soPin, userPin) {
1964
+
1965
+ var json = '{"function":"SOF_GenResetpwdResponse", "deviceName":"' + _curDevName + '", "request":"' + request + '", "soPin":"' + soPin + '", "userPin":"' + userPin + '"}';
1966
+ if (linuxWin == 2) {
1967
+ var retJSON = "";
1968
+ try {
1969
+ retJSON = AjaxIO(json);
1970
+ } catch (e) {
1971
+ return -3;
1972
+ }
1973
+
1974
+
1975
+ if (retJSON.length > 3) {
1976
+ var obj = eval("(" + retJSON + ")");
1977
+ return obj.request;
1978
+ } else {
1979
+ return -2;
1980
+
1981
+ }
1982
+ } else {
1983
+ try {
1984
+ AjaxIO(json);
1985
+ } catch (e) {
1986
+ return -3;
1987
+ }
1988
+ var ret = GetHttpResult();
1989
+ if (ret) {
1990
+ return ret.request;
1991
+ }
1992
+
1993
+ return -2;
1994
+ }
1995
+ };
1996
+
1997
+
1998
+ this.SOF_RemoteUnblockPIN = function (request) {
1999
+
2000
+ var json = '{"function":"SOF_RemoteUnblockPIN", "deviceName":"' + _curDevName + '", "request":"' + request + '"}';
2001
+ if (linuxWin == 2) {
2002
+ var retJSON = "";
2003
+ try {
2004
+ retJSON = AjaxIO(json);
2005
+ } catch (e) {
2006
+ return -3;
2007
+ }
2008
+
2009
+
2010
+ if (retJSON.length > 3) {
2011
+ var obj = eval("(" + retJSON + ")");
2012
+ return obj.rtn;
2013
+ } else {
2014
+ return -2;
2015
+
2016
+ }
2017
+ } else {
2018
+ try {
2019
+ AjaxIO(json);
2020
+ } catch (e) {
2021
+ return -3;
2022
+ }
2023
+ var ret = GetHttpResult();
2024
+ if (ret) {
2025
+ return ret.rtn;
2026
+ }
2027
+
2028
+ return -2;
2029
+ }
2030
+ };
2031
+
2032
+
2033
+ this.SOF_SignDataToPKCS7 = function (ContainerName, ulKeySpec, InData, ulDetached) {
2034
+
2035
+ var json = '{"function":"SOF_SignDataToPKCS7", "deviceName":"' + _curDevName + '", "containerName":"' + ContainerName + '", "keySpec":' + ulKeySpec + ', "inData":"' + InData + '", "detached":' + ulDetached + '}';
2036
+ if (linuxWin == 2) {
2037
+ var retJSON = "";
2038
+ try {
2039
+ retJSON = AjaxIO(json);
2040
+ } catch (e) {
2041
+ return -3;
2042
+ }
2043
+
2044
+
2045
+ if (retJSON.length > 3) {
2046
+ var obj = eval("(" + retJSON + ")");
2047
+ return obj.pkcs7;
2048
+ } else {
2049
+ return -2;
2050
+
2051
+ }
2052
+ } else {
2053
+ try {
2054
+ AjaxIO(json);
2055
+ } catch (e) {
2056
+ return -3;
2057
+ }
2058
+ var ret = GetHttpResult();
2059
+ if (ret) {
2060
+ return ret.pkcs7;
2061
+ }
2062
+
2063
+ return -2;
2064
+ }
2065
+ };
2066
+
2067
+
2068
+ this.SOF_VerifyDataToPKCS7 = function (strPkcs7Data, OriginalText, ulDetached) {
2069
+
2070
+ var json = '{"function":"SOF_VerifyDataToPKCS7", "deviceName":"' + _curDevName + '", "pkcs7":"' + strPkcs7Data + '", "original":"' + OriginalText + '", "detached":' + ulDetached + '}';
2071
+ if (linuxWin == 2) {
2072
+ var retJSON = "";
2073
+ try {
2074
+ retJSON = AjaxIO(json);
2075
+ } catch (e) {
2076
+ return -3;
2077
+ }
2078
+
2079
+
2080
+ if (retJSON.length > 3) {
2081
+ var obj = eval("(" + retJSON + ")");
2082
+ return obj.rtn;
2083
+ } else {
2084
+ return -2;
2085
+
2086
+ }
2087
+ } else {
2088
+ try {
2089
+ AjaxIO(json);
2090
+ } catch (e) {
2091
+ return -3;
2092
+ }
2093
+ var ret = GetHttpResult();
2094
+ if (ret) {
2095
+ return ret.rtn;
2096
+ }
2097
+
2098
+ return -2;
2099
+ }
2100
+ };
2101
+
2102
+ //按expType导出的公钥,格式为国密规范指定的格式或DER格式或裸数据格式
2103
+ this.SOF_ExportPubKey = function (containerName, keySpec, expType) //expType=1: 国密格式; 2:DER; 3:RAW (SM2 public key ONLY: X|Y, X,Y各为32字节)
2104
+ {
2105
+ var json = '{"function":"SOF_ExportPubKeyEx","deviceName":"' + _curDevName + '", "containerName":"' + containerName + '", "keySpec":' + keySpec + ', "expType":' + expType + '}';
2106
+ if (linuxWin == 2) {
2107
+ var retJSON = "";
2108
+ try {
2109
+ retJSON = AjaxIO(json);
2110
+ } catch (e) {
2111
+ return -3;
2112
+ }
2113
+
2114
+
2115
+ if (retJSON.length > 3) {
2116
+ var obj = eval("(" + retJSON + ")");
2117
+ return obj.pubKey;
2118
+ } else {
2119
+ return -2;
2120
+
2121
+ }
2122
+ } else {
2123
+ try {
2124
+ AjaxIO(json);
2125
+ } catch (e) {
2126
+ return -3;
2127
+ }
2128
+ var ret = GetHttpResult();
2129
+ if (ret) {
2130
+ return ret.pubKey;
2131
+ }
2132
+
2133
+ return -2;
2134
+ }
2135
+ }
2136
+
2137
+ //公钥加密
2138
+ this.SOF_EncryptByPubKey = function (strPubKey, strInput, cerType) {
2139
+ var json = '{"function":"SOF_EncryptByPubKey", "deviceName":"' + _curDevName + '", "pubKey":"' + strPubKey + '", "asymPlain":"' + strInput + '", "keySpec":' + cerType + '}';
2140
+ if (linuxWin == 2) {
2141
+ var retJSON = "";
2142
+ try {
2143
+ retJSON = AjaxIO(json);
2144
+ } catch (e) {
2145
+ return -3;
2146
+ }
2147
+
2148
+
2149
+ if (retJSON.length > 3) {
2150
+ var obj = eval("(" + retJSON + ")");
2151
+ return obj.asymCipher;
2152
+ } else {
2153
+ return -2;
2154
+
2155
+ }
2156
+ } else {
2157
+ try {
2158
+ AjaxIO(json);
2159
+ }
2160
+ catch (e) {
2161
+ return -3;
2162
+ }
2163
+
2164
+ var ret = GetHttpResult();
2165
+ if (ret) {
2166
+ return ret.asymCipher;
2167
+ }
2168
+
2169
+ return null;
2170
+ }
2171
+ }
2172
+
2173
+ //私钥解密
2174
+ this.SOF_DecryptByPrvKey = function (containerName, cerType, strAsymCipher) {
2175
+ var json = '{"function":"SOF_DecryptByPrvKey", "deviceName":"' + _curDevName + '", "containerName":"' + containerName + '", "asymCipher":"' + strAsymCipher + '", "keySpec":' + cerType + '}';
2176
+ if (linuxWin == 2) {
2177
+ var retJSON = "";
2178
+ try {
2179
+ retJSON = AjaxIO(json);
2180
+ } catch (e) {
2181
+ return -3;
2182
+ }
2183
+
2184
+
2185
+ if (retJSON.length > 3) {
2186
+ var obj = eval("(" + retJSON + ")");
2187
+ return obj.asymPlain;
2188
+ } else {
2189
+ return -2;
2190
+
2191
+ }
2192
+ } else {
2193
+ try {
2194
+ AjaxIO(json);
2195
+ }
2196
+ catch (e) {
2197
+ return -3;
2198
+ }
2199
+
2200
+ var ret = GetHttpResult();
2201
+ if (ret) {
2202
+ return ret.asymPlain;
2203
+ }
2204
+
2205
+ return null;
2206
+ }
2207
+ }
2208
+
2209
+ //RA客户端控件
2210
+ this.SOF_CreateKeyPair = function (container, keySpec, asymAlg, keyLength) {
2211
+ var json = '{"function":"SOF_CreateKeyPair","deviceName":"' + _curDevName + '", "containerName":"' + container + '", "asymAlg":' + asymAlg + ', "keySpec":' + keySpec + ',"keyLength":' + keyLength + '}';
2212
+ if (linuxWin == 2) {
2213
+ var retJSON = "";
2214
+ try {
2215
+ retJSON = AjaxIO(json);
2216
+ } catch (e) {
2217
+ return -3;
2218
+ }
2219
+
2220
+
2221
+ if (retJSON.length > 3) {
2222
+ var obj = eval("(" + retJSON + ")");
2223
+ return obj.rtn;
2224
+ } else {
2225
+ return -2;
2226
+
2227
+ }
2228
+ } else {
2229
+ try {
2230
+ AjaxIO(json);
2231
+ }
2232
+ catch (e) {
2233
+ return -3;
2234
+ }
2235
+
2236
+ var ret = GetHttpResult();
2237
+ if (ret) {
2238
+ return ret.rtn;
2239
+ }
2240
+
2241
+ return -2;
2242
+ }
2243
+ }
2244
+
2245
+ this.SOF_EnumCertContiner = function () {
2246
+ var json = '{"function":"SOF_EnumCertContiner", "deviceName":"' + _curDevName + '"}';
2247
+ if (linuxWin == 2) {
2248
+ var retJSON = "";
2249
+ try {
2250
+ retJSON = AjaxIO(json);
2251
+ } catch (e) {
2252
+ return -3;
2253
+ }
2254
+
2255
+
2256
+ if (retJSON.length > 3) {
2257
+ var obj = eval("(" + retJSON + ")");
2258
+ return obj.containerName;
2259
+ } else {
2260
+ return -2;
2261
+
2262
+ }
2263
+ } else {
2264
+ try {
2265
+ AjaxIO(json);
2266
+ }
2267
+ catch (e) {
2268
+ return -3;
2269
+ }
2270
+
2271
+ var ret = GetHttpResult();
2272
+ if (ret) {
2273
+ return ret.containerName;
2274
+ }
2275
+
2276
+ return "";
2277
+ }
2278
+ }
2279
+
2280
+ this.SOF_FindContainer = function (certSN) {
2281
+ var json = '{"function":"SOF_FindContainer","deviceName":"' + _curDevName + '", "certSN":"' + certSN + '"}';
2282
+ if (linuxWin == 2) {
2283
+ var retJSON = "";
2284
+ try {
2285
+ retJSON = AjaxIO(json);
2286
+ } catch (e) {
2287
+ return -3;
2288
+ }
2289
+
2290
+
2291
+ if (retJSON.length > 3) {
2292
+ var obj = eval("(" + retJSON + ")");
2293
+ return obj.containerName;
2294
+ } else {
2295
+ return -2;
2296
+
2297
+ }
2298
+ } else {
2299
+ try {
2300
+ AjaxIO(json);
2301
+ }
2302
+ catch (e) {
2303
+ return -3;
2304
+ }
2305
+
2306
+ var ret = GetHttpResult();
2307
+ if (ret) {
2308
+ return ret.containerName;
2309
+ }
2310
+
2311
+ return "";
2312
+ }
2313
+ }
2314
+
2315
+ this.SOF_DeleteCert = function (certSN) {
2316
+ var json = '{"function":"SOF_DeleteCert","deviceName":"' + _curDevName + '", "certSN":"' + certSN + '"}';
2317
+ if (linuxWin == 2) {
2318
+ var retJSON = "";
2319
+ try {
2320
+ retJSON = AjaxIO(json);
2321
+ } catch (e) {
2322
+ return -3;
2323
+ }
2324
+
2325
+
2326
+ if (retJSON.length > 3) {
2327
+ var obj = eval("(" + retJSON + ")");
2328
+ return obj.rtn;
2329
+ } else {
2330
+ return -2;
2331
+
2332
+ }
2333
+ } else {
2334
+ try {
2335
+ AjaxIO(json);
2336
+ }
2337
+ catch (e) {
2338
+ return -3;
2339
+ }
2340
+
2341
+ var ret = GetHttpResult();
2342
+ if (ret) {
2343
+ return ret.rtn;
2344
+ }
2345
+
2346
+ return -2;
2347
+ }
2348
+ }
2349
+
2350
+ this.SOF_DeleteContainer = function (certSN) {
2351
+ var json = '{"function":"SOF_DeleteContainer", "deviceName":"' + _curDevName + '", "certSN":"' + certSN + '"}';
2352
+ if (linuxWin == 2) {
2353
+ var retJSON = "";
2354
+ try {
2355
+ retJSON = AjaxIO(json);
2356
+ } catch (e) {
2357
+ return -3;
2358
+ }
2359
+
2360
+
2361
+ if (retJSON.length > 3) {
2362
+ var obj = eval("(" + retJSON + ")");
2363
+ return obj.rtn;
2364
+ } else {
2365
+ return -2;
2366
+
2367
+ }
2368
+ } else {
2369
+ try {
2370
+ AjaxIO(json);
2371
+ }
2372
+ catch (e) {
2373
+ return -3;
2374
+ }
2375
+
2376
+ var ret = GetHttpResult();
2377
+ if (ret) {
2378
+ return ret.rtn;
2379
+ }
2380
+
2381
+ return -2;
2382
+ }
2383
+ }
2384
+
2385
+ this.SOF_SignByCert = function (certSN, plain) {
2386
+ var json = '{"function":"SOF_SignByCert", "deviceName":"' + _curDevName + '", "certSN":"' + certSN + '", "inData":"' + plain + '"}';
2387
+ if (linuxWin == 2) {
2388
+ var retJSON = "";
2389
+ try {
2390
+ retJSON = AjaxIO(json);
2391
+ } catch (e) {
2392
+ return -3;
2393
+ }
2394
+
2395
+
2396
+ if (retJSON.length > 3) {
2397
+ var obj = eval("(" + retJSON + ")");
2398
+ return obj.signed;
2399
+ } else {
2400
+ return -2;
2401
+
2402
+ }
2403
+ } else {
2404
+ try {
2405
+ AjaxIO(json);
2406
+ }
2407
+ catch (e) {
2408
+ return -3;
2409
+ }
2410
+
2411
+ var ret = GetHttpResult();
2412
+ if (ret) {
2413
+ return ret.signed;
2414
+ }
2415
+
2416
+ return null;
2417
+ }
2418
+ }
2419
+
2420
+ this.SOF_VerifyByCert = function (certSN, plain, signature, digestMethod) {
2421
+
2422
+ var json = '{"function":"SOF_VerifyByCert", "deviceName":"' + _curDevName + '", "certSN":"' + certSN + '","digestMethod":' + digestMethod + ', "inData":"' + plain + '", "signed":"' + signature + '"}';
2423
+ if (linuxWin == 2) {
2424
+ var retJSON = "";
2425
+ try {
2426
+ retJSON = AjaxIO(json);
2427
+ } catch (e) {
2428
+ return -3;
2429
+ }
2430
+
2431
+
2432
+ if (retJSON.length > 3) {
2433
+ var obj = eval("(" + retJSON + ")");
2434
+ return obj.rtn;
2435
+ } else {
2436
+ return -2;
2437
+
2438
+ }
2439
+ } else {
2440
+ try {
2441
+ AjaxIO(json);
2442
+ }
2443
+ catch (e) {
2444
+ return -3;
2445
+ }
2446
+ var ret = GetHttpResult();
2447
+ if (ret) {
2448
+ return ret.rtn;
2449
+ }
2450
+
2451
+ return -2;
2452
+ }
2453
+ }
2454
+
2455
+ this.SOF_VerifyByExtCert = function (cert, plain, signature, digestMethod) {
2456
+ var json = '{"function":"SOF_VerifyByExtCert","deviceName":"' + _curDevName + '", "cert":"' + cert + '", "digestMethod":' + digestMethod + ', "inData":"' + plain + '", "signed":"' + signature + '"}';
2457
+ if (linuxWin == 2) {
2458
+ var retJSON = "";
2459
+ try {
2460
+ retJSON = AjaxIO(json);
2461
+ } catch (e) {
2462
+ return -3;
2463
+ }
2464
+
2465
+
2466
+ if (retJSON.length > 3) {
2467
+ var obj = eval("(" + retJSON + ")");
2468
+ return obj.rtn;
2469
+ } else {
2470
+ return -2;
2471
+
2472
+ }
2473
+ } else {
2474
+ try {
2475
+ AjaxIO(json);
2476
+ }
2477
+ catch (e) {
2478
+ return -3;
2479
+ }
2480
+
2481
+ var ret = GetHttpResult();
2482
+ if (ret) {
2483
+ return ret.rtn;
2484
+ }
2485
+
2486
+ return -2;
2487
+ }
2488
+ }
2489
+
2490
+ // this.SOF_GenerateP10Request = function (container, dn, asymAlg, keySpec, keyLength) {
2491
+ // var json = '{"function":"SOF_GenerateP10Request", "deviceName":"' + _curDevName + '", "containerName":"' + container + '", "certDN":"' + dn + '", "asymAlg":' + asymAlg + ', "keySpec":' + keySpec + ',"keyLength":' + keyLength + '}';
2492
+ // if (linuxWin == 2) {
2493
+ // var retJSON = "";
2494
+ // try {
2495
+ // retJSON = AjaxIO(json);
2496
+ // } catch (e) {
2497
+ // return -3;
2498
+ // }
2499
+ //
2500
+ //
2501
+ // if (retJSON.length > 3) {
2502
+ // var obj = eval("(" + retJSON + ")");
2503
+ // return obj.outData;
2504
+ // } else {
2505
+ // return -2;
2506
+ //
2507
+ // }
2508
+ // } else {
2509
+ // try {
2510
+ // AjaxIO(json);
2511
+ // }
2512
+ // catch (e) {
2513
+ // return -3;
2514
+ // }
2515
+ //
2516
+ // var ret = GetHttpResult();
2517
+ // if (ret) {
2518
+ // return ret.outData;
2519
+ // }
2520
+ //
2521
+ // return null;
2522
+ // }
2523
+ // }
2524
+ this.SOF_GenerateP10Request = function (_curDevName, container, dn, asymAlg, keySpec, keyLength) {
2525
+ var json = '{"function":"SOF_GenerateP10Request", "deviceName":"' + _curDevName + '", "containerName":"' + container + '", "certDN":"' + dn + '", "asymAlg":' + asymAlg + ', "keySpec":' + keySpec + ',"keyLength":' + keyLength + '}';
2526
+ if (linuxWin == 2) {
2527
+ var retJSON = "";
2528
+ try {
2529
+ retJSON = AjaxIO(json);
2530
+ } catch (e) {
2531
+ return -3;
2532
+ }
2533
+
2534
+
2535
+ if (retJSON.length > 3) {
2536
+ var obj = eval("(" + retJSON + ")");
2537
+ return obj.outData;
2538
+ } else {
2539
+ return -2;
2540
+
2541
+ }
2542
+ } else {
2543
+ try {
2544
+ AjaxIO(json);
2545
+ }
2546
+ catch (e) {
2547
+ return -3;
2548
+ }
2549
+
2550
+ var ret = GetHttpResult();
2551
+ if (ret) {
2552
+ return ret.outData;
2553
+ }
2554
+
2555
+ return null;
2556
+ }
2557
+ }
2558
+ this.SOF_ImportCert = function (container, cert, keySpec) {
2559
+ var json = '{"function":"SOF_ImportCert", "deviceName":"' + _curDevName + '", "containerName":"' + container + '", "cert":"' + cert + '", "keySpec":' + keySpec + '}';
2560
+ if (linuxWin == 2) {
2561
+ var retJSON = "";
2562
+ try {
2563
+ retJSON = AjaxIO(json);
2564
+ } catch (e) {
2565
+ return -3;
2566
+ }
2567
+
2568
+
2569
+ if (retJSON.length > 3) {
2570
+ var obj = eval("(" + retJSON + ")");
2571
+ return obj.rtn;
2572
+ } else {
2573
+ return -2;
2574
+
2575
+ }
2576
+ } else {
2577
+ try {
2578
+ AjaxIO(json);
2579
+ }
2580
+ catch (e) {
2581
+ return -3;
2582
+ }
2583
+
2584
+ var ret = GetHttpResult();
2585
+ if (ret) {
2586
+ return ret.rtn;
2587
+ }
2588
+
2589
+ return -2;
2590
+ }
2591
+ }
2592
+
2593
+ this.SOF_ImportCryptoCertAndKey = function (container, cert, nAsymAlg, EncryptedSessionKeyData, symAlg, EncryptedPrivateKeyData, mode) {
2594
+ var json = '{"function":"SOF_ImportCryptoCertAndKey", "deviceName":"' + _curDevName + '", "containerName":"' + container + '", "cert":"' + cert + '", "asymAlg":' + nAsymAlg + ', "sessionKey":"' + EncryptedSessionKeyData + '", "symAlg":"' + symAlg + '", "encrypedData":"' + EncryptedPrivateKeyData + ', + "mode":' + mode + '}';
2595
+ if (linuxWin == 2) {
2596
+ var retJSON = "";
2597
+ try {
2598
+ retJSON = AjaxIO(json);
2599
+ } catch (e) {
2600
+ return -3;
2601
+ }
2602
+
2603
+
2604
+ if (retJSON.length > 3) {
2605
+ var obj = eval("(" + retJSON + ")");
2606
+ return obj.rtn;
2607
+ } else {
2608
+ return -2;
2609
+
2610
+ }
2611
+ } else {
2612
+ try {
2613
+ AjaxIO(json);
2614
+ }
2615
+ catch (e) {
2616
+ return -3;
2617
+ }
2618
+
2619
+ var ret = GetHttpResult();
2620
+ if (ret) {
2621
+ return ret.rtn;
2622
+ }
2623
+
2624
+ return -2;
2625
+ }
2626
+ }
2627
+
2628
+ this.SOF_GenerateRandom = function (length) {
2629
+ var json = '{"function":"SOF_GenRandom", "deviceName":"' + _curDevName + '", "inDataLen":' + length + '}';
2630
+ if (linuxWin == 2) {
2631
+ var retJSON = "";
2632
+ try {
2633
+ retJSON = AjaxIO(json);
2634
+ } catch (e) {
2635
+ return -3;
2636
+ }
2637
+
2638
+
2639
+ if (retJSON.length > 3) {
2640
+ var obj = eval("(" + retJSON + ")");
2641
+ return obj.outData;
2642
+ } else {
2643
+ return -2;
2644
+
2645
+ }
2646
+ } else {
2647
+ try {
2648
+ AjaxIO(json);
2649
+ }
2650
+ catch (e) {
2651
+ return -3;
2652
+ }
2653
+
2654
+ var ret = GetHttpResult();
2655
+ if (ret) {
2656
+ return ret.outData;
2657
+ }
2658
+
2659
+ return -2;
2660
+ }
2661
+ }
2662
+
2663
+ this.SOF_SymEncryptFile = function (sessionKey, srcfile, destfile, type) {
2664
+ var json = '{"function":"SOF_SymEncryptFile", "deviceName":"' + _curDevName + '", "sessionKey":"' + sessionKey + '", "inFile":"' + srcfile.replace(/\\/g, '\\\\') + '", "outFile":"' + destfile.replace(/\\/g, '\\\\') + '", "type":' + type + '}';
2665
+ if (linuxWin == 2) {
2666
+ var retJSON = "";
2667
+ try {
2668
+ retJSON = AjaxIO(json);
2669
+ } catch (e) {
2670
+ return -3;
2671
+ }
2672
+
2673
+
2674
+ if (retJSON.length > 3) {
2675
+ var obj = eval("(" + retJSON + ")");
2676
+ return obj.rtn;
2677
+ } else {
2678
+ return -2;
2679
+
2680
+ }
2681
+ } else {
2682
+ try {
2683
+ AjaxIO(json);
2684
+ }
2685
+ catch (e) {
2686
+ return -3;
2687
+ }
2688
+
2689
+ var ret = GetHttpResult();
2690
+ if (ret) {
2691
+ return ret.rtn;
2692
+ }
2693
+
2694
+ return -2;
2695
+ }
2696
+ }
2697
+
2698
+ this.SOF_SymDecryptFile = function (sessionKey, srcfile, destfile, type) {
2699
+ var json = '{"function":"SOF_SymDecryptFile", "deviceName":"' + _curDevName + '", "sessionKey":"' + sessionKey + '", "inFile":"' + srcfile.replace(/\\/g, '\\\\') + '", "outFile":"' + destfile.replace(/\\/g, '\\\\') + '", "type":' + type + '}';
2700
+ if (linuxWin == 2) {
2701
+ var retJSON = "";
2702
+ try {
2703
+ retJSON = AjaxIO(json);
2704
+ } catch (e) {
2705
+ return -3;
2706
+ }
2707
+
2708
+
2709
+ if (retJSON.length > 3) {
2710
+ var obj = eval("(" + retJSON + ")");
2711
+ return obj.rtn;
2712
+ } else {
2713
+ return -2;
2714
+
2715
+ }
2716
+ } else {
2717
+ try {
2718
+ AjaxIO(json);
2719
+ }
2720
+ catch (e) {
2721
+ return -3;
2722
+ }
2723
+
2724
+ var ret = GetHttpResult();
2725
+ if (ret) {
2726
+ return ret.rtn;
2727
+ }
2728
+
2729
+ return -2;
2730
+ }
2731
+ }
2732
+
2733
+ this.SOF_SymEncryptData = function (sessionKey, inData) {
2734
+ var json = '{"function":"SOF_SymEncryptData", "deviceName":"' + _curDevName + '", "sessionKey":"' + sessionKey + '", "inData":"' + inData + '"}';
2735
+ if (linuxWin == 2) {
2736
+ var retJSON = "";
2737
+ try {
2738
+ retJSON = AjaxIO(json);
2739
+ } catch (e) {
2740
+ return -3;
2741
+ }
2742
+
2743
+
2744
+ if (retJSON.length > 3) {
2745
+ var obj = eval("(" + retJSON + ")");
2746
+ return obj.outData;
2747
+ } else {
2748
+ return -2;
2749
+
2750
+ }
2751
+ } else {
2752
+ try {
2753
+ AjaxIO(json);
2754
+ }
2755
+ catch (e) {
2756
+ return -3;
2757
+ }
2758
+
2759
+ var ret = GetHttpResult();
2760
+ if (ret) {
2761
+ return ret.outData;
2762
+ }
2763
+
2764
+ return null;
2765
+ }
2766
+ }
2767
+
2768
+ this.SOF_SymDecryptData = function (sessionKey, inData) {
2769
+ var json = '{"function":"SOF_SymDecryptData", "deviceName":"' + _curDevName + '", "sessionKey":"' + sessionKey + '", "inData":"' + inData + '"}';
2770
+ if (linuxWin == 2) {
2771
+ var retJSON = "";
2772
+ try {
2773
+ retJSON = AjaxIO(json);
2774
+ } catch (e) {
2775
+ return -3;
2776
+ }
2777
+
2778
+
2779
+ if (retJSON.length > 3) {
2780
+ var obj = eval("(" + retJSON + ")");
2781
+ return obj.outData;
2782
+ } else {
2783
+ return -2;
2784
+
2785
+ }
2786
+ } else {
2787
+ try {
2788
+ AjaxIO(json);
2789
+ }
2790
+ catch (e) {
2791
+ return -3;
2792
+ }
2793
+
2794
+ var ret = GetHttpResult();
2795
+ if (ret) {
2796
+ return ret.outData;
2797
+ }
2798
+
2799
+ return null;
2800
+ }
2801
+ }
2802
+
2803
+ /////////////////////////////////////////////////////////////////
2804
+ this.SOF_GenerateQRCode = function (qrcode_text_in) {
2805
+ var qrcode_text = qrcode_text_in.replace(/"/g, '\\"');
2806
+ var json = '{"module":"libQR","function":"SOF_GenerateQRCode", "inData":"' + qrcode_text + '"}';
2807
+ if (linuxWin == 2) {
2808
+ var retJSON = "";
2809
+ try {
2810
+ retJSON = AjaxIO(json);
2811
+ } catch (e) {
2812
+ return -3;
2813
+ }
2814
+
2815
+
2816
+ if (retJSON.length > 3) {
2817
+ var obj = eval("(" + retJSON + ")");
2818
+ return obj.outData;
2819
+ } else {
2820
+ return -2;
2821
+
2822
+ }
2823
+ } else {
2824
+ try {
2825
+ AjaxIO(json);
2826
+ }
2827
+ catch (e) {
2828
+ return -3;
2829
+ }
2830
+
2831
+ var ret = GetHttpResult();
2832
+ if (ret) {
2833
+ return ret.outData;
2834
+ }
2835
+
2836
+ return null;
2837
+ }
2838
+ }
2839
+
2840
+ this.SOF_VerifyPinMS = function (responseKey) {
2841
+ var json = '{"function":"SOF_VerifyPinMS", "deviceName":"' + _curDevName + '", "passWd":"' + responseKey + '"}';
2842
+ if (linuxWin == 2) {
2843
+ var retJSON = "";
2844
+ try {
2845
+ retJSON = AjaxIO(json);
2846
+ } catch (e) {
2847
+ return -3;
2848
+ }
2849
+
2850
+
2851
+ if (retJSON.length > 3) {
2852
+ var obj = eval("(" + retJSON + ")");
2853
+ return obj.rtn;
2854
+ } else {
2855
+ return -2;
2856
+
2857
+ }
2858
+ } else {
2859
+ try {
2860
+ AjaxIO(json);
2861
+ }
2862
+ catch (e) {
2863
+ return -3;
2864
+ }
2865
+
2866
+ var ret = GetHttpResult();
2867
+ if (ret) {
2868
+ return ret.rtn;
2869
+ }
2870
+
2871
+ return -2;
2872
+ }
2873
+ }
2874
+ /////////////////////////////////////////////////////////////////
2875
+ this.SOF_GetHardwareType = function () {
2876
+ var json = '{"function":"SOF_GetHardwareType", "deviceName":"' + _curDevName + '"}';
2877
+ if (linuxWin == 2) {
2878
+ var retJSON = "";
2879
+ try {
2880
+ retJSON = AjaxIO(json);
2881
+ } catch (e) {
2882
+ return -3;
2883
+ }
2884
+
2885
+
2886
+ if (retJSON.length > 3) {
2887
+ var obj = eval("(" + retJSON + ")");
2888
+ return obj.type;
2889
+ } else {
2890
+ return -2;
2891
+
2892
+ }
2893
+ } else {
2894
+ try {
2895
+ AjaxIO(json);
2896
+ }
2897
+ catch (e) {
2898
+ return -3;
2899
+ }
2900
+
2901
+ var ret = GetHttpResult();
2902
+ if (ret) {
2903
+ return ret.type;
2904
+ }
2905
+
2906
+ return -2;
2907
+ }
2908
+ }
2909
+
2910
+ this.SOF_VerifyFingerprint = function () {
2911
+ var json = '{"function":"SOF_VerifyFingerprint", "deviceName":"' + _curDevName + '"}';
2912
+ if (linuxWin == 2) {
2913
+ var retJSON = "";
2914
+ try {
2915
+ retJSON = AjaxIO(json);
2916
+ } catch (e) {
2917
+ return -3;
2918
+ }
2919
+
2920
+
2921
+ if (retJSON.length > 3) {
2922
+ var obj = eval("(" + retJSON + ")");
2923
+ return obj.rtn;
2924
+ } else {
2925
+ return -2;
2926
+
2927
+ }
2928
+ } else {
2929
+ try {
2930
+ AjaxIO(json);
2931
+ }
2932
+ catch (e) {
2933
+ return -3;
2934
+ }
2935
+
2936
+ var ret = GetHttpResult();
2937
+ if (ret) {
2938
+ return ret.rtn;
2939
+ }
2940
+
2941
+ return -2;
2942
+ }
2943
+ }
2944
+
2945
+ this.SOF_EnumFiles = function () {
2946
+ var json = '{"function":"SOF_EnumFiles", "deviceName":"' + _curDevName + '"}';
2947
+ if (linuxWin == 2) {
2948
+ var retJSON = "";
2949
+ try {
2950
+ retJSON = AjaxIO(json);
2951
+ } catch (e) {
2952
+ return -3;
2953
+ }
2954
+
2955
+
2956
+ if (retJSON.length > 3) {
2957
+ var obj = eval("(" + retJSON + ")");
2958
+ return obj.array;
2959
+ } else {
2960
+ return -2;
2961
+
2962
+ }
2963
+ } else {
2964
+ try {
2965
+ AjaxIO(json);
2966
+ }
2967
+ catch (e) {
2968
+ return -3;
2969
+ }
2970
+
2971
+ var ret = GetHttpResult();
2972
+ if (ret) {
2973
+ return ret.array;
2974
+ }
2975
+
2976
+ return -2;
2977
+ }
2978
+ }
2979
+
2980
+ this.SOF_ReadFile = function (fileName, offset, length) {
2981
+ var json = '{"function":"SOF_ReadFile", "deviceName":"' + _curDevName + '", "fileName":"' + fileName + '", "offset":' + offset + ',"length":' + length + '}';
2982
+ if (linuxWin == 2) {
2983
+ var retJSON = "";
2984
+ try {
2985
+ retJSON = AjaxIO(json);
2986
+ } catch (e) {
2987
+ return -3;
2988
+ }
2989
+
2990
+
2991
+ if (retJSON.length > 3) {
2992
+ var obj = eval("(" + retJSON + ")");
2993
+ return obj.outData;
2994
+ } else {
2995
+ return -2;
2996
+
2997
+ }
2998
+ } else {
2999
+ try {
3000
+ AjaxIO(json);
3001
+ }
3002
+ catch (e) {
3003
+ return -3;
3004
+ }
3005
+
3006
+ var ret = GetHttpResult();
3007
+ if (ret) {
3008
+ return ret.outData;
3009
+ }
3010
+ }
3011
+ }
3012
+
3013
+ this.SOF_WriteFile = function (fileName, offset, data) {
3014
+ var json = '{"function":"SOF_WriteFile", "deviceName":"' + _curDevName + '", "fileName":"' + fileName + '", "offset":' + offset + ',"inData":"' + data + '"}';
3015
+ if (linuxWin == 2) {
3016
+ var retJSON = "";
3017
+ try {
3018
+ retJSON = AjaxIO(json);
3019
+ } catch (e) {
3020
+ return -3;
3021
+ }
3022
+
3023
+
3024
+ if (retJSON.length > 3) {
3025
+ var obj = eval("(" + retJSON + ")");
3026
+ return obj.rtn;
3027
+ } else {
3028
+ return -2;
3029
+
3030
+ }
3031
+ } else {
3032
+ try {
3033
+ AjaxIO(json);
3034
+ }
3035
+ catch (e) {
3036
+ return -3;
3037
+ }
3038
+
3039
+ var ret = GetHttpResult();
3040
+ if (ret) {
3041
+ return ret.rtn;
3042
+ }
3043
+ }
3044
+ }
3045
+
3046
+ this.SOF_CreateFile = function (fileName, length, readRight, writeRight) {
3047
+ var json = '{"function":"SOF_CreateFile", "deviceName":"' + _curDevName + '","fileName":"' + fileName + '", "length" :' + length + ', "readRight":' + readRight + ',"writeRight":' + writeRight + '}';
3048
+ if (linuxWin == 2) {
3049
+ var retJSON = "";
3050
+ try {
3051
+ retJSON = AjaxIO(json);
3052
+ } catch (e) {
3053
+ return -3;
3054
+ }
3055
+
3056
+
3057
+ if (retJSON.length > 3) {
3058
+ var obj = eval("(" + retJSON + ")");
3059
+ return obj.rtn;
3060
+ } else {
3061
+ return -2;
3062
+
3063
+ }
3064
+ } else {
3065
+ try {
3066
+ AjaxIO(json);
3067
+ }
3068
+ catch (e) {
3069
+ return -3;
3070
+ }
3071
+
3072
+ var ret = GetHttpResult();
3073
+ if (ret) {
3074
+ return ret.rtn;
3075
+ }
3076
+ }
3077
+ }
3078
+
3079
+ this.SOF_DeleteFile = function (fileName) {
3080
+ var json = '{"function":"SOF_DeleteFile", "deviceName":"' + _curDevName + '","fileName":"' + fileName + '"}';
3081
+ if (linuxWin == 2) {
3082
+ var retJSON = "";
3083
+ try {
3084
+ retJSON = AjaxIO(json);
3085
+ } catch (e) {
3086
+ return -3;
3087
+ }
3088
+
3089
+
3090
+ if (retJSON.length > 3) {
3091
+ var obj = eval("(" + retJSON + ")");
3092
+ return obj.rtn;
3093
+ } else {
3094
+ return -2;
3095
+
3096
+ }
3097
+ } else {
3098
+ try {
3099
+ AjaxIO(json);
3100
+ }
3101
+ catch (e) {
3102
+ return -3;
3103
+ }
3104
+
3105
+ var ret = GetHttpResult();
3106
+ if (ret) {
3107
+ return ret.rtn;
3108
+ }
3109
+ }
3110
+ }
3111
+
3112
+ //Socket API
3113
+ this.SocketConnect = function (HostName, Port) {
3114
+ var json = '{"module":"libSocket","function":"SocketConnect", "HostName":"' + HostName + '", "Port":' + Port + '}';
3115
+ if (linuxWin == 2) {
3116
+ var retJSON = "";
3117
+ try {
3118
+ retJSON = AjaxIO(json);
3119
+ } catch (e) {
3120
+ return -3;
3121
+ }
3122
+
3123
+
3124
+ if (retJSON.length > 3) {
3125
+ var obj = eval("(" + retJSON + ")");
3126
+ return obj.rtn;
3127
+ } else {
3128
+ return -2;
3129
+
3130
+ }
3131
+ } else {
3132
+ try {
3133
+ AjaxIO(json);
3134
+ }
3135
+ catch (e) {
3136
+ return -3;
3137
+ }
3138
+
3139
+ var ret = GetHttpResult();
3140
+ if (ret) {
3141
+ return ret.rtn;
3142
+ }
3143
+ }
3144
+ }
3145
+
3146
+ this.SocketDisConnect = function () {
3147
+ var json = '{"module":"libSocket","function":"SocketDisConnect"}';
3148
+ if (linuxWin == 2) {
3149
+ var retJSON = "";
3150
+ try {
3151
+ retJSON = AjaxIO(json);
3152
+ } catch (e) {
3153
+ return -3;
3154
+ }
3155
+
3156
+
3157
+ if (retJSON.length > 3) {
3158
+ var obj = eval("(" + retJSON + ")");
3159
+ return obj.rtn;
3160
+ } else {
3161
+ return -2;
3162
+
3163
+ }
3164
+ } else {
3165
+ try {
3166
+ AjaxIO(json);
3167
+ }
3168
+ catch (e) {
3169
+ return -3;
3170
+ }
3171
+
3172
+ var ret = GetHttpResult();
3173
+ if (ret) {
3174
+ return ret.rtn;
3175
+ }
3176
+ }
3177
+ }
3178
+
3179
+ this.SocketSendText = function (SendText) {
3180
+ var json = '{"module":"libSocket","function":"SocketSendText", "SendText":"' + SendText + '"}';
3181
+ if (linuxWin == 2) {
3182
+ var retJSON = "";
3183
+ try {
3184
+ retJSON = AjaxIO(json);
3185
+ } catch (e) {
3186
+ return -3;
3187
+ }
3188
+
3189
+
3190
+ if (retJSON.length > 3) {
3191
+ var obj = eval("(" + retJSON + ")");
3192
+ return obj.RecvText;
3193
+ } else {
3194
+ return -2;
3195
+
3196
+ }
3197
+ } else {
3198
+ try {
3199
+ AjaxIO(json);
3200
+ }
3201
+ catch (e) {
3202
+ return -3;
3203
+ }
3204
+
3205
+ var ret = GetHttpResult();
3206
+ if (ret) {
3207
+ return ret.RecvText;
3208
+ }
3209
+ }
3210
+ }
3211
+ }