1+ // deno-lint-ignore-file no-slow-types
2+ // @ts -self-types="../type/namedgroup.d.ts"
3+
4+ import { Enum } from "./enum.js" ;
5+
6+ /**
7+ * Supported groups - @see https://datatracker.ietf.org/doc/html/rfc8446#section-4.2.7.
8+ */
9+ export class NamedGroup extends Enum {
10+ /* Elliptic Curve Groups (ECDHE) */
11+ static SECP256R1 = new NamedGroup ( 'SECP256R1' , 0x0017 ) ;
12+ static SECP384R1 = new NamedGroup ( 'SECP384R1' , 0x0018 ) ;
13+ static SECP521R1 = new NamedGroup ( 'SECP521R1' , 0x0019 ) ;
14+ static X25519 = new NamedGroup ( 'X25519' , 0x001D ) ;
15+ static X448 = new NamedGroup ( 'X448' , 0x001E ) ;
16+
17+ /* Finite Field Groups (DHE) */
18+ static FFDHE2048 = new NamedGroup ( 'FFDHE2048' , 0x0100 ) ;
19+ static FFDHE3072 = new NamedGroup ( 'FFDHE3072' , 0x0101 ) ;
20+ static FFDHE4096 = new NamedGroup ( 'FFDHE4096' , 0x0102 ) ;
21+ static FFDHE6144 = new NamedGroup ( 'FFDHE6144' , 0x0103 ) ;
22+ static FFDHE8192 = new NamedGroup ( 'FFDHE8192' , 0x0104 ) ;
23+ /**
24+ * check octet and return valid SignatureScheme
25+ *
26+ * @static
27+ * @param {Uint8Array } octet
28+ * @returns {NamedGroup }
29+ */
30+ static parse ( octet ) {
31+ const value = octet [ 0 ] * 256 + octet [ 1 ]
32+ return NamedGroup . fromValue ( value ) ?? Error ( `Unknown ${ value } NamedGroup type` ) ;
33+ }
34+
35+ /**return 16 */
36+ get bit ( ) { return 16 }
37+
38+ }
39+
40+ // npx -p typescript tsc ./src/namedgroup.js --declaration --allowJs --emitDeclarationOnly --lib ESNext --outDir ./dist
0 commit comments