pixel-react 1.14.91 → 1.14.92

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/lib/assets/icons/lambda_icon.svg.js +1 -1
  2. package/lib/assets/icons/lambda_icon.svg.js.map +1 -1
  3. package/lib/components/SessionManager/SessionManager.js +28 -21
  4. package/lib/components/SessionManager/SessionManager.js.map +1 -1
  5. package/lib/components/SessionManager/types.d.ts +1 -0
  6. package/lib/components/Tooltip/Tooltip.js +19 -0
  7. package/lib/components/Tooltip/Tooltip.js.map +1 -1
  8. package/lib/components/TruncatedTooltip/TruncatedTooltip.js +3 -0
  9. package/lib/components/TruncatedTooltip/TruncatedTooltip.js.map +1 -1
  10. package/lib/index.cjs +71 -5241
  11. package/lib/index.cjs.map +1 -1
  12. package/lib/index.d.ts +2 -1
  13. package/lib/node_modules/js-beautify/js/src/css/beautifier.js +1 -1
  14. package/lib/node_modules/js-beautify/js/src/css/options.js +1 -1
  15. package/lib/node_modules/js-beautify/js/src/html/tokenizer.js +1 -1
  16. package/lib/node_modules/js-beautify/js/src/javascript/beautifier.js +1 -1
  17. package/lib/node_modules/js-beautify/js/src/javascript/options.js +1 -1
  18. package/lib/node_modules/js-beautify/js/src/javascript/tokenizer.js +1 -1
  19. package/lib/styles.css +1 -1
  20. package/lib/styles.css.map +1 -1
  21. package/lib/utils/getEncryptedData/getEncryptedData.d.ts +1 -1
  22. package/lib/utils/getEncryptedData/getEncryptedData.js +17 -8
  23. package/lib/utils/getEncryptedData/getEncryptedData.js.map +1 -1
  24. package/package.json +1 -2
  25. package/lib/node_modules/jsencrypt/lib/JSEncrypt.js +0 -189
  26. package/lib/node_modules/jsencrypt/lib/JSEncrypt.js.map +0 -1
  27. package/lib/node_modules/jsencrypt/lib/JSEncryptRSAKey.js +0 -323
  28. package/lib/node_modules/jsencrypt/lib/JSEncryptRSAKey.js.map +0 -1
  29. package/lib/node_modules/jsencrypt/lib/index.js +0 -6
  30. package/lib/node_modules/jsencrypt/lib/index.js.map +0 -1
  31. package/lib/node_modules/jsencrypt/lib/lib/asn1js/asn1.js +0 -570
  32. package/lib/node_modules/jsencrypt/lib/lib/asn1js/asn1.js.map +0 -1
  33. package/lib/node_modules/jsencrypt/lib/lib/asn1js/base64.js +0 -88
  34. package/lib/node_modules/jsencrypt/lib/lib/asn1js/base64.js.map +0 -1
  35. package/lib/node_modules/jsencrypt/lib/lib/asn1js/hex.js +0 -66
  36. package/lib/node_modules/jsencrypt/lib/lib/asn1js/hex.js.map +0 -1
  37. package/lib/node_modules/jsencrypt/lib/lib/asn1js/int10.js +0 -87
  38. package/lib/node_modules/jsencrypt/lib/lib/asn1js/int10.js.map +0 -1
  39. package/lib/node_modules/jsencrypt/lib/lib/jsbn/base64.js +0 -65
  40. package/lib/node_modules/jsencrypt/lib/lib/jsbn/base64.js.map +0 -1
  41. package/lib/node_modules/jsencrypt/lib/lib/jsbn/jsbn.js +0 -1700
  42. package/lib/node_modules/jsencrypt/lib/lib/jsbn/jsbn.js.map +0 -1
  43. package/lib/node_modules/jsencrypt/lib/lib/jsbn/prng4.js +0 -48
  44. package/lib/node_modules/jsencrypt/lib/lib/jsbn/prng4.js.map +0 -1
  45. package/lib/node_modules/jsencrypt/lib/lib/jsbn/rng.js +0 -77
  46. package/lib/node_modules/jsencrypt/lib/lib/jsbn/rng.js.map +0 -1
  47. package/lib/node_modules/jsencrypt/lib/lib/jsbn/rsa.js +0 -371
  48. package/lib/node_modules/jsencrypt/lib/lib/jsbn/rsa.js.map +0 -1
  49. package/lib/node_modules/jsencrypt/lib/lib/jsbn/util.js +0 -61
  50. package/lib/node_modules/jsencrypt/lib/lib/jsbn/util.js.map +0 -1
  51. package/lib/node_modules/jsencrypt/lib/lib/jsrsasign/asn1-1.0.js +0 -1547
  52. package/lib/node_modules/jsencrypt/lib/lib/jsrsasign/asn1-1.0.js.map +0 -1
  53. package/lib/node_modules/jsencrypt/lib/lib/jsrsasign/yahoo.js +0 -71
  54. package/lib/node_modules/jsencrypt/lib/lib/jsrsasign/yahoo.js.map +0 -1
@@ -1,1547 +0,0 @@
1
- import { BigInteger } from '../jsbn/jsbn.js';
2
- import { YAHOO } from './yahoo.js';
3
-
4
- /* asn1-1.0.13.js (c) 2013-2017 Kenji Urushima | kjur.github.com/jsrsasign/license
5
- */
6
- /*
7
- * asn1.js - ASN.1 DER encoder classes
8
- *
9
- * Copyright (c) 2013-2017 Kenji Urushima (kenji.urushima@gmail.com)
10
- *
11
- * This software is licensed under the terms of the MIT License.
12
- * https://kjur.github.io/jsrsasign/license
13
- *
14
- * The above copyright and license notice shall be
15
- * included in all copies or substantial portions of the Software.
16
- */
17
- /**
18
- * @fileOverview
19
- * @name asn1-1.0.js
20
- * @author Kenji Urushima kenji.urushima@gmail.com
21
- * @version asn1 1.0.13 (2017-Jun-02)
22
- * @since jsrsasign 2.1
23
- * @license <a href="https://kjur.github.io/jsrsasign/license/">MIT License</a>
24
- */
25
- /**
26
- * kjur's class library name space
27
- * <p>
28
- * This name space provides following name spaces:
29
- * <ul>
30
- * <li>{@link KJUR.asn1} - ASN.1 primitive hexadecimal encoder</li>
31
- * <li>{@link KJUR.asn1.x509} - ASN.1 structure for X.509 certificate and CRL</li>
32
- * <li>{@link KJUR.crypto} - Java Cryptographic Extension(JCE) style MessageDigest/Signature
33
- * class and utilities</li>
34
- * </ul>
35
- * </p>
36
- * NOTE: Please ignore method summary and document of this namespace. This caused by a bug of jsdoc2.
37
- * @name KJUR
38
- * @namespace kjur's class library name space
39
- */
40
- var KJUR = {};
41
- /**
42
- * kjur's ASN.1 class library name space
43
- * <p>
44
- * This is ITU-T X.690 ASN.1 DER encoder class library and
45
- * class structure and methods is very similar to
46
- * org.bouncycastle.asn1 package of
47
- * well known BouncyCaslte Cryptography Library.
48
- * <h4>PROVIDING ASN.1 PRIMITIVES</h4>
49
- * Here are ASN.1 DER primitive classes.
50
- * <ul>
51
- * <li>0x01 {@link KJUR.asn1.DERBoolean}</li>
52
- * <li>0x02 {@link KJUR.asn1.DERInteger}</li>
53
- * <li>0x03 {@link KJUR.asn1.DERBitString}</li>
54
- * <li>0x04 {@link KJUR.asn1.DEROctetString}</li>
55
- * <li>0x05 {@link KJUR.asn1.DERNull}</li>
56
- * <li>0x06 {@link KJUR.asn1.DERObjectIdentifier}</li>
57
- * <li>0x0a {@link KJUR.asn1.DEREnumerated}</li>
58
- * <li>0x0c {@link KJUR.asn1.DERUTF8String}</li>
59
- * <li>0x12 {@link KJUR.asn1.DERNumericString}</li>
60
- * <li>0x13 {@link KJUR.asn1.DERPrintableString}</li>
61
- * <li>0x14 {@link KJUR.asn1.DERTeletexString}</li>
62
- * <li>0x16 {@link KJUR.asn1.DERIA5String}</li>
63
- * <li>0x17 {@link KJUR.asn1.DERUTCTime}</li>
64
- * <li>0x18 {@link KJUR.asn1.DERGeneralizedTime}</li>
65
- * <li>0x30 {@link KJUR.asn1.DERSequence}</li>
66
- * <li>0x31 {@link KJUR.asn1.DERSet}</li>
67
- * </ul>
68
- * <h4>OTHER ASN.1 CLASSES</h4>
69
- * <ul>
70
- * <li>{@link KJUR.asn1.ASN1Object}</li>
71
- * <li>{@link KJUR.asn1.DERAbstractString}</li>
72
- * <li>{@link KJUR.asn1.DERAbstractTime}</li>
73
- * <li>{@link KJUR.asn1.DERAbstractStructured}</li>
74
- * <li>{@link KJUR.asn1.DERTaggedObject}</li>
75
- * </ul>
76
- * <h4>SUB NAME SPACES</h4>
77
- * <ul>
78
- * <li>{@link KJUR.asn1.cades} - CAdES long term signature format</li>
79
- * <li>{@link KJUR.asn1.cms} - Cryptographic Message Syntax</li>
80
- * <li>{@link KJUR.asn1.csr} - Certificate Signing Request (CSR/PKCS#10)</li>
81
- * <li>{@link KJUR.asn1.tsp} - RFC 3161 Timestamping Protocol Format</li>
82
- * <li>{@link KJUR.asn1.x509} - RFC 5280 X.509 certificate and CRL</li>
83
- * </ul>
84
- * </p>
85
- * NOTE: Please ignore method summary and document of this namespace.
86
- * This caused by a bug of jsdoc2.
87
- * @name KJUR.asn1
88
- * @namespace
89
- */
90
- if (typeof KJUR.asn1 == "undefined" || !KJUR.asn1) KJUR.asn1 = {};
91
- /**
92
- * ASN1 utilities class
93
- * @name KJUR.asn1.ASN1Util
94
- * @class ASN1 utilities class
95
- * @since asn1 1.0.2
96
- */
97
- KJUR.asn1.ASN1Util = new function () {
98
- this.integerToByteHex = function (i) {
99
- var h = i.toString(16);
100
- if (h.length % 2 == 1) h = '0' + h;
101
- return h;
102
- };
103
- this.bigIntToMinTwosComplementsHex = function (bigIntegerValue) {
104
- var h = bigIntegerValue.toString(16);
105
- if (h.substr(0, 1) != '-') {
106
- if (h.length % 2 == 1) {
107
- h = '0' + h;
108
- } else {
109
- if (!h.match(/^[0-7]/)) {
110
- h = '00' + h;
111
- }
112
- }
113
- } else {
114
- var hPos = h.substr(1);
115
- var xorLen = hPos.length;
116
- if (xorLen % 2 == 1) {
117
- xorLen += 1;
118
- } else {
119
- if (!h.match(/^[0-7]/)) {
120
- xorLen += 2;
121
- }
122
- }
123
- var hMask = '';
124
- for (var i = 0; i < xorLen; i++) {
125
- hMask += 'f';
126
- }
127
- var biMask = new BigInteger(hMask, 16);
128
- var biNeg = biMask.xor(bigIntegerValue).add(BigInteger.ONE);
129
- h = biNeg.toString(16).replace(/^-/, '');
130
- }
131
- return h;
132
- };
133
- /**
134
- * get PEM string from hexadecimal data and header string
135
- * @name getPEMStringFromHex
136
- * @memberOf KJUR.asn1.ASN1Util
137
- * @function
138
- * @param {String} dataHex hexadecimal string of PEM body
139
- * @param {String} pemHeader PEM header string (ex. 'RSA PRIVATE KEY')
140
- * @return {String} PEM formatted string of input data
141
- * @description
142
- * This method converts a hexadecimal string to a PEM string with
143
- * a specified header. Its line break will be CRLF("\r\n").
144
- * @example
145
- * var pem = KJUR.asn1.ASN1Util.getPEMStringFromHex('616161', 'RSA PRIVATE KEY');
146
- * // value of pem will be:
147
- * -----BEGIN PRIVATE KEY-----
148
- * YWFh
149
- * -----END PRIVATE KEY-----
150
- */
151
- this.getPEMStringFromHex = function (dataHex, pemHeader) {
152
- return hextopem(dataHex, pemHeader);
153
- };
154
- /**
155
- * generate ASN1Object specifed by JSON parameters
156
- * @name newObject
157
- * @memberOf KJUR.asn1.ASN1Util
158
- * @function
159
- * @param {Array} param JSON parameter to generate ASN1Object
160
- * @return {KJUR.asn1.ASN1Object} generated object
161
- * @since asn1 1.0.3
162
- * @description
163
- * generate any ASN1Object specified by JSON param
164
- * including ASN.1 primitive or structured.
165
- * Generally 'param' can be described as follows:
166
- * <blockquote>
167
- * {TYPE-OF-ASNOBJ: ASN1OBJ-PARAMETER}
168
- * </blockquote>
169
- * 'TYPE-OF-ASN1OBJ' can be one of following symbols:
170
- * <ul>
171
- * <li>'bool' - DERBoolean</li>
172
- * <li>'int' - DERInteger</li>
173
- * <li>'bitstr' - DERBitString</li>
174
- * <li>'octstr' - DEROctetString</li>
175
- * <li>'null' - DERNull</li>
176
- * <li>'oid' - DERObjectIdentifier</li>
177
- * <li>'enum' - DEREnumerated</li>
178
- * <li>'utf8str' - DERUTF8String</li>
179
- * <li>'numstr' - DERNumericString</li>
180
- * <li>'prnstr' - DERPrintableString</li>
181
- * <li>'telstr' - DERTeletexString</li>
182
- * <li>'ia5str' - DERIA5String</li>
183
- * <li>'utctime' - DERUTCTime</li>
184
- * <li>'gentime' - DERGeneralizedTime</li>
185
- * <li>'seq' - DERSequence</li>
186
- * <li>'set' - DERSet</li>
187
- * <li>'tag' - DERTaggedObject</li>
188
- * </ul>
189
- * @example
190
- * newObject({'prnstr': 'aaa'});
191
- * newObject({'seq': [{'int': 3}, {'prnstr': 'aaa'}]})
192
- * // ASN.1 Tagged Object
193
- * newObject({'tag': {'tag': 'a1',
194
- * 'explicit': true,
195
- * 'obj': {'seq': [{'int': 3}, {'prnstr': 'aaa'}]}}});
196
- * // more simple representation of ASN.1 Tagged Object
197
- * newObject({'tag': ['a1',
198
- * true,
199
- * {'seq': [
200
- * {'int': 3},
201
- * {'prnstr': 'aaa'}]}
202
- * ]});
203
- */
204
- this.newObject = function (param) {
205
- var _KJUR = KJUR,
206
- _KJUR_asn1 = _KJUR.asn1,
207
- _DERBoolean = _KJUR_asn1.DERBoolean,
208
- _DERInteger = _KJUR_asn1.DERInteger,
209
- _DERBitString = _KJUR_asn1.DERBitString,
210
- _DEROctetString = _KJUR_asn1.DEROctetString,
211
- _DERNull = _KJUR_asn1.DERNull,
212
- _DERObjectIdentifier = _KJUR_asn1.DERObjectIdentifier,
213
- _DEREnumerated = _KJUR_asn1.DEREnumerated,
214
- _DERUTF8String = _KJUR_asn1.DERUTF8String,
215
- _DERNumericString = _KJUR_asn1.DERNumericString,
216
- _DERPrintableString = _KJUR_asn1.DERPrintableString,
217
- _DERTeletexString = _KJUR_asn1.DERTeletexString,
218
- _DERIA5String = _KJUR_asn1.DERIA5String,
219
- _DERUTCTime = _KJUR_asn1.DERUTCTime,
220
- _DERGeneralizedTime = _KJUR_asn1.DERGeneralizedTime,
221
- _DERSequence = _KJUR_asn1.DERSequence,
222
- _DERSet = _KJUR_asn1.DERSet,
223
- _DERTaggedObject = _KJUR_asn1.DERTaggedObject,
224
- _newObject = _KJUR_asn1.ASN1Util.newObject;
225
- var keys = Object.keys(param);
226
- if (keys.length != 1) throw "key of param shall be only one.";
227
- var key = keys[0];
228
- if (":bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:seq:set:tag:".indexOf(":" + key + ":") == -1) throw "undefined key: " + key;
229
- if (key == "bool") return new _DERBoolean(param[key]);
230
- if (key == "int") return new _DERInteger(param[key]);
231
- if (key == "bitstr") return new _DERBitString(param[key]);
232
- if (key == "octstr") return new _DEROctetString(param[key]);
233
- if (key == "null") return new _DERNull(param[key]);
234
- if (key == "oid") return new _DERObjectIdentifier(param[key]);
235
- if (key == "enum") return new _DEREnumerated(param[key]);
236
- if (key == "utf8str") return new _DERUTF8String(param[key]);
237
- if (key == "numstr") return new _DERNumericString(param[key]);
238
- if (key == "prnstr") return new _DERPrintableString(param[key]);
239
- if (key == "telstr") return new _DERTeletexString(param[key]);
240
- if (key == "ia5str") return new _DERIA5String(param[key]);
241
- if (key == "utctime") return new _DERUTCTime(param[key]);
242
- if (key == "gentime") return new _DERGeneralizedTime(param[key]);
243
- if (key == "seq") {
244
- var paramList = param[key];
245
- var a = [];
246
- for (var i = 0; i < paramList.length; i++) {
247
- var asn1Obj = _newObject(paramList[i]);
248
- a.push(asn1Obj);
249
- }
250
- return new _DERSequence({
251
- 'array': a
252
- });
253
- }
254
- if (key == "set") {
255
- var paramList = param[key];
256
- var a = [];
257
- for (var i = 0; i < paramList.length; i++) {
258
- var asn1Obj = _newObject(paramList[i]);
259
- a.push(asn1Obj);
260
- }
261
- return new _DERSet({
262
- 'array': a
263
- });
264
- }
265
- if (key == "tag") {
266
- var tagParam = param[key];
267
- if (Object.prototype.toString.call(tagParam) === '[object Array]' && tagParam.length == 3) {
268
- var obj = _newObject(tagParam[2]);
269
- return new _DERTaggedObject({
270
- tag: tagParam[0],
271
- explicit: tagParam[1],
272
- obj: obj
273
- });
274
- } else {
275
- var newParam = {};
276
- if (tagParam.explicit !== undefined) newParam.explicit = tagParam.explicit;
277
- if (tagParam.tag !== undefined) newParam.tag = tagParam.tag;
278
- if (tagParam.obj === undefined) throw "obj shall be specified for 'tag'.";
279
- newParam.obj = _newObject(tagParam.obj);
280
- return new _DERTaggedObject(newParam);
281
- }
282
- }
283
- };
284
- /**
285
- * get encoded hexadecimal string of ASN1Object specifed by JSON parameters
286
- * @name jsonToASN1HEX
287
- * @memberOf KJUR.asn1.ASN1Util
288
- * @function
289
- * @param {Array} param JSON parameter to generate ASN1Object
290
- * @return hexadecimal string of ASN1Object
291
- * @since asn1 1.0.4
292
- * @description
293
- * As for ASN.1 object representation of JSON object,
294
- * please see {@link newObject}.
295
- * @example
296
- * jsonToASN1HEX({'prnstr': 'aaa'});
297
- */
298
- this.jsonToASN1HEX = function (param) {
299
- var asn1Obj = this.newObject(param);
300
- return asn1Obj.getEncodedHex();
301
- };
302
- }();
303
- /**
304
- * get dot noted oid number string from hexadecimal value of OID
305
- * @name oidHexToInt
306
- * @memberOf KJUR.asn1.ASN1Util
307
- * @function
308
- * @param {String} hex hexadecimal value of object identifier
309
- * @return {String} dot noted string of object identifier
310
- * @since jsrsasign 4.8.3 asn1 1.0.7
311
- * @description
312
- * This static method converts from hexadecimal string representation of
313
- * ASN.1 value of object identifier to oid number string.
314
- * @example
315
- * KJUR.asn1.ASN1Util.oidHexToInt('550406') &rarr; "2.5.4.6"
316
- */
317
- KJUR.asn1.ASN1Util.oidHexToInt = function (hex) {
318
- var s = "";
319
- var i01 = parseInt(hex.substr(0, 2), 16);
320
- var i0 = Math.floor(i01 / 40);
321
- var i1 = i01 % 40;
322
- var s = i0 + "." + i1;
323
- var binbuf = "";
324
- for (var i = 2; i < hex.length; i += 2) {
325
- var value = parseInt(hex.substr(i, 2), 16);
326
- var bin = ("00000000" + value.toString(2)).slice(-8);
327
- binbuf = binbuf + bin.substr(1, 7);
328
- if (bin.substr(0, 1) == "0") {
329
- var bi = new BigInteger(binbuf, 2);
330
- s = s + "." + bi.toString(10);
331
- binbuf = "";
332
- }
333
- }
334
- return s;
335
- };
336
- /**
337
- * get hexadecimal value of object identifier from dot noted oid value
338
- * @name oidIntToHex
339
- * @memberOf KJUR.asn1.ASN1Util
340
- * @function
341
- * @param {String} oidString dot noted string of object identifier
342
- * @return {String} hexadecimal value of object identifier
343
- * @since jsrsasign 4.8.3 asn1 1.0.7
344
- * @description
345
- * This static method converts from object identifier value string.
346
- * to hexadecimal string representation of it.
347
- * @example
348
- * KJUR.asn1.ASN1Util.oidIntToHex("2.5.4.6") &rarr; "550406"
349
- */
350
- KJUR.asn1.ASN1Util.oidIntToHex = function (oidString) {
351
- var itox = function (i) {
352
- var h = i.toString(16);
353
- if (h.length == 1) h = '0' + h;
354
- return h;
355
- };
356
- var roidtox = function (roid) {
357
- var h = '';
358
- var bi = new BigInteger(roid, 10);
359
- var b = bi.toString(2);
360
- var padLen = 7 - b.length % 7;
361
- if (padLen == 7) padLen = 0;
362
- var bPad = '';
363
- for (var i = 0; i < padLen; i++) bPad += '0';
364
- b = bPad + b;
365
- for (var i = 0; i < b.length - 1; i += 7) {
366
- var b8 = b.substr(i, 7);
367
- if (i != b.length - 7) b8 = '1' + b8;
368
- h += itox(parseInt(b8, 2));
369
- }
370
- return h;
371
- };
372
- if (!oidString.match(/^[0-9.]+$/)) {
373
- throw "malformed oid string: " + oidString;
374
- }
375
- var h = '';
376
- var a = oidString.split('.');
377
- var i0 = parseInt(a[0]) * 40 + parseInt(a[1]);
378
- h += itox(i0);
379
- a.splice(0, 2);
380
- for (var i = 0; i < a.length; i++) {
381
- h += roidtox(a[i]);
382
- }
383
- return h;
384
- };
385
- // ********************************************************************
386
- // Abstract ASN.1 Classes
387
- // ********************************************************************
388
- // ********************************************************************
389
- /**
390
- * base class for ASN.1 DER encoder object
391
- * @name KJUR.asn1.ASN1Object
392
- * @class base class for ASN.1 DER encoder object
393
- * @property {Boolean} isModified flag whether internal data was changed
394
- * @property {String} hTLV hexadecimal string of ASN.1 TLV
395
- * @property {String} hT hexadecimal string of ASN.1 TLV tag(T)
396
- * @property {String} hL hexadecimal string of ASN.1 TLV length(L)
397
- * @property {String} hV hexadecimal string of ASN.1 TLV value(V)
398
- * @description
399
- */
400
- KJUR.asn1.ASN1Object = function () {
401
- var hV = '';
402
- /**
403
- * get hexadecimal ASN.1 TLV length(L) bytes from TLV value(V)
404
- * @name getLengthHexFromValue
405
- * @memberOf KJUR.asn1.ASN1Object#
406
- * @function
407
- * @return {String} hexadecimal string of ASN.1 TLV length(L)
408
- */
409
- this.getLengthHexFromValue = function () {
410
- if (typeof this.hV == "undefined" || this.hV == null) {
411
- throw "this.hV is null or undefined.";
412
- }
413
- if (this.hV.length % 2 == 1) {
414
- throw "value hex must be even length: n=" + hV.length + ",v=" + this.hV;
415
- }
416
- var n = this.hV.length / 2;
417
- var hN = n.toString(16);
418
- if (hN.length % 2 == 1) {
419
- hN = "0" + hN;
420
- }
421
- if (n < 128) {
422
- return hN;
423
- } else {
424
- var hNlen = hN.length / 2;
425
- if (hNlen > 15) {
426
- throw "ASN.1 length too long to represent by 8x: n = " + n.toString(16);
427
- }
428
- var head = 128 + hNlen;
429
- return head.toString(16) + hN;
430
- }
431
- };
432
- /**
433
- * get hexadecimal string of ASN.1 TLV bytes
434
- * @name getEncodedHex
435
- * @memberOf KJUR.asn1.ASN1Object#
436
- * @function
437
- * @return {String} hexadecimal string of ASN.1 TLV
438
- */
439
- this.getEncodedHex = function () {
440
- if (this.hTLV == null || this.isModified) {
441
- this.hV = this.getFreshValueHex();
442
- this.hL = this.getLengthHexFromValue();
443
- this.hTLV = this.hT + this.hL + this.hV;
444
- this.isModified = false;
445
- //alert("first time: " + this.hTLV);
446
- }
447
- return this.hTLV;
448
- };
449
- /**
450
- * get hexadecimal string of ASN.1 TLV value(V) bytes
451
- * @name getValueHex
452
- * @memberOf KJUR.asn1.ASN1Object#
453
- * @function
454
- * @return {String} hexadecimal string of ASN.1 TLV value(V) bytes
455
- */
456
- this.getValueHex = function () {
457
- this.getEncodedHex();
458
- return this.hV;
459
- };
460
- this.getFreshValueHex = function () {
461
- return '';
462
- };
463
- };
464
- // == BEGIN DERAbstractString ================================================
465
- /**
466
- * base class for ASN.1 DER string classes
467
- * @name KJUR.asn1.DERAbstractString
468
- * @class base class for ASN.1 DER string classes
469
- * @param {Array} params associative array of parameters (ex. {'str': 'aaa'})
470
- * @property {String} s internal string of value
471
- * @extends KJUR.asn1.ASN1Object
472
- * @description
473
- * <br/>
474
- * As for argument 'params' for constructor, you can specify one of
475
- * following properties:
476
- * <ul>
477
- * <li>str - specify initial ASN.1 value(V) by a string</li>
478
- * <li>hex - specify initial ASN.1 value(V) by a hexadecimal string</li>
479
- * </ul>
480
- * NOTE: 'params' can be omitted.
481
- */
482
- KJUR.asn1.DERAbstractString = function (params) {
483
- KJUR.asn1.DERAbstractString.superclass.constructor.call(this);
484
- /**
485
- * get string value of this string object
486
- * @name getString
487
- * @memberOf KJUR.asn1.DERAbstractString#
488
- * @function
489
- * @return {String} string value of this string object
490
- */
491
- this.getString = function () {
492
- return this.s;
493
- };
494
- /**
495
- * set value by a string
496
- * @name setString
497
- * @memberOf KJUR.asn1.DERAbstractString#
498
- * @function
499
- * @param {String} newS value by a string to set
500
- */
501
- this.setString = function (newS) {
502
- this.hTLV = null;
503
- this.isModified = true;
504
- this.s = newS;
505
- this.hV = stohex(this.s);
506
- };
507
- /**
508
- * set value by a hexadecimal string
509
- * @name setStringHex
510
- * @memberOf KJUR.asn1.DERAbstractString#
511
- * @function
512
- * @param {String} newHexString value by a hexadecimal string to set
513
- */
514
- this.setStringHex = function (newHexString) {
515
- this.hTLV = null;
516
- this.isModified = true;
517
- this.s = null;
518
- this.hV = newHexString;
519
- };
520
- this.getFreshValueHex = function () {
521
- return this.hV;
522
- };
523
- if (typeof params != "undefined") {
524
- if (typeof params == "string") {
525
- this.setString(params);
526
- } else if (typeof params['str'] != "undefined") {
527
- this.setString(params['str']);
528
- } else if (typeof params['hex'] != "undefined") {
529
- this.setStringHex(params['hex']);
530
- }
531
- }
532
- };
533
- YAHOO.lang.extend(KJUR.asn1.DERAbstractString, KJUR.asn1.ASN1Object);
534
- // == END DERAbstractString ================================================
535
- // == BEGIN DERAbstractTime ==================================================
536
- /**
537
- * base class for ASN.1 DER Generalized/UTCTime class
538
- * @name KJUR.asn1.DERAbstractTime
539
- * @class base class for ASN.1 DER Generalized/UTCTime class
540
- * @param {Array} params associative array of parameters (ex. {'str': '130430235959Z'})
541
- * @extends KJUR.asn1.ASN1Object
542
- * @description
543
- * @see KJUR.asn1.ASN1Object - superclass
544
- */
545
- KJUR.asn1.DERAbstractTime = function (params) {
546
- KJUR.asn1.DERAbstractTime.superclass.constructor.call(this);
547
- // --- PRIVATE METHODS --------------------
548
- this.localDateToUTC = function (d) {
549
- utc = d.getTime() + d.getTimezoneOffset() * 60000;
550
- var utcDate = new Date(utc);
551
- return utcDate;
552
- };
553
- /*
554
- * format date string by Data object
555
- * @name formatDate
556
- * @memberOf KJUR.asn1.AbstractTime;
557
- * @param {Date} dateObject
558
- * @param {string} type 'utc' or 'gen'
559
- * @param {boolean} withMillis flag for with millisections or not
560
- * @description
561
- * 'withMillis' flag is supported from asn1 1.0.6.
562
- */
563
- this.formatDate = function (dateObject, type, withMillis) {
564
- var pad = this.zeroPadding;
565
- var d = this.localDateToUTC(dateObject);
566
- var year = String(d.getFullYear());
567
- if (type == 'utc') year = year.substr(2, 2);
568
- var month = pad(String(d.getMonth() + 1), 2);
569
- var day = pad(String(d.getDate()), 2);
570
- var hour = pad(String(d.getHours()), 2);
571
- var min = pad(String(d.getMinutes()), 2);
572
- var sec = pad(String(d.getSeconds()), 2);
573
- var s = year + month + day + hour + min + sec;
574
- if (withMillis === true) {
575
- var millis = d.getMilliseconds();
576
- if (millis != 0) {
577
- var sMillis = pad(String(millis), 3);
578
- sMillis = sMillis.replace(/[0]+$/, "");
579
- s = s + "." + sMillis;
580
- }
581
- }
582
- return s + "Z";
583
- };
584
- this.zeroPadding = function (s, len) {
585
- if (s.length >= len) return s;
586
- return new Array(len - s.length + 1).join('0') + s;
587
- };
588
- // --- PUBLIC METHODS --------------------
589
- /**
590
- * get string value of this string object
591
- * @name getString
592
- * @memberOf KJUR.asn1.DERAbstractTime#
593
- * @function
594
- * @return {String} string value of this time object
595
- */
596
- this.getString = function () {
597
- return this.s;
598
- };
599
- /**
600
- * set value by a string
601
- * @name setString
602
- * @memberOf KJUR.asn1.DERAbstractTime#
603
- * @function
604
- * @param {String} newS value by a string to set such like "130430235959Z"
605
- */
606
- this.setString = function (newS) {
607
- this.hTLV = null;
608
- this.isModified = true;
609
- this.s = newS;
610
- this.hV = stohex(newS);
611
- };
612
- /**
613
- * set value by a Date object
614
- * @name setByDateValue
615
- * @memberOf KJUR.asn1.DERAbstractTime#
616
- * @function
617
- * @param {Integer} year year of date (ex. 2013)
618
- * @param {Integer} month month of date between 1 and 12 (ex. 12)
619
- * @param {Integer} day day of month
620
- * @param {Integer} hour hours of date
621
- * @param {Integer} min minutes of date
622
- * @param {Integer} sec seconds of date
623
- */
624
- this.setByDateValue = function (year, month, day, hour, min, sec) {
625
- var dateObject = new Date(Date.UTC(year, month - 1, day, hour, min, sec, 0));
626
- this.setByDate(dateObject);
627
- };
628
- this.getFreshValueHex = function () {
629
- return this.hV;
630
- };
631
- };
632
- YAHOO.lang.extend(KJUR.asn1.DERAbstractTime, KJUR.asn1.ASN1Object);
633
- // == END DERAbstractTime ==================================================
634
- // == BEGIN DERAbstractStructured ============================================
635
- /**
636
- * base class for ASN.1 DER structured class
637
- * @name KJUR.asn1.DERAbstractStructured
638
- * @class base class for ASN.1 DER structured class
639
- * @property {Array} asn1Array internal array of ASN1Object
640
- * @extends KJUR.asn1.ASN1Object
641
- * @description
642
- * @see KJUR.asn1.ASN1Object - superclass
643
- */
644
- KJUR.asn1.DERAbstractStructured = function (params) {
645
- KJUR.asn1.DERAbstractString.superclass.constructor.call(this);
646
- /**
647
- * set value by array of ASN1Object
648
- * @name setByASN1ObjectArray
649
- * @memberOf KJUR.asn1.DERAbstractStructured#
650
- * @function
651
- * @param {array} asn1ObjectArray array of ASN1Object to set
652
- */
653
- this.setByASN1ObjectArray = function (asn1ObjectArray) {
654
- this.hTLV = null;
655
- this.isModified = true;
656
- this.asn1Array = asn1ObjectArray;
657
- };
658
- /**
659
- * append an ASN1Object to internal array
660
- * @name appendASN1Object
661
- * @memberOf KJUR.asn1.DERAbstractStructured#
662
- * @function
663
- * @param {ASN1Object} asn1Object to add
664
- */
665
- this.appendASN1Object = function (asn1Object) {
666
- this.hTLV = null;
667
- this.isModified = true;
668
- this.asn1Array.push(asn1Object);
669
- };
670
- this.asn1Array = new Array();
671
- if (typeof params != "undefined") {
672
- if (typeof params['array'] != "undefined") {
673
- this.asn1Array = params['array'];
674
- }
675
- }
676
- };
677
- YAHOO.lang.extend(KJUR.asn1.DERAbstractStructured, KJUR.asn1.ASN1Object);
678
- // ********************************************************************
679
- // ASN.1 Object Classes
680
- // ********************************************************************
681
- // ********************************************************************
682
- /**
683
- * class for ASN.1 DER Boolean
684
- * @name KJUR.asn1.DERBoolean
685
- * @class class for ASN.1 DER Boolean
686
- * @extends KJUR.asn1.ASN1Object
687
- * @description
688
- * @see KJUR.asn1.ASN1Object - superclass
689
- */
690
- KJUR.asn1.DERBoolean = function () {
691
- KJUR.asn1.DERBoolean.superclass.constructor.call(this);
692
- this.hT = "01";
693
- this.hTLV = "0101ff";
694
- };
695
- YAHOO.lang.extend(KJUR.asn1.DERBoolean, KJUR.asn1.ASN1Object);
696
- // ********************************************************************
697
- /**
698
- * class for ASN.1 DER Integer
699
- * @name KJUR.asn1.DERInteger
700
- * @class class for ASN.1 DER Integer
701
- * @extends KJUR.asn1.ASN1Object
702
- * @description
703
- * <br/>
704
- * As for argument 'params' for constructor, you can specify one of
705
- * following properties:
706
- * <ul>
707
- * <li>int - specify initial ASN.1 value(V) by integer value</li>
708
- * <li>bigint - specify initial ASN.1 value(V) by BigInteger object</li>
709
- * <li>hex - specify initial ASN.1 value(V) by a hexadecimal string</li>
710
- * </ul>
711
- * NOTE: 'params' can be omitted.
712
- */
713
- KJUR.asn1.DERInteger = function (params) {
714
- KJUR.asn1.DERInteger.superclass.constructor.call(this);
715
- this.hT = "02";
716
- /**
717
- * set value by Tom Wu's BigInteger object
718
- * @name setByBigInteger
719
- * @memberOf KJUR.asn1.DERInteger#
720
- * @function
721
- * @param {BigInteger} bigIntegerValue to set
722
- */
723
- this.setByBigInteger = function (bigIntegerValue) {
724
- this.hTLV = null;
725
- this.isModified = true;
726
- this.hV = KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(bigIntegerValue);
727
- };
728
- /**
729
- * set value by integer value
730
- * @name setByInteger
731
- * @memberOf KJUR.asn1.DERInteger
732
- * @function
733
- * @param {Integer} integer value to set
734
- */
735
- this.setByInteger = function (intValue) {
736
- var bi = new BigInteger(String(intValue), 10);
737
- this.setByBigInteger(bi);
738
- };
739
- /**
740
- * set value by integer value
741
- * @name setValueHex
742
- * @memberOf KJUR.asn1.DERInteger#
743
- * @function
744
- * @param {String} hexadecimal string of integer value
745
- * @description
746
- * <br/>
747
- * NOTE: Value shall be represented by minimum octet length of
748
- * two's complement representation.
749
- * @example
750
- * new KJUR.asn1.DERInteger(123);
751
- * new KJUR.asn1.DERInteger({'int': 123});
752
- * new KJUR.asn1.DERInteger({'hex': '1fad'});
753
- */
754
- this.setValueHex = function (newHexString) {
755
- this.hV = newHexString;
756
- };
757
- this.getFreshValueHex = function () {
758
- return this.hV;
759
- };
760
- if (typeof params != "undefined") {
761
- if (typeof params['bigint'] != "undefined") {
762
- this.setByBigInteger(params['bigint']);
763
- } else if (typeof params['int'] != "undefined") {
764
- this.setByInteger(params['int']);
765
- } else if (typeof params == "number") {
766
- this.setByInteger(params);
767
- } else if (typeof params['hex'] != "undefined") {
768
- this.setValueHex(params['hex']);
769
- }
770
- }
771
- };
772
- YAHOO.lang.extend(KJUR.asn1.DERInteger, KJUR.asn1.ASN1Object);
773
- // ********************************************************************
774
- /**
775
- * class for ASN.1 DER encoded BitString primitive
776
- * @name KJUR.asn1.DERBitString
777
- * @class class for ASN.1 DER encoded BitString primitive
778
- * @extends KJUR.asn1.ASN1Object
779
- * @description
780
- * <br/>
781
- * As for argument 'params' for constructor, you can specify one of
782
- * following properties:
783
- * <ul>
784
- * <li>bin - specify binary string (ex. '10111')</li>
785
- * <li>array - specify array of boolean (ex. [true,false,true,true])</li>
786
- * <li>hex - specify hexadecimal string of ASN.1 value(V) including unused bits</li>
787
- * <li>obj - specify {@link KJUR.asn1.ASN1Util.newObject}
788
- * argument for "BitString encapsulates" structure.</li>
789
- * </ul>
790
- * NOTE1: 'params' can be omitted.<br/>
791
- * NOTE2: 'obj' parameter have been supported since
792
- * asn1 1.0.11, jsrsasign 6.1.1 (2016-Sep-25).<br/>
793
- * @example
794
- * // default constructor
795
- * o = new KJUR.asn1.DERBitString();
796
- * // initialize with binary string
797
- * o = new KJUR.asn1.DERBitString({bin: "1011"});
798
- * // initialize with boolean array
799
- * o = new KJUR.asn1.DERBitString({array: [true,false,true,true]});
800
- * // initialize with hexadecimal string (04 is unused bits)
801
- * o = new KJUR.asn1.DEROctetString({hex: "04bac0"});
802
- * // initialize with ASN1Util.newObject argument for encapsulated
803
- * o = new KJUR.asn1.DERBitString({obj: {seq: [{int: 3}, {prnstr: 'aaa'}]}});
804
- * // above generates a ASN.1 data like this:
805
- * // BIT STRING, encapsulates {
806
- * // SEQUENCE {
807
- * // INTEGER 3
808
- * // PrintableString 'aaa'
809
- * // }
810
- * // }
811
- */
812
- KJUR.asn1.DERBitString = function (params) {
813
- if (params !== undefined && typeof params.obj !== "undefined") {
814
- var o = KJUR.asn1.ASN1Util.newObject(params.obj);
815
- params.hex = "00" + o.getEncodedHex();
816
- }
817
- KJUR.asn1.DERBitString.superclass.constructor.call(this);
818
- this.hT = "03";
819
- /**
820
- * set ASN.1 value(V) by a hexadecimal string including unused bits
821
- * @name setHexValueIncludingUnusedBits
822
- * @memberOf KJUR.asn1.DERBitString#
823
- * @function
824
- * @param {String} newHexStringIncludingUnusedBits
825
- */
826
- this.setHexValueIncludingUnusedBits = function (newHexStringIncludingUnusedBits) {
827
- this.hTLV = null;
828
- this.isModified = true;
829
- this.hV = newHexStringIncludingUnusedBits;
830
- };
831
- /**
832
- * set ASN.1 value(V) by unused bit and hexadecimal string of value
833
- * @name setUnusedBitsAndHexValue
834
- * @memberOf KJUR.asn1.DERBitString#
835
- * @function
836
- * @param {Integer} unusedBits
837
- * @param {String} hValue
838
- */
839
- this.setUnusedBitsAndHexValue = function (unusedBits, hValue) {
840
- if (unusedBits < 0 || 7 < unusedBits) {
841
- throw "unused bits shall be from 0 to 7: u = " + unusedBits;
842
- }
843
- var hUnusedBits = "0" + unusedBits;
844
- this.hTLV = null;
845
- this.isModified = true;
846
- this.hV = hUnusedBits + hValue;
847
- };
848
- /**
849
- * set ASN.1 DER BitString by binary string<br/>
850
- * @name setByBinaryString
851
- * @memberOf KJUR.asn1.DERBitString#
852
- * @function
853
- * @param {String} binaryString binary value string (i.e. '10111')
854
- * @description
855
- * Its unused bits will be calculated automatically by length of
856
- * 'binaryValue'. <br/>
857
- * NOTE: Trailing zeros '0' will be ignored.
858
- * @example
859
- * o = new KJUR.asn1.DERBitString();
860
- * o.setByBooleanArray("01011");
861
- */
862
- this.setByBinaryString = function (binaryString) {
863
- binaryString = binaryString.replace(/0+$/, '');
864
- var unusedBits = 8 - binaryString.length % 8;
865
- if (unusedBits == 8) unusedBits = 0;
866
- for (var i = 0; i <= unusedBits; i++) {
867
- binaryString += '0';
868
- }
869
- var h = '';
870
- for (var i = 0; i < binaryString.length - 1; i += 8) {
871
- var b = binaryString.substr(i, 8);
872
- var x = parseInt(b, 2).toString(16);
873
- if (x.length == 1) x = '0' + x;
874
- h += x;
875
- }
876
- this.hTLV = null;
877
- this.isModified = true;
878
- this.hV = '0' + unusedBits + h;
879
- };
880
- /**
881
- * set ASN.1 TLV value(V) by an array of boolean<br/>
882
- * @name setByBooleanArray
883
- * @memberOf KJUR.asn1.DERBitString#
884
- * @function
885
- * @param {array} booleanArray array of boolean (ex. [true, false, true])
886
- * @description
887
- * NOTE: Trailing falses will be ignored in the ASN.1 DER Object.
888
- * @example
889
- * o = new KJUR.asn1.DERBitString();
890
- * o.setByBooleanArray([false, true, false, true, true]);
891
- */
892
- this.setByBooleanArray = function (booleanArray) {
893
- var s = '';
894
- for (var i = 0; i < booleanArray.length; i++) {
895
- if (booleanArray[i] == true) {
896
- s += '1';
897
- } else {
898
- s += '0';
899
- }
900
- }
901
- this.setByBinaryString(s);
902
- };
903
- /**
904
- * generate an array of falses with specified length<br/>
905
- * @name newFalseArray
906
- * @memberOf KJUR.asn1.DERBitString
907
- * @function
908
- * @param {Integer} nLength length of array to generate
909
- * @return {array} array of boolean falses
910
- * @description
911
- * This static method may be useful to initialize boolean array.
912
- * @example
913
- * o = new KJUR.asn1.DERBitString();
914
- * o.newFalseArray(3) &rarr; [false, false, false]
915
- */
916
- this.newFalseArray = function (nLength) {
917
- var a = new Array(nLength);
918
- for (var i = 0; i < nLength; i++) {
919
- a[i] = false;
920
- }
921
- return a;
922
- };
923
- this.getFreshValueHex = function () {
924
- return this.hV;
925
- };
926
- if (typeof params != "undefined") {
927
- if (typeof params == "string" && params.toLowerCase().match(/^[0-9a-f]+$/)) {
928
- this.setHexValueIncludingUnusedBits(params);
929
- } else if (typeof params['hex'] != "undefined") {
930
- this.setHexValueIncludingUnusedBits(params['hex']);
931
- } else if (typeof params['bin'] != "undefined") {
932
- this.setByBinaryString(params['bin']);
933
- } else if (typeof params['array'] != "undefined") {
934
- this.setByBooleanArray(params['array']);
935
- }
936
- }
937
- };
938
- YAHOO.lang.extend(KJUR.asn1.DERBitString, KJUR.asn1.ASN1Object);
939
- // ********************************************************************
940
- /**
941
- * class for ASN.1 DER OctetString<br/>
942
- * @name KJUR.asn1.DEROctetString
943
- * @class class for ASN.1 DER OctetString
944
- * @param {Array} params associative array of parameters (ex. {'str': 'aaa'})
945
- * @extends KJUR.asn1.DERAbstractString
946
- * @description
947
- * This class provides ASN.1 OctetString simple type.<br/>
948
- * Supported "params" attributes are:
949
- * <ul>
950
- * <li>str - to set a string as a value</li>
951
- * <li>hex - to set a hexadecimal string as a value</li>
952
- * <li>obj - to set a encapsulated ASN.1 value by JSON object
953
- * which is defined in {@link KJUR.asn1.ASN1Util.newObject}</li>
954
- * </ul>
955
- * NOTE: A parameter 'obj' have been supported
956
- * for "OCTET STRING, encapsulates" structure.
957
- * since asn1 1.0.11, jsrsasign 6.1.1 (2016-Sep-25).
958
- * @see KJUR.asn1.DERAbstractString - superclass
959
- * @example
960
- * // default constructor
961
- * o = new KJUR.asn1.DEROctetString();
962
- * // initialize with string
963
- * o = new KJUR.asn1.DEROctetString({str: "aaa"});
964
- * // initialize with hexadecimal string
965
- * o = new KJUR.asn1.DEROctetString({hex: "616161"});
966
- * // initialize with ASN1Util.newObject argument
967
- * o = new KJUR.asn1.DEROctetString({obj: {seq: [{int: 3}, {prnstr: 'aaa'}]}});
968
- * // above generates a ASN.1 data like this:
969
- * // OCTET STRING, encapsulates {
970
- * // SEQUENCE {
971
- * // INTEGER 3
972
- * // PrintableString 'aaa'
973
- * // }
974
- * // }
975
- */
976
- KJUR.asn1.DEROctetString = function (params) {
977
- if (params !== undefined && typeof params.obj !== "undefined") {
978
- var o = KJUR.asn1.ASN1Util.newObject(params.obj);
979
- params.hex = o.getEncodedHex();
980
- }
981
- KJUR.asn1.DEROctetString.superclass.constructor.call(this, params);
982
- this.hT = "04";
983
- };
984
- YAHOO.lang.extend(KJUR.asn1.DEROctetString, KJUR.asn1.DERAbstractString);
985
- // ********************************************************************
986
- /**
987
- * class for ASN.1 DER Null
988
- * @name KJUR.asn1.DERNull
989
- * @class class for ASN.1 DER Null
990
- * @extends KJUR.asn1.ASN1Object
991
- * @description
992
- * @see KJUR.asn1.ASN1Object - superclass
993
- */
994
- KJUR.asn1.DERNull = function () {
995
- KJUR.asn1.DERNull.superclass.constructor.call(this);
996
- this.hT = "05";
997
- this.hTLV = "0500";
998
- };
999
- YAHOO.lang.extend(KJUR.asn1.DERNull, KJUR.asn1.ASN1Object);
1000
- // ********************************************************************
1001
- /**
1002
- * class for ASN.1 DER ObjectIdentifier
1003
- * @name KJUR.asn1.DERObjectIdentifier
1004
- * @class class for ASN.1 DER ObjectIdentifier
1005
- * @param {Array} params associative array of parameters (ex. {'oid': '2.5.4.5'})
1006
- * @extends KJUR.asn1.ASN1Object
1007
- * @description
1008
- * <br/>
1009
- * As for argument 'params' for constructor, you can specify one of
1010
- * following properties:
1011
- * <ul>
1012
- * <li>oid - specify initial ASN.1 value(V) by a oid string (ex. 2.5.4.13)</li>
1013
- * <li>hex - specify initial ASN.1 value(V) by a hexadecimal string</li>
1014
- * </ul>
1015
- * NOTE: 'params' can be omitted.
1016
- */
1017
- KJUR.asn1.DERObjectIdentifier = function (params) {
1018
- var itox = function (i) {
1019
- var h = i.toString(16);
1020
- if (h.length == 1) h = '0' + h;
1021
- return h;
1022
- };
1023
- var roidtox = function (roid) {
1024
- var h = '';
1025
- var bi = new BigInteger(roid, 10);
1026
- var b = bi.toString(2);
1027
- var padLen = 7 - b.length % 7;
1028
- if (padLen == 7) padLen = 0;
1029
- var bPad = '';
1030
- for (var i = 0; i < padLen; i++) bPad += '0';
1031
- b = bPad + b;
1032
- for (var i = 0; i < b.length - 1; i += 7) {
1033
- var b8 = b.substr(i, 7);
1034
- if (i != b.length - 7) b8 = '1' + b8;
1035
- h += itox(parseInt(b8, 2));
1036
- }
1037
- return h;
1038
- };
1039
- KJUR.asn1.DERObjectIdentifier.superclass.constructor.call(this);
1040
- this.hT = "06";
1041
- /**
1042
- * set value by a hexadecimal string
1043
- * @name setValueHex
1044
- * @memberOf KJUR.asn1.DERObjectIdentifier#
1045
- * @function
1046
- * @param {String} newHexString hexadecimal value of OID bytes
1047
- */
1048
- this.setValueHex = function (newHexString) {
1049
- this.hTLV = null;
1050
- this.isModified = true;
1051
- this.s = null;
1052
- this.hV = newHexString;
1053
- };
1054
- /**
1055
- * set value by a OID string<br/>
1056
- * @name setValueOidString
1057
- * @memberOf KJUR.asn1.DERObjectIdentifier#
1058
- * @function
1059
- * @param {String} oidString OID string (ex. 2.5.4.13)
1060
- * @example
1061
- * o = new KJUR.asn1.DERObjectIdentifier();
1062
- * o.setValueOidString("2.5.4.13");
1063
- */
1064
- this.setValueOidString = function (oidString) {
1065
- if (!oidString.match(/^[0-9.]+$/)) {
1066
- throw "malformed oid string: " + oidString;
1067
- }
1068
- var h = '';
1069
- var a = oidString.split('.');
1070
- var i0 = parseInt(a[0]) * 40 + parseInt(a[1]);
1071
- h += itox(i0);
1072
- a.splice(0, 2);
1073
- for (var i = 0; i < a.length; i++) {
1074
- h += roidtox(a[i]);
1075
- }
1076
- this.hTLV = null;
1077
- this.isModified = true;
1078
- this.s = null;
1079
- this.hV = h;
1080
- };
1081
- /**
1082
- * set value by a OID name
1083
- * @name setValueName
1084
- * @memberOf KJUR.asn1.DERObjectIdentifier#
1085
- * @function
1086
- * @param {String} oidName OID name (ex. 'serverAuth')
1087
- * @since 1.0.1
1088
- * @description
1089
- * OID name shall be defined in 'KJUR.asn1.x509.OID.name2oidList'.
1090
- * Otherwise raise error.
1091
- * @example
1092
- * o = new KJUR.asn1.DERObjectIdentifier();
1093
- * o.setValueName("serverAuth");
1094
- */
1095
- this.setValueName = function (oidName) {
1096
- var oid = KJUR.asn1.x509.OID.name2oid(oidName);
1097
- if (oid !== '') {
1098
- this.setValueOidString(oid);
1099
- } else {
1100
- throw "DERObjectIdentifier oidName undefined: " + oidName;
1101
- }
1102
- };
1103
- this.getFreshValueHex = function () {
1104
- return this.hV;
1105
- };
1106
- if (params !== undefined) {
1107
- if (typeof params === "string") {
1108
- if (params.match(/^[0-2].[0-9.]+$/)) {
1109
- this.setValueOidString(params);
1110
- } else {
1111
- this.setValueName(params);
1112
- }
1113
- } else if (params.oid !== undefined) {
1114
- this.setValueOidString(params.oid);
1115
- } else if (params.hex !== undefined) {
1116
- this.setValueHex(params.hex);
1117
- } else if (params.name !== undefined) {
1118
- this.setValueName(params.name);
1119
- }
1120
- }
1121
- };
1122
- YAHOO.lang.extend(KJUR.asn1.DERObjectIdentifier, KJUR.asn1.ASN1Object);
1123
- // ********************************************************************
1124
- /**
1125
- * class for ASN.1 DER Enumerated
1126
- * @name KJUR.asn1.DEREnumerated
1127
- * @class class for ASN.1 DER Enumerated
1128
- * @extends KJUR.asn1.ASN1Object
1129
- * @description
1130
- * <br/>
1131
- * As for argument 'params' for constructor, you can specify one of
1132
- * following properties:
1133
- * <ul>
1134
- * <li>int - specify initial ASN.1 value(V) by integer value</li>
1135
- * <li>hex - specify initial ASN.1 value(V) by a hexadecimal string</li>
1136
- * </ul>
1137
- * NOTE: 'params' can be omitted.
1138
- * @example
1139
- * new KJUR.asn1.DEREnumerated(123);
1140
- * new KJUR.asn1.DEREnumerated({int: 123});
1141
- * new KJUR.asn1.DEREnumerated({hex: '1fad'});
1142
- */
1143
- KJUR.asn1.DEREnumerated = function (params) {
1144
- KJUR.asn1.DEREnumerated.superclass.constructor.call(this);
1145
- this.hT = "0a";
1146
- /**
1147
- * set value by Tom Wu's BigInteger object
1148
- * @name setByBigInteger
1149
- * @memberOf KJUR.asn1.DEREnumerated#
1150
- * @function
1151
- * @param {BigInteger} bigIntegerValue to set
1152
- */
1153
- this.setByBigInteger = function (bigIntegerValue) {
1154
- this.hTLV = null;
1155
- this.isModified = true;
1156
- this.hV = KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(bigIntegerValue);
1157
- };
1158
- /**
1159
- * set value by integer value
1160
- * @name setByInteger
1161
- * @memberOf KJUR.asn1.DEREnumerated#
1162
- * @function
1163
- * @param {Integer} integer value to set
1164
- */
1165
- this.setByInteger = function (intValue) {
1166
- var bi = new BigInteger(String(intValue), 10);
1167
- this.setByBigInteger(bi);
1168
- };
1169
- /**
1170
- * set value by integer value
1171
- * @name setValueHex
1172
- * @memberOf KJUR.asn1.DEREnumerated#
1173
- * @function
1174
- * @param {String} hexadecimal string of integer value
1175
- * @description
1176
- * <br/>
1177
- * NOTE: Value shall be represented by minimum octet length of
1178
- * two's complement representation.
1179
- */
1180
- this.setValueHex = function (newHexString) {
1181
- this.hV = newHexString;
1182
- };
1183
- this.getFreshValueHex = function () {
1184
- return this.hV;
1185
- };
1186
- if (typeof params != "undefined") {
1187
- if (typeof params['int'] != "undefined") {
1188
- this.setByInteger(params['int']);
1189
- } else if (typeof params == "number") {
1190
- this.setByInteger(params);
1191
- } else if (typeof params['hex'] != "undefined") {
1192
- this.setValueHex(params['hex']);
1193
- }
1194
- }
1195
- };
1196
- YAHOO.lang.extend(KJUR.asn1.DEREnumerated, KJUR.asn1.ASN1Object);
1197
- // ********************************************************************
1198
- /**
1199
- * class for ASN.1 DER UTF8String
1200
- * @name KJUR.asn1.DERUTF8String
1201
- * @class class for ASN.1 DER UTF8String
1202
- * @param {Array} params associative array of parameters (ex. {'str': 'aaa'})
1203
- * @extends KJUR.asn1.DERAbstractString
1204
- * @description
1205
- * @see KJUR.asn1.DERAbstractString - superclass
1206
- */
1207
- KJUR.asn1.DERUTF8String = function (params) {
1208
- KJUR.asn1.DERUTF8String.superclass.constructor.call(this, params);
1209
- this.hT = "0c";
1210
- };
1211
- YAHOO.lang.extend(KJUR.asn1.DERUTF8String, KJUR.asn1.DERAbstractString);
1212
- // ********************************************************************
1213
- /**
1214
- * class for ASN.1 DER NumericString
1215
- * @name KJUR.asn1.DERNumericString
1216
- * @class class for ASN.1 DER NumericString
1217
- * @param {Array} params associative array of parameters (ex. {'str': 'aaa'})
1218
- * @extends KJUR.asn1.DERAbstractString
1219
- * @description
1220
- * @see KJUR.asn1.DERAbstractString - superclass
1221
- */
1222
- KJUR.asn1.DERNumericString = function (params) {
1223
- KJUR.asn1.DERNumericString.superclass.constructor.call(this, params);
1224
- this.hT = "12";
1225
- };
1226
- YAHOO.lang.extend(KJUR.asn1.DERNumericString, KJUR.asn1.DERAbstractString);
1227
- // ********************************************************************
1228
- /**
1229
- * class for ASN.1 DER PrintableString
1230
- * @name KJUR.asn1.DERPrintableString
1231
- * @class class for ASN.1 DER PrintableString
1232
- * @param {Array} params associative array of parameters (ex. {'str': 'aaa'})
1233
- * @extends KJUR.asn1.DERAbstractString
1234
- * @description
1235
- * @see KJUR.asn1.DERAbstractString - superclass
1236
- */
1237
- KJUR.asn1.DERPrintableString = function (params) {
1238
- KJUR.asn1.DERPrintableString.superclass.constructor.call(this, params);
1239
- this.hT = "13";
1240
- };
1241
- YAHOO.lang.extend(KJUR.asn1.DERPrintableString, KJUR.asn1.DERAbstractString);
1242
- // ********************************************************************
1243
- /**
1244
- * class for ASN.1 DER TeletexString
1245
- * @name KJUR.asn1.DERTeletexString
1246
- * @class class for ASN.1 DER TeletexString
1247
- * @param {Array} params associative array of parameters (ex. {'str': 'aaa'})
1248
- * @extends KJUR.asn1.DERAbstractString
1249
- * @description
1250
- * @see KJUR.asn1.DERAbstractString - superclass
1251
- */
1252
- KJUR.asn1.DERTeletexString = function (params) {
1253
- KJUR.asn1.DERTeletexString.superclass.constructor.call(this, params);
1254
- this.hT = "14";
1255
- };
1256
- YAHOO.lang.extend(KJUR.asn1.DERTeletexString, KJUR.asn1.DERAbstractString);
1257
- // ********************************************************************
1258
- /**
1259
- * class for ASN.1 DER IA5String
1260
- * @name KJUR.asn1.DERIA5String
1261
- * @class class for ASN.1 DER IA5String
1262
- * @param {Array} params associative array of parameters (ex. {'str': 'aaa'})
1263
- * @extends KJUR.asn1.DERAbstractString
1264
- * @description
1265
- * @see KJUR.asn1.DERAbstractString - superclass
1266
- */
1267
- KJUR.asn1.DERIA5String = function (params) {
1268
- KJUR.asn1.DERIA5String.superclass.constructor.call(this, params);
1269
- this.hT = "16";
1270
- };
1271
- YAHOO.lang.extend(KJUR.asn1.DERIA5String, KJUR.asn1.DERAbstractString);
1272
- // ********************************************************************
1273
- /**
1274
- * class for ASN.1 DER UTCTime
1275
- * @name KJUR.asn1.DERUTCTime
1276
- * @class class for ASN.1 DER UTCTime
1277
- * @param {Array} params associative array of parameters (ex. {'str': '130430235959Z'})
1278
- * @extends KJUR.asn1.DERAbstractTime
1279
- * @description
1280
- * <br/>
1281
- * As for argument 'params' for constructor, you can specify one of
1282
- * following properties:
1283
- * <ul>
1284
- * <li>str - specify initial ASN.1 value(V) by a string (ex.'130430235959Z')</li>
1285
- * <li>hex - specify initial ASN.1 value(V) by a hexadecimal string</li>
1286
- * <li>date - specify Date object.</li>
1287
- * </ul>
1288
- * NOTE: 'params' can be omitted.
1289
- * <h4>EXAMPLES</h4>
1290
- * @example
1291
- * d1 = new KJUR.asn1.DERUTCTime();
1292
- * d1.setString('130430125959Z');
1293
- *
1294
- * d2 = new KJUR.asn1.DERUTCTime({'str': '130430125959Z'});
1295
- * d3 = new KJUR.asn1.DERUTCTime({'date': new Date(Date.UTC(2015, 0, 31, 0, 0, 0, 0))});
1296
- * d4 = new KJUR.asn1.DERUTCTime('130430125959Z');
1297
- */
1298
- KJUR.asn1.DERUTCTime = function (params) {
1299
- KJUR.asn1.DERUTCTime.superclass.constructor.call(this, params);
1300
- this.hT = "17";
1301
- /**
1302
- * set value by a Date object<br/>
1303
- * @name setByDate
1304
- * @memberOf KJUR.asn1.DERUTCTime#
1305
- * @function
1306
- * @param {Date} dateObject Date object to set ASN.1 value(V)
1307
- * @example
1308
- * o = new KJUR.asn1.DERUTCTime();
1309
- * o.setByDate(new Date("2016/12/31"));
1310
- */
1311
- this.setByDate = function (dateObject) {
1312
- this.hTLV = null;
1313
- this.isModified = true;
1314
- this.date = dateObject;
1315
- this.s = this.formatDate(this.date, 'utc');
1316
- this.hV = stohex(this.s);
1317
- };
1318
- this.getFreshValueHex = function () {
1319
- if (typeof this.date == "undefined" && typeof this.s == "undefined") {
1320
- this.date = new Date();
1321
- this.s = this.formatDate(this.date, 'utc');
1322
- this.hV = stohex(this.s);
1323
- }
1324
- return this.hV;
1325
- };
1326
- if (params !== undefined) {
1327
- if (params.str !== undefined) {
1328
- this.setString(params.str);
1329
- } else if (typeof params == "string" && params.match(/^[0-9]{12}Z$/)) {
1330
- this.setString(params);
1331
- } else if (params.hex !== undefined) {
1332
- this.setStringHex(params.hex);
1333
- } else if (params.date !== undefined) {
1334
- this.setByDate(params.date);
1335
- }
1336
- }
1337
- };
1338
- YAHOO.lang.extend(KJUR.asn1.DERUTCTime, KJUR.asn1.DERAbstractTime);
1339
- // ********************************************************************
1340
- /**
1341
- * class for ASN.1 DER GeneralizedTime
1342
- * @name KJUR.asn1.DERGeneralizedTime
1343
- * @class class for ASN.1 DER GeneralizedTime
1344
- * @param {Array} params associative array of parameters (ex. {'str': '20130430235959Z'})
1345
- * @property {Boolean} withMillis flag to show milliseconds or not
1346
- * @extends KJUR.asn1.DERAbstractTime
1347
- * @description
1348
- * <br/>
1349
- * As for argument 'params' for constructor, you can specify one of
1350
- * following properties:
1351
- * <ul>
1352
- * <li>str - specify initial ASN.1 value(V) by a string (ex.'20130430235959Z')</li>
1353
- * <li>hex - specify initial ASN.1 value(V) by a hexadecimal string</li>
1354
- * <li>date - specify Date object.</li>
1355
- * <li>millis - specify flag to show milliseconds (from 1.0.6)</li>
1356
- * </ul>
1357
- * NOTE1: 'params' can be omitted.
1358
- * NOTE2: 'withMillis' property is supported from asn1 1.0.6.
1359
- */
1360
- KJUR.asn1.DERGeneralizedTime = function (params) {
1361
- KJUR.asn1.DERGeneralizedTime.superclass.constructor.call(this, params);
1362
- this.hT = "18";
1363
- this.withMillis = false;
1364
- /**
1365
- * set value by a Date object
1366
- * @name setByDate
1367
- * @memberOf KJUR.asn1.DERGeneralizedTime#
1368
- * @function
1369
- * @param {Date} dateObject Date object to set ASN.1 value(V)
1370
- * @example
1371
- * When you specify UTC time, use 'Date.UTC' method like this:<br/>
1372
- * o1 = new DERUTCTime();
1373
- * o1.setByDate(date);
1374
- *
1375
- * date = new Date(Date.UTC(2015, 0, 31, 23, 59, 59, 0)); #2015JAN31 23:59:59
1376
- */
1377
- this.setByDate = function (dateObject) {
1378
- this.hTLV = null;
1379
- this.isModified = true;
1380
- this.date = dateObject;
1381
- this.s = this.formatDate(this.date, 'gen', this.withMillis);
1382
- this.hV = stohex(this.s);
1383
- };
1384
- this.getFreshValueHex = function () {
1385
- if (this.date === undefined && this.s === undefined) {
1386
- this.date = new Date();
1387
- this.s = this.formatDate(this.date, 'gen', this.withMillis);
1388
- this.hV = stohex(this.s);
1389
- }
1390
- return this.hV;
1391
- };
1392
- if (params !== undefined) {
1393
- if (params.str !== undefined) {
1394
- this.setString(params.str);
1395
- } else if (typeof params == "string" && params.match(/^[0-9]{14}Z$/)) {
1396
- this.setString(params);
1397
- } else if (params.hex !== undefined) {
1398
- this.setStringHex(params.hex);
1399
- } else if (params.date !== undefined) {
1400
- this.setByDate(params.date);
1401
- }
1402
- if (params.millis === true) {
1403
- this.withMillis = true;
1404
- }
1405
- }
1406
- };
1407
- YAHOO.lang.extend(KJUR.asn1.DERGeneralizedTime, KJUR.asn1.DERAbstractTime);
1408
- // ********************************************************************
1409
- /**
1410
- * class for ASN.1 DER Sequence
1411
- * @name KJUR.asn1.DERSequence
1412
- * @class class for ASN.1 DER Sequence
1413
- * @extends KJUR.asn1.DERAbstractStructured
1414
- * @description
1415
- * <br/>
1416
- * As for argument 'params' for constructor, you can specify one of
1417
- * following properties:
1418
- * <ul>
1419
- * <li>array - specify array of ASN1Object to set elements of content</li>
1420
- * </ul>
1421
- * NOTE: 'params' can be omitted.
1422
- */
1423
- KJUR.asn1.DERSequence = function (params) {
1424
- KJUR.asn1.DERSequence.superclass.constructor.call(this, params);
1425
- this.hT = "30";
1426
- this.getFreshValueHex = function () {
1427
- var h = '';
1428
- for (var i = 0; i < this.asn1Array.length; i++) {
1429
- var asn1Obj = this.asn1Array[i];
1430
- h += asn1Obj.getEncodedHex();
1431
- }
1432
- this.hV = h;
1433
- return this.hV;
1434
- };
1435
- };
1436
- YAHOO.lang.extend(KJUR.asn1.DERSequence, KJUR.asn1.DERAbstractStructured);
1437
- // ********************************************************************
1438
- /**
1439
- * class for ASN.1 DER Set
1440
- * @name KJUR.asn1.DERSet
1441
- * @class class for ASN.1 DER Set
1442
- * @extends KJUR.asn1.DERAbstractStructured
1443
- * @description
1444
- * <br/>
1445
- * As for argument 'params' for constructor, you can specify one of
1446
- * following properties:
1447
- * <ul>
1448
- * <li>array - specify array of ASN1Object to set elements of content</li>
1449
- * <li>sortflag - flag for sort (default: true). ASN.1 BER is not sorted in 'SET OF'.</li>
1450
- * </ul>
1451
- * NOTE1: 'params' can be omitted.<br/>
1452
- * NOTE2: sortflag is supported since 1.0.5.
1453
- */
1454
- KJUR.asn1.DERSet = function (params) {
1455
- KJUR.asn1.DERSet.superclass.constructor.call(this, params);
1456
- this.hT = "31";
1457
- this.sortFlag = true; // item shall be sorted only in ASN.1 DER
1458
- this.getFreshValueHex = function () {
1459
- var a = new Array();
1460
- for (var i = 0; i < this.asn1Array.length; i++) {
1461
- var asn1Obj = this.asn1Array[i];
1462
- a.push(asn1Obj.getEncodedHex());
1463
- }
1464
- if (this.sortFlag == true) a.sort();
1465
- this.hV = a.join('');
1466
- return this.hV;
1467
- };
1468
- if (typeof params != "undefined") {
1469
- if (typeof params.sortflag != "undefined" && params.sortflag == false) this.sortFlag = false;
1470
- }
1471
- };
1472
- YAHOO.lang.extend(KJUR.asn1.DERSet, KJUR.asn1.DERAbstractStructured);
1473
- // ********************************************************************
1474
- /**
1475
- * class for ASN.1 DER TaggedObject
1476
- * @name KJUR.asn1.DERTaggedObject
1477
- * @class class for ASN.1 DER TaggedObject
1478
- * @extends KJUR.asn1.ASN1Object
1479
- * @description
1480
- * <br/>
1481
- * Parameter 'tagNoNex' is ASN.1 tag(T) value for this object.
1482
- * For example, if you find '[1]' tag in a ASN.1 dump,
1483
- * 'tagNoHex' will be 'a1'.
1484
- * <br/>
1485
- * As for optional argument 'params' for constructor, you can specify *ANY* of
1486
- * following properties:
1487
- * <ul>
1488
- * <li>explicit - specify true if this is explicit tag otherwise false
1489
- * (default is 'true').</li>
1490
- * <li>tag - specify tag (default is 'a0' which means [0])</li>
1491
- * <li>obj - specify ASN1Object which is tagged</li>
1492
- * </ul>
1493
- * @example
1494
- * d1 = new KJUR.asn1.DERUTF8String({'str':'a'});
1495
- * d2 = new KJUR.asn1.DERTaggedObject({'obj': d1});
1496
- * hex = d2.getEncodedHex();
1497
- */
1498
- KJUR.asn1.DERTaggedObject = function (params) {
1499
- KJUR.asn1.DERTaggedObject.superclass.constructor.call(this);
1500
- this.hT = "a0";
1501
- this.hV = '';
1502
- this.isExplicit = true;
1503
- this.asn1Object = null;
1504
- /**
1505
- * set value by an ASN1Object
1506
- * @name setString
1507
- * @memberOf KJUR.asn1.DERTaggedObject#
1508
- * @function
1509
- * @param {Boolean} isExplicitFlag flag for explicit/implicit tag
1510
- * @param {Integer} tagNoHex hexadecimal string of ASN.1 tag
1511
- * @param {ASN1Object} asn1Object ASN.1 to encapsulate
1512
- */
1513
- this.setASN1Object = function (isExplicitFlag, tagNoHex, asn1Object) {
1514
- this.hT = tagNoHex;
1515
- this.isExplicit = isExplicitFlag;
1516
- this.asn1Object = asn1Object;
1517
- if (this.isExplicit) {
1518
- this.hV = this.asn1Object.getEncodedHex();
1519
- this.hTLV = null;
1520
- this.isModified = true;
1521
- } else {
1522
- this.hV = null;
1523
- this.hTLV = asn1Object.getEncodedHex();
1524
- this.hTLV = this.hTLV.replace(/^../, tagNoHex);
1525
- this.isModified = false;
1526
- }
1527
- };
1528
- this.getFreshValueHex = function () {
1529
- return this.hV;
1530
- };
1531
- if (typeof params != "undefined") {
1532
- if (typeof params['tag'] != "undefined") {
1533
- this.hT = params['tag'];
1534
- }
1535
- if (typeof params['explicit'] != "undefined") {
1536
- this.isExplicit = params['explicit'];
1537
- }
1538
- if (typeof params['obj'] != "undefined") {
1539
- this.asn1Object = params['obj'];
1540
- this.setASN1Object(this.isExplicit, this.hT, this.asn1Object);
1541
- }
1542
- }
1543
- };
1544
- YAHOO.lang.extend(KJUR.asn1.DERTaggedObject, KJUR.asn1.ASN1Object);
1545
-
1546
- export { KJUR };
1547
- //# sourceMappingURL=asn1-1.0.js.map