tls-debug 0.4.1 → 0.4.2
raw patch · 4 files changed
+33/−4 lines, 4 filesdep ~cryptonite
Dependency ranges changed: cryptonite
Files
- src/RetrieveCertificate.hs +1/−0
- src/SimpleClient.hs +16/−2
- src/SimpleServer.hs +14/−0
- tls-debug.cabal +2/−2
src/RetrieveCertificate.hs view
@@ -104,6 +104,7 @@ case other of [destination,port] -> doMain destination port opts+ [destination] -> doMain destination "443" opts _ -> printUsage >> exitFailure where outputFormat [] = "simple"
src/SimpleClient.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-}+import Crypto.Random import Network.BSD import Network.Socket (socket, Family(..), SocketType(..), sClose, SockAddr(..), connect) import Network.TLS@@ -91,13 +92,17 @@ , sharedCredentials = maybe mempty fst certCredsRequest } , clientHooks = def { onCertificateRequest = maybe (onCertificateRequest def) snd certCredsRequest }+ , clientDebug = def { debugSeed = foldl getDebugSeed Nothing flags+ , debugPrintSeed = if DebugPrintSeed `elem` flags+ then (\seed -> putStrLn ("seed: " ++ show (seedToInteger seed)))+ else (\_ -> return ())+ } } where validateCache | validateCert = def | otherwise = ValidationCache (\_ _ _ -> return ValidationCachePass) (\_ _ _ -> return ())- myCiphers = foldl accBogusCipher (filter withUseCipher ciphers) flags where accBogusCipher acc (BogusCipher c) = case reads c of@@ -116,6 +121,10 @@ [] -> True l -> cipherID c `elem` l + getDebugSeed :: Maybe Seed -> Flag -> Maybe Seed+ getDebugSeed _ (DebugSeed seed) = seedFromInteger <$> readNumber seed+ getDebugSeed acc _ = acc+ tlsConnectVer | Tls12 `elem` flags = TLS12 | Tls11 `elem` flags = TLS11@@ -143,6 +152,8 @@ | BenchData String | UseCipher String | ListCiphers+ | DebugSeed String+ | DebugPrintSeed | Help deriving (Show,Eq) @@ -172,6 +183,8 @@ , Option [] ["bench-data"] (ReqArg BenchData "amount") "amount of data to benchmark with" , Option [] ["use-cipher"] (ReqArg UseCipher "cipher-id") "use a specific cipher" , Option [] ["list-ciphers"] (NoArg ListCiphers) "list all ciphers supported and exit"+ , Option [] ["debug-seed"] (ReqArg DebugSeed "debug-seed") "debug: set a specific seed for randomness"+ , Option [] ["debug-print-seed"] (NoArg DebugPrintSeed) "debug: set a specific seed for randomness" ] noSession = Nothing@@ -187,7 +200,8 @@ doTLS certCredRequest (Just session) where runBench isSend =- runTLS False False+ runTLS (Debug `elem` flags)+ (IODebug `elem` flags) (getDefaultParams flags hostname certStore sStorage Nothing noSession) hostname port $ \ctx -> do handshake ctx if isSend
src/SimpleServer.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-}+import Crypto.Random import Network.BSD import Network.Socket (socket, Family(..), SocketType(..), sClose, SockAddr(..), bind, listen, accept) import Network.TLS@@ -98,6 +99,11 @@ } , serverHooks = def , serverSupported = def { supportedVersions = supportedVers, supportedCiphers = myCiphers }+ , serverDebug = def { debugSeed = foldl getDebugSeed Nothing flags+ , debugPrintSeed = if DebugPrintSeed `elem` flags+ then (\seed -> putStrLn ("seed: " ++ show (seedToInteger seed)))+ else (\_ -> return ())+ } } where validateCache@@ -123,6 +129,10 @@ [] -> True l -> cipherID c `elem` l + getDebugSeed :: Maybe Seed -> Flag -> Maybe Seed+ getDebugSeed _ (DebugSeed seed) = seedFromInteger <$> readNumber seed+ getDebugSeed acc _ = acc+ tlsConnectVer | Tls12 `elem` flags = TLS12 | Tls11 `elem` flags = TLS11@@ -149,6 +159,8 @@ | ListCiphers | Certificate String | Key String+ | DebugSeed String+ | DebugPrintSeed | Help deriving (Show,Eq) @@ -176,6 +188,8 @@ , Option [] ["use-cipher"] (ReqArg UseCipher "cipher-id") "use a specific cipher" , Option [] ["list-ciphers"] (NoArg ListCiphers) "list all ciphers supported and exit" , Option [] ["certificate"] (ReqArg Certificate "certificate") "certificate file"+ , Option [] ["debug-seed"] (ReqArg DebugSeed "debug-seed") "debug: set a specific seed for randomness"+ , Option [] ["debug-print-seed"] (NoArg DebugPrintSeed) "debug: set a specific seed for randomness" , Option [] ["key"] (ReqArg Key "key") "certificate file" ]
tls-debug.cabal view
@@ -1,5 +1,5 @@ Name: tls-debug-Version: 0.4.1+Version: 0.4.2 Description: A set of program to test and debug various aspect of the TLS package. .@@ -67,7 +67,7 @@ , network , bytestring , data-default-class- , cryptonite+ , cryptonite >= 0.14 , x509-system >= 1.0 , tls >= 1.3 && < 1.4 Buildable: True