22// @ts -self-types="../type/certificatetype.d.ts"
33
44import { Enum } from "./enum.js" ;
5- import { Constrained , Struct , Uint24 , Uint8 , Uint16 } from "./dep.ts"
5+ import { Constrained , Struct , Uint24 , Uint8 , Uint16 , Extension } from "./dep.ts"
66
77/**
88 * Supported groups - @see https://datatracker.ietf.org/doc/html/rfc8446#section-4.2.7.
@@ -77,8 +77,14 @@ class Cert_data extends Constrained {
7777class Extensions extends Constrained {
7878 static from ( array ) {
7979 const copy = Uint8Array . from ( array ) ;
80- const lengthOf = Uint16 . from ( copy ) . value ;
81- return new Extensions ( copy . subarray ( 2 , lengthOf + 2 ) )
80+ const _lengthOf = Uint16 . from ( copy ) . value ;
81+ let offset = 2 ;
82+ const extensions = [ ] ;
83+ while ( offset < copy . length ) {
84+ const extension = Extension . from ( copy . subarray ( offset ) ) ; offset += extension . length ;
85+ extensions . push ( extension ) ;
86+ }
87+ return new Extensions ( ...extensions )
8288 }
8389 constructor ( ...extension ) {
8490 super ( 0 , 2 ** 16 - 1 , ...extension ) ;
@@ -101,9 +107,14 @@ class Certificate_request_context extends Constrained {
101107class Certificate_list extends Constrained {
102108 static from ( array ) {
103109 const copy = Uint8Array . from ( array ) ;
104- const lengthOf = Uint24 . from ( copy ) . value ;
105- const certificateEntry = CertificateEntry . from ( copy . subarray ( 3 , lengthOf + 3 ) ) ;
106- return new Certificate_list ( certificateEntry )
110+ const _lengthOf = Uint24 . from ( copy ) . value ;
111+ let offset = 3 ;
112+ const certificateEntries = [ ]
113+ while ( offset < copy . length ) {
114+ const certificateEntry = CertificateEntry . from ( copy . subarray ( offset ) ) ; offset += certificateEntry . length ;
115+ certificateEntries . push ( certificateEntry )
116+ }
117+ return new Certificate_list ( ...certificateEntries )
107118 }
108119 constructor ( ...certificateEntry ) {
109120 super ( 0 , 2 ** 24 - 1 , ...certificateEntry ) ;
0 commit comments