Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ Below are the algorithms built in (based on Web Cryptography) and their runtime
| HKDF-SHA512 <sub>`0x0003`</sub> | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| SHAKE128 <sub>`0x0010`</sub> | ✓[^24.7] | | | | | ✓ |
| SHAKE256 <sub>`0x0011`</sub> | ✓[^24.7] | | | | | ✓ |
| TurboSHAKE128 <sub>`0x0012`</sub> | | | | | | ✓ |
| TurboSHAKE256 <sub>`0x0013`</sub> | | | | | | ✓ |
| TurboSHAKE128 <sub>`0x0012`</sub> | ✓[^todo] | | | | | ✓ |
| TurboSHAKE256 <sub>`0x0013`</sub> | ✓[^todo] | | | | | ✓ |

### Authenticated Encryption (AEAD)

Expand Down Expand Up @@ -146,3 +146,5 @@ specifications.
[browsers]: https://panva.github.io/hpke/

[^24.7]: Available in Node.js versions >= 24.7.0

[^todo]: Available in Node.js versions >= TODO
2 changes: 2 additions & 0 deletions docs/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions docs/type-aliases/KDFFactory.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions docs/variables/KDF_TurboSHAKE128.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions docs/variables/KDF_TurboSHAKE256.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 62 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1331,6 +1331,8 @@ export type KEMFactory = () => Readonly<KEM>
* - {@link KDF_HKDF_SHA512 | HKDF-SHA512}
* - {@link KDF_SHAKE128 | SHAKE128}
* - {@link KDF_SHAKE256 | SHAKE256}
* - {@link KDF_TurboSHAKE128 | TurboSHAKE128}
* - {@link KDF_TurboSHAKE256 | TurboSHAKE256}
*
* > [!TIP]\
* > {@link CipherSuite} is not limited to using only these exported KDF implementations. Any function
Expand Down Expand Up @@ -2532,6 +2534,66 @@ export const KDF_SHAKE256: KDFFactory = function (): SHAKE {
}
}

/**
* TurboSHAKE128 key derivation function.
*
* A one-stage KDF using the TurboSHAKE128 extendable-output function (XOF) with an output length
* (Nh) of 32 bytes.
*
* Depends on the following Web Cryptography algorithms being supported in the runtime:
*
* - TurboSHAKE128 digest
*
* This is a factory function that must be passed to the {@link CipherSuite} constructor.
*
* > [!TIP]\
* > An implementation of this algorithm not reliant on Web Cryptography is also exported by
* > [`@panva/hpke-noble`](https://www.npmjs.com/package/@panva/hpke-noble)
*
* @group KDF Algorithms
* @see [HPKE-PQ One-Stage KDFs](https://datatracker.ietf.org/doc/html/draft-ietf-hpke-pq-04.html#section-5)
*/
export const KDF_TurboSHAKE128: KDFFactory = function (): SHAKE {
return {
id: 0x0012,
type: 'KDF',
name: 'TurboSHAKE128',
Nh: 32,
algorithm: 'TurboSHAKE128',
...SHAKE_SHARED(),
}
}

/**
* TurboSHAKE256 key derivation function.
*
* A one-stage KDF using the TurboSHAKE256 extendable-output function (XOF) with an output length
* (Nh) of 64 bytes.
*
* Depends on the following Web Cryptography algorithms being supported in the runtime:
*
* - TurboSHAKE256 digest
*
* This is a factory function that must be passed to the {@link CipherSuite} constructor.
*
* > [!TIP]\
* > An implementation of this algorithm not reliant on Web Cryptography is also exported by
* > [`@panva/hpke-noble`](https://www.npmjs.com/package/@panva/hpke-noble)
*
* @group KDF Algorithms
* @see [HPKE-PQ One-Stage KDFs](https://datatracker.ietf.org/doc/html/draft-ietf-hpke-pq-04.html#section-5)
*/
export const KDF_TurboSHAKE256: KDFFactory = function (): SHAKE {
return {
id: 0x0013,
type: 'KDF',
name: 'TurboSHAKE256',
Nh: 64,
algorithm: 'TurboSHAKE256',
...SHAKE_SHARED(),
}
}

async function getPublicKeyByExport(
name: string,
key: CryptoKey,
Expand Down
2 changes: 1 addition & 1 deletion test/run-workerd.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const unsupported = {
'KEM_MLKEM768_P256',
'KEM_MLKEM1024_P384',
],
kdf: ['KDF_SHAKE128', 'KDF_SHAKE256'],
kdf: ['KDF_SHAKE128', 'KDF_SHAKE256', 'KDF_TurboSHAKE128', 'KDF_TurboSHAKE256'],
aead: ['AEAD_ChaCha20Poly1305'],
}

Expand Down
8 changes: 8 additions & 0 deletions test/support.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ export const supported: Record<string, () => boolean | undefined> = {
// @ts-expect-error
return supports('digest', { name: 'cSHAKE256', outputLength: 512, length: 512 })
},
KDF_TurboSHAKE128() {
// @ts-expect-error
return supports('digest', { name: 'TurboSHAKE128', outputLength: 256 })
},
KDF_TurboSHAKE256() {
// @ts-expect-error
return supports('digest', { name: 'TurboSHAKE256', outputLength: 512 })
},
KEM_ML_KEM_512() {
return supports('generateKey', 'ML-KEM-512')
},
Expand Down