packages feed

tls 1.3.5 → 1.3.6

raw patch · 17 files changed

+218/−91 lines, 17 filesdep ~basedep ~cryptonite

Dependency ranges changed: base, cryptonite

Files

Network/TLS/Extension.hs view
@@ -258,21 +258,32 @@  data NamedCurve =       SEC CurveName+    | BrainPool BrainPoolCurve     | NamedCurve_arbitrary_explicit_prime_curves     | NamedCurve_arbitrary_explicit_char2_curves     deriving (Show,Eq) --- FIXME: currently maximum crypto strength of our supported---        cipher suite is 128 bits. Not support 384 and 512.+data BrainPoolCurve =+      BrainPoolP512R1 -- 28+    | BrainPoolP384R1 -- 27+    | BrainPoolP256R1 -- 26+    deriving (Show,Eq)+ availableEllipticCurves :: [NamedCurve]-availableEllipticCurves = [SEC SEC_p160r1, SEC SEC_p224r1, SEC SEC_p256r1]+availableEllipticCurves = [SEC SEC_p256r1, SEC SEC_p521r1]  instance EnumSafe16 NamedCurve where     fromEnumSafe16 NamedCurve_arbitrary_explicit_prime_curves = 0xFF01     fromEnumSafe16 NamedCurve_arbitrary_explicit_char2_curves = 0xFF02     fromEnumSafe16 (SEC nc) = maybe (error "named curve: internal error") id $ fromCurveName nc+    fromEnumSafe16 (BrainPool BrainPoolP512R1) = 28+    fromEnumSafe16 (BrainPool BrainPoolP384R1) = 27+    fromEnumSafe16 (BrainPool BrainPoolP256R1) = 26     toEnumSafe16 0xFF01 = Just NamedCurve_arbitrary_explicit_prime_curves     toEnumSafe16 0xFF02 = Just NamedCurve_arbitrary_explicit_char2_curves+    toEnumSafe16 26     = Just (BrainPool BrainPoolP256R1)+    toEnumSafe16 27     = Just (BrainPool BrainPoolP384R1)+    toEnumSafe16 28     = Just (BrainPool BrainPoolP512R1)     toEnumSafe16 n      = SEC <$> toCurveName n  -- on decode, filter all unknown curves
Network/TLS/Extension/EC.hs view
@@ -33,6 +33,9 @@ toCurveName 23 = Just SEC_p256r1 toCurveName 24 = Just SEC_p384r1 toCurveName 25 = Just SEC_p521r1+--toCurveName 26 = Just  Brainpool_P256r1+--toCurveName 27 = Just Brainpool_P384r1+--toCurveName 28 = Just Brainpool_P512r1 toCurveName _  = Nothing  fromCurveName :: CurveName -> Maybe Word16
Network/TLS/Extra/Cipher.hs view
@@ -35,8 +35,11 @@     , cipher_DHE_DSS_RC4_SHA1     , cipher_DHE_RSA_AES128GCM_SHA256     , cipher_ECDHE_RSA_AES128GCM_SHA256+    , cipher_ECDHE_RSA_AES256GCM_SHA384     , cipher_ECDHE_RSA_AES128CBC_SHA256     , cipher_ECDHE_RSA_AES128CBC_SHA+    , cipher_ECDHE_RSA_AES256CBC_SHA+    , cipher_ECDHE_RSA_AES256CBC_SHA384     , cipher_ECDHE_ECDSA_AES128GCM_SHA256     ) where @@ -89,6 +92,24 @@             (output, aeadFinal) = aeadDecrypt aead input             tag                 = aeadFinalize aeadFinal 16 +aes256gcm :: BulkDirection -> BulkKey -> BulkAEAD+aes256gcm BulkEncrypt key =+    let ctx = noFail (cipherInit key) :: AES256+     in (\nonce d ad ->+            let aeadIni = noFail (aeadInit AEAD_GCM ctx nonce)+             in swap $ aeadSimpleEncrypt aeadIni ad d 16)+aes256gcm BulkDecrypt key =+    let ctx = noFail (cipherInit key) :: AES256+     in (\nonce d ad ->+            let aeadIni = noFail (aeadInit AEAD_GCM ctx nonce)+             in simpleDecrypt aeadIni ad d)+  where+    simpleDecrypt aeadIni header input = (output, tag)+      where+            aead                = aeadAppendHeader aeadIni header+            (output, aeadFinal) = aeadDecrypt aead input+            tag                 = aeadFinalize aeadFinal 16+ noFail :: CryptoFailable a -> a noFail = throwCryptoError @@ -118,7 +139,10 @@ -- this choice of ciphersuite should satisfy most normal need ciphersuite_all :: [Cipher] ciphersuite_all =-    [ cipher_ECDHE_RSA_AES128GCM_SHA256+    [ cipher_ECDHE_RSA_AES256GCM_SHA384+    , cipher_ECDHE_RSA_AES128GCM_SHA256+    , cipher_ECDHE_RSA_AES256CBC_SHA384+    , cipher_ECDHE_RSA_AES256CBC_SHA     , cipher_ECDHE_ECDSA_AES128GCM_SHA256     , cipher_DHE_RSA_AES256_SHA256, cipher_DHE_RSA_AES128_SHA256     , cipher_DHE_RSA_AES256_SHA1, cipher_DHE_RSA_AES128_SHA1@@ -136,7 +160,16 @@  -- | the strongest ciphers supported. ciphersuite_strong :: [Cipher]-ciphersuite_strong = [cipher_ECDHE_RSA_AES128GCM_SHA256, cipher_ECDHE_ECDSA_AES128GCM_SHA256, cipher_DHE_RSA_AES256_SHA256, cipher_AES256_SHA256, cipher_AES256_SHA1]+ciphersuite_strong =+    [ cipher_ECDHE_RSA_AES256GCM_SHA384+    , cipher_ECDHE_RSA_AES128GCM_SHA256+    , cipher_ECDHE_RSA_AES256CBC_SHA384+    , cipher_ECDHE_RSA_AES256CBC_SHA+    , cipher_ECDHE_ECDSA_AES128GCM_SHA256+    , cipher_DHE_RSA_AES256_SHA256+    , cipher_AES256_SHA256+    , cipher_AES256_SHA1+    ]  -- | DHE-RSA cipher suite ciphersuite_dhe_rsa :: [Cipher]@@ -151,7 +184,7 @@ ciphersuite_unencrypted :: [Cipher] ciphersuite_unencrypted = [cipher_null_MD5, cipher_null_SHA1] -bulk_null, bulk_rc4, bulk_aes128, bulk_aes256, bulk_tripledes_ede, bulk_aes128gcm :: Bulk+bulk_null, bulk_rc4, bulk_aes128, bulk_aes256, bulk_tripledes_ede, bulk_aes128gcm, bulk_aes256gcm :: Bulk bulk_null = Bulk     { bulkName         = "null"     , bulkKeySize      = 0@@ -194,6 +227,16 @@     , bulkF            = BulkAeadF aes128gcm     } +bulk_aes256gcm = Bulk+    { bulkName         = "AES256GCM"+    , bulkKeySize      = 32 -- RFC 5116 Sec 5.1: K_LEN+    , bulkIVSize       = 4  -- RFC 5288 GCMNonce.salt, fixed_iv_length+    , bulkExplicitIV   = 8+    , bulkAuthTagLen   = 16+    , bulkBlockSize    = 0  -- dummy, not used+    , bulkF            = BulkAeadF aes256gcm+    }+ bulk_aes256 = Bulk     { bulkName         = "AES256"     , bulkKeySize      = 32@@ -269,6 +312,28 @@     , cipherMinVer       = Just SSL3     } +-- | AES cipher (128 bit key), DHE key exchanged signed by DSA and SHA1 for digest+cipher_DHE_DSS_AES128_SHA1 :: Cipher+cipher_DHE_DSS_AES128_SHA1 = Cipher+    { cipherID           = 0x32+    , cipherName         = "DHE-DSA-AES128-SHA1"+    , cipherBulk         = bulk_aes128+    , cipherHash         = SHA1+    , cipherKeyExchange  = CipherKeyExchange_DHE_DSS+    , cipherMinVer       = Nothing+    }++-- | AES cipher (128 bit key), DHE key exchanged signed by RSA and SHA1 for digest+cipher_DHE_RSA_AES128_SHA1 :: Cipher+cipher_DHE_RSA_AES128_SHA1 = Cipher+    { cipherID           = 0x33+    , cipherName         = "DHE-RSA-AES128-SHA1"+    , cipherBulk         = bulk_aes128+    , cipherHash         = SHA1+    , cipherKeyExchange  = CipherKeyExchange_DHE_RSA+    , cipherMinVer       = Nothing+    }+ -- | AES cipher (256 bit key), RSA key exchange and SHA1 for digest cipher_AES256_SHA1 :: Cipher cipher_AES256_SHA1 = Cipher@@ -280,6 +345,22 @@     , cipherMinVer       = Just SSL3     } +-- | AES cipher (256 bit key), DHE key exchanged signed by DSA and SHA1 for digest+cipher_DHE_DSS_AES256_SHA1 :: Cipher+cipher_DHE_DSS_AES256_SHA1 = cipher_DHE_DSS_AES128_SHA1+    { cipherID           = 0x38+    , cipherName         = "DHE-DSA-AES256-SHA1"+    , cipherBulk         = bulk_aes256+    }++-- | AES cipher (256 bit key), DHE key exchanged signed by RSA and SHA1 for digest+cipher_DHE_RSA_AES256_SHA1 :: Cipher+cipher_DHE_RSA_AES256_SHA1 = cipher_DHE_RSA_AES128_SHA1+    { cipherID           = 0x39+    , cipherName         = "DHE-RSA-AES256-SHA1"+    , cipherBulk         = bulk_aes256+    }+ -- | AES cipher (128 bit key), RSA key exchange and SHA256 for digest cipher_AES128_SHA256 :: Cipher cipher_AES128_SHA256 = Cipher@@ -302,44 +383,7 @@     , cipherMinVer       = Just TLS12     } --- | AES cipher (128 bit key), DHE key exchanged signed by RSA and SHA1 for digest-cipher_DHE_RSA_AES128_SHA1 :: Cipher-cipher_DHE_RSA_AES128_SHA1 = Cipher-    { cipherID           = 0x33-    , cipherName         = "DHE-RSA-AES128-SHA1"-    , cipherBulk         = bulk_aes128-    , cipherHash         = SHA1-    , cipherKeyExchange  = CipherKeyExchange_DHE_RSA-    , cipherMinVer       = Nothing-    } --- | AES cipher (256 bit key), DHE key exchanged signed by RSA and SHA1 for digest-cipher_DHE_RSA_AES256_SHA1 :: Cipher-cipher_DHE_RSA_AES256_SHA1 = cipher_DHE_RSA_AES128_SHA1-    { cipherID           = 0x39-    , cipherName         = "DHE-RSA-AES256-SHA1"-    , cipherBulk         = bulk_aes256-    }---- | AES cipher (128 bit key), DHE key exchanged signed by DSA and SHA1 for digest-cipher_DHE_DSS_AES128_SHA1 :: Cipher-cipher_DHE_DSS_AES128_SHA1 = Cipher-    { cipherID           = 0x32-    , cipherName         = "DHE-DSA-AES128-SHA1"-    , cipherBulk         = bulk_aes128-    , cipherHash         = SHA1-    , cipherKeyExchange  = CipherKeyExchange_DHE_DSS-    , cipherMinVer       = Nothing-    }---- | AES cipher (256 bit key), DHE key exchanged signed by DSA and SHA1 for digest-cipher_DHE_DSS_AES256_SHA1 :: Cipher-cipher_DHE_DSS_AES256_SHA1 = cipher_DHE_DSS_AES128_SHA1-    { cipherID           = 0x38-    , cipherName         = "DHE-DSA-AES256-SHA1"-    , cipherBulk         = bulk_aes256-    }- cipher_DHE_DSS_RC4_SHA1 :: Cipher cipher_DHE_DSS_RC4_SHA1 = cipher_DHE_DSS_AES128_SHA1     { cipherID           = 0x66@@ -383,16 +427,6 @@     , cipherMinVer       = Just TLS12 -- RFC 5288 Sec 4     } -cipher_ECDHE_RSA_AES128GCM_SHA256 :: Cipher-cipher_ECDHE_RSA_AES128GCM_SHA256 = Cipher-    { cipherID           = 0xc02f-    , cipherName         = "ECDHE-RSA-AES128GCM-SHA256"-    , cipherBulk         = bulk_aes128gcm-    , cipherHash         = SHA256-    , cipherKeyExchange  = CipherKeyExchange_ECDHE_RSA-    , cipherMinVer       = Just TLS12 -- RFC 5288 Sec 4-    }- cipher_ECDHE_RSA_AES128CBC_SHA :: Cipher cipher_ECDHE_RSA_AES128CBC_SHA = Cipher     { cipherID           = 0xc013@@ -403,17 +437,36 @@     , cipherMinVer       = Just TLS10     } ---TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 +cipher_ECDHE_RSA_AES256CBC_SHA :: Cipher+cipher_ECDHE_RSA_AES256CBC_SHA = Cipher+    { cipherID           = 0xc014+    , cipherName         = "ECDHE-RSA-AES256CBC-SHA"+    , cipherBulk         = bulk_aes256+    , cipherHash         = SHA1+    , cipherKeyExchange  = CipherKeyExchange_ECDHE_RSA+    , cipherMinVer       = Just TLS10+    }+ cipher_ECDHE_RSA_AES128CBC_SHA256 :: Cipher cipher_ECDHE_RSA_AES128CBC_SHA256 = Cipher     { cipherID           = 0xc027-    , cipherName         = "ECDHE-RSA-AES128CBC-SHA"+    , cipherName         = "ECDHE-RSA-AES128CBC-SHA256"     , cipherBulk         = bulk_aes128     , cipherHash         = SHA256     , cipherKeyExchange  = CipherKeyExchange_ECDHE_RSA     , cipherMinVer       = Just TLS12 -- RFC 5288 Sec 4     } +cipher_ECDHE_RSA_AES256CBC_SHA384 :: Cipher+cipher_ECDHE_RSA_AES256CBC_SHA384 = Cipher+    { cipherID           = 0xc027+    , cipherName         = "ECDHE-RSA-AES256CBC-SHA384"+    , cipherBulk         = bulk_aes256+    , cipherHash         = SHA384+    , cipherKeyExchange  = CipherKeyExchange_ECDHE_RSA+    , cipherMinVer       = Just TLS12 -- RFC 5288 Sec 4+    }+ cipher_ECDHE_ECDSA_AES128GCM_SHA256 :: Cipher cipher_ECDHE_ECDSA_AES128GCM_SHA256 = Cipher     { cipherID           = 0xc02b@@ -423,6 +476,27 @@     , cipherKeyExchange  = CipherKeyExchange_ECDHE_ECDSA     , cipherMinVer       = Just TLS12 -- RFC 5289     }++cipher_ECDHE_RSA_AES128GCM_SHA256 :: Cipher+cipher_ECDHE_RSA_AES128GCM_SHA256 = Cipher+    { cipherID           = 0xc02f+    , cipherName         = "ECDHE-RSA-AES128GCM-SHA256"+    , cipherBulk         = bulk_aes128gcm+    , cipherHash         = SHA256+    , cipherKeyExchange  = CipherKeyExchange_ECDHE_RSA+    , cipherMinVer       = Just TLS12 -- RFC 5288 Sec 4+    }++cipher_ECDHE_RSA_AES256GCM_SHA384 :: Cipher+cipher_ECDHE_RSA_AES256GCM_SHA384 = Cipher+    { cipherID           = 0xc030+    , cipherName         = "ECDHE-RSA-AES256GCM-SHA256"+    , cipherBulk         = bulk_aes256gcm+    , cipherHash         = SHA384+    , cipherKeyExchange  = CipherKeyExchange_ECDHE_RSA+    , cipherMinVer       = Just TLS12 -- RFC 5289+    }+ {- TLS 1.0 ciphers definition 
Network/TLS/Handshake/Client.hs view
@@ -21,6 +21,7 @@ import Network.TLS.ErrT import Network.TLS.Extension import Network.TLS.IO+import Network.TLS.Imports import Network.TLS.State hiding (getNegotiatedProtocol) import Network.TLS.Measurement import Network.TLS.Wire (encodeWord16)@@ -32,7 +33,6 @@ import qualified Data.ByteString as B import Data.ByteString.Char8 () -import Control.Applicative ((<$>), (<*>)) import Control.Monad.State import Control.Exception (SomeException) @@ -75,7 +75,7 @@                                  ]          toExtensionRaw :: Extension e => e -> ExtensionRaw-        toExtensionRaw ext = (extensionID ext, extensionEncode ext)+        toExtensionRaw ext = ExtensionRaw (extensionID ext) (extensionEncode ext)          secureReneg  =                 if supportedSecureRenegotiation $ ctxSupported ctx@@ -114,7 +114,7 @@                 [ ClientHello highestVer crand clientSession (map cipherID ciphers)                               (map compressionID compressions) extensions Nothing                 ]-            return $ map fst extensions+            return $ map (\(ExtensionRaw i _) -> i) extensions          sendMaybeNPN = do             suggest <- usingState_ ctx $ getServerNextProtocolSuggest@@ -262,8 +262,8 @@                  _ -> return () -processServerExtension :: (ExtensionID, Bytes) -> TLSSt ()-processServerExtension (0xff01, content) = do+processServerExtension :: ExtensionRaw -> TLSSt ()+processServerExtension (ExtensionRaw 0xff01 content) = do     cv <- getVerifiedData ClientRole     sv <- getVerifiedData ServerRole     let bs = extensionEncode (SecureRenegotiation cv $ Just sv)@@ -300,7 +300,7 @@      -- intersect sent extensions in client and the received extensions from server.     -- if server returns extensions that we didn't request, fail.-    when (not $ null $ filter (not . flip elem sentExts . fst) exts) $+    when (not $ null $ filter (not . flip elem sentExts . (\(ExtensionRaw i _) -> i)) exts) $         throwCore $ Error_Protocol ("spurious extensions received", True, UnsupportedExtension)      let resumingSession =@@ -313,7 +313,7 @@         setVersion rver     usingHState ctx $ setServerHelloParameters rver serverRan cipherAlg compressAlg -    case extensionDecode False `fmap` (lookup extensionID_ApplicationLayerProtocolNegotiation exts) of+    case extensionDecode False `fmap` (extensionLookup extensionID_ApplicationLayerProtocolNegotiation exts) of         Just (Just (ApplicationLayerProtocolNegotiation [proto])) -> usingState_ ctx $ do             mprotos <- getClientALPNSuggest             case mprotos of@@ -323,7 +323,7 @@                 _ -> return ()         _ -> return () -    case extensionDecode False `fmap` (lookup extensionID_NextProtocolNegotiation exts) of+    case extensionDecode False `fmap` (extensionLookup extensionID_NextProtocolNegotiation exts) of         Just (Just (NextProtocolNegotiation protos)) -> usingState_ ctx $ do             alpnDone <- getExtensionALPN             unless alpnDone $ do
Network/TLS/Handshake/Common.hs view
@@ -13,6 +13,7 @@     , runRecvState     , recvPacketHandshake     , onRecvStateHandshake+    , extensionLookup     ) where  import Control.Concurrent.MVar@@ -30,6 +31,7 @@ import Network.TLS.Types import Network.TLS.Cipher import Network.TLS.Util+import Data.List (find) import Data.ByteString.Char8 ()  import Control.Monad.State@@ -132,3 +134,6 @@                         , sessionCipher  = cipherID $ fromJust "cipher" $ stCipher tx                         , sessionSecret  = ms                         }++extensionLookup toFind = fmap (\(ExtensionRaw _ content) -> content)+                       . find (\(ExtensionRaw eid content) -> eid == toFind)
Network/TLS/Handshake/Process.hs view
@@ -57,7 +57,7 @@   where secureRenegotiation = supportedSecureRenegotiation $ ctxSupported ctx         -- RFC5746: secure renegotiation         -- the renegotiation_info extension: 0xff01-        processClientExtension (0xff01, content) | secureRenegotiation = do+        processClientExtension (ExtensionRaw 0xff01 content) | secureRenegotiation = do             v <- getVerifiedData ClientRole             let bs = extensionEncode (SecureRenegotiation v Nothing)             unless (bs `bytesEq` content) $ throwError $ Error_Protocol ("client verified data not matching: " ++ show v ++ ":" ++ show content, True, HandshakeFailure)
Network/TLS/Handshake/Server.hs view
@@ -12,6 +12,7 @@     ) where  import Network.TLS.Parameters+import Network.TLS.Imports import Network.TLS.Context.Internal import Network.TLS.Session import Network.TLS.Struct@@ -28,13 +29,11 @@ import Network.TLS.Handshake.Process import Network.TLS.Handshake.Key import Network.TLS.Measurement-import Data.Monoid import Data.Maybe (isJust, listToMaybe, mapMaybe) import Data.List (intersect, sortBy) import qualified Data.ByteString as B import Data.ByteString.Char8 () -import Control.Applicative ((<$>)) import Control.Monad.State  import Network.TLS.Handshake.Signature@@ -112,7 +111,7 @@     when (null commonCompressions) $ throwCore $         Error_Protocol ("no compression in common with the client", True, HandshakeFailure) -    let serverName = case extensionDecode False `fmap` (lookup extensionID_ServerName exts) of+    let serverName = case extensionDecode False `fmap` (extensionLookup extensionID_ServerName exts) of             Just (Just (ServerName ns)) -> listToMaybe (mapMaybe toHostName ns)                 where toHostName (ServerNameHostName hostName) = Just hostName                       toHostName (ServerNameOther _)           = Nothing@@ -136,17 +135,17 @@      maybe (return ()) (usingState_ ctx . setClientSNI) serverName -    case extensionDecode False `fmap` (lookup extensionID_ApplicationLayerProtocolNegotiation exts) of+    case extensionDecode False `fmap` (extensionLookup extensionID_ApplicationLayerProtocolNegotiation exts) of         Just (Just (ApplicationLayerProtocolNegotiation protos)) -> usingState_ ctx $ setClientALPNSuggest protos         _ -> return () -    case extensionDecode False `fmap` (lookup extensionID_EllipticCurves exts) of+    case extensionDecode False `fmap` (extensionLookup extensionID_EllipticCurves exts) of         Just (Just (EllipticCurvesSupported es)) -> usingState_ ctx $ setClientEllipticCurveSuggest es         _ -> return ()      -- Currently, we don't send back EcPointFormats. In this case,     -- the client chooses EcPointFormat_Uncompressed.-    case extensionDecode False `fmap` (lookup extensionID_EcPointFormats exts) of+    case extensionDecode False `fmap` (extensionLookup extensionID_EcPointFormats exts) of         Just (Just (EcPointFormatsSupported fs)) -> usingState_ ctx $ setClientEcPointFormatSuggest fs         _ -> return () @@ -163,7 +162,7 @@  doHandshake :: ServerParams -> Maybe Credential -> Context -> Version -> Cipher             -> Compression -> Session -> Maybe SessionData-            -> [(ExtensionID, a)] -> IO ()+            -> [ExtensionRaw] -> IO () doHandshake sparams mcred ctx chosenVersion usedCipher usedCompression clientSession resumeSessionData exts = do     case resumeSessionData of         Nothing -> do@@ -181,8 +180,8 @@             recvChangeCipherAndFinish ctx     handshakeTerminate ctx   where-        clientRequestedNPN = isJust $ lookup extensionID_NextProtocolNegotiation exts-        clientALPNSuggest = isJust $ lookup extensionID_ApplicationLayerProtocolNegotiation exts+        clientRequestedNPN = isJust $ extensionLookup extensionID_NextProtocolNegotiation exts+        clientALPNSuggest = isJust $ extensionLookup extensionID_ApplicationLayerProtocolNegotiation exts          applicationProtocol = do             protos <- alpn@@ -196,8 +195,8 @@                     usingState_ ctx $ do                         setExtensionALPN True                         setNegotiatedProtocol proto-                    return $ [ ( extensionID_ApplicationLayerProtocolNegotiation-                                                                                                               , extensionEncode $ ApplicationLayerProtocolNegotiation [proto]) ]+                    return $ [ ExtensionRaw extensionID_ApplicationLayerProtocolNegotiation+                                            (extensionEncode $ ApplicationLayerProtocolNegotiation [proto]) ]                 (_, _)                  -> return []              | otherwise = return []         npn = do@@ -210,8 +209,8 @@                     usingState_ ctx $ do                         setExtensionNPN True                         setServerNextProtocolSuggest protos-                    return [ ( extensionID_NextProtocolNegotiation-                             , extensionEncode $ NextProtocolNegotiation protos) ]+                    return [ ExtensionRaw extensionID_NextProtocolNegotiation+                             (extensionEncode $ NextProtocolNegotiation protos) ]                 Nothing -> return []  @@ -235,7 +234,7 @@                                     cvf <- getVerifiedData ClientRole                                     svf <- getVerifiedData ServerRole                                     return $ extensionEncode (SecureRenegotiation cvf $ Just svf)-                            return [ (0xff01, vf) ]+                            return [ ExtensionRaw 0xff01 vf ]                     else return []             protoExt <- applicationProtocol             let extensions = secRengExt ++ protoExt
Network/TLS/Handshake/Signature.hs view
@@ -19,6 +19,7 @@ import Network.TLS.Crypto import Network.TLS.Context.Internal import Network.TLS.Struct+import Network.TLS.Imports import Network.TLS.Packet (generateCertificateVerify_SSL, encodeSignedDHParams, encodeSignedECDHParams) import Network.TLS.Parameters (supportedHashSignatures) import Network.TLS.State@@ -26,7 +27,6 @@ import Network.TLS.Handshake.Key import Network.TLS.Util -import Control.Applicative import Control.Monad.State  certificateVerifyCheck :: Context
+ Network/TLS/Imports.hs view
@@ -0,0 +1,26 @@+-- |+-- Module      : Network.TLS.Imports+-- License     : BSD-style+-- Maintainer  : Vincent Hanquez <vincent@snarc.org>+-- Stability   : experimental+-- Portability : unknown+--+module Network.TLS.Imports+    (+    -- generic exports+      module E+    -- project definition+    , Bytes+    , showBytesHex+    ) where++import qualified Control.Applicative as E+import qualified Data.Monoid as E++import qualified Data.ByteString as B+import           Data.ByteArray.Encoding as B++type Bytes = B.ByteString++showBytesHex :: Bytes -> String+showBytesHex bs = show (B.convertToBase B.Base16 bs :: Bytes)
Network/TLS/Packet.hs view
@@ -58,12 +58,12 @@     , putSignatureHashAlgorithm     ) where +import Network.TLS.Imports import Network.TLS.Struct import Network.TLS.Wire import Network.TLS.Cap import Data.Maybe (fromJust) import Data.Word-import Control.Applicative ((<$>), (<*>)) import Control.Monad import Data.ASN1.Types (fromASN1, toASN1) import Data.ASN1.Encoding (decodeASN1', encodeASN1')@@ -474,10 +474,10 @@     extdatalen <- getWord16     extdata <- getBytes $ fromIntegral extdatalen     extxs <- getExtensions (len - fromIntegral extdatalen - 4)-    return $ (extty, extdata) : extxs+    return $ ExtensionRaw extty extdata : extxs  putExtension :: ExtensionRaw -> Put-putExtension (ty, l) = putWord16 ty >> putOpaque16 l+putExtension (ExtensionRaw ty l) = putWord16 ty >> putOpaque16 l  putExtensions :: [ExtensionRaw] -> Put putExtensions [] = return ()
Network/TLS/Parameters.hs view
@@ -34,7 +34,6 @@ import Network.TLS.Credentials import Network.TLS.X509 import Network.TLS.RNG (Seed)-import Data.Monoid import Data.Default.Class import qualified Data.ByteString as B 
Network/TLS/State.hs view
@@ -57,7 +57,7 @@     , withRNG     ) where -import Control.Applicative+import Network.TLS.Imports import Network.TLS.Struct import Network.TLS.RNG import Network.TLS.Types (Role(..))
Network/TLS/Struct.hs view
@@ -17,7 +17,7 @@     , CipherType(..)     , CipherData(..)     , ExtensionID-    , ExtensionRaw+    , ExtensionRaw(..)     , CertificateType(..)     , HashAlgorithm(..)     , SignatureAlgorithm(..)@@ -71,13 +71,12 @@ import Network.TLS.Crypto.DH import Network.TLS.Crypto.ECDH import Network.TLS.Util.Serialization+import Network.TLS.Imports #if MIN_VERSION_mtl(2,2,1) #else import Control.Monad.Error #endif -type Bytes = ByteString- data ConnectionEnd = ConnectionServer | ConnectionClient data CipherType = CipherStream | CipherBlock | CipherAEAD @@ -180,7 +179,12 @@  type FinishedData = Bytes type ExtensionID  = Word16-type ExtensionRaw = (ExtensionID, Bytes)++data ExtensionRaw = ExtensionRaw ExtensionID Bytes+    deriving (Eq)++instance Show ExtensionRaw where+    show (ExtensionRaw eid bs) = "ExtensionRaw " ++ show eid ++ " " ++ showBytesHex bs ++ ""  constrRandom32 :: (Bytes -> a) -> Bytes -> Maybe a constrRandom32 constr l = if B.length l == 32 then Just (constr l) else Nothing
Network/TLS/Util.hs view
@@ -13,7 +13,7 @@         ) where  import Data.List (foldl')-import Network.TLS.Struct (Bytes)+import Network.TLS.Imports (Bytes) import qualified Data.ByteString as B  import Control.Exception (SomeException)
Tests/Connection.hs view
@@ -32,6 +32,8 @@         { bulkName      = "id"         , bulkKeySize   = 16         , bulkIVSize    = 16+        , bulkExplicitIV= 0+        , bulkAuthTagLen= 0         , bulkBlockSize = 16         , bulkF         = BulkBlockF $ \_ _ _ -> (\m -> (m, B.empty))         }@@ -61,6 +63,8 @@         { bulkName      = "stream"         , bulkKeySize   = 16         , bulkIVSize    = 0+        , bulkExplicitIV= 0+        , bulkAuthTagLen= 0         , bulkBlockSize = 0         , bulkF         = BulkStreamF passThrough         }
Tests/PubKey.hs view
@@ -56,6 +56,7 @@ dhParams = DH.Params     { DH.params_p = 0x00ccaa3884b50789ebea8d39bef8bbc66e20f2a78f537a76f26b4edde5de8b0ff15a8193abf0873cbdc701323a2bf6e860affa6e043fe8300d47e95baf9f6354cb     , DH.params_g = 0x2+    , DH.params_bits = 512     }  dsaParams :: DSA.Params
tls.cabal view
@@ -1,5 +1,5 @@ Name:                tls-Version:             1.3.5+Version:             1.3.6 Description:    Native Haskell TLS and SSL protocol implementation for server and client.    .@@ -48,7 +48,7 @@                    , data-default-class                    -- crypto related                    , memory-                   , cryptonite >= 0.14+                   , cryptonite >= 0.15                    -- certificate related                    , asn1-types >= 0.2.0                    , asn1-encoding@@ -92,6 +92,7 @@                      Network.TLS.Handshake.State                      Network.TLS.Hooks                      Network.TLS.IO+                     Network.TLS.Imports                      Network.TLS.MAC                      Network.TLS.Measurement                      Network.TLS.Packet