Added support for SHA3 hashed keys (in 8 varieties), when git-annex is built using the cryptonite library.

While cryptohash has SHA3 support, it has not been updated for the final
version of the spec. Note that cryptonite has not been ported to all arches
that cryptohash builds on yet.
This commit is contained in:
Joey Hess 2015-08-06 15:02:25 -04:00
parent 6ded6fd19a
commit 0ec9bc2200
8 changed files with 133 additions and 57 deletions

View file

@ -185,7 +185,7 @@ fromAuthToken = TE.decodeLatin1 . toBytes
fromAuthToken = id
#endif
{- Generates a random sha512 string, encapsulated in a SecureMem,
{- Generates a random sha2_512 string, encapsulated in a SecureMem,
- suitable to be used for an authentication secret. -}
genAuthToken :: IO AuthToken
genAuthToken = do
@ -193,7 +193,7 @@ genAuthToken = do
return $
case genBytes 512 g of
Left e -> error $ "failed to generate auth token: " ++ show e
Right (s, _) -> toAuthToken $ T.pack $ show $ sha512 $ L.fromChunks [s]
Right (s, _) -> toAuthToken $ T.pack $ show $ sha2_512 $ L.fromChunks [s]
{- A Yesod isAuthorized method, which checks the auth cgi parameter
- against a token extracted from the Yesod application.