From 949fa2d426ea74ee5a0c784a9df39aa87030f63d Mon Sep 17 00:00:00 2001 From: Maximilian Tagher Date: Sun, 16 Aug 2015 20:50:29 -0400 Subject: [PATCH] Slightly improve comment about constant time comparison --- yesod-form/Yesod/Form/Functions.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/yesod-form/Yesod/Form/Functions.hs b/yesod-form/Yesod/Form/Functions.hs index 0d83b799..6fe69b04 100644 --- a/yesod-form/Yesod/Form/Functions.hs +++ b/yesod-form/Yesod/Form/Functions.hs @@ -228,9 +228,10 @@ postHelper form env = do | not (Map.lookup tokenKey params === reqToken req) -> FormFailure [renderMessage m langs MsgCsrfWarning] _ -> res + -- It's important to use constant-time comparison (constEqBytes) in order to avoid timing attacks. where (Just [t1]) === (Just t2) = TE.encodeUtf8 t1 `constEqBytes` TE.encodeUtf8 t2 - Nothing === Nothing = True -- It's important to use constTimeEq - _ === _ = False -- in order to avoid timing attacks. + Nothing === Nothing = True + _ === _ = False return ((res', xml), enctype) -- | Similar to 'runFormPost', except it always ignores the currently available