packages feed

SHA 1.6.4.1 → 1.6.4.2

raw patch · 2 files changed

+72/−73 lines, 2 filesdep ~binarynew-component:exe:sha224new-component:exe:sha256new-component:exe:sha512PVP: minor bump suggested

API additions: PVP suggests at least a minor version bump

Dependency ranges changed: binary

API changes (from Hackage documentation)

+ Data.Digest.Pure.SHA: calc_k :: Word64 -> Word64 -> Word64 -> Word64
+ Data.Digest.Pure.SHA: fromBigEndianSBS :: (Integral a, Bits a) => ByteString -> a
+ Data.Digest.Pure.SHA: padSHA1 :: ByteString -> ByteString
+ Data.Digest.Pure.SHA: padSHA1Chunks :: Int -> [ByteString]
+ Data.Digest.Pure.SHA: padSHA512 :: ByteString -> ByteString
+ Data.Digest.Pure.SHA: padSHA512Chunks :: Int -> [ByteString]
+ Data.Digest.Pure.SHA: toBigEndianSBS :: (Integral a, Bits a) => Int -> a -> ByteString

Files

SHA.cabal view
@@ -1,6 +1,6 @@ name:       SHA category:   Cryptography, Codec-version:    1.6.4.1+version:    1.6.4.2 license:    BSD3 license-file: LICENSE author:     Adam Wick <awick@galois.com>, Brian Lewis <brian@lorf.org>@@ -19,53 +19,36 @@              these do not presently reach the speed of well-tuned libraries,               like OpenSSL. -Flag test-  Description: Build the SHA test suite.-  Default: False- Flag exe-  Description: Build a sha1 and a sha384 executable similar to 'md5sum'.+  Description: Build a sha executables similar to 'md5sum'.   Default: False -Flag DecoderInterface-  Description: Force SHA to build with support for binary's Decoder.- Library   hs-source-dirs: src   build-depends: array > 0 && < 10000,                  base >= 4 && < 6,+                 binary >= 0.7 && < 10000,                  bytestring > 0.8 && < 10000-  if flag(DecoderInterface)-    build-depends: binary >= 0.7 && < 10000-    cpp-options: -DINCLUDE_DECODER_INTERFACE-  else-    build-depends: binary >= 0 && < 0.7   exposed-modules: Data.Digest.Pure.SHA   GHC-Options: -Wall -fno-ignore-asserts -fno-warn-orphans                -funbox-strict-fields -fwarn-tabs-  extensions: CPP, BangPatterns+  extensions: BangPatterns   if impl(ghc >= 6.12) && impl(ghc < 7.7)     Ghc-Options: -fregs-graph -Executable test_sha-  hs-source-dirs: src-  if flag(test)-    build-depends: array > 0 && < 10000,-                   base > 4.3 && < 7,-                   bytestring > 0.8 && < 10000,-                   QuickCheck >= 2.5 && < 3,-                   test-framework >= 0.8.0.3 && < 10000,-                   test-framework-quickcheck2 >= 0.3.0.2 && < 10000-    if flag(DecoderInterface)-      build-depends: binary >= 0.7 && < 10000-      cpp-options: -DINCLUDE_DECODER_INTERFACE-    else-      build-depends: binary >= 0 && < 0.7-  else-    buildable: False-  Main-Is: Test.hs-  Other-Modules: Data.Digest.Pure.SHA-  extensions: CPP, BangPatterns, MultiParamTypeClasses, DeriveDataTypeable+test-suite test-sha+  type:            exitcode-stdio-1.0+  hs-source-dirs:  src+  main-is:         Test.hs+  ghc-options:     -Wall -fhpc+  build-depends: array > 0 && < 10000,+                 base > 4.3 && < 7,+                 binary >= 0.7 && < 10000,+                 bytestring > 0.8 && < 10000,+                 QuickCheck >= 2.5 && < 3,+                 test-framework >= 0.8.0.3 && < 10000,+                 test-framework-quickcheck2 >= 0.3.0.2 && < 10000+  extensions: BangPatterns, MultiParamTypeClasses, DeriveDataTypeable   GHC-Options: -O2 -Wall -fno-ignore-asserts -fno-warn-orphans                -funbox-strict-fields -fwarn-tabs   cpp-options: -DSHA_TEST@@ -76,31 +59,71 @@   if !flag(exe)     buildable: False   hs-source-dirs: src-bin-  if flag(exe)-    build-depends: base >= 4 && < 6,-                   bytestring > 0.8 && < 10000,-                   directory > 0.0 && < 10000,-                   SHA > 1.6 && < 10000+  build-depends: base >= 4 && < 6,+                 bytestring > 0.8 && < 10000,+                 directory > 0.0 && < 10000,+                 SHA > 1.6 && < 10000   Main-Is: Main.hs   extensions: CPP   GHC-Options: -O2 -Wall -fno-ignore-asserts -fno-warn-orphans                -funbox-strict-fields -fwarn-tabs   cpp-options: -DALGORITHM=sha1 -Executable sha384+Executable sha224   if !flag(exe)     buildable: False   hs-source-dirs: src-bin-  if flag(exe)-    build-depends: base >= 4 && < 6,-                   bytestring > 0.8 && < 10000,-                   directory > 0.0 && < 10000,-                   SHA > 1.6 && < 10000+  build-depends: base >= 4 && < 6,+                 bytestring > 0.8 && < 10000,+                 directory > 0.0 && < 10000,+                 SHA > 1.6 && < 10000+  Main-Is: Main.hs+  extensions: CPP   GHC-Options: -O2 -Wall -fno-ignore-asserts -fno-warn-orphans                -funbox-strict-fields -fwarn-tabs+  cpp-options: -DALGORITHM=sha224++Executable sha256+  if !flag(exe)+    buildable: False+  hs-source-dirs: src-bin+  build-depends: base >= 4 && < 6,+                 bytestring > 0.8 && < 10000,+                 directory > 0.0 && < 10000,+                 SHA > 1.6 && < 10000   Main-Is: Main.hs   extensions: CPP+  GHC-Options: -O2 -Wall -fno-ignore-asserts -fno-warn-orphans+               -funbox-strict-fields -fwarn-tabs+  cpp-options: -DALGORITHM=sha256++Executable sha384+  if !flag(exe)+    buildable: False+  hs-source-dirs: src-bin+  build-depends: base >= 4 && < 6,+                 bytestring > 0.8 && < 10000,+                 directory > 0.0 && < 10000,+                 SHA > 1.6 && < 10000+  Main-Is: Main.hs+  extensions: CPP+  GHC-Options: -O2 -Wall -fno-ignore-asserts -fno-warn-orphans+               -funbox-strict-fields -fwarn-tabs   cpp-options: -DALGORITHM=sha384++Executable sha512+  if !flag(exe)+    buildable: False+  hs-source-dirs: src-bin+  build-depends: base >= 4 && < 6,+                 bytestring > 0.8 && < 10000,+                 directory > 0.0 && < 10000,+                 SHA > 1.6 && < 10000+  Main-Is: Main.hs+  extensions: CPP+  GHC-Options: -O2 -Wall -fno-ignore-asserts -fno-warn-orphans+               -funbox-strict-fields -fwarn-tabs+  cpp-options: -DALGORITHM=sha512  source-repository head   type:     git
src/Data/Digest/Pure/SHA.hs view
@@ -15,7 +15,6 @@        , sha256        , sha384        , sha512-#ifdef INCLUDE_DECODER_INTERFACE        , sha1Incremental        , completeSha1Incremental        , sha224Incremental@@ -26,19 +25,17 @@        , completeSha384Incremental        , sha512Incremental        , completeSha512Incremental-#endif          -- * Calculating message authentication codes (MACs)        , hmacSha1        , hmacSha224        , hmacSha256        , hmacSha384        , hmacSha512-#ifdef SHA_TEST+         -- * Internal routines included for testing        , toBigEndianSBS, fromBigEndianSBS        , calc_k        , padSHA1, padSHA512        , padSHA1Chunks, padSHA512Chunks-#endif        )  where  @@ -50,10 +47,7 @@ import qualified Data.ByteString.Lazy as BS import qualified Data.ByteString as SBS import Data.Char (intToDigit)--#ifdef INCLUDE_DECODER_INTERFACE import Data.List (foldl')-#endif  -- | An abstract datatype for digests. newtype Digest t = Digest ByteString deriving (Eq,Ord)@@ -63,15 +57,15 @@  instance Binary (Digest SHA1State) where   get = Digest `fmap` getLazyByteString 20-  put (Digest bs) = put bs+  put (Digest bs) = putLazyByteString bs  instance Binary (Digest SHA256State) where   get = Digest `fmap` getLazyByteString 32-  put (Digest bs) = put bs+  put (Digest bs) = putLazyByteString bs  instance Binary (Digest SHA512State) where   get = Digest `fmap` getLazyByteString 64-  put (Digest bs) = put bs+  put (Digest bs) = putLazyByteString bs  -- -------------------------------------------------------------------------- --@@ -221,18 +215,14 @@ padSHA1 :: ByteString -> ByteString padSHA1 = generic_pad 448 512 64 -#if defined(INCLUDE_DECODER_INTERFACE) || defined(SHA_TEST) padSHA1Chunks :: Int -> [SBS.ByteString] padSHA1Chunks = generic_pad_chunks 448 512 64-#endif  padSHA512 :: ByteString -> ByteString padSHA512 = generic_pad 896 1024 128 -#if defined(INCLUDE_DECODER_INTERFACE) || defined(SHA_TEST) padSHA512Chunks :: Int -> [SBS.ByteString] padSHA512Chunks = generic_pad_chunks 896 1024 128-#endif  generic_pad :: Word64 -> Word64 -> Int -> ByteString -> ByteString generic_pad a b lSize bs =@@ -271,11 +261,9 @@  where    getBits x = fromIntegral $ (val `shiftR` x) .&. 0xFF -#ifdef SHA_TEST fromBigEndianSBS :: (Integral a, Bits a) => SBS.ByteString -> a fromBigEndianSBS =   SBS.foldl (\ acc x -> (acc `shiftL` 8) + fromIntegral x) 0-#endif  -- -------------------------------------------------------------------------- --@@ -977,7 +965,6 @@       then return s_in       else nextChunk s_in >>= getAll -#ifdef INCLUDE_DECODER_INTERFACE runSHAIncremental :: a -> (a -> Get a) -> Decoder a runSHAIncremental s nextChunk = runGetIncremental (getAll s)  where@@ -995,7 +982,6 @@        Fail _ _ _ -> error "Decoder is in Fail state."        Partial _ -> error "Decoder is in Partial state."        Done _ _ x -> Digest $ runPut $! synthesize x-#endif  -- |Compute the SHA-1 hash of the given ByteString. The output is guaranteed -- to be exactly 160 bits, or 20 bytes, long. This is a good default for@@ -1007,7 +993,6 @@   fstate = runSHA initialSHA1State processSHA1Block bs_pad   bs_out = runPut $! synthesizeSHA1 fstate -#ifdef INCLUDE_DECODER_INTERFACE -- |Similar to `sha1` but use an incremental interface. When the decoder has -- been completely fed, `completeSha1Incremental` must be used so it can -- finish successfully.@@ -1016,7 +1001,6 @@  completeSha1Incremental :: Decoder SHA1State -> Int -> Digest SHA1State completeSha1Incremental = generic_complete padSHA1Chunks synthesizeSHA1-#endif  -- |Compute the SHA-224 hash of the given ByteString. Note that SHA-224 and -- SHA-384 differ only slightly from SHA-256 and SHA-512, and use truncated@@ -1029,7 +1013,6 @@   fstate = runSHA initialSHA224State processSHA256Block bs_pad   bs_out = runPut $! synthesizeSHA224 fstate -#ifdef INCLUDE_DECODER_INTERFACE -- |Similar to `sha224` but use an incremental interface. When the decoder has -- been completely fed, `completeSha224Incremental` must be used so it can -- finish successfully.@@ -1038,7 +1021,6 @@  completeSha224Incremental :: Decoder SHA256State -> Int -> Digest SHA256State completeSha224Incremental = generic_complete padSHA1Chunks synthesizeSHA224-#endif  -- |Compute the SHA-256 hash of the given ByteString. The output is guaranteed -- to be exactly 256 bits, or 32 bytes, long. If your security requirements@@ -1051,7 +1033,6 @@   fstate = runSHA initialSHA256State processSHA256Block bs_pad   bs_out = runPut $! synthesizeSHA256 fstate -#ifdef INCLUDE_DECODER_INTERFACE -- |Similar to `sha256` but use an incremental interface. When the decoder has -- been completely fed, `completeSha256Incremental` must be used so it can -- finish successfully.@@ -1060,7 +1041,6 @@  completeSha256Incremental :: Decoder SHA256State -> Int -> Digest SHA256State completeSha256Incremental = generic_complete padSHA1Chunks synthesizeSHA256-#endif  -- |Compute the SHA-384 hash of the given ByteString. Yup, you guessed it, -- the output will be exactly 384 bits, or 48 bytes, long.@@ -1071,7 +1051,6 @@   fstate = runSHA initialSHA384State processSHA512Block bs_pad   bs_out = runPut $! synthesizeSHA384 fstate -#ifdef INCLUDE_DECODER_INTERFACE -- |Similar to `sha384` but use an incremental interface. When the decoder has -- been completely fed, `completeSha384Incremental` must be used so it can -- finish successfully.@@ -1080,7 +1059,6 @@  completeSha384Incremental :: Decoder SHA512State -> Int -> Digest SHA512State completeSha384Incremental = generic_complete padSHA512Chunks synthesizeSHA384-#endif  -- |For those for whom only the biggest hashes will do, this computes the -- SHA-512 hash of the given ByteString. The output will be 64 bytes, or@@ -1092,7 +1070,6 @@   fstate = runSHA initialSHA512State processSHA512Block bs_pad   bs_out = runPut $! synthesizeSHA512 fstate -#ifdef INCLUDE_DECODER_INTERFACE -- |Similar to `sha512` but use an incremental interface. When the decoder has -- been completely fed, `completeSha512Incremental` must be used so it can -- finish successfully.@@ -1101,7 +1078,6 @@  completeSha512Incremental :: Decoder SHA512State -> Int -> Digest SHA512State completeSha512Incremental = generic_complete padSHA512Chunks synthesizeSHA512-#endif  -- --------------------------------------------------------------------------