Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dummy key agreement with codepoint 0xfe33 #162

Merged
merged 1 commit into from
Oct 10, 2023
Merged
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
8 changes: 8 additions & 0 deletions src/crypto/tls/cfkem.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"fmt"
"io"

"github.com/cloudflare/circl/hpke"
"github.com/cloudflare/circl/kem"
"github.com/cloudflare/circl/kem/hybrid"
)
Expand All @@ -42,6 +43,11 @@ var (
X25519Kyber768Draft00Old = CurveID(0xfe31)
P256Kyber768Draft00 = CurveID(0xfe32)
invalidCurveID = CurveID(0)

// A key agreeement similar in size but purposefully incompatible with
// X25519. The goal is to have a key agreement that servers will not
// support, so we can test HelloRetryRquest.
DummyKex = CurveID(0xfe33)
)

func singleClientKeySharePrivateFor(ks clientKeySharePrivate, group CurveID) singleClientKeySharePrivate {
Expand All @@ -58,6 +64,8 @@ func curveIdToCirclScheme(id CurveID) kem.Scheme {
return hybrid.Kyber768X25519()
case P256Kyber768Draft00:
return hybrid.P256Kyber768Draft00()
case DummyKex:
return hpke.KEM_X25519_HKDF_SHA256.Scheme()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the intended semantics of this? Are we expected to negotiate it? Can we have a test in cfkem_test.go for this identifier?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added test. Semantics is as explained in the comment of the CurveID.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, the test at least assures that we won't crash.

}
return nil
}
Expand Down
1 change: 1 addition & 0 deletions src/crypto/tls/cfkem_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ func TestHybridKEX(t *testing.T) {
X25519Kyber768Draft00,
X25519Kyber768Draft00Old,
P256Kyber768Draft00,
DummyKex,
} {
run(curveID, true, true, false, false)
run(curveID, true, false, false, false)
Expand Down