File tree Expand file tree Collapse file tree 3 files changed +25
-14
lines changed Expand file tree Collapse file tree 3 files changed +25
-14
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " @tls/enum" ,
3- "version" : " 0.5.6 " ,
3+ "version" : " 0.5.7 " ,
44 "exports" : " ./src/mod.ts" ,
55 "publish" : {
66 "exclude" : [" dist/" ]
Original file line number Diff line number Diff line change @@ -167,7 +167,24 @@ export class KeyShareEntry extends Struct {
167167 }
168168}
169169
170-
170+ export class NamedGroupList extends Constrained {
171+ static from ( array ) {
172+ const copy = Uint8Array . from ( array ) ;
173+ const lengthOf = Uint16 . from ( copy ) . value ;
174+ const namedGroups = new Set ;
175+ let offset = 2 ;
176+ while ( true ) {
177+ const namedgroup = NamedGroup . from ( copy . subarray ( offset ) ) ; offset += 2 ;
178+ namedGroups . add ( namedgroup ) ;
179+ if ( offset >= lengthOf + 2 ) break ;
180+ }
181+ return new NamedGroupList ( ...namedGroups )
182+ }
183+ constructor ( ...namedGroups ) {
184+ super ( 2 , 2 ** 16 - 1 , ...namedGroups . map ( e => e . Uint16 ) ) ;
185+ this . namedGroups = namedGroups
186+ }
187+ }
171188
172189
173190
Original file line number Diff line number Diff line change 11import { assertEquals } from "jsr:@std/assert" ;
2- import { NamedGroup } from "../src/namedgroup.js" ;
2+ import { NamedGroup , NamedGroupList } from "../src/namedgroup.js" ;
33
44Deno . test (
55 "NamedGroup" ,
@@ -19,15 +19,9 @@ Deno.test(
1919 }
2020)
2121
22- //const x25519 = NamedGroup.X25519.keyShareEntry();
2322
24- const x25519 = NamedGroup . X25519 ;
25- assertEquals ( x25519 . name , 'X25519' )
26- const pub = x25519 . keyGen . getPublicKey ( x25519 . privateKey ) ;
27- assertEquals ( pub . length , 32 )
28- const peerPublicKey = crypto . getRandomValues ( new Uint8Array ( 32 ) ) ;
29- assertEquals ( peerPublicKey . length , 32 )
30- const sharedKey = x25519 . getSharedKey ( peerPublicKey )
31- assertEquals ( sharedKey . length , 32 )
32-
33- debugger ;
23+ Deno . test ( "NamedGroupList" , ( ) => {
24+ const namedGroupList = new NamedGroupList ( NamedGroup . X25519 , NamedGroup . X448 ) ;
25+ const backNGL = NamedGroupList . from ( namedGroupList ) ;
26+ assertEquals ( namedGroupList . toString ( ) , backNGL . toString ( ) )
27+ } )
You can’t perform that action at this time.
0 commit comments