pixel-react 1.14.87 → 1.14.89

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