module Network.TLS.Types.Secret where
import Crypto.Debug (DebugShow (..))
import Data.ByteArray (convert)
import Network.TLS.Imports
import Network.TLS.Types.Cipher
data EarlySecret
data HandshakeSecret
data ApplicationSecret
data ResumptionSecret
newtype BaseSecret a = BaseSecret Secret
instance Show (BaseSecret a) where
show :: BaseSecret a -> String
show BaseSecret a
_ = String
"<secret>"
instance DebugShow (BaseSecret a) where
debugShow :: BaseSecret a -> String
debugShow (BaseSecret ScrubbedBytes
bs) = ByteString -> String
showBytesHex (ByteString -> String) -> ByteString -> String
forall a b. (a -> b) -> a -> b
$ ScrubbedBytes -> ByteString
forall bin bout.
(ByteArrayAccess bin, ByteArray bout) =>
bin -> bout
convert ScrubbedBytes
bs
newtype AnyTrafficSecret a = AnyTrafficSecret Secret
instance Show (AnyTrafficSecret a) where
show :: AnyTrafficSecret a -> String
show AnyTrafficSecret a
_ = String
"<secret>"
instance DebugShow (AnyTrafficSecret a) where
debugShow :: AnyTrafficSecret a -> String
debugShow (AnyTrafficSecret ScrubbedBytes
bs) = ByteString -> String
showBytesHex (ByteString -> String) -> ByteString -> String
forall a b. (a -> b) -> a -> b
$ ScrubbedBytes -> ByteString
forall bin bout.
(ByteArrayAccess bin, ByteArray bout) =>
bin -> bout
convert ScrubbedBytes
bs
newtype ClientTrafficSecret a = ClientTrafficSecret Secret
instance Show (ClientTrafficSecret a) where
show :: ClientTrafficSecret a -> String
show ClientTrafficSecret a
_ = String
"<secret>"
instance DebugShow (ClientTrafficSecret a) where
debugShow :: ClientTrafficSecret a -> String
debugShow (ClientTrafficSecret ScrubbedBytes
bs) = ByteString -> String
showBytesHex (ByteString -> String) -> ByteString -> String
forall a b. (a -> b) -> a -> b
$ ScrubbedBytes -> ByteString
forall bin bout.
(ByteArrayAccess bin, ByteArray bout) =>
bin -> bout
convert ScrubbedBytes
bs
newtype ServerTrafficSecret a = ServerTrafficSecret Secret
instance Show (ServerTrafficSecret a) where
show :: ServerTrafficSecret a -> String
show ServerTrafficSecret a
_ = String
"<secret>"
instance DebugShow (ServerTrafficSecret a) where
debugShow :: ServerTrafficSecret a -> String
debugShow (ServerTrafficSecret ScrubbedBytes
bs) = ByteString -> String
showBytesHex (ByteString -> String) -> ByteString -> String
forall a b. (a -> b) -> a -> b
$ ScrubbedBytes -> ByteString
forall bin bout.
(ByteArrayAccess bin, ByteArray bout) =>
bin -> bout
convert ScrubbedBytes
bs
data SecretTriple a = SecretTriple
{ forall a. SecretTriple a -> BaseSecret a
triBase :: BaseSecret a
, forall a. SecretTriple a -> ClientTrafficSecret a
triClient :: ClientTrafficSecret a
, forall a. SecretTriple a -> ServerTrafficSecret a
triServer :: ServerTrafficSecret a
}
deriving (Int -> SecretTriple a -> ShowS
[SecretTriple a] -> ShowS
SecretTriple a -> String
(Int -> SecretTriple a -> ShowS)
-> (SecretTriple a -> String)
-> ([SecretTriple a] -> ShowS)
-> Show (SecretTriple a)
forall a. Int -> SecretTriple a -> ShowS
forall a. [SecretTriple a] -> ShowS
forall a. SecretTriple a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall a. Int -> SecretTriple a -> ShowS
showsPrec :: Int -> SecretTriple a -> ShowS
$cshow :: forall a. SecretTriple a -> String
show :: SecretTriple a -> String
$cshowList :: forall a. [SecretTriple a] -> ShowS
showList :: [SecretTriple a] -> ShowS
Show)
data SecretPair a = SecretPair
{ forall a. SecretPair a -> BaseSecret a
pairBase :: BaseSecret a
, forall a. SecretPair a -> ClientTrafficSecret a
pairClient :: ClientTrafficSecret a
}
deriving (Int -> SecretPair a -> ShowS
[SecretPair a] -> ShowS
SecretPair a -> String
(Int -> SecretPair a -> ShowS)
-> (SecretPair a -> String)
-> ([SecretPair a] -> ShowS)
-> Show (SecretPair a)
forall a. Int -> SecretPair a -> ShowS
forall a. [SecretPair a] -> ShowS
forall a. SecretPair a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall a. Int -> SecretPair a -> ShowS
showsPrec :: Int -> SecretPair a -> ShowS
$cshow :: forall a. SecretPair a -> String
show :: SecretPair a -> String
$cshowList :: forall a. [SecretPair a] -> ShowS
showList :: [SecretPair a] -> ShowS
Show)
type TrafficSecrets a = (ClientTrafficSecret a, ServerTrafficSecret a)
newtype ExporterSecret = ExporterSecret Secret
instance Show ExporterSecret where
show :: ExporterSecret -> String
show ExporterSecret
_ = String
"<secret>"
instance DebugShow ExporterSecret where
debugShow :: ExporterSecret -> String
debugShow (ExporterSecret ScrubbedBytes
bs) = ByteString -> String
showBytesHex (ByteString -> String) -> ByteString -> String
forall a b. (a -> b) -> a -> b
$ ScrubbedBytes -> ByteString
forall bin bout.
(ByteArrayAccess bin, ByteArray bout) =>
bin -> bout
convert ScrubbedBytes
bs
newtype MainSecret = MainSecret Secret
instance Show MainSecret where
show :: MainSecret -> String
show MainSecret
_ = String
"<secret>"
instance DebugShow MainSecret where
debugShow :: MainSecret -> String
debugShow (MainSecret ScrubbedBytes
bs) = ByteString -> String
showBytesHex (ByteString -> String) -> ByteString -> String
forall a b. (a -> b) -> a -> b
$ ScrubbedBytes -> ByteString
forall bin bout.
(ByteArrayAccess bin, ByteArray bout) =>
bin -> bout
convert ScrubbedBytes
bs