packages feed

hashes-0.3.0.1: hashes.cabal

cabal-version: 3.0
name: hashes
version: 0.3.0.1
synopsis: Hash functions
Description: Efficient implementations of hash functions
homepage: https://github.com/larskuhtz/hs-hashes
bug-reports: https://github.com/larskuhtz/hs-hashes/issues
license: MIT
license-file: LICENSE
author: Lars Kuhtz
maintainer: lakuhtz@gmail.com
copyright: Copyright (c) 2019-2024 Lars Kuhtz <lakuhtz@gmail.com>
category: Data
tested-with:
    GHC==9.10
    GHC==9.6
    GHC==9.4
    GHC==9.2
extra-doc-files:
    README.md
    CHANGELOG.md
extra-source-files:
    cbits/keccak.h
    cbits/keccak.c

source-repository head
    type: git
    location: https://github.com/larskuhtz/hs-hashes.git

flag with-openssl
    description:
        Include cryptograph hash functions from openssl. Requires that openssl
        is installed in the system at a location where cabal can find it.
    default: True
    manual: True

flag benchmark-cryptonite
    description: Include implementations from the cryptonite package in benchmarks
    default: False
    manual: True

flag test-cryptonite
    description: Test compatibility with implementations of hash functions in cryptonite
    default: False
    manual: True

flag openssl-use-pkg-config
    description: Use pkg-config to find OpenSSL (macOS and linux only).
    default: False
    manual: True

common openssl-common
    if flag(with-openssl)
        c-sources:
            cbits/keccak.c
        cpp-options: -DWITH_OPENSSL=1
        if flag(openssl-use-pkg-config)
            pkgconfig-depends: libcrypto
        else
            extra-libraries: crypto
        include-dirs: cbits

library
    import: openssl-common
    hs-source-dirs: src
    default-language: Haskell2010
    exposed-modules:
        Data.Hash.Class.Mutable
        Data.Hash.Class.Mutable.Internal
        Data.Hash.Class.Mutable.Salted
        Data.Hash.Class.Pure
        Data.Hash.Class.Pure.Internal
        Data.Hash.Class.Pure.Salted
        Data.Hash.FNV1
        Data.Hash.FNV1.Salted
        Data.Hash.Internal.Utils
        Data.Hash.SipHash
    -- this allows us to #include <opensslv.h> on Gentoo
    -- from a Haskell file
    if arch(x86_64)
        cpp-options: -D__x86_64__
    if arch(aarch64)
        cpp-options: -D__aarch64__
    if flag(with-openssl)
        exposed-modules:
            Data.Hash.Blake2
            Data.Hash.Internal.OpenSSL
            Data.Hash.Keccak
            Data.Hash.SHA2
            Data.Hash.SHA3
    ghc-options:
        -mbmi2
        -msse4.2
    build-depends:
        , base >=4.11 && <5
        , bytestring >=0.10

test-suite tests
    import: openssl-common
    type: exitcode-stdio-1.0
    hs-source-dirs: test
    default-language: Haskell2010
    ghc-options:
        -rtsopts
        -threaded
        -with-rtsopts=-N
    main-is: Main.hs
    other-modules:
        Test.Data.Hash.SipHash
        Test.Data.Hash.FNV1
        Test.Data.Hash.Class.Pure
    build-depends:
        -- internal
        , hashes
        -- external
        , QuickCheck >=2.13
        , base >=4.11 && <5
        , bytestring >=0.10
        , hspec >=2.11
        , vector >=0.12

    if flag(with-openssl)
        build-depends:
            , sha-validation >=0.1.0.1
        other-modules:
            Test.Data.Hash.SHA2
            Test.Data.Hash.SHA3
            Test.Data.Hash.Keccak

    if flag(test-cryptonite)
        build-depends:
            , memory >=0.14
            , cryptonite >=0.29
        cpp-options: -DTEST_CRYPTONITE=1
        other-modules:
            Cryptonite

benchmark benchmarks
    import: openssl-common
    type: exitcode-stdio-1.0
    hs-source-dirs: bench
    main-is: Main.hs
    default-language: Haskell2010
    ghc-options:
        -rtsopts
        -threaded
        -with-rtsopts=-N
        -mbmi2
        -msse4.2
    build-depends:
        -- internal
        , hashes

        -- external
        , base >=4.10 && <5
        , bytestring >=0.10
        , criterion >= 1.5

    if flag(benchmark-cryptonite)
        build-depends:
            , memory >=0.14
            , cryptonite >=0.29
        cpp-options: -DBENCHMARK_CRYPTONITE=1