Skip to content

Commit

Permalink
Merge pull request #85 from cdepillabout/optional-scrypt-lib
Browse files Browse the repository at this point in the history
Make scrypt test dep optional and not required on darwin
  • Loading branch information
cdepillabout authored Nov 10, 2024
2 parents abf2e55 + 01c5ea8 commit a37127d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
8 changes: 8 additions & 0 deletions password/ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog for `password`

## 3.1.0.1

- Redo the conditionals in the `password.cabal` file so that the scrypt
library is only included as a test dependency on `x86_64`. This generally
shouldn't affect users of the `password` library.
Thanks to [@sternenseemann](https://github.com/sternenseemann)
[#85](https://github.com/cdepillabout/password/pull/85)

## 3.1.0.0

- Switched default cryptographic backend library from `cryptonite` to `crypton`.
Expand Down
20 changes: 14 additions & 6 deletions password/password.cabal
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cabal-version: 1.12

name: password
version: 3.1.0.0
version: 3.1.0.1
category: Data
synopsis: Hashing and checking of passwords
description:
Expand Down Expand Up @@ -154,6 +154,7 @@ test-suite password-tasty
test/tasty
main-is:
Spec.hs

other-modules:
Data.Password.Internal
-- We're also putting all the modules from
Expand Down Expand Up @@ -182,8 +183,10 @@ test-suite password-tasty
other-modules:
Scrypt
Data.Password.Scrypt

ghc-options:
-threaded -O2 -rtsopts -with-rtsopts=-N

build-depends:
base >=4.9 && <5
, base64
Expand All @@ -200,23 +203,28 @@ test-suite password-tasty
default-language:
Haskell2010

if os(darwin)
cpp-options: -DIS_MAC_OS
else
build-depends: scrypt

if flag(argon2)
cpp-options:
-DCABAL_FLAG_argon2

if flag(bcrypt)
cpp-options:
-DCABAL_FLAG_bcrypt

if flag(pbkdf2)
cpp-options:
-DCABAL_FLAG_pbkdf2

if flag(scrypt)
cpp-options:
-DCABAL_FLAG_scrypt

-- The scrypt package is optionally used in tests to ensure compatibility
-- between password and scrypt. However, scrypt requires the x86_64 arch
-- with the SSE2 instruction set.
if arch(x86_64)
build-depends: scrypt

if flag(cryptonite)
build-depends:
cryptonite
Expand Down
9 changes: 6 additions & 3 deletions password/test/tasty/Scrypt.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ import Test.Tasty.Golden (goldenVsString)
import Test.Tasty.QuickCheck
import Test.QuickCheck.Instances.Text ()

#ifndef IS_MAC_OS
#ifdef x86_64_HOST_ARCH
import qualified Crypto.Scrypt as Scrypt
#endif

import Data.Password.Types
import Data.Password.Scrypt

Expand All @@ -30,7 +31,7 @@ testScrypt = testGroup "scrypt"
checkPassword
extractParams
testsParams8Rounds
#ifndef IS_MAC_OS
#ifdef x86_64_HOST_ARCH
, testProperty "scrypt <-> cryptonite" $ withMaxSuccess 10 checkScrypt
#endif
, testGolden
Expand All @@ -41,7 +42,9 @@ testScrypt = testGroup "scrypt"
hash4Rounds = hashPasswordWithParams testsParams4Rounds
testsParams4Rounds = defaultParams{ scryptRounds = 4, scryptSalt = 16 }

#ifndef IS_MAC_OS
#ifdef x86_64_HOST_ARCH
-- The scrypt library is only available on x86_64, so we only compare password's
-- scrypt functionality against the actual scrypt library when building on x86_64.
checkScrypt :: Text -> Property
checkScrypt pass = ioProperty $ do
s@(Scrypt.Salt salt) <- Scrypt.newSalt
Expand Down

0 comments on commit a37127d

Please sign in to comment.