add an helper to use the compression context easily
This commit is contained in:
parent
d4ca9e0d9d
commit
84ace35a7e
1 changed files with 8 additions and 0 deletions
|
@ -21,6 +21,7 @@ module Network.TLS.State
|
|||
, newTLSState
|
||||
, genTLSRandom
|
||||
, withTLSRNG
|
||||
, withCompression
|
||||
, assert -- FIXME move somewhere else (Internal.hs ?)
|
||||
, updateStatusHs
|
||||
, updateStatusCC
|
||||
|
@ -175,6 +176,13 @@ withTLSRNG (StateRNG rng) f = case f rng of
|
|||
Left err -> Left err
|
||||
Right (a, rng') -> Right (a, StateRNG rng')
|
||||
|
||||
withCompression :: (Compression -> (Compression, a)) -> TLSSt a
|
||||
withCompression f = do
|
||||
compression <- stCompression <$> get
|
||||
let (nc, a) = f compression
|
||||
modify (\st -> st { stCompression = nc })
|
||||
return a
|
||||
|
||||
genTLSRandom :: (MonadState TLSState m, MonadError TLSError m) => Int -> m Bytes
|
||||
genTLSRandom n = do
|
||||
st <- get
|
||||
|
|
Loading…
Reference in a new issue