tls 0.8.1 → 0.8.2
raw patch · 3 files changed
+38/−38 lines, 3 filesdep +test-frameworkdep +test-framework-quickcheck2dep −HUnitdep ~certificatedep ~cryptocipher
Dependencies added: test-framework, test-framework-quickcheck2
Dependencies removed: HUnit
Dependency ranges changed: certificate, cryptocipher
Files
- Network/TLS/Receiving.hs +2/−6
- Tests.hs +30/−28
- tls.cabal +6/−4
Network/TLS/Receiving.hs view
@@ -31,8 +31,6 @@ import Network.TLS.Crypto import Data.Certificate.X509 -import qualified Crypto.Cipher.RSA as RSA- returnEither :: Either TLSError a -> TLSSt a returnEither (Left err) = throwError err returnEither (Right a) = return a@@ -253,7 +251,5 @@ processCertificates certs = do let (X509 mainCert _ _ _ _) = head certs case certPubKey mainCert of- PubKeyRSA (lm, m, e) -> do- let pk = PubRSA (RSA.PublicKey { RSA.public_sz = fromIntegral lm, RSA.public_n = m, RSA.public_e = e })- setPublicKey pk- _ -> return ()+ PubKeyRSA pubkey -> setPublicKey (PubRSA pubkey)+ _ -> return ()
Tests.hs view
@@ -2,6 +2,8 @@ import Test.QuickCheck import Test.QuickCheck.Test+import Test.Framework (defaultMain, testGroup)+import Test.Framework.Providers.QuickCheck2 (testProperty) --import Tests.Certificate @@ -13,7 +15,7 @@ import Network.TLS.Struct import Network.TLS.Packet import Control.Monad-import Control.Applicative ((<$>))+import Control.Applicative import System.IO genByteString :: Int -> Gen B.ByteString@@ -39,16 +41,16 @@ #endif instance Arbitrary Header where- arbitrary = liftM3 Header arbitrary arbitrary arbitrary+ arbitrary = Header <$> arbitrary <*> arbitrary <*> arbitrary instance Arbitrary ClientRandom where- arbitrary = liftM ClientRandom (genByteString 32)+ arbitrary = ClientRandom <$> (genByteString 32) instance Arbitrary ServerRandom where- arbitrary = liftM ServerRandom (genByteString 32)+ arbitrary = ServerRandom <$> (genByteString 32) instance Arbitrary ClientKeyData where- arbitrary = liftM ClientKeyData (genByteString 46)+ arbitrary = ClientKeyData <$> (genByteString 46) instance Arbitrary Session where arbitrary = do@@ -70,21 +72,30 @@ , CertificateType_RSA_Ephemeral_DH, CertificateType_DSS_Ephemeral_DH , CertificateType_fortezza_dms ] --- we hardcode the pubkey for generated X509. at later stage this will be generated as well.-pubkey = PubKeyRSA (1,2,3)- instance Arbitrary Handshake where arbitrary = oneof- [ liftM6 ClientHello arbitrary arbitrary arbitrary arbitraryCiphersIDs arbitraryCompressionIDs (return [])- , liftM6 ServerHello arbitrary arbitrary arbitrary arbitrary arbitrary (return [])+ [ ClientHello+ <$> arbitrary+ <*> arbitrary+ <*> arbitrary+ <*> arbitraryCiphersIDs+ <*> arbitraryCompressionIDs+ <*> (return [])+ , ServerHello+ <$> arbitrary+ <*> arbitrary+ <*> arbitrary+ <*> arbitrary+ <*> arbitrary+ <*> (return []) --, liftM Certificates (resize 2 $ listOf $ arbitraryX509 pubkey)- , return HelloRequest- , return ServerHelloDone- , liftM2 ClientKeyXchg arbitrary arbitrary+ , pure HelloRequest+ , pure ServerHelloDone+ , ClientKeyXchg <$> arbitrary <*> arbitrary --, liftM ServerKeyXchg --, liftM3 CertRequest arbitrary (return Nothing) (return []) --, liftM CertVerify (return [])- , liftM Finished (genByteString 12)+ , Finished <$> (genByteString 12) ] {- quickcheck property -}@@ -95,18 +106,9 @@ decodeHs b = either (Left . id) (uncurry (decodeHandshake cp) . head) $ decodeHandshakes b cp = CurrentParams { cParamsVersion = TLS10, cParamsKeyXchgType = CipherKeyExchange_RSA } -myQuickCheckArgs = stdArgs- { replay = Nothing- , maxSuccess = 500- , maxDiscard = 2000- , maxSize = 500- }--run_test n t =- putStr (" " ++ n ++ " ... ") >> hFlush stdout >> quickCheckWith myQuickCheckArgs t--liftM6 f m1 m2 m3 m4 m5 m6 = do { x1 <- m1; x2 <- m2; x3 <- m3; x4 <- m4; x5 <- m5; x6 <- m6; return (f x1 x2 x3 x4 x5 x6) }+tests = testGroup "Marshalling"+ [ testProperty "Header" prop_header_marshalling_id+ , testProperty "Handshake" prop_handshake_marshalling_id+ ] -main = do- run_test "marshalling header = id" prop_header_marshalling_id- run_test "marshalling handshake = id" prop_handshake_marshalling_id+main = defaultMain [ tests ]
tls.cabal view
@@ -1,5 +1,5 @@ Name: tls-Version: 0.8.1+Version: 0.8.2 Description: Native Haskell TLS and SSL protocol implementation for server and client. .@@ -41,8 +41,8 @@ , cereal >= 0.3 , bytestring , crypto-api >= 0.5- , cryptocipher >= 0.2.5- , certificate >= 0.9.4 && < 1.0+ , cryptocipher >= 0.3.0+ , certificate >= 1.0.0 && < 1.1.0 Exposed-modules: Network.TLS Network.TLS.Cipher Network.TLS.Compression@@ -66,11 +66,13 @@ if flag(test) Buildable: True Build-Depends: base >= 3 && < 5- , HUnit , QuickCheck >= 2+ , test-framework+ , test-framework-quickcheck2 , bytestring else Buildable: False+ ghc-options: -Wall -fhpc source-repository head type: git