From 1b9c4477fb542cddbb05012a52c602eb203b2d83 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 1 Mar 2011 17:07:15 -0400 Subject: [PATCH] New backends: SHA512 SHA384 SHA256 SHA224 --- Backend/SHA224.hs | 14 ++++++++++++++ Backend/SHA256.hs | 14 ++++++++++++++ Backend/SHA384.hs | 14 ++++++++++++++ Backend/SHA512.hs | 14 ++++++++++++++ BackendList.hs | 8 ++++++++ configure.hs | 10 ++++++++-- debian/changelog | 1 + doc/backends.mdwn | 3 +++ 8 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 Backend/SHA224.hs create mode 100644 Backend/SHA256.hs create mode 100644 Backend/SHA384.hs create mode 100644 Backend/SHA512.hs diff --git a/Backend/SHA224.hs b/Backend/SHA224.hs new file mode 100644 index 0000000000..614f31c4b8 --- /dev/null +++ b/Backend/SHA224.hs @@ -0,0 +1,14 @@ +{- git-annex "SHA224" backend + - + - Copyright 2011 Joey Hess + - + - Licensed under the GNU GPL version 3 or higher. + -} + +module Backend.SHA224 (backend) where + +import Types +import Backend.SHA + +backend :: Backend Annex +backend = genBackend 224 diff --git a/Backend/SHA256.hs b/Backend/SHA256.hs new file mode 100644 index 0000000000..42d3d48c7d --- /dev/null +++ b/Backend/SHA256.hs @@ -0,0 +1,14 @@ +{- git-annex "SHA256" backend + - + - Copyright 2011 Joey Hess + - + - Licensed under the GNU GPL version 3 or higher. + -} + +module Backend.SHA256 (backend) where + +import Types +import Backend.SHA + +backend :: Backend Annex +backend = genBackend 256 diff --git a/Backend/SHA384.hs b/Backend/SHA384.hs new file mode 100644 index 0000000000..0cf77ea647 --- /dev/null +++ b/Backend/SHA384.hs @@ -0,0 +1,14 @@ +{- git-annex "SHA384" backend + - + - Copyright 2011 Joey Hess + - + - Licensed under the GNU GPL version 3 or higher. + -} + +module Backend.SHA384 (backend) where + +import Types +import Backend.SHA + +backend :: Backend Annex +backend = genBackend 384 diff --git a/Backend/SHA512.hs b/Backend/SHA512.hs new file mode 100644 index 0000000000..aed8bbcedf --- /dev/null +++ b/Backend/SHA512.hs @@ -0,0 +1,14 @@ +{- git-annex "SHA512" backend + - + - Copyright 2011 Joey Hess + - + - Licensed under the GNU GPL version 3 or higher. + -} + +module Backend.SHA512 (backend) where + +import Types +import Backend.SHA + +backend :: Backend Annex +backend = genBackend 512 diff --git a/BackendList.hs b/BackendList.hs index 5ae78bcc7f..4279b69fc9 100644 --- a/BackendList.hs +++ b/BackendList.hs @@ -10,6 +10,10 @@ module BackendList (allBackends) where -- When adding a new backend, import it here and add it to the list. import qualified Backend.WORM import qualified Backend.SHA1 +import qualified Backend.SHA256 +import qualified Backend.SHA512 +import qualified Backend.SHA224 +import qualified Backend.SHA384 import qualified Backend.URL import Types @@ -17,5 +21,9 @@ allBackends :: [Backend Annex] allBackends = [ Backend.WORM.backend , Backend.SHA1.backend + , Backend.SHA256.backend + , Backend.SHA512.backend + , Backend.SHA224.backend + , Backend.SHA384.backend , Backend.URL.backend ] diff --git a/configure.hs b/configure.hs index b5437ec1a5..772ba54899 100644 --- a/configure.hs +++ b/configure.hs @@ -11,11 +11,17 @@ tests = [ , testCp "cp_p" "-p" , testCp "cp_reflink_auto" "--reflink=auto" , TestCase "uuid generator" $ selectCmd "uuid" ["uuid", "uuidgen"] - , TestCase "sha1sum" $ requireCmd "sha1sum" "sha1sum /dev/null" , TestCase "unicode FilePath support" $ unicodeFilePath - ] + ] ++ shaTestCases [1, 256, 512, 224, 384] + +shaTestCases :: [Int] -> [TestCase] +shaTestCases l = map make l + where + make n = + let cmd = "sha" ++ show n ++ "sum" + in TestCase cmd $ requireCmd cmd (cmd ++ " Sun, 13 Feb 2011 00:48:02 -0400 diff --git a/doc/backends.mdwn b/doc/backends.mdwn index 3e605e4b15..5d02ad3a1c 100644 --- a/doc/backends.mdwn +++ b/doc/backends.mdwn @@ -19,6 +19,9 @@ can use different backends for different files. allows modifications of files to be tracked. Its need to generate checksums can make it slower for large files. for use. +* `SHA512`, `SHA384`, `SHA256`, `SHA224` -- Like SHA1, but larger + checksums. Mostly useful for the very paranoid, or anyone who is + researching checksum collisions and wants to annex their colliding data. ;) * `URL` -- This backend downloads the file's content from an external URL. The `annex.backends` git-config setting can be used to list the backends