summaryrefslogtreecommitdiffhomepage
path: root/HTTP
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2017-03-03 15:44:01 -0400
committerJoey Hess <joeyh@joeyh.name>2017-03-03 15:49:51 -0400
commitfc39ddb96af70c14c5de739408b03a14ef2053bf (patch)
treed81aedc573531e1e0e45d110a1eae1e12c296d21 /HTTP
parent0e5dac41b5d08d72c3799d9cc52de0ed95c2e870 (diff)
downloadkeysafe-fc39ddb96af70c14c5de739408b03a14ef2053bf.tar.gz
Updated to use raaz-0.1.1.
This commit was sponsored by John Peloquin on Patreon.
Diffstat (limited to 'HTTP')
-rw-r--r--HTTP/ProofOfWork.hs17
-rw-r--r--HTTP/Server.hs1
2 files changed, 12 insertions, 6 deletions
diff --git a/HTTP/ProofOfWork.hs b/HTTP/ProofOfWork.hs
index a94b19b..61fea20 100644
--- a/HTTP/ProofOfWork.hs
+++ b/HTTP/ProofOfWork.hs
@@ -95,10 +95,13 @@ mkProofOfWorkRequirement (Seconds n)
newtype RequestIDSecret = RequestIDSecret (Raaz.Key (Raaz.HMAC Raaz.SHA256))
+-- | Random data is generated insecurely, eg not locked in memory because
+-- this is a transient secret.
newRequestIDSecret :: IO RequestIDSecret
-newRequestIDSecret = do
- prg <- Raaz.newPRG () :: IO Raaz.SystemPRG
- RequestIDSecret <$> Raaz.random prg
+newRequestIDSecret = RequestIDSecret <$> Raaz.insecurely gen
+ where
+ gen :: Raaz.RandM (Raaz.Key (Raaz.HMAC Raaz.SHA256))
+ gen = Raaz.random
mkRequestID :: RequestIDSecret -> IO RequestID
mkRequestID secret = mkRequeestID' secret <$> mkRandomSalt
@@ -113,11 +116,15 @@ validRequestID secret rid =
let rid' = mkRequeestID' secret (randomSalt rid)
in requestHMAC rid == requestHMAC rid'
+-- | Random data is generated insecurely, eg not locked in memory because
+-- this is a transient secret.
mkRandomSalt :: IO RandomSalt
mkRandomSalt = do
- prg <- Raaz.newPRG () :: IO Raaz.SystemPRG
- rs <- replicateM 16 (Raaz.random prg :: IO Word8)
+ rs <- Raaz.insecurely $ replicateM 16 gen
return $ RandomSalt $ T.pack $ concatMap show rs
+ where
+ gen :: Raaz.RandM Word8
+ gen = Raaz.random
class POWIdent p where
getPOWIdent :: p -> B.ByteString
diff --git a/HTTP/Server.hs b/HTTP/Server.hs
index 6fd570d..61bdbfd 100644
--- a/HTTP/Server.hs
+++ b/HTTP/Server.hs
@@ -18,7 +18,6 @@ import CmdLine (ServerConfig(..))
import Storage.Local
import Serialization ()
import Servant
-import Network.Wai
import Network.Wai.Handler.Warp
import Control.Monad.IO.Class
import Control.Concurrent