• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

LukaJCB / ts-mls / 20945201760

13 Jan 2026 04:55AM UTC coverage: 95.199% (-0.5%) from 95.727%
20945201760

push

github

web-flow
Use CiphersuiteId instead of CiphersuiteName for internal values (#200)

* Use CiphersuiteId instead of CiphersuiteName for internal values

* Use ProtocolVersionValue instead of ProtocolVersionName

* Use CredentialTypeValue instead of CredentialTypeName

* Use DefaultProposalTypeValue instead of DefaultProposalTypeName

* Remove extensionType

* Refactor credential

* Cleanup

* Use LeafNodeSourceValue insteda of Name

* Cleanup

* Update NodeType and LeafNodeSource

* Update contentType

* Update resumptionPskusage & senderTypes

* Update wireformat and pskTypes

* Update ts-mls.api

412 of 421 branches covered (97.86%)

Branch coverage included in aggregate %.

193 of 208 new or added lines in 35 files covered. (92.79%)

6 existing lines in 3 files now uncovered.

2364 of 2495 relevant lines covered (94.75%)

75088.28 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.91
/src/crypto/ciphersuite.ts
1
import { Signature, SignatureAlgorithm } from "./signature.js"
2
import { Hash, HashAlgorithm } from "./hash.js"
3
import { Kdf } from "./kdf.js"
4
import { Hpke, HpkeAlgorithm } from "./hpke.js"
5
import { BufferEncoder, encode, Encoder } from "../codec/tlsEncoder.js"
6
import { decodeUint16, uint16Encoder } from "../codec/number.js"
7
import { Decoder } from "../codec/tlsDecoder.js"
8
import { Rng } from "./rng.js"
9
import { reverseMap } from "../util/enumHelpers.js"
10

11
/** @public */
12
export interface CiphersuiteImpl {
13
  hash: Hash
14
  hpke: Hpke
15
  signature: Signature
16
  kdf: Kdf
17
  rng: Rng
18
  name: CiphersuiteId
19
}
20

21
/** @public */
22
export const ciphersuites = {
3✔
23
  MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519: 1,
24
  MLS_128_DHKEMP256_AES128GCM_SHA256_P256: 2,
25
  MLS_128_DHKEMX25519_CHACHA20POLY1305_SHA256_Ed25519: 3,
26
  MLS_256_DHKEMX448_AES256GCM_SHA512_Ed448: 4,
27
  MLS_256_DHKEMP521_AES256GCM_SHA512_P521: 5,
28
  MLS_256_DHKEMX448_CHACHA20POLY1305_SHA512_Ed448: 6,
29
  MLS_256_DHKEMP384_AES256GCM_SHA384_P384: 7,
30
  MLS_128_MLKEM512_AES128GCM_SHA256_Ed25519: 77,
31
  MLS_128_MLKEM512_CHACHA20POLY1305_SHA256_Ed25519: 78,
32
  MLS_256_MLKEM768_AES256GCM_SHA384_Ed25519: 79,
33
  MLS_256_MLKEM768_CHACHA20POLY1305_SHA384_Ed25519: 80,
34
  MLS_256_MLKEM1024_AES256GCM_SHA512_Ed25519: 81,
35
  MLS_256_MLKEM1024_CHACHA20POLY1305_SHA512_Ed25519: 82,
36
  MLS_256_XWING_AES256GCM_SHA512_Ed25519: 83,
37
  MLS_256_XWING_CHACHA20POLY1305_SHA512_Ed25519: 84,
38
  MLS_256_MLKEM1024_AES256GCM_SHA512_MLDSA87: 85,
39
  MLS_256_MLKEM1024_CHACHA20POLY1305_SHA512_MLDSA87: 86,
40
  MLS_256_XWING_AES256GCM_SHA512_MLDSA87: 87,
41
  MLS_256_XWING_CHACHA20POLY1305_SHA512_MLDSA87: 88,
42
} as const
43

44
/** @public */
45
export type CiphersuiteName = keyof typeof ciphersuites
46
/** @public */
47
export type CiphersuiteId = (typeof ciphersuites)[CiphersuiteName]
48

49
export const ciphersuiteEncoder: BufferEncoder<CiphersuiteId> = uint16Encoder
3✔
50

51
export const encodeCiphersuite: Encoder<CiphersuiteId> = encode(ciphersuiteEncoder)
3✔
52

53
export const decodeCiphersuite: Decoder<CiphersuiteId> = (b, offset) => {
3✔
54
  const decoded = decodeUint16(b, offset)
117,159✔
55
  return decoded === undefined ? undefined : [decoded[0] as CiphersuiteId, decoded[1]]
117,159✔
56
}
57

58
export function getCiphersuiteNameFromId(id: CiphersuiteId): CiphersuiteName {
UNCOV
59
  return reverseMap(ciphersuites)[id] as CiphersuiteName
×
60
}
61

62
export function getCiphersuiteFromId(id: CiphersuiteId): Ciphersuite {
63
  return ciphersuiteValues[id]
540✔
64
}
65

66
/** @public */
67
export function getCiphersuiteFromName(name: CiphersuiteName): Ciphersuite {
68
  return ciphersuiteValues[ciphersuites[name]]
956✔
69
}
70

71
const ciphersuiteValues: Record<CiphersuiteId, Ciphersuite> = {
3✔
72
  1: {
73
    hash: "SHA-256",
74
    hpke: {
75
      kem: "DHKEM-X25519-HKDF-SHA256",
76
      aead: "AES128GCM",
77
      kdf: "HKDF-SHA256",
78
    },
79
    signature: "Ed25519",
80
    name: 1,
81
  },
82
  2: {
83
    hash: "SHA-256",
84
    hpke: {
85
      kem: "DHKEM-P256-HKDF-SHA256",
86
      aead: "AES128GCM",
87
      kdf: "HKDF-SHA256",
88
    },
89
    signature: "P256",
90
    name: 2,
91
  },
92
  3: {
93
    hash: "SHA-256",
94
    hpke: {
95
      kem: "DHKEM-X25519-HKDF-SHA256",
96
      aead: "CHACHA20POLY1305",
97
      kdf: "HKDF-SHA256",
98
    },
99
    signature: "Ed25519",
100
    name: 3,
101
  },
102
  4: {
103
    hash: "SHA-512",
104
    hpke: {
105
      kem: "DHKEM-X448-HKDF-SHA512",
106
      aead: "AES256GCM",
107
      kdf: "HKDF-SHA512",
108
    },
109
    signature: "Ed448",
110
    name: 4,
111
  },
112
  5: {
113
    hash: "SHA-512",
114
    hpke: {
115
      kem: "DHKEM-P521-HKDF-SHA512",
116
      aead: "AES256GCM",
117
      kdf: "HKDF-SHA512",
118
    },
119
    signature: "P521",
120
    name: 5,
121
  },
122
  6: {
123
    hash: "SHA-512",
124
    hpke: {
125
      kem: "DHKEM-X448-HKDF-SHA512",
126
      aead: "CHACHA20POLY1305",
127
      kdf: "HKDF-SHA512",
128
    },
129
    signature: "Ed448",
130
    name: 6,
131
  },
132
  7: {
133
    hash: "SHA-384",
134
    hpke: {
135
      kem: "DHKEM-P384-HKDF-SHA384",
136
      aead: "AES256GCM",
137
      kdf: "HKDF-SHA384",
138
    },
139
    signature: "P384",
140
    name: 7,
141
  },
142

143
  77: {
144
    hash: "SHA-256",
145
    hpke: {
146
      kem: "ML-KEM-512",
147
      aead: "AES256GCM",
148
      kdf: "HKDF-SHA512",
149
    },
150
    signature: "Ed25519",
151
    name: 77,
152
  },
153
  78: {
154
    hash: "SHA-256",
155
    hpke: {
156
      kem: "ML-KEM-512",
157
      aead: "CHACHA20POLY1305",
158
      kdf: "HKDF-SHA512",
159
    },
160
    signature: "Ed25519",
161
    name: 78,
162
  },
163
  79: {
164
    hash: "SHA-384",
165
    hpke: {
166
      kem: "ML-KEM-768",
167
      aead: "AES256GCM",
168
      kdf: "HKDF-SHA512",
169
    },
170
    signature: "Ed25519",
171
    name: 79,
172
  },
173
  80: {
174
    hash: "SHA-384",
175
    hpke: {
176
      kem: "ML-KEM-768",
177
      aead: "CHACHA20POLY1305",
178
      kdf: "HKDF-SHA512",
179
    },
180
    signature: "Ed25519",
181
    name: 80,
182
  },
183
  81: {
184
    hash: "SHA-512",
185
    hpke: {
186
      kem: "ML-KEM-1024",
187
      aead: "AES256GCM",
188
      kdf: "HKDF-SHA512",
189
    },
190
    signature: "Ed25519",
191
    name: 81,
192
  },
193
  82: {
194
    hash: "SHA-512",
195
    hpke: {
196
      kem: "ML-KEM-1024",
197
      aead: "CHACHA20POLY1305",
198
      kdf: "HKDF-SHA512",
199
    },
200
    signature: "Ed25519",
201
    name: 82,
202
  },
203
  83: {
204
    hash: "SHA-512",
205
    hpke: {
206
      kem: "X-Wing",
207
      aead: "AES256GCM",
208
      kdf: "HKDF-SHA512",
209
    },
210
    signature: "Ed25519",
211
    name: 83,
212
  },
213
  84: {
214
    hash: "SHA-512",
215
    hpke: {
216
      kem: "X-Wing",
217
      aead: "CHACHA20POLY1305",
218
      kdf: "HKDF-SHA512",
219
    },
220
    signature: "Ed25519",
221
    name: 84,
222
  },
223
  85: {
224
    hash: "SHA-512",
225
    hpke: {
226
      kem: "ML-KEM-1024",
227
      aead: "AES256GCM",
228
      kdf: "HKDF-SHA512",
229
    },
230
    signature: "ML-DSA-87",
231
    name: 85,
232
  },
233
  86: {
234
    hash: "SHA-512",
235
    hpke: {
236
      kem: "ML-KEM-1024",
237
      aead: "CHACHA20POLY1305",
238
      kdf: "HKDF-SHA512",
239
    },
240
    signature: "ML-DSA-87",
241
    name: 86,
242
  },
243
  87: {
244
    hash: "SHA-512",
245
    hpke: {
246
      kem: "X-Wing",
247
      aead: "AES256GCM",
248
      kdf: "HKDF-SHA512",
249
    },
250
    signature: "ML-DSA-87",
251
    name: 87,
252
  },
253
  88: {
254
    hash: "SHA-512",
255
    hpke: {
256
      kem: "X-Wing",
257
      aead: "CHACHA20POLY1305",
258
      kdf: "HKDF-SHA512",
259
    },
260
    signature: "ML-DSA-87",
261
    name: 88,
262
  },
263
} as const
264

265
/** @public */
266
export type Ciphersuite = {
267
  hash: HashAlgorithm
268
  hpke: HpkeAlgorithm
269
  signature: SignatureAlgorithm
270
  name: CiphersuiteId
271
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc