hash-string 0.1.0.0 → 0.1.0.1
raw patch · 3 files changed
+21/−11 lines, 3 filesdep +data-array-bytedep ~bytestringPVP ok
version bump matches the API change (PVP)
Dependencies added: data-array-byte
Dependency ranges changed: bytestring
API changes (from Hackage documentation)
Files
- CHANGELOG.md +7/−0
- hash-string.cabal +11/−2
- lib/Crypto/HashString/Implementation.hs +3/−9
CHANGELOG.md view
@@ -1,3 +1,10 @@ # Revision history for hash-string +## 0.1.0.1 (2025-05-31)++* Removed a mildly problematic non-constant-time branch when xor'ing the same+ physical string with itself.+ +* Improved support for GHC versions < 9.4+ ## 0.1.0.0 (2025-01-20)
hash-string.cabal view
@@ -1,6 +1,6 @@ cabal-version: 1.24 name: hash-string-version: 0.1.0.0+version: 0.1.0.1 synopsis: binary strings supporting constant-time base16 and comparisons description:@@ -23,8 +23,12 @@ other-modules: Crypto.HashString.Implementation build-depends: base < 5,- bytestring,+ bytestring >= 0.11.3, ghc-prim++ if impl(ghc < 9.4)+ build-depends: data-array-byte+ hs-source-dirs: lib include-dirs: csrc @@ -38,6 +42,11 @@ csrc/hs_hashstring_xor.c default-language: Haskell2010++source-repository head+ type: git+ location: http://github.com/auth-global/self-documenting-cryptography+ subdir: hash-string test-suite test default-language: Haskell2010
lib/Crypto/HashString/Implementation.hs view
@@ -79,9 +79,7 @@ xorLeft :: HashString -> HashString -> HashString xorLeft (HashString strl@(ByteArray ptrl)) (HashString strr@(ByteArray ptrr))- | compareInt# 0# (unsafePtrEquality# ptrl ptrr) /= EQ = fromShort (SB.replicate (SB.length (SBS ptrl)) 0)- | otherwise =- unsafePerformIO . IO $ \st ->+ = unsafePerformIO . IO $ \st -> let !lenl0@(I# lenl) = SB.length (SBS ptrl) !lenr0@(I# lenr) = SB.length (SBS ptrr) !(# st0, a #) = newByteArray# lenl st@@ -95,9 +93,7 @@ xorMin :: HashString -> HashString -> HashString xorMin (HashString strl@(ByteArray ptrl)) (HashString strr@(ByteArray ptrr))- | compareInt# 0# (unsafePtrEquality# ptrl ptrr) /= EQ = fromShort (SB.replicate (SB.length (SBS ptrl)) 0)- | otherwise =- unsafePerformIO . IO $ \st ->+ = unsafePerformIO . IO $ \st -> let !minlen0@(I# minlen) = min (SB.length (SBS ptrl)) (SB.length (SBS ptrr)) !(# st0, a #) = newByteArray# minlen st !(# st1, () #) = unIO (c_xormin_ba ptrl ptrr (fromIntegral minlen0) a) st0@@ -110,9 +106,7 @@ xorMax :: HashString -> HashString -> HashString xorMax (HashString strl@(ByteArray ptrl)) (HashString strr@(ByteArray ptrr))- | compareInt# 0# (unsafePtrEquality# ptrl ptrr) /= EQ = fromShort (SB.replicate (SB.length (SBS ptrl)) 0)- | otherwise =- unsafePerformIO . IO $ \st ->+ = unsafePerformIO . IO $ \st -> let !lenl = SB.length (SBS ptrl) !lenr = SB.length (SBS ptrr) !(I# maxlen) = max lenl lenr