apple / apple/swift-tls

Missing secp256r1 (P-256) key exchange

Open
#10 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Swift
Stars
97
Forks
9
Avg merge
1d 6h
Merged PRs (30d)
4

Description

Hello,

I am experimenting with the entire QUIC stack on linux for a server framework built on top, I noticed some issue whilst connecting with other library that don't offer the same key exchange (or offer a limited variety)

I tested a patch locally and I was wondering if it was useful to push the idea here

Important note : this patch was made with the help of GPT 5.5 (finding the missing part) and Claude (applying the fix to the main code), I did manual verification and ran the test, tho I cannot say if this add anything to the limited scope of SwiftTLS.

The branch is here https://github.com/hironichu/swift-tls/tree/feature/secp256r1-key-exchange

`NamedGroup.secp256` (0x0017) was declared but had no ephemeral key implementation, so configuring `keyExchangeGroup = .secp256` failed on both sides: the client's `startHandshake` threw `handshakeError` and the server hardcoded its supported groups to
`[.x25519MLKEM768, .secp384, .x25519]`.

- Add `P256EphemeralKey` and the corresponding `.p256` cases / a `.secp256` case to `generateEphemeralKeyForNamedGroup`, mirroring the existing P-384 implementation.
- Route the client `startHandshake` through the shared `generateEphemeralKeyForNamedGroup` helper instead of a duplicated inline switch, so client and server derive key shares from one path.
- Let the server honor the configured group via a new `fixedKeyExchangeGroup` on its configuration; default offered groups are unchanged, so secp256 is opt-in and the change is backward compatible.
- Add a client-to-server P-256 handshake test.

Motivation: interop with P-256-only TLS 1.3 / QUIC peers.

Contributor guide

Open the contributing guide

Research direction

Start with the existing P-384 implementation and the generateEphemeralKeyForNamedGroup helper, then trace the client startHandshake path and the server configuration. Add the P-256 cases and configurable server group described in the issue, and add a client-to-server P-256 handshake test. Done means P-256 handshakes succeed while the default offered groups remain unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
networking, security
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.