packages feed

tls 2.4.14 → 2.4.15

raw patch · 6 files changed

+65/−7 lines, 6 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,5 +1,10 @@ # Change log for "tls" +## Version 2.4.15++* Order key_share as supported_groups.+  [#642](https://github.com/haskell-tls/hs-tls/pull/642)+ ## Version 2.4.14  * Require hpke 0.4.
Network/TLS/Crypto/Types.hs view
@@ -110,7 +110,10 @@ --   implementation. supportedNamedGroups :: [Group] supportedNamedGroups =-    [ X25519 -- 128 bits security+    [ X25519MLKEM768+    , P256MLKEM768+    , P384MLKEM1024+    , X25519 -- 128 bits security     , P256 -- 128 bits security     , P384 -- 192 bits security     , X448 -- 224 bits security@@ -120,9 +123,6 @@     , FFDHE4096 -- 150 bits security     , FFDHE6144 -- 175 bits security     , FFDHE8192 -- 192 bits security-    , X25519MLKEM768-    , P256MLKEM768-    , P384MLKEM1024     , -- , MLKEM512       MLKEM768     , MLKEM1024
Network/TLS/Handshake/Client.hs view
@@ -67,7 +67,11 @@     handshake cparams ctx grps Nothing   where     groupsSupported = supportedGroups (ctxSupported ctx)-    groupsSelected = onSelectKeyShareGroups (clientHooks cparams) groupsSupported+    -- RFC 9846 Section 4.3.8: key shares follow "supported_groups" in its+    -- order, whatever the hook returns.+    groupsSelected =+        let selected = onSelectKeyShareGroups (clientHooks cparams) groupsSupported+         in filter (`elem` selected) groupsSupported  -- https://tools.ietf.org/html/rfc8446#section-4.1.2 says: -- "The client will also send a
Network/TLS/Parameters.hs view
@@ -410,7 +410,7 @@     --   The default value includes all groups with security strength     --   of 128 bits or more.     ---    --   Default: @[X25519,P256,P384,X448,P521,FFDHE3072,FFDHE4096,FFDHE6144,FFDHE8192,X25519MLKEM768,P256MLKEM768,P384MLKEM1024,MLKEM768,MLKEM1024]@+    --   Default: @[X25519MLKEM768,P256MLKEM768,P384MLKEM1024,X25519,P256,P384,X448,P521,FFDHE3072,FFDHE4096,FFDHE6144,FFDHE8192,MLKEM768,MLKEM1024]@     , supportedGroupsTLS13 :: [[Group]]     -- ^ The inside @[Group]@ is the list of @Group@ at the same level     -- in preferred order.  The inside @[Group]@s are also listed in@@ -677,6 +677,8 @@     -- ^ A function to select groups in "key_share" by TLS 1.3 client.     --     --   Client's 'supportedGroups' is passed as the 1st argument.+    --   The result is put in the order of 'supportedGroups', and+    --   groups not in it are dropped (RFC 9846 Section 4.3.8).     --     --   The default function specifies a pair of hybrid (classical +     --   post quantum) group and classical group to transit from
test/HandshakeSpec.hs view
@@ -240,6 +240,10 @@             handshake13_mldsa_wrong_scheme         it "rejects an X25519MLKEM768 key share with a zero X25519 part" $             handshake13_x25519mlkem768_zero_x25519+        it "orders key_share as supported_groups by default" $+            handshake13_key_share_order id+        it "orders key_share as supported_groups whatever the hook returns" $+            handshake13_key_share_order (const [FFDHE2048, X25519, X25519MLKEM768])         prop "can handshake with TLS 1.3 Post-handshake auth" post_handshake_auth         it             "keeps record alignment when a slow record follows client auth"@@ -2865,6 +2869,49 @@         | grp == X25519MLKEM768 =             KeyShareEntry grp $ B.take 1184 key <> B.replicate 32 0     zeroEntry kse = kse++-- RFC 9846 Section 4.3.8: the key shares appear in the order of+-- supported_groups.  FFDHE2048 is not in the default supported_groups.+handshake13_key_share_order :: ([Group] -> [Group]) -> IO ()+handshake13_key_share_order hook = do+    CSP13 (cli, srv) <- generate arbitrary+    let select = hook . onSelectKeyShareGroups defaultClientHooks+        params =+            ( cli+                { clientSupported =+                    (clientSupported cli){supportedGroups = supportedNamedGroups}+                , clientHooks = (clientHooks cli){onSelectKeyShareGroups = select}+                }+            , srv+                { serverSupported =+                    (serverSupported srv)+                        { supportedGroups = supportedNamedGroups+                        , supportedGroupsTLS13 = supportedGroupsTLS13 defaultSupported+                        }+                }+            )+    hellos <- newIORef []+    withPairContextWith (id, id) params $ \(cctx, sctx) -> do+        contextHookSetHandshakeRecv sctx $ \hs -> do+            case hs of+                ClientHello ch -> modifyIORef hellos (ch :)+                _ -> return ()+            return hs+        concurrently_ (handshake sctx) (handshake cctx)+    chs <- readIORef hellos+    chs `shouldNotBe` []+    forM_ chs $ \ch -> do+        let exts = chExtensions ch+            groups = case extensionLookup EID_SupportedGroups exts+                >>= extensionDecode MsgTClientHello of+                Just (SupportedGroups gs) -> gs+                Nothing -> []+            shares = case extensionLookup EID_KeyShare exts+                >>= extensionDecode MsgTClientHello of+                Just (KeyShareClientHello kses) -> map keyShareEntryGroup kses+                _ -> []+        shares `shouldNotBe` []+        shares `shouldSatisfy` (`isSubsequenceOf` groups)  serverRejectedZeroX25519 :: TLSException -> Bool serverRejectedZeroX25519 (HandshakeFailed (Error_Protocol msg alert)) =
tls.cabal view
@@ -1,6 +1,6 @@ cabal-version:      2.0 name:               tls-version:            2.4.14+version:            2.4.15 license:            BSD3 license-file:       LICENSE copyright:          Vincent Hanquez <vincent@snarc.org>