Skip to content

Conversation

@thehajime
Copy link
Contributor

currently, a certificate generated with p384 curve key is not usable with hs-tls.

openssl ecparam -out ec_key.pem -name secp384r1 -genkey
openssl req -new -key ec_key.pem -x509 -nodes -days 3650 -out ec_cert.pem

the server using hs-tls shows 'credential not found' message.

% ./dist-newstyle/build/x86_64-linux/ghc-9.6.7/tls-debug-0.4.8/x/tls-simpleserver/build/tls-simpleserver/tls-simpleserver -d -v --key ./ec_key.pem --certificate ./ec_cert.pem  4433

connection from 127.0.0.1:59262
debug: << Handshake [ClientHello (CH {chVersion = TLS1.2, chRandom = ClientRandom "b9928e6a7a414497d22acf44a9091cb783fd13691d91b73707f33379e74ac9e1", chSession = Session "9be672a956ddc3ada2e187984e83c8870bed292b0ffbe4ddaed222316b600680", chCiphers = [0xC02C,0xC0AD,0xCCA9,0xC02B,0xC0AC,0xC030,0xCCA8,0xC02F,0x1302,0x1303,0x1301,0x1304,0xC0AE,0xC0AF,0x1305], chComps = [0], chExtensions = [ServerName ["127.0.0.1"],SupportedGroups [X25519,X448,P256,FFDHE2048,FFDHE3072,FFDHE4096,P384,FFDHE6144,FFDHE8192,P521],EcPointFormatsSupported [EcPointFormat_Uncompressed],SignatureAlgorithms [(TLS13,Ed448),(TLS13,Ed25519),(SHA512,ECDSA),(SHA384,ECDSA),(SHA256,ECDSA),(TLS13,RSApssRSAeSHA512),(TLS13,RSApssRSAeSHA384),(TLS13,RSApssRSAeSHA256),(TLS13,RSApsspssSHA512),(TLS13,RSApsspssSHA384),(TLS13,RSApsspssSHA256),(SHA512,RSA),(SHA384,RSA),(SHA256,RSA),(SHA1,RSA),(SHA1,ECDSA)],ExtendedMainSecret,CompressCertificate [zlib],SessionTicket "",Versions [TLS1.3,TLS1.2],PskKeyExchangeModes [PSK_DHE_KE],PostHandshakeAuth,KeyShare [X25519],SecureRenegotiation "00"]})]
debug: >> Alert13 [(AlertLevel_Fatal,HandshakeFailure)] tls-simpleserver: HandshakeFailed (Error_Protocol "credential not found" HandshakeFailure)

this commit adds a support for p384 and p521 curves with the limitation of not being able to generate in constant time. it also changes a test case to cover the original issue of 'credential not found'.

probablly this relates to the closed issue #424.

currently, a certificate generated with p384 curve key is not usable
with hs-tls.

```
openssl ecparam -out ec_key.pem -name secp384r1 -genkey
openssl req -new -key ec_key.pem -x509 -nodes -days 3650 -out ec_cert.pem
```

the server using hs-tls shows 'credential not found' message.

```
% ./dist-newstyle/build/x86_64-linux/ghc-9.6.7/tls-debug-0.4.8/x/tls-simpleserver/build/tls-simpleserver/tls-simpleserver -d -v --key ./ec_key.pem --certificate ./ec_cert.pem  4433

connection from 127.0.0.1:59262
debug: << Handshake [ClientHello (CH {chVersion = TLS1.2, chRandom = ClientRandom "b9928e6a7a414497d22acf44a9091cb783fd13691d91b73707f33379e74ac9e1", chSession = Session "9be672a956ddc3ada2e187984e83c8870bed292b0ffbe4ddaed222316b600680", chCiphers = [0xC02C,0xC0AD,0xCCA9,0xC02B,0xC0AC,0xC030,0xCCA8,0xC02F,0x1302,0x1303,0x1301,0x1304,0xC0AE,0xC0AF,0x1305], chComps = [0], chExtensions = [ServerName ["127.0.0.1"],SupportedGroups [X25519,X448,P256,FFDHE2048,FFDHE3072,FFDHE4096,P384,FFDHE6144,FFDHE8192,P521],EcPointFormatsSupported [EcPointFormat_Uncompressed],SignatureAlgorithms [(TLS13,Ed448),(TLS13,Ed25519),(SHA512,ECDSA),(SHA384,ECDSA),(SHA256,ECDSA),(TLS13,RSApssRSAeSHA512),(TLS13,RSApssRSAeSHA384),(TLS13,RSApssRSAeSHA256),(TLS13,RSApsspssSHA512),(TLS13,RSApsspssSHA384),(TLS13,RSApsspssSHA256),(SHA512,RSA),(SHA384,RSA),(SHA256,RSA),(SHA1,RSA),(SHA1,ECDSA)],ExtendedMainSecret,CompressCertificate [zlib],SessionTicket "",Versions [TLS1.3,TLS1.2],PskKeyExchangeModes [PSK_DHE_KE],PostHandshakeAuth,KeyShare [X25519],SecureRenegotiation "00"]})]
debug: >> Alert13 [(AlertLevel_Fatal,HandshakeFailure)] tls-simpleserver: HandshakeFailed (Error_Protocol "credential not found" HandshakeFailure)
```

this commit adds a support for p384 and p521 curves with the limitation
of not being able to generate in constant time.  it also changes a test
case to cover the original issue of 'credential not found'.

probablly this relates to the closed issue haskell-tls#424.

Signed-off-by: Hajime Tazaki <[email protected]>
@kazu-yamamoto kazu-yamamoto self-requested a review January 7, 2026 07:11
Copy link
Collaborator

@kazu-yamamoto kazu-yamamoto left a comment

Choose a reason for hiding this comment

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

Nice work!

kazu-yamamoto added a commit to kazu-yamamoto/hs-tls that referenced this pull request Jan 7, 2026
@kazu-yamamoto
Copy link
Collaborator

Rebased and merged. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants