Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.

Commit

Permalink
Support building against system argon2.
Browse files Browse the repository at this point in the history
  • Loading branch information
QuLogic committed May 26, 2018
1 parent a441271 commit b21b47e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
6 changes: 6 additions & 0 deletions cbits/cryptonite_argon2.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@ int cryptonite_argon2_hash_haskell(const uint32_t t_cost,
const size_t hashlen, argon2_type type,
const uint32_t version)
{
#ifdef USE_SYSTEM_LIBRARY
return argon2_hash(t_cost, m_cost, parallelism, pwd, pwdlen,
salt, saltlen, hash, hashlen, NULL, 0, type,
version);
#else
return cryptonite_argon2_hash(t_cost, m_cost, parallelism, pwd, pwdlen,
salt, saltlen, hash, hashlen, type,
version);
#endif
}

19 changes: 14 additions & 5 deletions cryptonite.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ source-repository head
type: git
location: https://github.com/haskell-crypto/cryptonite

Flag use-system-library
Description: Use system @libargon2@ (via @pkg-config(1)@) and @blake2@ libraries instead of embedded copies
Default: False
manual: True

Flag support_aesni
Description: allow compilation with AESNI on system and architecture that supports it
Default: True
Expand All @@ -78,7 +83,7 @@ Flag support_pclmuldq
Manual: True

Flag support_sse
Description: Use SSE optimized version of (BLAKE2, ARGON2)
Description: Use SSE optimized version of (BLAKE2, ARGON2) (does nothing when using system libraries)
Default: False
Manual: True

Expand Down Expand Up @@ -344,11 +349,15 @@ Library
, cbits/blake2/ref/blake2bp-ref.c
include-dirs: cbits/blake2/ref

if arch(x86_64) || flag(support_sse)
CPP-options: -DSUPPORT_SSE
if flag(use-system-library)
CC-options: -DUSE_SYSTEM_LIBRARY
PkgConfig-Depends: libargon2
else
if arch(x86_64) || flag(support_sse)
CPP-options: -DSUPPORT_SSE

C-sources: cbits/argon2/argon2.c
include-dirs: cbits/argon2
C-sources: cbits/argon2/argon2.c
include-dirs: cbits/argon2

if os(windows)
cpp-options: -DWINDOWS
Expand Down

0 comments on commit b21b47e

Please sign in to comment.