@sswroom/sswr 1.6.3 → 1.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Changelog +20 -0
- package/cert.d.ts +55 -53
- package/cert.js +733 -134
- package/certutil.d.ts +11 -11
- package/certutil.js +11 -6
- package/data.d.ts +29 -1
- package/data.js +152 -24
- package/geometry.d.ts +11 -3
- package/geometry.js +110 -17
- package/hash.js +7 -2
- package/kml.d.ts +1 -1
- package/kml.js +46 -4
- package/leaflet.d.ts +2 -2
- package/leaflet.js +48 -4
- package/map.js +11 -0
- package/math.d.ts +1 -1
- package/math.js +361 -29
- package/media.d.ts +1 -1
- package/media.js +20 -9
- package/package.json +1 -1
- package/parser.js +30 -9
- package/text.d.ts +1 -1
- package/text.js +2 -2
- package/unit.js +746 -663
- package/web.d.ts +3 -0
- package/web.js +138 -15
package/cert.js
CHANGED
|
@@ -68,6 +68,11 @@ export const ContentDataType = {
|
|
|
68
68
|
|
|
69
69
|
export class ASN1Data extends data.ParsedObject
|
|
70
70
|
{
|
|
71
|
+
/**
|
|
72
|
+
* @param {string} sourceName
|
|
73
|
+
* @param {string} objType
|
|
74
|
+
* @param {ArrayBuffer} buff
|
|
75
|
+
*/
|
|
71
76
|
constructor(sourceName, objType, buff)
|
|
72
77
|
{
|
|
73
78
|
super(sourceName, objType);
|
|
@@ -87,6 +92,12 @@ export class ASN1Data extends data.ParsedObject
|
|
|
87
92
|
return this.reader;
|
|
88
93
|
}
|
|
89
94
|
|
|
95
|
+
/**
|
|
96
|
+
* @param {string[]} arr
|
|
97
|
+
* @param {data.ByteReader} reader
|
|
98
|
+
* @param {number} ofst
|
|
99
|
+
* @param {number} len
|
|
100
|
+
*/
|
|
90
101
|
static appendInteger(arr, reader, ofst, len)
|
|
91
102
|
{
|
|
92
103
|
if (len == 1)
|
|
@@ -118,6 +129,11 @@ export class ASN1Data extends data.ParsedObject
|
|
|
118
129
|
|
|
119
130
|
export class X509File extends ASN1Data
|
|
120
131
|
{
|
|
132
|
+
/**
|
|
133
|
+
* @param {any} sourceName
|
|
134
|
+
* @param {any} objType
|
|
135
|
+
* @param {any} buff
|
|
136
|
+
*/
|
|
121
137
|
constructor(sourceName, objType, buff)
|
|
122
138
|
{
|
|
123
139
|
super(sourceName, objType, buff);
|
|
@@ -133,11 +149,17 @@ export class X509File extends ASN1Data
|
|
|
133
149
|
return 0;
|
|
134
150
|
}
|
|
135
151
|
|
|
152
|
+
/**
|
|
153
|
+
* @param {any} index
|
|
154
|
+
*/
|
|
136
155
|
getCertName(index)
|
|
137
156
|
{
|
|
138
157
|
return null;
|
|
139
158
|
}
|
|
140
159
|
|
|
160
|
+
/**
|
|
161
|
+
* @param {any} index
|
|
162
|
+
*/
|
|
141
163
|
getNewCert(index)
|
|
142
164
|
{
|
|
143
165
|
return null;
|
|
@@ -148,11 +170,14 @@ export class X509File extends ASN1Data
|
|
|
148
170
|
return fileTypeGetName(this.getFileType())+": "+this.toShortName();
|
|
149
171
|
}
|
|
150
172
|
|
|
173
|
+
/**
|
|
174
|
+
* @param {X509Key} key
|
|
175
|
+
*/
|
|
151
176
|
isSignatureKey(key)
|
|
152
177
|
{
|
|
153
178
|
let data = ASN1Util.pduGetItem(this.reader, 0, this.reader.getLength(), "1.1");
|
|
154
179
|
let signature = ASN1Util.pduGetItem(this.reader, 0, this.reader.getLength(), "1.3");
|
|
155
|
-
if (data ==
|
|
180
|
+
if (data == null || signature == null || signature.itemType != ASN1ItemType.BIT_STRING)
|
|
156
181
|
{
|
|
157
182
|
return false;
|
|
158
183
|
}
|
|
@@ -191,6 +216,12 @@ export class X509File extends ASN1Data
|
|
|
191
216
|
algType: algType};
|
|
192
217
|
}
|
|
193
218
|
|
|
219
|
+
/**
|
|
220
|
+
* @param {data.ByteReader} reader
|
|
221
|
+
* @param {number} startOfst
|
|
222
|
+
* @param {number} endOfst
|
|
223
|
+
* @param {string | null | undefined} path
|
|
224
|
+
*/
|
|
194
225
|
static isSigned(reader, startOfst, endOfst, path)
|
|
195
226
|
{
|
|
196
227
|
let cnt = ASN1Util.pduCountItem(reader, startOfst, endOfst, path);
|
|
@@ -209,6 +240,14 @@ export class X509File extends ASN1Data
|
|
|
209
240
|
return true;
|
|
210
241
|
}
|
|
211
242
|
|
|
243
|
+
/**
|
|
244
|
+
* @param {data.ByteReader} reader
|
|
245
|
+
* @param {number} startOfst
|
|
246
|
+
* @param {number} endOfst
|
|
247
|
+
* @param {string} path
|
|
248
|
+
* @param {string[]} sb
|
|
249
|
+
* @param {string | null} varName
|
|
250
|
+
*/
|
|
212
251
|
static appendSigned(reader, startOfst, endOfst, path, sb, varName)
|
|
213
252
|
{
|
|
214
253
|
let name;
|
|
@@ -240,6 +279,12 @@ export class X509File extends ASN1Data
|
|
|
240
279
|
}
|
|
241
280
|
}
|
|
242
281
|
|
|
282
|
+
/**
|
|
283
|
+
* @param {data.ByteReader} reader
|
|
284
|
+
* @param {number} startOfst
|
|
285
|
+
* @param {number} endOfst
|
|
286
|
+
* @param {string | null | undefined} path
|
|
287
|
+
*/
|
|
243
288
|
static isTBSCertificate(reader, startOfst, endOfst, path)
|
|
244
289
|
{
|
|
245
290
|
let cnt = ASN1Util.pduCountItem(reader, startOfst, endOfst, path);
|
|
@@ -279,6 +324,14 @@ export class X509File extends ASN1Data
|
|
|
279
324
|
return true;
|
|
280
325
|
}
|
|
281
326
|
|
|
327
|
+
/**
|
|
328
|
+
* @param {data.ByteReader} reader
|
|
329
|
+
* @param {number} startOfst
|
|
330
|
+
* @param {number} endOfst
|
|
331
|
+
* @param {string} path
|
|
332
|
+
* @param {string[]} sb
|
|
333
|
+
* @param {string} varName
|
|
334
|
+
*/
|
|
282
335
|
static appendTBSCertificate(reader, startOfst, endOfst, path, sb, varName)
|
|
283
336
|
{
|
|
284
337
|
let name;
|
|
@@ -392,17 +445,37 @@ export class X509File extends ASN1Data
|
|
|
392
445
|
}
|
|
393
446
|
}
|
|
394
447
|
|
|
448
|
+
/**
|
|
449
|
+
* @param {data.ByteReader} reader
|
|
450
|
+
* @param {number} startOfst
|
|
451
|
+
* @param {number} endOfst
|
|
452
|
+
* @param {string} path
|
|
453
|
+
*/
|
|
395
454
|
static isCertificate(reader, startOfst, endOfst, path)
|
|
396
455
|
{
|
|
397
456
|
return X509File.isSigned(reader, startOfst, endOfst, path) && X509File.isTBSCertificate(reader, startOfst, endOfst, path+".1");
|
|
398
457
|
}
|
|
399
458
|
|
|
459
|
+
/**
|
|
460
|
+
* @param {data.ByteReader} reader
|
|
461
|
+
* @param {number} startOfst
|
|
462
|
+
* @param {number} endOfst
|
|
463
|
+
* @param {string} path
|
|
464
|
+
* @param {any[]} sb
|
|
465
|
+
* @param {string | null} varName
|
|
466
|
+
*/
|
|
400
467
|
static appendCertificate(reader, startOfst, endOfst, path, sb, varName)
|
|
401
468
|
{
|
|
402
469
|
X509File.appendTBSCertificate(reader, startOfst, endOfst, path+".1", sb, varName);
|
|
403
470
|
X509File.appendSigned(reader, startOfst, endOfst, path, sb, varName);
|
|
404
471
|
}
|
|
405
472
|
|
|
473
|
+
/**
|
|
474
|
+
* @param {data.ByteReader} reader
|
|
475
|
+
* @param {number} startOfst
|
|
476
|
+
* @param {number} endOfst
|
|
477
|
+
* @param {string | null | undefined} path
|
|
478
|
+
*/
|
|
406
479
|
static isTBSCertList(reader, startOfst, endOfst, path)
|
|
407
480
|
{
|
|
408
481
|
let cnt = ASN1Util.pduCountItem(reader, startOfst, endOfst, path);
|
|
@@ -443,6 +516,14 @@ export class X509File extends ASN1Data
|
|
|
443
516
|
return true;
|
|
444
517
|
}
|
|
445
518
|
|
|
519
|
+
/**
|
|
520
|
+
* @param {data.ByteReader} reader
|
|
521
|
+
* @param {number} startOfst
|
|
522
|
+
* @param {number} endOfst
|
|
523
|
+
* @param {string} path
|
|
524
|
+
* @param {(string | number)[]} sb
|
|
525
|
+
* @param {string} varName
|
|
526
|
+
*/
|
|
446
527
|
static appendTBSCertList(reader, startOfst, endOfst, path, sb, varName)
|
|
447
528
|
{
|
|
448
529
|
let dt;
|
|
@@ -577,46 +658,64 @@ export class X509File extends ASN1Data
|
|
|
577
658
|
}
|
|
578
659
|
}
|
|
579
660
|
|
|
661
|
+
/**
|
|
662
|
+
* @param {data.ByteReader} reader
|
|
663
|
+
* @param {number} startOfst
|
|
664
|
+
* @param {number} endOfst
|
|
665
|
+
* @param {string} path
|
|
666
|
+
*/
|
|
580
667
|
static isCertificateList(reader, startOfst, endOfst, path)
|
|
581
668
|
{
|
|
582
669
|
return X509File.isSigned(reader, startOfst, endOfst, path) && X509File.isTBSCertList(reader, startOfst, endOfst, path+".1");
|
|
583
670
|
}
|
|
584
671
|
|
|
672
|
+
/**
|
|
673
|
+
* @param {data.ByteReader} reader
|
|
674
|
+
* @param {number} startOfst
|
|
675
|
+
* @param {number} endOfst
|
|
676
|
+
* @param {string} path
|
|
677
|
+
* @param {any[]} sb
|
|
678
|
+
* @param {string} varName
|
|
679
|
+
*/
|
|
585
680
|
static appendCertificateList(reader, startOfst, endOfst, path, sb, varName)
|
|
586
681
|
{
|
|
587
682
|
X509File.appendTBSCertList(reader, startOfst, endOfst, path+".1", sb, varName);
|
|
588
683
|
X509File.appendSigned(reader, startOfst, endOfst, path, sb, varName);
|
|
589
684
|
}
|
|
590
685
|
|
|
591
|
-
|
|
686
|
+
/**
|
|
687
|
+
* @param {data.ByteReader} reader
|
|
688
|
+
* @param {number} startOfst
|
|
689
|
+
* @param {number} endOfst
|
|
690
|
+
* @param {string | null | undefined} path
|
|
691
|
+
*/
|
|
692
|
+
static isPrivateKeyInfo(reader, startOfst, endOfst, path)
|
|
592
693
|
{
|
|
593
|
-
|
|
694
|
+
let cnt = ASN1Util.pduCountItem(reader, startOfst, endOfst, path);
|
|
594
695
|
if (cnt != 3 && cnt != 4)
|
|
595
696
|
{
|
|
596
697
|
return false;
|
|
597
698
|
}
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
Text.StrConcat(sptr, ".1");
|
|
602
|
-
if (ASN1Util.pduGetItemType(pdu, pduEnd, sbuff) != ASN1ItemType.INTEGER)
|
|
699
|
+
let sbuff;
|
|
700
|
+
sbuff = path + ".1";
|
|
701
|
+
if (ASN1Util.pduGetItemType(reader, startOfst, endOfst, sbuff) != ASN1ItemType.INTEGER)
|
|
603
702
|
{
|
|
604
703
|
return false;
|
|
605
704
|
}
|
|
606
|
-
|
|
607
|
-
if (ASN1Util.pduGetItemType(
|
|
705
|
+
sbuff = path + ".2";
|
|
706
|
+
if (ASN1Util.pduGetItemType(reader, startOfst, endOfst, sbuff) != ASN1ItemType.SEQUENCE)
|
|
608
707
|
{
|
|
609
708
|
return false;
|
|
610
709
|
}
|
|
611
|
-
|
|
612
|
-
if (ASN1Util.pduGetItemType(
|
|
710
|
+
sbuff = path + ".3";
|
|
711
|
+
if (ASN1Util.pduGetItemType(reader, startOfst, endOfst, sbuff) != ASN1ItemType.OCTET_STRING)
|
|
613
712
|
{
|
|
614
713
|
return false;
|
|
615
714
|
}
|
|
616
715
|
if (cnt == 4)
|
|
617
716
|
{
|
|
618
|
-
|
|
619
|
-
if (ASN1Util.pduGetItemType(
|
|
717
|
+
sbuff = path + ".4";
|
|
718
|
+
if (ASN1Util.pduGetItemType(reader, startOfst, endOfst, sbuff) != ASN1ItemType.SET)
|
|
620
719
|
{
|
|
621
720
|
return false;
|
|
622
721
|
}
|
|
@@ -624,49 +723,58 @@ export class X509File extends ASN1Data
|
|
|
624
723
|
return true;
|
|
625
724
|
}
|
|
626
725
|
|
|
726
|
+
/**
|
|
727
|
+
* @param {data.ByteReader} reader
|
|
728
|
+
* @param {number} startOfst
|
|
729
|
+
* @param {number} endOfst
|
|
730
|
+
* @param {string} path
|
|
731
|
+
* @param {any[]} sb
|
|
732
|
+
*/
|
|
627
733
|
static appendPrivateKeyInfo(reader, startOfst, endOfst, path, sb)
|
|
628
734
|
{
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
KeyType keyType = KeyType.Unknown;
|
|
635
|
-
sptr = Text.StrConcat(sbuff, path);
|
|
636
|
-
Text.StrConcat(sptr, ".1");
|
|
637
|
-
if ((itemPDU = ASN1Util.pduGetItem(pdu, pduEnd, sbuff, len, itemType)) != 0)
|
|
735
|
+
let sbuff;
|
|
736
|
+
let itemPDU;
|
|
737
|
+
let keyType = KeyType.Unknown;
|
|
738
|
+
sbuff = path + ".1";
|
|
739
|
+
if ((itemPDU = ASN1Util.pduGetItem(reader, startOfst, endOfst, sbuff)) != null)
|
|
638
740
|
{
|
|
639
|
-
if (itemType == ASN1ItemType.INTEGER)
|
|
741
|
+
if (itemPDU.itemType == ASN1ItemType.INTEGER)
|
|
640
742
|
{
|
|
641
|
-
sb.push("version = ")
|
|
642
|
-
|
|
643
|
-
sb.push("\r\n")
|
|
743
|
+
sb.push("version = ");
|
|
744
|
+
X509File.appendVersion(reader, startOfst, endOfst, sbuff, sb);
|
|
745
|
+
sb.push("\r\n");
|
|
644
746
|
}
|
|
645
747
|
}
|
|
646
|
-
|
|
647
|
-
if ((itemPDU = ASN1Util.pduGetItem(
|
|
748
|
+
sbuff = path + ".2";
|
|
749
|
+
if ((itemPDU = ASN1Util.pduGetItem(reader, startOfst, endOfst, sbuff)) != null)
|
|
648
750
|
{
|
|
649
|
-
if (itemType == ASN1ItemType.SEQUENCE)
|
|
751
|
+
if (itemPDU.itemType == ASN1ItemType.SEQUENCE)
|
|
650
752
|
{
|
|
651
|
-
|
|
753
|
+
keyType = X509File.appendAlgorithmIdentifier(reader, itemPDU.dataOfst, itemPDU.endOfst, sb, "privateKeyAlgorithm", false);
|
|
652
754
|
}
|
|
653
755
|
}
|
|
654
|
-
|
|
655
|
-
if ((itemPDU = ASN1Util.pduGetItem(
|
|
756
|
+
sbuff = path + ".3";
|
|
757
|
+
if ((itemPDU = ASN1Util.pduGetItem(reader, startOfst, endOfst, sbuff)) != null)
|
|
656
758
|
{
|
|
657
|
-
if (itemType == ASN1ItemType.OCTET_STRING)
|
|
759
|
+
if (itemPDU.itemType == ASN1ItemType.OCTET_STRING)
|
|
658
760
|
{
|
|
659
|
-
sb.push("privateKey = ")
|
|
660
|
-
sb.push("\r\n")
|
|
761
|
+
sb.push("privateKey = ");
|
|
762
|
+
sb.push("\r\n");
|
|
661
763
|
if (keyType != KeyType.Unknown)
|
|
662
764
|
{
|
|
663
|
-
|
|
664
|
-
privkey.
|
|
765
|
+
let privkey = new X509PrivKey("PrivKey", reader.getU8Arr(itemPDU.dataOfst, itemPDU.contLen));
|
|
766
|
+
sb.push(privkey.toString());
|
|
665
767
|
}
|
|
666
768
|
}
|
|
667
769
|
}
|
|
668
|
-
}
|
|
770
|
+
}
|
|
669
771
|
|
|
772
|
+
/**
|
|
773
|
+
* @param {data.ByteReader} reader
|
|
774
|
+
* @param {number} startOfst
|
|
775
|
+
* @param {number} endOfst
|
|
776
|
+
* @param {string | null | undefined} path
|
|
777
|
+
*/
|
|
670
778
|
static isCertificateRequestInfo(reader, startOfst, endOfst, path)
|
|
671
779
|
{
|
|
672
780
|
let cnt = ASN1Util.pduCountItem(reader, startOfst, endOfst, path);
|
|
@@ -694,6 +802,13 @@ export class X509File extends ASN1Data
|
|
|
694
802
|
return true;
|
|
695
803
|
}
|
|
696
804
|
|
|
805
|
+
/**
|
|
806
|
+
* @param {data.ByteReader} reader
|
|
807
|
+
* @param {number} startOfst
|
|
808
|
+
* @param {number} endOfst
|
|
809
|
+
* @param {string} path
|
|
810
|
+
* @param {string[]} sb
|
|
811
|
+
*/
|
|
697
812
|
static appendCertificateRequestInfo(reader, startOfst, endOfst, path, sb)
|
|
698
813
|
{
|
|
699
814
|
let i = 1;
|
|
@@ -762,17 +877,36 @@ export class X509File extends ASN1Data
|
|
|
762
877
|
}
|
|
763
878
|
}
|
|
764
879
|
|
|
880
|
+
/**
|
|
881
|
+
* @param {data.ByteReader} reader
|
|
882
|
+
* @param {number} startOfst
|
|
883
|
+
* @param {number} endOfst
|
|
884
|
+
* @param {string} path
|
|
885
|
+
*/
|
|
765
886
|
static isCertificateRequest(reader, startOfst, endOfst, path)
|
|
766
887
|
{
|
|
767
888
|
return X509File.isSigned(reader, startOfst, endOfst, path) && X509File.isCertificateRequestInfo(reader, startOfst, endOfst, path+".1");
|
|
768
889
|
}
|
|
769
890
|
|
|
891
|
+
/**
|
|
892
|
+
* @param {data.ByteReader} reader
|
|
893
|
+
* @param {number} startOfst
|
|
894
|
+
* @param {number} endOfst
|
|
895
|
+
* @param {string} path
|
|
896
|
+
* @param {any[]} sb
|
|
897
|
+
*/
|
|
770
898
|
static appendCertificateRequest(reader, startOfst, endOfst, path, sb)
|
|
771
899
|
{
|
|
772
900
|
X509File.appendCertificateRequestInfo(reader, startOfst, endOfst, path+".1", sb);
|
|
773
901
|
X509File.appendSigned(reader, startOfst, endOfst, path, sb, null);
|
|
774
902
|
}
|
|
775
903
|
|
|
904
|
+
/**
|
|
905
|
+
* @param {data.ByteReader} reader
|
|
906
|
+
* @param {number} startOfst
|
|
907
|
+
* @param {number} endOfst
|
|
908
|
+
* @param {string | null | undefined} path
|
|
909
|
+
*/
|
|
776
910
|
static isPublicKeyInfo(reader, startOfst, endOfst, path)
|
|
777
911
|
{
|
|
778
912
|
let cnt = ASN1Util.pduCountItem(reader, startOfst, endOfst, path);
|
|
@@ -791,6 +925,13 @@ export class X509File extends ASN1Data
|
|
|
791
925
|
return true;
|
|
792
926
|
}
|
|
793
927
|
|
|
928
|
+
/**
|
|
929
|
+
* @param {data.ByteReader} reader
|
|
930
|
+
* @param {number} startOfst
|
|
931
|
+
* @param {number} endOfst
|
|
932
|
+
* @param {string} path
|
|
933
|
+
* @param {any[]} sb
|
|
934
|
+
*/
|
|
794
935
|
static appendPublicKeyInfo(reader, startOfst, endOfst, path, sb)
|
|
795
936
|
{
|
|
796
937
|
let buff = ASN1Util.pduGetItem(reader, startOfst, endOfst, path);
|
|
@@ -806,6 +947,12 @@ export class X509File extends ASN1Data
|
|
|
806
947
|
}
|
|
807
948
|
}
|
|
808
949
|
|
|
950
|
+
/**
|
|
951
|
+
* @param {data.ByteReader} reader
|
|
952
|
+
* @param {number} startOfst
|
|
953
|
+
* @param {number} endOfst
|
|
954
|
+
* @param {string | null | undefined} path
|
|
955
|
+
*/
|
|
809
956
|
static isContentInfo(reader, startOfst, endOfst, path)
|
|
810
957
|
{
|
|
811
958
|
if (ASN1Util.pduGetItemType(reader, startOfst, endOfst, path) != ASN1ItemType.SEQUENCE)
|
|
@@ -826,6 +973,15 @@ export class X509File extends ASN1Data
|
|
|
826
973
|
return true;
|
|
827
974
|
}
|
|
828
975
|
|
|
976
|
+
/**
|
|
977
|
+
* @param {data.ByteReader} reader
|
|
978
|
+
* @param {number} startOfst
|
|
979
|
+
* @param {number} endOfst
|
|
980
|
+
* @param {string} path
|
|
981
|
+
* @param {any[]} sb
|
|
982
|
+
* @param {string | null} varName
|
|
983
|
+
* @param {number} dataType
|
|
984
|
+
*/
|
|
829
985
|
static appendContentInfo(reader, startOfst, endOfst, path, sb, varName, dataType)
|
|
830
986
|
{
|
|
831
987
|
let buff = ASN1Util.pduGetItem(reader, startOfst, endOfst, path);
|
|
@@ -884,6 +1040,12 @@ export class X509File extends ASN1Data
|
|
|
884
1040
|
}
|
|
885
1041
|
}
|
|
886
1042
|
|
|
1043
|
+
/**
|
|
1044
|
+
* @param {data.ByteReader} reader
|
|
1045
|
+
* @param {number} startOfst
|
|
1046
|
+
* @param {number} endOfst
|
|
1047
|
+
* @param {string | null | undefined} path
|
|
1048
|
+
*/
|
|
887
1049
|
static isPFX(reader, startOfst, endOfst, path)
|
|
888
1050
|
{
|
|
889
1051
|
if (ASN1Util.pduGetItemType(reader, startOfst, endOfst, path) != ASN1ItemType.SEQUENCE)
|
|
@@ -911,6 +1073,14 @@ export class X509File extends ASN1Data
|
|
|
911
1073
|
return true;
|
|
912
1074
|
}
|
|
913
1075
|
|
|
1076
|
+
/**
|
|
1077
|
+
* @param {data.ByteReader} reader
|
|
1078
|
+
* @param {number} startOfst
|
|
1079
|
+
* @param {number} endOfst
|
|
1080
|
+
* @param {string} path
|
|
1081
|
+
* @param {any[]} sb
|
|
1082
|
+
* @param {string | null} varName
|
|
1083
|
+
*/
|
|
914
1084
|
static appendPFX(reader, startOfst, endOfst, path, sb, varName)
|
|
915
1085
|
{
|
|
916
1086
|
let buff = ASN1Util.pduGetItem(reader, startOfst, endOfst, path);
|
|
@@ -946,6 +1116,13 @@ export class X509File extends ASN1Data
|
|
|
946
1116
|
}
|
|
947
1117
|
}
|
|
948
1118
|
|
|
1119
|
+
/**
|
|
1120
|
+
* @param {data.ByteReader} reader
|
|
1121
|
+
* @param {number} startOfst
|
|
1122
|
+
* @param {number} endOfst
|
|
1123
|
+
* @param {string} path
|
|
1124
|
+
* @param {string[]} sb
|
|
1125
|
+
*/
|
|
949
1126
|
static appendVersion(reader, startOfst, endOfst, path, sb)
|
|
950
1127
|
{
|
|
951
1128
|
let itemPDU = ASN1Util.pduGetItem(reader, startOfst, endOfst, path);
|
|
@@ -969,6 +1146,14 @@ export class X509File extends ASN1Data
|
|
|
969
1146
|
}
|
|
970
1147
|
}
|
|
971
1148
|
|
|
1149
|
+
/**
|
|
1150
|
+
* @param {data.ByteReader} reader
|
|
1151
|
+
* @param {number} startOfst
|
|
1152
|
+
* @param {number} endOfst
|
|
1153
|
+
* @param {string[]} sb
|
|
1154
|
+
* @param {string} varName
|
|
1155
|
+
* @param {boolean} pubKey
|
|
1156
|
+
*/
|
|
972
1157
|
static appendAlgorithmIdentifier(reader, startOfst, endOfst, sb, varName, pubKey)
|
|
973
1158
|
{
|
|
974
1159
|
let itemPDU;
|
|
@@ -1071,6 +1256,13 @@ export class X509File extends ASN1Data
|
|
|
1071
1256
|
return keyType;
|
|
1072
1257
|
}
|
|
1073
1258
|
|
|
1259
|
+
/**
|
|
1260
|
+
* @param {data.ByteReader} reader
|
|
1261
|
+
* @param {number} startOfst
|
|
1262
|
+
* @param {number} endOfst
|
|
1263
|
+
* @param {string[]} sb
|
|
1264
|
+
* @param {string} varName
|
|
1265
|
+
*/
|
|
1074
1266
|
static appendValidity(reader, startOfst, endOfst, sb, varName)
|
|
1075
1267
|
{
|
|
1076
1268
|
let dt;
|
|
@@ -1095,6 +1287,13 @@ export class X509File extends ASN1Data
|
|
|
1095
1287
|
}
|
|
1096
1288
|
}
|
|
1097
1289
|
|
|
1290
|
+
/**
|
|
1291
|
+
* @param {data.ByteReader} reader
|
|
1292
|
+
* @param {number} startOfst
|
|
1293
|
+
* @param {number} endOfst
|
|
1294
|
+
* @param {string[]} sb
|
|
1295
|
+
* @param {string} varName
|
|
1296
|
+
*/
|
|
1098
1297
|
static appendSubjectPublicKeyInfo(reader, startOfst, endOfst, sb, varName)
|
|
1099
1298
|
{
|
|
1100
1299
|
let itemPDU;
|
|
@@ -1124,6 +1323,13 @@ export class X509File extends ASN1Data
|
|
|
1124
1323
|
}
|
|
1125
1324
|
}
|
|
1126
1325
|
|
|
1326
|
+
/**
|
|
1327
|
+
* @param {data.ByteReader} reader
|
|
1328
|
+
* @param {number} startOfst
|
|
1329
|
+
* @param {number} endOfst
|
|
1330
|
+
* @param {any} sb
|
|
1331
|
+
* @param {string} varName
|
|
1332
|
+
*/
|
|
1127
1333
|
static appendName(reader, startOfst, endOfst, sb, varName)
|
|
1128
1334
|
{
|
|
1129
1335
|
let itemPDU;
|
|
@@ -1142,6 +1348,13 @@ export class X509File extends ASN1Data
|
|
|
1142
1348
|
}
|
|
1143
1349
|
}
|
|
1144
1350
|
|
|
1351
|
+
/**
|
|
1352
|
+
* @param {data.ByteReader} reader
|
|
1353
|
+
* @param {number} startOfst
|
|
1354
|
+
* @param {number} endOfst
|
|
1355
|
+
* @param {any} sb
|
|
1356
|
+
* @param {string} varName
|
|
1357
|
+
*/
|
|
1145
1358
|
static appendRelativeDistinguishedName(reader, startOfst, endOfst, sb, varName)
|
|
1146
1359
|
{
|
|
1147
1360
|
let itemPDU;
|
|
@@ -1161,6 +1374,13 @@ export class X509File extends ASN1Data
|
|
|
1161
1374
|
}
|
|
1162
1375
|
}
|
|
1163
1376
|
|
|
1377
|
+
/**
|
|
1378
|
+
* @param {data.ByteReader} reader
|
|
1379
|
+
* @param {number} startOfst
|
|
1380
|
+
* @param {number} endOfst
|
|
1381
|
+
* @param {string[]} sb
|
|
1382
|
+
* @param {string} varName
|
|
1383
|
+
*/
|
|
1164
1384
|
static appendAttributeTypeAndDistinguishedValue(reader, startOfst, endOfst, sb, varName)
|
|
1165
1385
|
{
|
|
1166
1386
|
let typePDU = ASN1Util.pduGetItem(reader, startOfst, endOfst, "1");
|
|
@@ -1238,6 +1458,13 @@ export class X509File extends ASN1Data
|
|
|
1238
1458
|
}
|
|
1239
1459
|
}
|
|
1240
1460
|
|
|
1461
|
+
/**
|
|
1462
|
+
* @param {data.ByteReader} reader
|
|
1463
|
+
* @param {number} startOfst
|
|
1464
|
+
* @param {number} endOfst
|
|
1465
|
+
* @param {any} sb
|
|
1466
|
+
* @param {string} varName
|
|
1467
|
+
*/
|
|
1241
1468
|
static appendCRLExtensions(reader, startOfst, endOfst, sb, varName)
|
|
1242
1469
|
{
|
|
1243
1470
|
let itemPDU;
|
|
@@ -1256,6 +1483,13 @@ export class X509File extends ASN1Data
|
|
|
1256
1483
|
}
|
|
1257
1484
|
}
|
|
1258
1485
|
|
|
1486
|
+
/**
|
|
1487
|
+
* @param {data.ByteReader} reader
|
|
1488
|
+
* @param {number} startOfst
|
|
1489
|
+
* @param {number} endOfst
|
|
1490
|
+
* @param {string[]} sb
|
|
1491
|
+
* @param {string} varName
|
|
1492
|
+
*/
|
|
1259
1493
|
static appendCRLExtension(reader, startOfst, endOfst, sb, varName)
|
|
1260
1494
|
{
|
|
1261
1495
|
let extension;
|
|
@@ -1298,13 +1532,13 @@ export class X509File extends ASN1Data
|
|
|
1298
1532
|
let extOID = reader.getU8Arr(extension.dataOfst, extension.contLen);
|
|
1299
1533
|
if (ASN1Util.oidEqualsText(extOID, "1.3.6.1.5.5.7.1.1")) //id-pe-authorityInfoAccess
|
|
1300
1534
|
{
|
|
1301
|
-
if ((itemPDU = ASN1Util.pduGetItem(itemPDU.dataOfst, itemPDU.endOfst, "1")) != null && itemPDU.itemType == ASN1ItemType.SEQUENCE)
|
|
1535
|
+
if ((itemPDU = ASN1Util.pduGetItem(reader, itemPDU.dataOfst, itemPDU.endOfst, "1")) != null && itemPDU.itemType == ASN1ItemType.SEQUENCE)
|
|
1302
1536
|
{
|
|
1303
1537
|
let i = 1;
|
|
1304
|
-
while ((subItemPDU = ASN1Util.pduGetItem(itemPDU.dataOfst, itemPDU.endOfst, i.toString())) != null && subItemPDU.itemType == ASN1ItemType.SEQUENCE)
|
|
1538
|
+
while ((subItemPDU = ASN1Util.pduGetItem(reader, itemPDU.dataOfst, itemPDU.endOfst, i.toString())) != null && subItemPDU.itemType == ASN1ItemType.SEQUENCE)
|
|
1305
1539
|
{
|
|
1306
1540
|
let descPDU;
|
|
1307
|
-
if ((descPDU = ASN1Util.pduGetItem(subItemPDU.dataOfst, subItemPDU.endOfst, "1")) != null && descPDU.itemType == ASN1ItemType.OID)
|
|
1541
|
+
if ((descPDU = ASN1Util.pduGetItem(reader, subItemPDU.dataOfst, subItemPDU.endOfst, "1")) != null && descPDU.itemType == ASN1ItemType.OID)
|
|
1308
1542
|
{
|
|
1309
1543
|
sb.push(varName);
|
|
1310
1544
|
sb.push(".authorityInfoAccess[");
|
|
@@ -1338,13 +1572,13 @@ export class X509File extends ASN1Data
|
|
|
1338
1572
|
}
|
|
1339
1573
|
else if (ASN1Util.oidEqualsText(extOID, "2.5.29.15")) //id-ce-keyUsage
|
|
1340
1574
|
{
|
|
1341
|
-
if ((subItemPDU = ASN1Util.pduGetItem(itemPDU.dataOfst, itemPDU.endOfst, "1")) != null && subItemPDU.itemType == ASN1ItemType.BIT_STRING)
|
|
1575
|
+
if ((subItemPDU = ASN1Util.pduGetItem(reader, itemPDU.dataOfst, itemPDU.endOfst, "1")) != null && subItemPDU.itemType == ASN1ItemType.BIT_STRING)
|
|
1342
1576
|
{
|
|
1343
1577
|
sb.push(varName);
|
|
1344
1578
|
sb.push(".keyUsage =");
|
|
1345
1579
|
if (subItemPDU.contLen >= 2)
|
|
1346
1580
|
{
|
|
1347
|
-
let v = reader.readUInt8(
|
|
1581
|
+
let v = reader.readUInt8(subItemPDU.dataOfst + 1);
|
|
1348
1582
|
if (v & 0x80) sb.push(" digitalSignature");
|
|
1349
1583
|
if (v & 0x40) sb.push(" nonRepudiation");
|
|
1350
1584
|
if (v & 0x20) sb.push(" keyEncipherment");
|
|
@@ -1356,7 +1590,7 @@ export class X509File extends ASN1Data
|
|
|
1356
1590
|
}
|
|
1357
1591
|
if (subItemPDU.contLen >= 3)
|
|
1358
1592
|
{
|
|
1359
|
-
let v = reader.readUInt8(
|
|
1593
|
+
let v = reader.readUInt8(subItemPDU.dataOfst + 2);
|
|
1360
1594
|
if (v & 0x80) sb.push(" decipherOnly");
|
|
1361
1595
|
}
|
|
1362
1596
|
sb.push("\r\n");
|
|
@@ -1541,86 +1775,107 @@ export class X509File extends ASN1Data
|
|
|
1541
1775
|
}
|
|
1542
1776
|
}
|
|
1543
1777
|
|
|
1544
|
-
|
|
1778
|
+
/**
|
|
1779
|
+
* @param {data.ByteReader} reader
|
|
1780
|
+
* @param {number} startOfst
|
|
1781
|
+
* @param {number} endOfst
|
|
1782
|
+
* @param {string[]} sb
|
|
1783
|
+
* @param {string} varName
|
|
1784
|
+
*/
|
|
1785
|
+
static appendMSOSVersion(reader, startOfst, endOfst, sb, varName)
|
|
1545
1786
|
{
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
const UInt8 *itemPDU = ASN1Util.pduGetItem(pdu, pduEnd, "1", itemLen, itemType);
|
|
1549
|
-
if (itemType == Net.ASN1Util.ItemType.IT_IA5STRING)
|
|
1787
|
+
let itemPDU = ASN1Util.pduGetItem(reader, startOfst, endOfst, "1");
|
|
1788
|
+
if (itemPDU && itemPDU.itemType == ASN1ItemType.IA5STRING)
|
|
1550
1789
|
{
|
|
1551
1790
|
sb.push(varName);
|
|
1552
|
-
sb.push(".version = ")
|
|
1553
|
-
sb
|
|
1554
|
-
sb.push("\r\n")
|
|
1791
|
+
sb.push(".version = ");
|
|
1792
|
+
sb.push(new TextDecoder().decode(reader.getU8Arr(itemPDU.dataOfst, itemPDU.contLen)));
|
|
1793
|
+
sb.push("\r\n");
|
|
1555
1794
|
}
|
|
1556
1795
|
}
|
|
1557
1796
|
|
|
1797
|
+
/**
|
|
1798
|
+
* @param {data.ByteReader} reader
|
|
1799
|
+
* @param {number} startOfst
|
|
1800
|
+
* @param {number} endOfst
|
|
1801
|
+
* @param {string[]} sb
|
|
1802
|
+
* @param {string} varName
|
|
1803
|
+
*/
|
|
1558
1804
|
static appendMSRequestClientInfo(reader, startOfst, endOfst, sb, varName)
|
|
1559
1805
|
{
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
const UInt8 *itemPDU;
|
|
1563
|
-
if ((itemPDU = ASN1Util.pduGetItem(pdu, pduEnd, "1", itemLen, itemType)) != 0 && itemType == Net.ASN1Util.ItemType.IT_SEQUENCE)
|
|
1806
|
+
let itemPDU;
|
|
1807
|
+
if ((itemPDU = ASN1Util.pduGetItem(reader, startOfst, endOfst, "1")) != null && itemPDU.itemType == ASN1ItemType.SEQUENCE)
|
|
1564
1808
|
{
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
if ((subitemPDU = ASN1Util.pduGetItem(itemPDU, itemPDU + itemLen, "1", subitemLen, itemType)) != 0 && itemType == Net.ASN1Util.ItemType.IT_INTEGER)
|
|
1809
|
+
let subitemPDU;
|
|
1810
|
+
if ((subitemPDU = ASN1Util.pduGetItem(reader, itemPDU.dataOfst, itemPDU.endOfst, "1")) != null && subitemPDU.itemType == ASN1ItemType.INTEGER)
|
|
1568
1811
|
{
|
|
1569
1812
|
sb.push(varName);
|
|
1570
|
-
sb.push(".unknown = ")
|
|
1571
|
-
|
|
1572
|
-
sb.push("\r\n")
|
|
1813
|
+
sb.push(".unknown = ");
|
|
1814
|
+
sb.push(ASN1Util.integerToString(reader, subitemPDU.dataOfst, subitemPDU.contLen));
|
|
1815
|
+
sb.push("\r\n");
|
|
1573
1816
|
}
|
|
1574
|
-
if ((subitemPDU = ASN1Util.pduGetItem(itemPDU, itemPDU
|
|
1817
|
+
if ((subitemPDU = ASN1Util.pduGetItem(reader, itemPDU.dataOfst, itemPDU.endOfst, "2")) != null && subitemPDU.itemType == ASN1ItemType.UTF8STRING)
|
|
1575
1818
|
{
|
|
1576
1819
|
sb.push(varName);
|
|
1577
|
-
sb.push(".machine = ")
|
|
1578
|
-
sb
|
|
1579
|
-
sb.push("\r\n")
|
|
1820
|
+
sb.push(".machine = ");
|
|
1821
|
+
sb.push(new TextDecoder().decode(reader.getU8Arr(subitemPDU.dataOfst, subitemPDU.contLen)));
|
|
1822
|
+
sb.push("\r\n");
|
|
1580
1823
|
}
|
|
1581
|
-
if ((subitemPDU = ASN1Util.pduGetItem(itemPDU, itemPDU
|
|
1824
|
+
if ((subitemPDU = ASN1Util.pduGetItem(reader, itemPDU.dataOfst, itemPDU.endOfst, "3")) != null && subitemPDU.itemType == ASN1ItemType.UTF8STRING)
|
|
1582
1825
|
{
|
|
1583
1826
|
sb.push(varName);
|
|
1584
|
-
sb.push(".user = ")
|
|
1585
|
-
sb
|
|
1586
|
-
sb.push("\r\n")
|
|
1827
|
+
sb.push(".user = ");
|
|
1828
|
+
sb.push(new TextDecoder().decode(reader.getU8Arr(subitemPDU.dataOfst, subitemPDU.contLen)));
|
|
1829
|
+
sb.push("\r\n");
|
|
1587
1830
|
}
|
|
1588
|
-
if ((subitemPDU = ASN1Util.pduGetItem(itemPDU, itemPDU
|
|
1831
|
+
if ((subitemPDU = ASN1Util.pduGetItem(reader, itemPDU.dataOfst, itemPDU.endOfst, "4")) != null && subitemPDU.itemType == ASN1ItemType.UTF8STRING)
|
|
1589
1832
|
{
|
|
1590
1833
|
sb.push(varName);
|
|
1591
|
-
sb.push(".software = ")
|
|
1592
|
-
sb
|
|
1593
|
-
sb.push("\r\n")
|
|
1834
|
+
sb.push(".software = ");
|
|
1835
|
+
sb.push(new TextDecoder().decode(reader.getU8Arr(subitemPDU.dataOfst, subitemPDU.contLen)));
|
|
1836
|
+
sb.push("\r\n");
|
|
1594
1837
|
}
|
|
1595
1838
|
}
|
|
1596
1839
|
}
|
|
1597
1840
|
|
|
1841
|
+
/**
|
|
1842
|
+
* @param {data.ByteReader} reader
|
|
1843
|
+
* @param {number} startOfst
|
|
1844
|
+
* @param {number} endOfst
|
|
1845
|
+
* @param {string[]} sb
|
|
1846
|
+
* @param {string} varName
|
|
1847
|
+
*/
|
|
1598
1848
|
static appendMSEnrollmentCSPProvider(reader, startOfst, endOfst, sb, varName)
|
|
1599
1849
|
{
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
const UInt8 *itemPDU;
|
|
1603
|
-
if ((itemPDU = ASN1Util.pduGetItem(pdu, pduEnd, "1", itemLen, itemType)) != 0 && itemType == Net.ASN1Util.ItemType.IT_SEQUENCE)
|
|
1850
|
+
let itemPDU;
|
|
1851
|
+
if ((itemPDU = ASN1Util.pduGetItem(reader, startOfst, endOfst, "1")) != null && itemPDU.itemType == ASN1ItemType.SEQUENCE)
|
|
1604
1852
|
{
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
if ((subitemPDU = ASN1Util.pduGetItem(itemPDU, itemPDU + itemLen, "1", subitemLen, itemType)) != 0 && itemType == Net.ASN1Util.ItemType.IT_INTEGER)
|
|
1853
|
+
let subitemPDU;
|
|
1854
|
+
if ((subitemPDU = ASN1Util.pduGetItem(reader, itemPDU.dataOfst, itemPDU.endOfst, "1")) != null && subitemPDU.itemType == ASN1ItemType.INTEGER)
|
|
1608
1855
|
{
|
|
1609
1856
|
sb.push(varName);
|
|
1610
|
-
sb.push(".unknown = ")
|
|
1611
|
-
|
|
1612
|
-
sb.push("\r\n")
|
|
1857
|
+
sb.push(".unknown = ");
|
|
1858
|
+
sb.push(ASN1Util.integerToString(reader, subitemPDU.dataOfst, subitemPDU.contLen));
|
|
1859
|
+
sb.push("\r\n");
|
|
1613
1860
|
}
|
|
1614
|
-
if ((subitemPDU = ASN1Util.pduGetItem(itemPDU, itemPDU
|
|
1861
|
+
if ((subitemPDU = ASN1Util.pduGetItem(reader, itemPDU.dataOfst, itemPDU.endOfst, "2")) != null && subitemPDU.itemType == ASN1ItemType.BMPSTRING)
|
|
1615
1862
|
{
|
|
1863
|
+
let enc = new text.UTF16BETextBinEnc();
|
|
1616
1864
|
sb.push(varName);
|
|
1617
|
-
sb.push(".provider = ")
|
|
1618
|
-
sb
|
|
1619
|
-
sb.push("\r\n")
|
|
1865
|
+
sb.push(".provider = ");
|
|
1866
|
+
sb.push(enc.encodeBin(reader.getU8Arr(subitemPDU.dataOfst, subitemPDU.contLen)));
|
|
1867
|
+
sb.push("\r\n");
|
|
1620
1868
|
}
|
|
1621
1869
|
}
|
|
1622
|
-
}
|
|
1870
|
+
}
|
|
1623
1871
|
|
|
1872
|
+
/**
|
|
1873
|
+
* @param {data.ByteReader} reader
|
|
1874
|
+
* @param {number} startOfst
|
|
1875
|
+
* @param {number} endOfst
|
|
1876
|
+
* @param {any} sb
|
|
1877
|
+
* @param {string} varName
|
|
1878
|
+
*/
|
|
1624
1879
|
static appendGeneralNames(reader, startOfst, endOfst, sb, varName)
|
|
1625
1880
|
{
|
|
1626
1881
|
let itemPDU;
|
|
@@ -1637,6 +1892,14 @@ export class X509File extends ASN1Data
|
|
|
1637
1892
|
}
|
|
1638
1893
|
}
|
|
1639
1894
|
|
|
1895
|
+
/**
|
|
1896
|
+
* @param {data.ByteReader} reader
|
|
1897
|
+
* @param {number} startOfst
|
|
1898
|
+
* @param {number} endOfst
|
|
1899
|
+
* @param {string} path
|
|
1900
|
+
* @param {string[]} sb
|
|
1901
|
+
* @param {string} varName
|
|
1902
|
+
*/
|
|
1640
1903
|
static appendGeneralName(reader, startOfst, endOfst, path, sb, varName)
|
|
1641
1904
|
{
|
|
1642
1905
|
let subItemPDU;
|
|
@@ -1694,7 +1957,7 @@ export class X509File extends ASN1Data
|
|
|
1694
1957
|
{
|
|
1695
1958
|
sb.push(net.getIPv4Name(reader.readInt32(subItemPDU.dataOfst, false)));
|
|
1696
1959
|
}
|
|
1697
|
-
else if (
|
|
1960
|
+
else if (subItemPDU.contLen == 16)
|
|
1698
1961
|
{
|
|
1699
1962
|
/* Net.SocketUtil.AddressInfo addr;
|
|
1700
1963
|
Net.SocketUtil.SetAddrInfoV6(addr, subItemPDU, 0);
|
|
@@ -1721,6 +1984,14 @@ export class X509File extends ASN1Data
|
|
|
1721
1984
|
return false;
|
|
1722
1985
|
}
|
|
1723
1986
|
|
|
1987
|
+
/**
|
|
1988
|
+
* @param {data.ByteReader} reader
|
|
1989
|
+
* @param {number} startOfst
|
|
1990
|
+
* @param {number} endOfst
|
|
1991
|
+
* @param {string} path
|
|
1992
|
+
* @param {string[]} sb
|
|
1993
|
+
* @param {string} varName
|
|
1994
|
+
*/
|
|
1724
1995
|
static appendDistributionPoint(reader, startOfst, endOfst, path, sb, varName)
|
|
1725
1996
|
{
|
|
1726
1997
|
let itemPDU;
|
|
@@ -1754,7 +2025,7 @@ export class X509File extends ASN1Data
|
|
|
1754
2025
|
if (v & 0x2) sb.push("certificateHold");
|
|
1755
2026
|
if (v & 0x1) sb.push("privilegeWithdrawn");
|
|
1756
2027
|
}
|
|
1757
|
-
if (
|
|
2028
|
+
if (subItemPDU.contLen >= 3)
|
|
1758
2029
|
{
|
|
1759
2030
|
let v = reader.readUInt8(subItemPDU.dataOfst + 2);
|
|
1760
2031
|
if (v & 0x80) sb.push("aACompromise");
|
|
@@ -1774,6 +2045,13 @@ export class X509File extends ASN1Data
|
|
|
1774
2045
|
return false;
|
|
1775
2046
|
}
|
|
1776
2047
|
|
|
2048
|
+
/**
|
|
2049
|
+
* @param {data.ByteReader} reader
|
|
2050
|
+
* @param {number} startOfst
|
|
2051
|
+
* @param {number} endOfst
|
|
2052
|
+
* @param {any} sb
|
|
2053
|
+
* @param {string} varName
|
|
2054
|
+
*/
|
|
1777
2055
|
static appendDistributionPointName(reader, startOfst, endOfst, sb, varName)
|
|
1778
2056
|
{
|
|
1779
2057
|
let i;
|
|
@@ -1795,6 +2073,14 @@ export class X509File extends ASN1Data
|
|
|
1795
2073
|
}
|
|
1796
2074
|
}
|
|
1797
2075
|
|
|
2076
|
+
/**
|
|
2077
|
+
* @param {data.ByteReader} reader
|
|
2078
|
+
* @param {number} startOfst
|
|
2079
|
+
* @param {number} endOfst
|
|
2080
|
+
* @param {string} path
|
|
2081
|
+
* @param {string[]} sb
|
|
2082
|
+
* @param {any} varName
|
|
2083
|
+
*/
|
|
1798
2084
|
static appendPolicyInformation(reader, startOfst, endOfst, path, sb, varName)
|
|
1799
2085
|
{
|
|
1800
2086
|
let itemPDU;
|
|
@@ -1838,7 +2124,7 @@ export class X509File extends ASN1Data
|
|
|
1838
2124
|
sb.push(reader.readUTF8(itemPDU.dataOfst, itemPDU.contLen));
|
|
1839
2125
|
sb.push("\r\n");
|
|
1840
2126
|
}
|
|
1841
|
-
else if (itemType == ASN1ItemType.SEQUENCE)
|
|
2127
|
+
else if (itemPDU.itemType == ASN1ItemType.SEQUENCE)
|
|
1842
2128
|
{
|
|
1843
2129
|
/////////////////////////////////// UserNotice
|
|
1844
2130
|
}
|
|
@@ -1850,6 +2136,13 @@ export class X509File extends ASN1Data
|
|
|
1850
2136
|
return false;
|
|
1851
2137
|
}
|
|
1852
2138
|
|
|
2139
|
+
/**
|
|
2140
|
+
* @param {data.ByteReader} reader
|
|
2141
|
+
* @param {number} startOfst
|
|
2142
|
+
* @param {number} endOfst
|
|
2143
|
+
* @param {string[]} sb
|
|
2144
|
+
* @param {string} varName
|
|
2145
|
+
*/
|
|
1853
2146
|
static appendPKCS7SignedData(reader, startOfst, endOfst, sb, varName)
|
|
1854
2147
|
{
|
|
1855
2148
|
let itemPDU = ASN1Util.pduGetItem(reader, startOfst, endOfst, "1");
|
|
@@ -1872,23 +2165,30 @@ export class X509File extends ASN1Data
|
|
|
1872
2165
|
}
|
|
1873
2166
|
let i = 4;
|
|
1874
2167
|
subItemPDU = ASN1Util.pduGetItem(reader, itemPDU.dataOfst, itemPDU.endOfst, "4");
|
|
1875
|
-
if (subItemPDU !=
|
|
2168
|
+
if (subItemPDU != null && subItemPDU.itemType == ASN1ItemType.CONTEXT_SPECIFIC_0)
|
|
1876
2169
|
{
|
|
1877
2170
|
X509File.appendCertificate(reader, subItemPDU.dataOfst, subItemPDU.endOfst, "1", sb, "signedData.certificates");
|
|
1878
2171
|
subItemPDU = ASN1Util.pduGetItem(reader, itemPDU.dataOfst, itemPDU.endOfst, (++i).toString());
|
|
1879
2172
|
}
|
|
1880
|
-
if (subItemPDU !=
|
|
2173
|
+
if (subItemPDU != null && subItemPDU.itemType == ASN1ItemType.CONTEXT_SPECIFIC_1)
|
|
1881
2174
|
{
|
|
1882
2175
|
//AppendCertificate(subItemPDU, subItemPDU + subItemLen, "1", sb, CSTR("signedData.crls"));
|
|
1883
2176
|
subItemPDU = ASN1Util.pduGetItem(reader, itemPDU.dataOfst, itemPDU.endOfst, (++i).toString());
|
|
1884
2177
|
}
|
|
1885
|
-
if (subItemPDU !=
|
|
2178
|
+
if (subItemPDU != null && subItemPDU.itemType == ASN1ItemType.SET)
|
|
1886
2179
|
{
|
|
1887
2180
|
X509File.appendPKCS7SignerInfos(reader, subItemPDU.dataOfst, subItemPDU.endOfst, sb, "signedData.signerInfos");
|
|
1888
2181
|
}
|
|
1889
2182
|
}
|
|
1890
2183
|
}
|
|
1891
2184
|
|
|
2185
|
+
/**
|
|
2186
|
+
* @param {data.ByteReader} reader
|
|
2187
|
+
* @param {number} startOfst
|
|
2188
|
+
* @param {number} endOfst
|
|
2189
|
+
* @param {any} sb
|
|
2190
|
+
* @param {string} varName
|
|
2191
|
+
*/
|
|
1892
2192
|
static appendPKCS7DigestAlgorithmIdentifiers(reader, startOfst, endOfst, sb, varName)
|
|
1893
2193
|
{
|
|
1894
2194
|
let itemPDU;
|
|
@@ -1906,6 +2206,13 @@ export class X509File extends ASN1Data
|
|
|
1906
2206
|
}
|
|
1907
2207
|
}
|
|
1908
2208
|
|
|
2209
|
+
/**
|
|
2210
|
+
* @param {data.ByteReader} reader
|
|
2211
|
+
* @param {number} startOfst
|
|
2212
|
+
* @param {number} endOfst
|
|
2213
|
+
* @param {any} sb
|
|
2214
|
+
* @param {string} varName
|
|
2215
|
+
*/
|
|
1909
2216
|
static appendPKCS7SignerInfos(reader, startOfst, endOfst, sb, varName)
|
|
1910
2217
|
{
|
|
1911
2218
|
let itemPDU;
|
|
@@ -1924,6 +2231,13 @@ export class X509File extends ASN1Data
|
|
|
1924
2231
|
}
|
|
1925
2232
|
}
|
|
1926
2233
|
|
|
2234
|
+
/**
|
|
2235
|
+
* @param {data.ByteReader} reader
|
|
2236
|
+
* @param {number} startOfst
|
|
2237
|
+
* @param {number} endOfst
|
|
2238
|
+
* @param {string[]} sb
|
|
2239
|
+
* @param {string} varName
|
|
2240
|
+
*/
|
|
1927
2241
|
static appendPKCS7SignerInfo(reader, startOfst, endOfst, sb, varName)
|
|
1928
2242
|
{
|
|
1929
2243
|
let i;
|
|
@@ -1971,6 +2285,13 @@ export class X509File extends ASN1Data
|
|
|
1971
2285
|
}
|
|
1972
2286
|
}
|
|
1973
2287
|
|
|
2288
|
+
/**
|
|
2289
|
+
* @param {data.ByteReader} reader
|
|
2290
|
+
* @param {number} startOfst
|
|
2291
|
+
* @param {number} endOfst
|
|
2292
|
+
* @param {string[]} sb
|
|
2293
|
+
* @param {string} varName
|
|
2294
|
+
*/
|
|
1974
2295
|
static appendIssuerAndSerialNumber(reader, startOfst, endOfst, sb, varName)
|
|
1975
2296
|
{
|
|
1976
2297
|
let itemPDU;
|
|
@@ -1987,6 +2308,13 @@ export class X509File extends ASN1Data
|
|
|
1987
2308
|
}
|
|
1988
2309
|
}
|
|
1989
2310
|
|
|
2311
|
+
/**
|
|
2312
|
+
* @param {data.ByteReader} reader
|
|
2313
|
+
* @param {number} startOfst
|
|
2314
|
+
* @param {number} endOfst
|
|
2315
|
+
* @param {string[]} sb
|
|
2316
|
+
* @param {string} varName
|
|
2317
|
+
*/
|
|
1990
2318
|
static appendPKCS7Attributes(reader, startOfst, endOfst, sb, varName)
|
|
1991
2319
|
{
|
|
1992
2320
|
let itemPDU;
|
|
@@ -2077,6 +2405,14 @@ export class X509File extends ASN1Data
|
|
|
2077
2405
|
}
|
|
2078
2406
|
}
|
|
2079
2407
|
|
|
2408
|
+
/**
|
|
2409
|
+
* @param {data.ByteReader} reader
|
|
2410
|
+
* @param {number} startOfst
|
|
2411
|
+
* @param {number} endOfst
|
|
2412
|
+
* @param {string} path
|
|
2413
|
+
* @param {string[]} sb
|
|
2414
|
+
* @param {string} varName
|
|
2415
|
+
*/
|
|
2080
2416
|
static appendMacData(reader, startOfst, endOfst, path, sb, varName)
|
|
2081
2417
|
{
|
|
2082
2418
|
let itemPDU;
|
|
@@ -2106,6 +2442,13 @@ export class X509File extends ASN1Data
|
|
|
2106
2442
|
return false;
|
|
2107
2443
|
}
|
|
2108
2444
|
|
|
2445
|
+
/**
|
|
2446
|
+
* @param {data.ByteReader} reader
|
|
2447
|
+
* @param {number} startOfst
|
|
2448
|
+
* @param {number} endOfst
|
|
2449
|
+
* @param {string[]} sb
|
|
2450
|
+
* @param {string} varName
|
|
2451
|
+
*/
|
|
2109
2452
|
static appendDigestInfo(reader, startOfst, endOfst, sb, varName)
|
|
2110
2453
|
{
|
|
2111
2454
|
let itemPDU;
|
|
@@ -2122,6 +2465,14 @@ export class X509File extends ASN1Data
|
|
|
2122
2465
|
}
|
|
2123
2466
|
}
|
|
2124
2467
|
|
|
2468
|
+
/**
|
|
2469
|
+
* @param {any} reader
|
|
2470
|
+
* @param {number} startOfst
|
|
2471
|
+
* @param {number} endOfst
|
|
2472
|
+
* @param {any} sb
|
|
2473
|
+
* @param {string} varName
|
|
2474
|
+
* @param {any} dataType
|
|
2475
|
+
*/
|
|
2125
2476
|
static appendData(reader, startOfst, endOfst, sb, varName, dataType)
|
|
2126
2477
|
{
|
|
2127
2478
|
switch (dataType)
|
|
@@ -2135,6 +2486,14 @@ export class X509File extends ASN1Data
|
|
|
2135
2486
|
}
|
|
2136
2487
|
}
|
|
2137
2488
|
|
|
2489
|
+
/**
|
|
2490
|
+
* @param {data.ByteReader} reader
|
|
2491
|
+
* @param {number} startOfst
|
|
2492
|
+
* @param {number} endOfst
|
|
2493
|
+
* @param {string[]} sb
|
|
2494
|
+
* @param {string} varName
|
|
2495
|
+
* @param {any} dataType
|
|
2496
|
+
*/
|
|
2138
2497
|
static appendEncryptedData(reader, startOfst, endOfst, sb, varName, dataType)
|
|
2139
2498
|
{
|
|
2140
2499
|
let itemPDU;
|
|
@@ -2170,6 +2529,13 @@ export class X509File extends ASN1Data
|
|
|
2170
2529
|
}
|
|
2171
2530
|
}
|
|
2172
2531
|
|
|
2532
|
+
/**
|
|
2533
|
+
* @param {data.ByteReader} reader
|
|
2534
|
+
* @param {number} startOfst
|
|
2535
|
+
* @param {number} endOfst
|
|
2536
|
+
* @param {any} sb
|
|
2537
|
+
* @param {string} varName
|
|
2538
|
+
*/
|
|
2173
2539
|
static appendAuthenticatedSafe(reader, startOfst, endOfst, sb, varName)
|
|
2174
2540
|
{
|
|
2175
2541
|
let itemPDU;
|
|
@@ -2187,10 +2553,18 @@ export class X509File extends ASN1Data
|
|
|
2187
2553
|
}
|
|
2188
2554
|
}
|
|
2189
2555
|
|
|
2556
|
+
/**
|
|
2557
|
+
* @param {data.ByteReader} reader
|
|
2558
|
+
* @param {number} startOfst
|
|
2559
|
+
* @param {number} endOfst
|
|
2560
|
+
* @param {string[]} sb
|
|
2561
|
+
* @param {string} varName
|
|
2562
|
+
* @param {any} dataType
|
|
2563
|
+
*/
|
|
2190
2564
|
static appendEncryptedContentInfo(reader, startOfst, endOfst, sb, varName, dataType)
|
|
2191
2565
|
{
|
|
2192
2566
|
let itemPDU;
|
|
2193
|
-
if ((itemPDU = ASN1Util.pduGetItem(reader, startOfst, endOfst, "1")) !=
|
|
2567
|
+
if ((itemPDU = ASN1Util.pduGetItem(reader, startOfst, endOfst, "1")) != null && itemPDU.itemType == ASN1ItemType.OID)
|
|
2194
2568
|
{
|
|
2195
2569
|
sb.push(varName);
|
|
2196
2570
|
sb.push(".contentType = ");
|
|
@@ -2202,7 +2576,7 @@ export class X509File extends ASN1Data
|
|
|
2202
2576
|
}
|
|
2203
2577
|
sb.push("\r\n");
|
|
2204
2578
|
}
|
|
2205
|
-
if ((itemPDU = ASN1Util.pduGetItem(reader, startOfst, endOfst, "2")) !=
|
|
2579
|
+
if ((itemPDU = ASN1Util.pduGetItem(reader, startOfst, endOfst, "2")) != null && itemPDU.itemType == ASN1ItemType.SEQUENCE)
|
|
2206
2580
|
{
|
|
2207
2581
|
let name = "contentEncryptionAlgorithm";
|
|
2208
2582
|
if (varName)
|
|
@@ -2220,6 +2594,12 @@ export class X509File extends ASN1Data
|
|
|
2220
2594
|
}
|
|
2221
2595
|
}
|
|
2222
2596
|
|
|
2597
|
+
/**
|
|
2598
|
+
* @param {data.ByteReader} reader
|
|
2599
|
+
* @param {number} startOfst
|
|
2600
|
+
* @param {number} endOfst
|
|
2601
|
+
* @param {string} oidText
|
|
2602
|
+
*/
|
|
2223
2603
|
static nameGetByOID(reader, startOfst, endOfst, oidText)
|
|
2224
2604
|
{
|
|
2225
2605
|
if (!(reader instanceof data.ByteReader))
|
|
@@ -2260,11 +2640,21 @@ export class X509File extends ASN1Data
|
|
|
2260
2640
|
return null;
|
|
2261
2641
|
}
|
|
2262
2642
|
|
|
2643
|
+
/**
|
|
2644
|
+
* @param {data.ByteReader} reader
|
|
2645
|
+
* @param {number} startOfst
|
|
2646
|
+
* @param {number} endOfst
|
|
2647
|
+
*/
|
|
2263
2648
|
static nameGetCN(reader, startOfst, endOfst)
|
|
2264
2649
|
{
|
|
2265
2650
|
return X509File.nameGetByOID(reader, startOfst, endOfst, "2.5.4.3");
|
|
2266
2651
|
}
|
|
2267
2652
|
|
|
2653
|
+
/**
|
|
2654
|
+
* @param {data.ByteReader} reader
|
|
2655
|
+
* @param {number} startOfst
|
|
2656
|
+
* @param {number} endOfst
|
|
2657
|
+
*/
|
|
2268
2658
|
static namesGet(reader, startOfst, endOfst)
|
|
2269
2659
|
{
|
|
2270
2660
|
let names = {};
|
|
@@ -2281,7 +2671,7 @@ export class X509File extends ASN1Data
|
|
|
2281
2671
|
|
|
2282
2672
|
if ((itemPDU = ASN1Util.pduGetItem(reader, startOfst, endOfst, i.toString()+".1")) != null)
|
|
2283
2673
|
{
|
|
2284
|
-
if (itemType == ASN1ItemType.SEQUENCE)
|
|
2674
|
+
if (itemPDU.itemType == ASN1ItemType.SEQUENCE)
|
|
2285
2675
|
{
|
|
2286
2676
|
oidPDU = ASN1Util.pduGetItem(reader, itemPDU.rawOfst + itemPDU.hdrLen, itemPDU.rawOfst + itemPDU.hdrLen + itemPDU.contLen, "1");
|
|
2287
2677
|
if (oidPDU != null && oidPDU.itemType == ASN1ItemType.OID)
|
|
@@ -2326,6 +2716,11 @@ export class X509File extends ASN1Data
|
|
|
2326
2716
|
return names;
|
|
2327
2717
|
}
|
|
2328
2718
|
|
|
2719
|
+
/**
|
|
2720
|
+
* @param {data.ByteReader} reader
|
|
2721
|
+
* @param {number} startOfst
|
|
2722
|
+
* @param {number} endOfst
|
|
2723
|
+
*/
|
|
2329
2724
|
static extensionsGet(reader, startOfst, endOfst)
|
|
2330
2725
|
{
|
|
2331
2726
|
let ext = {};
|
|
@@ -2358,6 +2753,9 @@ export class X509File extends ASN1Data
|
|
|
2358
2753
|
let oid = new Uint8Array(reader.getArrayBuffer(oidPDU.rawOfst + oidPDU.hdrLen, oidPDU.contLen));
|
|
2359
2754
|
if (ASN1Util.oidEqualsText(oid, "2.5.29.17")) //id-ce-subjectAltName
|
|
2360
2755
|
{
|
|
2756
|
+
/**
|
|
2757
|
+
* @type {any[]}
|
|
2758
|
+
*/
|
|
2361
2759
|
ext.subjectAltName = [];
|
|
2362
2760
|
let j = 0;
|
|
2363
2761
|
let k = ASN1Util.pduCountItem(reader, strPDU.rawOfst + strPDU.hdrLen, strPDU.rawOfst + strPDU.hdrLen + strPDU.contLen, "1");
|
|
@@ -2412,6 +2810,11 @@ export class X509File extends ASN1Data
|
|
|
2412
2810
|
return ext;
|
|
2413
2811
|
}
|
|
2414
2812
|
|
|
2813
|
+
/**
|
|
2814
|
+
* @param {data.ByteReader} reader
|
|
2815
|
+
* @param {number} startOfst
|
|
2816
|
+
* @param {number} endOfst
|
|
2817
|
+
*/
|
|
2415
2818
|
static extensionsGetCRLDistributionPoints(reader, startOfst, endOfst)
|
|
2416
2819
|
{
|
|
2417
2820
|
let ret = [];
|
|
@@ -2461,14 +2864,20 @@ export class X509File extends ASN1Data
|
|
|
2461
2864
|
return ret;
|
|
2462
2865
|
}
|
|
2463
2866
|
|
|
2867
|
+
/**
|
|
2868
|
+
* @param {data.ByteReader} reader
|
|
2869
|
+
* @param {number} startOfst
|
|
2870
|
+
* @param {number} endOfst
|
|
2871
|
+
* @param {any[]} distPoints
|
|
2872
|
+
*/
|
|
2464
2873
|
static distributionPointAdd(reader, startOfst, endOfst, distPoints)
|
|
2465
2874
|
{
|
|
2466
2875
|
let itemPDU;
|
|
2467
2876
|
if ((itemPDU = ASN1Util.pduGetItem(reader, startOfst, endOfst, "1")) != null && itemPDU.itemType == ASN1ItemType.CONTEXT_SPECIFIC_0)
|
|
2468
2877
|
{
|
|
2469
|
-
if ((itemPDU = ASN1Util.pduGetItem(reader
|
|
2878
|
+
if ((itemPDU = ASN1Util.pduGetItem(reader.getU8Arr(itemPDU.rawOfst), itemPDU.hdrLen, itemPDU.rawOfst + itemPDU.hdrLen + itemPDU.contLen, "1")) != null && itemPDU.itemType == ASN1ItemType.CONTEXT_SPECIFIC_0)
|
|
2470
2879
|
{
|
|
2471
|
-
if ((itemPDU = ASN1Util.pduGetItem(reader
|
|
2880
|
+
if ((itemPDU = ASN1Util.pduGetItem(reader.getU8Arr(itemPDU.rawOfst), itemPDU.hdrLen, itemPDU.rawOfst + itemPDU.hdrLen + itemPDU.contLen, "1")) != null && itemPDU.itemType == ASN1ItemType.CHOICE_6)
|
|
2472
2881
|
{
|
|
2473
2882
|
distPoints.push(reader.readUTF8(itemPDU.rawOfst + itemPDU.hdrLen, itemPDU.contLen));
|
|
2474
2883
|
return true;
|
|
@@ -2478,6 +2887,11 @@ export class X509File extends ASN1Data
|
|
|
2478
2887
|
return false;
|
|
2479
2888
|
}
|
|
2480
2889
|
|
|
2890
|
+
/**
|
|
2891
|
+
* @param {data.ByteReader} reader
|
|
2892
|
+
* @param {number} startOfst
|
|
2893
|
+
* @param {number} endOfst
|
|
2894
|
+
*/
|
|
2481
2895
|
static publicKeyGetNew(reader, startOfst, endOfst)
|
|
2482
2896
|
{
|
|
2483
2897
|
let oidPDU = ASN1Util.pduGetItem(reader, startOfst, endOfst, "1.1");
|
|
@@ -2501,6 +2915,12 @@ export class X509File extends ASN1Data
|
|
|
2501
2915
|
return null;
|
|
2502
2916
|
}
|
|
2503
2917
|
|
|
2918
|
+
/**
|
|
2919
|
+
* @param {data.ByteReader} reader
|
|
2920
|
+
* @param {number} startOfst
|
|
2921
|
+
* @param {number} endOfst
|
|
2922
|
+
* @param {number} keyType
|
|
2923
|
+
*/
|
|
2504
2924
|
static keyGetLeng(reader, startOfst, endOfst, keyType)
|
|
2505
2925
|
{
|
|
2506
2926
|
let keyPDU;
|
|
@@ -2548,6 +2968,10 @@ export class X509File extends ASN1Data
|
|
|
2548
2968
|
}
|
|
2549
2969
|
}
|
|
2550
2970
|
|
|
2971
|
+
/**
|
|
2972
|
+
* @param {ArrayBuffer | Iterable<number>} oid
|
|
2973
|
+
* @param {boolean} pubKey
|
|
2974
|
+
*/
|
|
2551
2975
|
static keyTypeFromOID(oid, pubKey)
|
|
2552
2976
|
{
|
|
2553
2977
|
let arr = new Uint8Array(oid);
|
|
@@ -2569,6 +2993,11 @@ export class X509File extends ASN1Data
|
|
|
2569
2993
|
return KeyType.Unknown;
|
|
2570
2994
|
}
|
|
2571
2995
|
|
|
2996
|
+
/**
|
|
2997
|
+
* @param {data.ByteReader} reader
|
|
2998
|
+
* @param {number} startOfst
|
|
2999
|
+
* @param {number} endOfst
|
|
3000
|
+
*/
|
|
2572
3001
|
static algorithmIdentifierGet(reader, startOfst, endOfst)
|
|
2573
3002
|
{
|
|
2574
3003
|
let cnt = ASN1Util.pduCountItem(reader, startOfst, endOfst, null);
|
|
@@ -2627,6 +3056,10 @@ export class X509File extends ASN1Data
|
|
|
2627
3056
|
|
|
2628
3057
|
export class X509Cert extends X509File
|
|
2629
3058
|
{
|
|
3059
|
+
/**
|
|
3060
|
+
* @param {string} sourceName
|
|
3061
|
+
* @param {ArrayBuffer} buff
|
|
3062
|
+
*/
|
|
2630
3063
|
constructor(sourceName, buff)
|
|
2631
3064
|
{
|
|
2632
3065
|
super(sourceName, "application/x-pem-file", buff);
|
|
@@ -2698,6 +3131,9 @@ export class X509Cert extends X509File
|
|
|
2698
3131
|
return 1;
|
|
2699
3132
|
}
|
|
2700
3133
|
|
|
3134
|
+
/**
|
|
3135
|
+
* @param {number} index
|
|
3136
|
+
*/
|
|
2701
3137
|
getCertName(index)
|
|
2702
3138
|
{
|
|
2703
3139
|
if (index != 0)
|
|
@@ -2705,6 +3141,9 @@ export class X509Cert extends X509File
|
|
|
2705
3141
|
return this.getSubjectCN();
|
|
2706
3142
|
}
|
|
2707
3143
|
|
|
3144
|
+
/**
|
|
3145
|
+
* @param {number} index
|
|
3146
|
+
*/
|
|
2708
3147
|
getNewCert(index)
|
|
2709
3148
|
{
|
|
2710
3149
|
if (index != 0)
|
|
@@ -2903,7 +3342,7 @@ export class X509Cert extends X509File
|
|
|
2903
3342
|
{
|
|
2904
3343
|
return null;
|
|
2905
3344
|
}
|
|
2906
|
-
if (pdu.itemType ==
|
|
3345
|
+
if (pdu.itemType == ASN1ItemType.CONTEXT_SPECIFIC_0)
|
|
2907
3346
|
{
|
|
2908
3347
|
pdu = ASN1Util.pduGetItem(this.reader, 0, this.reader.getLength(), "1.1.7");
|
|
2909
3348
|
if (pdu)
|
|
@@ -2972,6 +3411,9 @@ export class X509Cert extends X509File
|
|
|
2972
3411
|
return null;
|
|
2973
3412
|
}
|
|
2974
3413
|
|
|
3414
|
+
/**
|
|
3415
|
+
* @param {string} domain
|
|
3416
|
+
*/
|
|
2975
3417
|
domainValid(domain)
|
|
2976
3418
|
{
|
|
2977
3419
|
let valid = false;
|
|
@@ -3049,7 +3491,7 @@ export class X509Cert extends X509File
|
|
|
3049
3491
|
pdu = ASN1Util.pduGetItem(this.reader, 0, this.reader.getLength(), "1.1.8.1");
|
|
3050
3492
|
if (pdu)
|
|
3051
3493
|
{
|
|
3052
|
-
return X509File.extensionsGetCRLDistributionPoints(reader, pdu.rawOfst + pdu.hdrLen, pdu.rawOfst + pdu.hdrLen + pdu.contLen);
|
|
3494
|
+
return X509File.extensionsGetCRLDistributionPoints(this.reader, pdu.rawOfst + pdu.hdrLen, pdu.rawOfst + pdu.hdrLen + pdu.contLen);
|
|
3053
3495
|
}
|
|
3054
3496
|
}
|
|
3055
3497
|
else
|
|
@@ -3057,7 +3499,7 @@ export class X509Cert extends X509File
|
|
|
3057
3499
|
pdu = ASN1Util.pduGetItem(this.reader, 0, this.reader.getLength(), "1.1.7.1");
|
|
3058
3500
|
if (pdu)
|
|
3059
3501
|
{
|
|
3060
|
-
return X509File.extensionsGetCRLDistributionPoints(reader, pdu.rawOfst + pdu.hdrLen, pdu.rawOfst + pdu.hdrLen + pdu.contLen);
|
|
3502
|
+
return X509File.extensionsGetCRLDistributionPoints(this.reader, pdu.rawOfst + pdu.hdrLen, pdu.rawOfst + pdu.hdrLen + pdu.contLen);
|
|
3061
3503
|
}
|
|
3062
3504
|
}
|
|
3063
3505
|
return [];
|
|
@@ -3118,6 +3560,10 @@ export class X509Cert extends X509File
|
|
|
3118
3560
|
|
|
3119
3561
|
export class X509CertReq extends X509File
|
|
3120
3562
|
{
|
|
3563
|
+
/**
|
|
3564
|
+
* @param {string} sourceName
|
|
3565
|
+
* @param {ArrayBuffer} buff
|
|
3566
|
+
*/
|
|
3121
3567
|
constructor(sourceName, buff)
|
|
3122
3568
|
{
|
|
3123
3569
|
super(sourceName, "application/x-pem-file", buff);
|
|
@@ -3237,6 +3683,11 @@ export class X509CertReq extends X509File
|
|
|
3237
3683
|
|
|
3238
3684
|
export class X509Key extends X509File
|
|
3239
3685
|
{
|
|
3686
|
+
/**
|
|
3687
|
+
* @param {string} sourceName
|
|
3688
|
+
* @param {ArrayBuffer} buff
|
|
3689
|
+
* @param {number} keyType
|
|
3690
|
+
*/
|
|
3240
3691
|
constructor(sourceName, buff, keyType)
|
|
3241
3692
|
{
|
|
3242
3693
|
super(sourceName, "application/x-pem-file", buff);
|
|
@@ -3487,7 +3938,7 @@ export class X509Key extends X509File
|
|
|
3487
3938
|
|
|
3488
3939
|
getRSAPrivateExponent()
|
|
3489
3940
|
{
|
|
3490
|
-
if (this.keyType != KeyType.RSA) return
|
|
3941
|
+
if (this.keyType != KeyType.RSA) return null;
|
|
3491
3942
|
let len = ASN1Util.pduGetItem(this.reader, 0, this.reader.getLength(), "1.4");
|
|
3492
3943
|
if (len)
|
|
3493
3944
|
{
|
|
@@ -3498,7 +3949,7 @@ export class X509Key extends X509File
|
|
|
3498
3949
|
|
|
3499
3950
|
getRSAPrime1()
|
|
3500
3951
|
{
|
|
3501
|
-
if (this.keyType != KeyType.RSA) return
|
|
3952
|
+
if (this.keyType != KeyType.RSA) return null;
|
|
3502
3953
|
let len = ASN1Util.pduGetItem(this.reader, 0, this.reader.getLength(), "1.5");
|
|
3503
3954
|
if (len)
|
|
3504
3955
|
{
|
|
@@ -3509,7 +3960,7 @@ export class X509Key extends X509File
|
|
|
3509
3960
|
|
|
3510
3961
|
getRSAPrime2()
|
|
3511
3962
|
{
|
|
3512
|
-
if (this.keyType != KeyType.RSA) return
|
|
3963
|
+
if (this.keyType != KeyType.RSA) return null;
|
|
3513
3964
|
let len = ASN1Util.pduGetItem(this.reader, 0, this.reader.getLength(), "1.6");
|
|
3514
3965
|
if (len)
|
|
3515
3966
|
{
|
|
@@ -3520,7 +3971,7 @@ export class X509Key extends X509File
|
|
|
3520
3971
|
|
|
3521
3972
|
getRSAExponent1()
|
|
3522
3973
|
{
|
|
3523
|
-
if (this.keyType != KeyType.RSA) return
|
|
3974
|
+
if (this.keyType != KeyType.RSA) return null;
|
|
3524
3975
|
let len = ASN1Util.pduGetItem(this.reader, 0, this.reader.getLength(), "1.7");
|
|
3525
3976
|
if (len)
|
|
3526
3977
|
{
|
|
@@ -3531,7 +3982,7 @@ export class X509Key extends X509File
|
|
|
3531
3982
|
|
|
3532
3983
|
getRSAExponent2()
|
|
3533
3984
|
{
|
|
3534
|
-
if (this.keyType != KeyType.RSA) return
|
|
3985
|
+
if (this.keyType != KeyType.RSA) return null;
|
|
3535
3986
|
let len = ASN1Util.pduGetItem(this.reader, 0, this.reader.getLength(), "1.8");
|
|
3536
3987
|
if (len)
|
|
3537
3988
|
{
|
|
@@ -3542,7 +3993,7 @@ export class X509Key extends X509File
|
|
|
3542
3993
|
|
|
3543
3994
|
getRSACoefficient()
|
|
3544
3995
|
{
|
|
3545
|
-
if (this.keyType != KeyType.RSA) return
|
|
3996
|
+
if (this.keyType != KeyType.RSA) return null;
|
|
3546
3997
|
let len = ASN1Util.pduGetItem(this.reader, 0, this.reader.getLength(), "1.9");
|
|
3547
3998
|
if (len)
|
|
3548
3999
|
{
|
|
@@ -3578,7 +4029,7 @@ export class X509Key extends X509File
|
|
|
3578
4029
|
{
|
|
3579
4030
|
return this.reader.getArrayBuffer(itemPDU.rawOfst + itemPDU.hdrLen + 1, itemPDU.contLen - 1);
|
|
3580
4031
|
}
|
|
3581
|
-
return
|
|
4032
|
+
return null;
|
|
3582
4033
|
}
|
|
3583
4034
|
else if (this.keyType == KeyType.ECDSA)
|
|
3584
4035
|
{
|
|
@@ -3590,7 +4041,7 @@ export class X509Key extends X509File
|
|
|
3590
4041
|
{
|
|
3591
4042
|
return this.reader.getArrayBuffer(itemPDU.rawOfst + itemPDU.hdrLen + 1, itemPDU.contLen - 1);
|
|
3592
4043
|
}
|
|
3593
|
-
return
|
|
4044
|
+
return null;
|
|
3594
4045
|
}
|
|
3595
4046
|
itemPDU = ASN1Util.pduGetItem(this.reader, 0, this.reader.getLength(), "1.4");
|
|
3596
4047
|
if (itemPDU != null && itemPDU.itemType == ASN1ItemType.CONTEXT_SPECIFIC_1)
|
|
@@ -3600,13 +4051,13 @@ export class X509Key extends X509File
|
|
|
3600
4051
|
{
|
|
3601
4052
|
return this.reader.getArrayBuffer(itemPDU.rawOfst + itemPDU.hdrLen + 1, itemPDU.contLen - 1);
|
|
3602
4053
|
}
|
|
3603
|
-
return
|
|
4054
|
+
return null;
|
|
3604
4055
|
}
|
|
3605
|
-
return
|
|
4056
|
+
return null;
|
|
3606
4057
|
}
|
|
3607
4058
|
else
|
|
3608
4059
|
{
|
|
3609
|
-
return
|
|
4060
|
+
return null;
|
|
3610
4061
|
}
|
|
3611
4062
|
}
|
|
3612
4063
|
|
|
@@ -3635,6 +4086,10 @@ export class X509Key extends X509File
|
|
|
3635
4086
|
return ECName.Unknown;
|
|
3636
4087
|
}
|
|
3637
4088
|
|
|
4089
|
+
/**
|
|
4090
|
+
* @param {ArrayBuffer} buff
|
|
4091
|
+
* @param {ArrayBuffer} paramOID
|
|
4092
|
+
*/
|
|
3638
4093
|
static fromECPublicKey(buff, paramOID)
|
|
3639
4094
|
{
|
|
3640
4095
|
let pdu = new ASN1PDUBuilder();
|
|
@@ -3651,6 +4106,10 @@ export class X509Key extends X509File
|
|
|
3651
4106
|
|
|
3652
4107
|
export class X509PrivKey extends X509File
|
|
3653
4108
|
{
|
|
4109
|
+
/**
|
|
4110
|
+
* @param {string} sourceName
|
|
4111
|
+
* @param {ArrayBuffer} buff
|
|
4112
|
+
*/
|
|
3654
4113
|
constructor(sourceName, buff)
|
|
3655
4114
|
{
|
|
3656
4115
|
super(sourceName, "application/x-pem-file", buff);
|
|
@@ -3668,14 +4127,14 @@ export class X509PrivKey extends X509File
|
|
|
3668
4127
|
{
|
|
3669
4128
|
return "";
|
|
3670
4129
|
}
|
|
3671
|
-
let keyType = X509File.keyTypeFromOID(reader.getArrayBuffer(oidPDU.dataOfst, oidPDU.contLen), false);
|
|
4130
|
+
let keyType = X509File.keyTypeFromOID(this.reader.getArrayBuffer(oidPDU.dataOfst, oidPDU.contLen), false);
|
|
3672
4131
|
let keyPDU = ASN1Util.pduGetItem(this.reader, 0, this.reader.getLength(), "1.3");
|
|
3673
4132
|
if (keyPDU && keyPDU.itemType == ASN1ItemType.OCTET_STRING)
|
|
3674
4133
|
{
|
|
3675
4134
|
let sb = [];
|
|
3676
4135
|
sb.push(keyTypeGetName(keyType));
|
|
3677
4136
|
sb.push(' ');
|
|
3678
|
-
sb.push(X509File.keyGetLeng(reader, keyPDU.dataOfst, keyPDU.endOfst, keyType));
|
|
4137
|
+
sb.push(X509File.keyGetLeng(this.reader, keyPDU.dataOfst, keyPDU.endOfst, keyType));
|
|
3679
4138
|
sb.push(" bits");
|
|
3680
4139
|
return sb.join("");
|
|
3681
4140
|
}
|
|
@@ -3735,6 +4194,11 @@ export class X509PrivKey extends X509File
|
|
|
3735
4194
|
return null;
|
|
3736
4195
|
}
|
|
3737
4196
|
|
|
4197
|
+
/**
|
|
4198
|
+
* @param {any} keyType
|
|
4199
|
+
* @param {string | ArrayBuffer} buff
|
|
4200
|
+
* @param {string | null} sourceName
|
|
4201
|
+
*/
|
|
3738
4202
|
static createFromKeyBuff(keyType, buff, sourceName)
|
|
3739
4203
|
{
|
|
3740
4204
|
if (sourceName == null)
|
|
@@ -3754,6 +4218,9 @@ export class X509PrivKey extends X509File
|
|
|
3754
4218
|
return new X509PrivKey(sourceName, keyPDU.getArrayBuffer());
|
|
3755
4219
|
}
|
|
3756
4220
|
|
|
4221
|
+
/**
|
|
4222
|
+
* @param {{ getKeyType: () => any; getECName: () => any; getECPrivate: () => any; getECPublic: () => any; sourceName: any; getASN1Buff: () => { (): any; new (): any; getArrayBuffer: { (): any; new (): any; }; }; }} key
|
|
4223
|
+
*/
|
|
3757
4224
|
static createFromKey(key)
|
|
3758
4225
|
{
|
|
3759
4226
|
if (!(key instanceof X509Key))
|
|
@@ -3776,7 +4243,14 @@ export class X509PrivKey extends X509File
|
|
|
3776
4243
|
keyPDU.beginSequence();
|
|
3777
4244
|
keyPDU.appendInt32(1);
|
|
3778
4245
|
keyBuff = key.getECPrivate();
|
|
3779
|
-
|
|
4246
|
+
if (keyBuff)
|
|
4247
|
+
{
|
|
4248
|
+
keyPDU.appendOctetString(keyBuff);
|
|
4249
|
+
}
|
|
4250
|
+
else
|
|
4251
|
+
{
|
|
4252
|
+
keyPDU.appendOctetString(new Uint8Array().buffer);
|
|
4253
|
+
}
|
|
3780
4254
|
keyBuff = key.getECPublic();
|
|
3781
4255
|
if (keyBuff)
|
|
3782
4256
|
{
|
|
@@ -3802,6 +4276,10 @@ export class X509PrivKey extends X509File
|
|
|
3802
4276
|
|
|
3803
4277
|
export class X509PubKey extends X509File
|
|
3804
4278
|
{
|
|
4279
|
+
/**
|
|
4280
|
+
* @param {string} sourceName
|
|
4281
|
+
* @param {ArrayBuffer} buff
|
|
4282
|
+
*/
|
|
3805
4283
|
constructor(sourceName, buff)
|
|
3806
4284
|
{
|
|
3807
4285
|
super(sourceName, "application/x-pem-file", buff);
|
|
@@ -3819,13 +4297,13 @@ export class X509PubKey extends X509File
|
|
|
3819
4297
|
{
|
|
3820
4298
|
return null;
|
|
3821
4299
|
}
|
|
3822
|
-
let keyType = X509File.keyTypeFromOID(reader.getArrayBuffer(oidPDU.rawOfst + oidPDU.hdrLen, oidPDU.contLen), true);
|
|
4300
|
+
let keyType = X509File.keyTypeFromOID(this.reader.getArrayBuffer(oidPDU.rawOfst + oidPDU.hdrLen, oidPDU.contLen), true);
|
|
3823
4301
|
let keyPDU = ASN1Util.pduGetItem(this.reader, 0, this.reader.getLength(), "1.2");
|
|
3824
4302
|
if (keyPDU && keyPDU.itemType == ASN1ItemType.OCTET_STRING)
|
|
3825
4303
|
{
|
|
3826
4304
|
let sb = [];
|
|
3827
4305
|
sb.push(keyTypeGetName(keyType)+" ");
|
|
3828
|
-
sb.push(keyGetLeng(reader, keyPDU.rawOfst + keyPDU.hdrLen, keyPDU.rawOfst + keyPDU.hdrLen + keyPDU.contLen, keyType));
|
|
4306
|
+
sb.push(X509File.keyGetLeng(this.reader, keyPDU.rawOfst + keyPDU.hdrLen, keyPDU.rawOfst + keyPDU.hdrLen + keyPDU.contLen, keyType));
|
|
3829
4307
|
sb.push(" bits");
|
|
3830
4308
|
return sb.join("");
|
|
3831
4309
|
}
|
|
@@ -3873,6 +4351,11 @@ export class X509PubKey extends X509File
|
|
|
3873
4351
|
return null;
|
|
3874
4352
|
}
|
|
3875
4353
|
|
|
4354
|
+
/**
|
|
4355
|
+
* @param {number} keyType
|
|
4356
|
+
* @param {ArrayBuffer} buff
|
|
4357
|
+
* @param {any} sourceName
|
|
4358
|
+
*/
|
|
3876
4359
|
static createFromKeyBuff(keyType, buff, sourceName)
|
|
3877
4360
|
{
|
|
3878
4361
|
let keyPDU = new ASN1PDUBuilder();
|
|
@@ -3894,14 +4377,21 @@ export class X509PubKey extends X509File
|
|
|
3894
4377
|
return new X509PubKey(sourceName, keyPDU.getArrayBuffer());
|
|
3895
4378
|
}
|
|
3896
4379
|
|
|
4380
|
+
/**
|
|
4381
|
+
* @param {{ getKeyType: () => any; getASN1Buff: () => { (): any; new (): any; getArrayBuffer: { (): any; new (): any; }; }; sourceName: any; }} key
|
|
4382
|
+
*/
|
|
3897
4383
|
static createFromKey(key)
|
|
3898
4384
|
{
|
|
3899
|
-
return createFromKeyBuff(key.getKeyType(), key.getASN1Buff().getArrayBuffer(), key.sourceName);
|
|
4385
|
+
return X509PubKey.createFromKeyBuff(key.getKeyType(), key.getASN1Buff().getArrayBuffer(), key.sourceName);
|
|
3900
4386
|
}
|
|
3901
4387
|
}
|
|
3902
4388
|
|
|
3903
4389
|
export class X509PKCS7 extends X509File
|
|
3904
4390
|
{
|
|
4391
|
+
/**
|
|
4392
|
+
* @param {string} sourceName
|
|
4393
|
+
* @param {ArrayBuffer} buff
|
|
4394
|
+
*/
|
|
3905
4395
|
constructor(sourceName, buff)
|
|
3906
4396
|
{
|
|
3907
4397
|
super(sourceName, "application/x-pem-file", buff);
|
|
@@ -3926,6 +4416,9 @@ export class X509PKCS7 extends X509File
|
|
|
3926
4416
|
return ASN1Util.pduCountItem(this.reader, certListPDU.dataOfst, certListPDU.endOfst, null);
|
|
3927
4417
|
}
|
|
3928
4418
|
|
|
4419
|
+
/**
|
|
4420
|
+
* @param {number} index
|
|
4421
|
+
*/
|
|
3929
4422
|
getCertName(index)
|
|
3930
4423
|
{
|
|
3931
4424
|
let certListPDU = ASN1Util.pduGetItem(this.reader, 0, this.reader.getLength(), "1.2.1.4");
|
|
@@ -3950,6 +4443,9 @@ export class X509PKCS7 extends X509File
|
|
|
3950
4443
|
return null;
|
|
3951
4444
|
}
|
|
3952
4445
|
|
|
4446
|
+
/**
|
|
4447
|
+
* @param {number} index
|
|
4448
|
+
*/
|
|
3953
4449
|
getNewCert(index)
|
|
3954
4450
|
{
|
|
3955
4451
|
let certListPDU = ASN1Util.pduGetItem(this.reader, 0, this.reader.getLength(), "1.2.1.4");
|
|
@@ -3997,7 +4493,7 @@ export class X509PKCS7 extends X509File
|
|
|
3997
4493
|
{
|
|
3998
4494
|
return false;
|
|
3999
4495
|
}
|
|
4000
|
-
return ASN1Util.oidEqualsText(reader.getU8Arr(itemPDU.dataOfst, itemPDU.contLen), "1.2.840.113549.1.7.2");
|
|
4496
|
+
return ASN1Util.oidEqualsText(this.reader.getU8Arr(itemPDU.dataOfst, itemPDU.contLen), "1.2.840.113549.1.7.2");
|
|
4001
4497
|
}
|
|
4002
4498
|
|
|
4003
4499
|
getDigestType()
|
|
@@ -4053,6 +4549,10 @@ export class X509PKCS7 extends X509File
|
|
|
4053
4549
|
|
|
4054
4550
|
export class X509PKCS12 extends X509File
|
|
4055
4551
|
{
|
|
4552
|
+
/**
|
|
4553
|
+
* @param {string} sourceName
|
|
4554
|
+
* @param {ArrayBuffer} buff
|
|
4555
|
+
*/
|
|
4056
4556
|
constructor(sourceName, buff)
|
|
4057
4557
|
{
|
|
4058
4558
|
super(sourceName, "application/x-pem-file", buff);
|
|
@@ -4072,11 +4572,17 @@ export class X509PKCS12 extends X509File
|
|
|
4072
4572
|
return 0;
|
|
4073
4573
|
}
|
|
4074
4574
|
|
|
4575
|
+
/**
|
|
4576
|
+
* @param {any} index
|
|
4577
|
+
*/
|
|
4075
4578
|
getCertName(index)
|
|
4076
4579
|
{
|
|
4077
4580
|
return null;
|
|
4078
4581
|
}
|
|
4079
4582
|
|
|
4583
|
+
/**
|
|
4584
|
+
* @param {any} index
|
|
4585
|
+
*/
|
|
4080
4586
|
getNewCert(index)
|
|
4081
4587
|
{
|
|
4082
4588
|
return null;
|
|
@@ -4110,6 +4616,10 @@ export class X509PKCS12 extends X509File
|
|
|
4110
4616
|
|
|
4111
4617
|
export class X509FileList extends X509File
|
|
4112
4618
|
{
|
|
4619
|
+
/**
|
|
4620
|
+
* @param {string} sourceName
|
|
4621
|
+
* @param {{ reader: { getArrayBuffer: () => any; }; }} cert
|
|
4622
|
+
*/
|
|
4113
4623
|
constructor(sourceName, cert)
|
|
4114
4624
|
{
|
|
4115
4625
|
super(sourceName, "application/x-pem-file", cert.reader.getArrayBuffer());
|
|
@@ -4137,6 +4647,9 @@ export class X509FileList extends X509File
|
|
|
4137
4647
|
return ret;
|
|
4138
4648
|
}
|
|
4139
4649
|
|
|
4650
|
+
/**
|
|
4651
|
+
* @param {number} index
|
|
4652
|
+
*/
|
|
4140
4653
|
getCertName(index)
|
|
4141
4654
|
{
|
|
4142
4655
|
let i;
|
|
@@ -4155,6 +4668,9 @@ export class X509FileList extends X509File
|
|
|
4155
4668
|
return null;
|
|
4156
4669
|
}
|
|
4157
4670
|
|
|
4671
|
+
/**
|
|
4672
|
+
* @param {number} index
|
|
4673
|
+
*/
|
|
4158
4674
|
getNewCert(index)
|
|
4159
4675
|
{
|
|
4160
4676
|
let i;
|
|
@@ -4193,7 +4709,7 @@ export class X509FileList extends X509File
|
|
|
4193
4709
|
}
|
|
4194
4710
|
else
|
|
4195
4711
|
{
|
|
4196
|
-
return this.fileList[0]
|
|
4712
|
+
return this.fileList[0].isValid();
|
|
4197
4713
|
}
|
|
4198
4714
|
}
|
|
4199
4715
|
|
|
@@ -4231,6 +4747,9 @@ export class X509FileList extends X509File
|
|
|
4231
4747
|
return this.fileList[0].createNames();
|
|
4232
4748
|
}
|
|
4233
4749
|
|
|
4750
|
+
/**
|
|
4751
|
+
* @param {any} file
|
|
4752
|
+
*/
|
|
4234
4753
|
addFile(file)
|
|
4235
4754
|
{
|
|
4236
4755
|
this.fileList.push(file);
|
|
@@ -4241,6 +4760,9 @@ export class X509FileList extends X509File
|
|
|
4241
4760
|
return this.fileList.length;
|
|
4242
4761
|
}
|
|
4243
4762
|
|
|
4763
|
+
/**
|
|
4764
|
+
* @param {string | number} index
|
|
4765
|
+
*/
|
|
4244
4766
|
getFile(index)
|
|
4245
4767
|
{
|
|
4246
4768
|
return this.fileList[index];
|
|
@@ -4249,7 +4771,7 @@ export class X509FileList extends X509File
|
|
|
4249
4771
|
setDefaultSourceName()
|
|
4250
4772
|
{
|
|
4251
4773
|
let file;
|
|
4252
|
-
let j =
|
|
4774
|
+
let j = -1;
|
|
4253
4775
|
let i = this.fileList.length;
|
|
4254
4776
|
while (i-- > 0)
|
|
4255
4777
|
{
|
|
@@ -4259,7 +4781,7 @@ export class X509FileList extends X509File
|
|
|
4259
4781
|
j = i;
|
|
4260
4782
|
}
|
|
4261
4783
|
}
|
|
4262
|
-
if (j !=
|
|
4784
|
+
if (j != -1)
|
|
4263
4785
|
{
|
|
4264
4786
|
this.setSourceName(this.fileList[j].sourceName);
|
|
4265
4787
|
}
|
|
@@ -4268,6 +4790,10 @@ export class X509FileList extends X509File
|
|
|
4268
4790
|
|
|
4269
4791
|
export class X509CRL extends X509File
|
|
4270
4792
|
{
|
|
4793
|
+
/**
|
|
4794
|
+
* @param {string} sourceName
|
|
4795
|
+
* @param {ArrayBuffer} buff
|
|
4796
|
+
*/
|
|
4271
4797
|
constructor(sourceName, buff)
|
|
4272
4798
|
{
|
|
4273
4799
|
super(sourceName, "application/x-pem-file", buff);
|
|
@@ -4283,14 +4809,14 @@ export class X509CRL extends X509File
|
|
|
4283
4809
|
let tmpBuff = ASN1Util.pduGetItem(this.reader, 0, this.reader.getLength(), "1.1.3");
|
|
4284
4810
|
if (tmpBuff != null && tmpBuff.itemType == ASN1ItemType.SEQUENCE)
|
|
4285
4811
|
{
|
|
4286
|
-
return X509File.nameGetCN(reader, tmpBuff.dataOfst, tmpBuff.endOfst);
|
|
4812
|
+
return X509File.nameGetCN(this.reader, tmpBuff.dataOfst, tmpBuff.endOfst);
|
|
4287
4813
|
}
|
|
4288
4814
|
else
|
|
4289
4815
|
{
|
|
4290
4816
|
tmpBuff = ASN1Util.pduGetItem(this.reader, 0, this.reader.getLength(), "1.1.2");
|
|
4291
4817
|
if (tmpBuff != null && tmpBuff.itemType == ASN1ItemType.SEQUENCE)
|
|
4292
4818
|
{
|
|
4293
|
-
return X509File.nameGetCN(reader, tmpBuff.dataOfst, tmpBuff.endOfst);
|
|
4819
|
+
return X509File.nameGetCN(this.reader, tmpBuff.dataOfst, tmpBuff.endOfst);
|
|
4294
4820
|
}
|
|
4295
4821
|
}
|
|
4296
4822
|
return "";
|
|
@@ -4372,7 +4898,7 @@ export class X509CRL extends X509File
|
|
|
4372
4898
|
hasVersion()
|
|
4373
4899
|
{
|
|
4374
4900
|
let itemPDU;
|
|
4375
|
-
if ((itemPDU = ASN1Util.pduGetItem(this.reader, 0, this.reader.getLength(), "1.1.1") != null
|
|
4901
|
+
if ((itemPDU = ASN1Util.pduGetItem(this.reader, 0, this.reader.getLength(), "1.1.1")) != null && itemPDU.itemType == ASN1ItemType.INTEGER)
|
|
4376
4902
|
{
|
|
4377
4903
|
return true;
|
|
4378
4904
|
}
|
|
@@ -4392,7 +4918,7 @@ export class X509CRL extends X509File
|
|
|
4392
4918
|
}
|
|
4393
4919
|
if (tmpBuff != null && tmpBuff.itemType == ASN1ItemType.SEQUENCE)
|
|
4394
4920
|
{
|
|
4395
|
-
return X509File.nameGetCN(reader, tmpBuff.dataOfst, tmpBuff.endOfst);
|
|
4921
|
+
return X509File.nameGetCN(this.reader, tmpBuff.dataOfst, tmpBuff.endOfst);
|
|
4396
4922
|
}
|
|
4397
4923
|
else
|
|
4398
4924
|
{
|
|
@@ -4413,7 +4939,7 @@ export class X509CRL extends X509File
|
|
|
4413
4939
|
}
|
|
4414
4940
|
if (itemPDU != null && (itemPDU.itemType == ASN1ItemType.UTCTIME || itemPDU.itemType == ASN1ItemType.GENERALIZEDTIME))
|
|
4415
4941
|
{
|
|
4416
|
-
return ASN1Util.pduParseUTCTimeCont(reader, itemPDU.dataOfst, itemPDU.endOfst);
|
|
4942
|
+
return ASN1Util.pduParseUTCTimeCont(this.reader, itemPDU.dataOfst, itemPDU.endOfst);
|
|
4417
4943
|
}
|
|
4418
4944
|
else
|
|
4419
4945
|
{
|
|
@@ -4434,7 +4960,7 @@ export class X509CRL extends X509File
|
|
|
4434
4960
|
}
|
|
4435
4961
|
if (itemPDU != null && (itemPDU.itemType == ASN1ItemType.UTCTIME || itemPDU.itemType == ASN1ItemType.GENERALIZEDTIME))
|
|
4436
4962
|
{
|
|
4437
|
-
return ASN1Util.pduParseUTCTimeCont(reader, itemPDU.dataOfst, itemPDU.endOfst);
|
|
4963
|
+
return ASN1Util.pduParseUTCTimeCont(this.reader, itemPDU.dataOfst, itemPDU.endOfst);
|
|
4438
4964
|
}
|
|
4439
4965
|
else
|
|
4440
4966
|
{
|
|
@@ -4442,6 +4968,9 @@ export class X509CRL extends X509File
|
|
|
4442
4968
|
}
|
|
4443
4969
|
}
|
|
4444
4970
|
|
|
4971
|
+
/**
|
|
4972
|
+
* @param {{ getSerialNumber: () => any; }} cert
|
|
4973
|
+
*/
|
|
4445
4974
|
isRevoked(cert)
|
|
4446
4975
|
{
|
|
4447
4976
|
let sn = cert.getSerialNumber();
|
|
@@ -4476,10 +5005,10 @@ export class X509CRL extends X509File
|
|
|
4476
5005
|
while (true)
|
|
4477
5006
|
{
|
|
4478
5007
|
let subitemPDU;
|
|
4479
|
-
subitemPDU = ASN1Util.pduGetItem(reader, itemPDU.dataOfst, itemPDU.endOfst, (++i)+".1");
|
|
5008
|
+
subitemPDU = ASN1Util.pduGetItem(this.reader, itemPDU.dataOfst, itemPDU.endOfst, (++i)+".1");
|
|
4480
5009
|
if (subitemPDU == null)
|
|
4481
5010
|
break;
|
|
4482
|
-
if (subitemPDU.itemType == ASN1ItemType.INTEGER && data.arrayBufferEquals(reader.getArrayBuffer(subitemPDU.dataOfst, subitemPDU.contLen), sn))
|
|
5011
|
+
if (subitemPDU.itemType == ASN1ItemType.INTEGER && data.arrayBufferEquals(this.reader.getArrayBuffer(subitemPDU.dataOfst, subitemPDU.contLen), sn))
|
|
4483
5012
|
{
|
|
4484
5013
|
return true;
|
|
4485
5014
|
}
|
|
@@ -4488,6 +5017,9 @@ export class X509CRL extends X509File
|
|
|
4488
5017
|
}
|
|
4489
5018
|
}
|
|
4490
5019
|
|
|
5020
|
+
/**
|
|
5021
|
+
* @param {string} algType
|
|
5022
|
+
*/
|
|
4491
5023
|
export function algTypeGetHash(algType)
|
|
4492
5024
|
{
|
|
4493
5025
|
switch (algType)
|
|
@@ -4516,6 +5048,9 @@ export function algTypeGetHash(algType)
|
|
|
4516
5048
|
}
|
|
4517
5049
|
}
|
|
4518
5050
|
|
|
5051
|
+
/**
|
|
5052
|
+
* @param {any} fileType
|
|
5053
|
+
*/
|
|
4519
5054
|
export function fileTypeGetName(fileType)
|
|
4520
5055
|
{
|
|
4521
5056
|
switch (fileType)
|
|
@@ -4543,6 +5078,9 @@ export function fileTypeGetName(fileType)
|
|
|
4543
5078
|
}
|
|
4544
5079
|
}
|
|
4545
5080
|
|
|
5081
|
+
/**
|
|
5082
|
+
* @param {number} keyType
|
|
5083
|
+
*/
|
|
4546
5084
|
export function keyTypeGetName(keyType)
|
|
4547
5085
|
{
|
|
4548
5086
|
switch (keyType)
|
|
@@ -4565,6 +5103,33 @@ export function keyTypeGetName(keyType)
|
|
|
4565
5103
|
}
|
|
4566
5104
|
}
|
|
4567
5105
|
|
|
5106
|
+
/**
|
|
5107
|
+
* @param {any} keyType
|
|
5108
|
+
*/
|
|
5109
|
+
export function keyTypeGetOID(keyType)
|
|
5110
|
+
{
|
|
5111
|
+
switch (keyType)
|
|
5112
|
+
{
|
|
5113
|
+
case KeyType.RSA:
|
|
5114
|
+
return "1.2.840.113549.1.1.1";
|
|
5115
|
+
case KeyType.DSA:
|
|
5116
|
+
return "1.2.840.10040.4.1";
|
|
5117
|
+
case KeyType.ECDSA:
|
|
5118
|
+
return "1.2.840.10045.2.1";
|
|
5119
|
+
case KeyType.ED25519:
|
|
5120
|
+
return "1.3.101.112";
|
|
5121
|
+
case KeyType.ECPublic:
|
|
5122
|
+
return "1.2.840.10045.2.1";
|
|
5123
|
+
case KeyType.RSAPublic:
|
|
5124
|
+
case KeyType.Unknown:
|
|
5125
|
+
default:
|
|
5126
|
+
return "1.2.840.113549.1.1.1";
|
|
5127
|
+
}
|
|
5128
|
+
}
|
|
5129
|
+
|
|
5130
|
+
/**
|
|
5131
|
+
* @param {number} ecName
|
|
5132
|
+
*/
|
|
4568
5133
|
export function ecNameGetName(ecName)
|
|
4569
5134
|
{
|
|
4570
5135
|
switch (ecName)
|
|
@@ -4581,6 +5146,9 @@ export function ecNameGetName(ecName)
|
|
|
4581
5146
|
}
|
|
4582
5147
|
}
|
|
4583
5148
|
|
|
5149
|
+
/**
|
|
5150
|
+
* @param {number} ecName
|
|
5151
|
+
*/
|
|
4584
5152
|
export function ecNameGetOID(ecName)
|
|
4585
5153
|
{
|
|
4586
5154
|
switch (ecName)
|
|
@@ -4597,6 +5165,9 @@ export function ecNameGetOID(ecName)
|
|
|
4597
5165
|
}
|
|
4598
5166
|
}
|
|
4599
5167
|
|
|
5168
|
+
/**
|
|
5169
|
+
* @param {ArrayBuffer | Iterable<number>} buff
|
|
5170
|
+
*/
|
|
4600
5171
|
export function ecNameFromOID(buff)
|
|
4601
5172
|
{
|
|
4602
5173
|
let arr = new Uint8Array(buff);
|
|
@@ -4613,4 +5184,32 @@ export function ecNameFromOID(buff)
|
|
|
4613
5184
|
return ECName.secp521r1;
|
|
4614
5185
|
}
|
|
4615
5186
|
return ECName.Unknown;
|
|
4616
|
-
}
|
|
5187
|
+
}
|
|
5188
|
+
|
|
5189
|
+
/**
|
|
5190
|
+
* @param {Uint8Array | number[]} oid
|
|
5191
|
+
*/
|
|
5192
|
+
export function hashTypeFromOID(oid)
|
|
5193
|
+
{
|
|
5194
|
+
if (ASN1Util.oidEqualsText(oid, "2.16.840.1.101.3.4.2.1"))
|
|
5195
|
+
{
|
|
5196
|
+
return hash.HashType.SHA256;
|
|
5197
|
+
}
|
|
5198
|
+
else if (ASN1Util.oidEqualsText(oid, "2.16.840.1.101.3.4.2.2"))
|
|
5199
|
+
{
|
|
5200
|
+
return hash.HashType.SHA384;
|
|
5201
|
+
}
|
|
5202
|
+
else if (ASN1Util.oidEqualsText(oid, "2.16.840.1.101.3.4.2.3"))
|
|
5203
|
+
{
|
|
5204
|
+
return hash.HashType.SHA512;
|
|
5205
|
+
}
|
|
5206
|
+
else if (ASN1Util.oidEqualsText(oid, "2.16.840.1.101.3.4.2.4"))
|
|
5207
|
+
{
|
|
5208
|
+
return hash.HashType.SHA224;
|
|
5209
|
+
}
|
|
5210
|
+
else if (ASN1Util.oidEqualsText(oid, "1.3.14.3.2.26"))
|
|
5211
|
+
{
|
|
5212
|
+
return hash.HashType.SHA1;
|
|
5213
|
+
}
|
|
5214
|
+
return hash.HashType.Unknown;
|
|
5215
|
+
}
|