diff options
| author | Roman Smrž <roman.smrz@seznam.cz> | 2026-11-08 15:08:02 +0100 |
|---|---|---|
| committer | Roman Smrž <roman.smrz@seznam.cz> | 2026-11-08 20:41:24 +0100 |
| commit | aefa4b4dc76c3feaab223ff7afe1293c7434fae0 (patch) | |
| tree | 65106a4d4c3443e7a057082f8cb768c2400d3be4 /src/Erebos/Network/Protocol.hs | |
| parent | 4a83167a5199ad078b14b0df7a2ac1ef0b4f58b6 (diff) | |
Use ByteString in nonce-related functions
Diffstat (limited to 'src/Erebos/Network/Protocol.hs')
| -rw-r--r-- | src/Erebos/Network/Protocol.hs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/Erebos/Network/Protocol.hs b/src/Erebos/Network/Protocol.hs index 87272a2..92ec93a 100644 --- a/src/Erebos/Network/Protocol.hs +++ b/src/Erebos/Network/Protocol.hs @@ -49,7 +49,7 @@ import Data.Binary import Data.Binary.Get import Data.Binary.Put import Data.Bits -import Data.ByteArray (Bytes, ScrubbedBytes) +import Data.ByteArray (ScrubbedBytes) import Data.ByteArray qualified as BA import Data.ByteString (ByteString) import Data.ByteString qualified as B @@ -145,7 +145,7 @@ instance Binary ParsedCookie where putByteString cookieContent get = do - Just cookieNonce <- maybeCryptoError . C.nonce12 . BA.convert <$> getByteString 12 + Just cookieNonce <- maybeCryptoError . C.nonce12 <$> getByteString 12 cookieValidity <- getWord32be Just cookieMac <- maybeCryptoError . C.authTag <$> getByteString 16 cookieContent <- BL.toStrict <$> getRemainingLazyByteString @@ -800,7 +800,7 @@ generateCookieHeaders Connection {..} ch = catMaybes <$> sequence [ echoHeader, createCookie :: GlobalState addr -> addr -> IO Cookie createCookie GlobalState {..} addr = do - (nonceBytes :: Bytes) <- getRandomBytes 12 + nonceBytes <- getRandomBytes 12 validUntil <- (fromNanoSecs (60 * 10^(9 :: Int)) +) <$> getTime Monotonic let validSecondsFromStart = fromIntegral $ toNanoSecs (validUntil - gStartTime) `div` (10^(9 :: Int)) cookieValidity = validSecondsFromStart - gCookieStartTime |