Skip to content

Commit 779e52b

Browse files
committed
version 0.3.3 revise certificate_list, Extensions
1 parent 47f6656 commit 779e52b

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tls/enum",
3-
"version": "0.3.2",
3+
"version": "0.3.3",
44
"exports": "./src/mod.ts",
55
"publish": {
66
"exclude": ["dist/"]

src/certificatetype.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// @ts-self-types="../type/certificatetype.d.ts"
33

44
import { 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 {
7777
class 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 {
101107
class 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

Comments
 (0)