Skip to content

Commit

Permalink
kem: add X25519MLKEM768 TLS hybrid KEM
Browse files Browse the repository at this point in the history
  • Loading branch information
bwesterb committed Sep 5, 2024
1 parent c311e46 commit 2d6cd98
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
21 changes: 16 additions & 5 deletions kem/hybrid/hybrid.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Package hybrid defines several hybrid classical/quantum KEMs.
// Package hybrid defines several hybrid classical/quantum KEMs for use in TLS.
//
// KEMs are combined by simple concatenation of shared secrets, cipher texts,
// public keys, etc, see
// Hybrid KEMs in TLS are created by simple concatenation
// of shared secrets, cipher texts, public keys, etc.
// This is safe for TLS, see eg.
//
// https://datatracker.ietf.org/doc/draft-ietf-tls-hybrid-design/
// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-56Cr2.pdf
//
// Note that this is only fine if the shared secret is used in its entirety
// in a next step, such as being hashed or used as key.
// Note that this approach is not proven secure in broader context.
//
// For deriving a KEM keypair deterministically and encapsulating
// deterministically, we expand a single seed to both using SHAKE256,
Expand Down Expand Up @@ -38,6 +38,7 @@ import (
"github.com/cloudflare/circl/kem/kyber/kyber1024"
"github.com/cloudflare/circl/kem/kyber/kyber512"
"github.com/cloudflare/circl/kem/kyber/kyber768"
"github.com/cloudflare/circl/kem/mlkem/mlkem768"
)

var ErrUninitialized = errors.New("public or private key not initialized")
Expand All @@ -57,6 +58,10 @@ func Kyber1024X448() kem.Scheme { return kyber1024X }
// Returns the hybrid KEM of Kyber768Draft00 and P-256.
func P256Kyber768Draft00() kem.Scheme { return p256Kyber768Draft00 }

// Returns the hybrid KEM of ML-KEM-768 and X25519.
// https://www.ietf.org/archive/id/draft-kwiatkowski-tls-ecdhe-mlkem-01.html
func X25519MLKEM768() kem.Scheme { return xmlkem768 }

var p256Kyber768Draft00 kem.Scheme = &scheme{
"P256Kyber768Draft00",
p256Kem,
Expand Down Expand Up @@ -87,6 +92,12 @@ var kyber1024X kem.Scheme = &scheme{
kyber1024.Scheme(),
}

var xmlkem768 kem.Scheme = &scheme{
"X25519MLKEM768",
mlkem768.Scheme(),
x25519Kem,
}

// Public key of a hybrid KEM.
type publicKey struct {
scheme *scheme
Expand Down
1 change: 1 addition & 0 deletions kem/schemes/schemes.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ var allSchemes = [...]kem.Scheme{
hybrid.Kyber768X448(),
hybrid.Kyber1024X448(),
hybrid.P256Kyber768Draft00(),
hybrid.X25519MLKEM768(),
}

var allSchemeNames map[string]kem.Scheme
Expand Down
1 change: 1 addition & 0 deletions kem/schemes/schemes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,5 @@ func Example_schemes() {
// Kyber768-X448
// Kyber1024-X448
// P256Kyber768Draft00
// X25519MLKEM768
}

0 comments on commit 2d6cd98

Please sign in to comment.