[DHG_packages] 01/01: argon2: patch to fix build on 32-bit archs
Sean Whitton
spw-guest at moszumanska.debian.org
Mon Sep 26 19:02:03 UTC 2016
This is an automated email from the git hooks/post-receive script.
spw-guest pushed a commit to branch master
in repository DHG_packages.
commit 4082f96d465c8eb5185b6fd017af52ab9c009cb2
Author: Sean Whitton <spwhitton at spwhitton.name>
Date: Mon Sep 26 11:59:17 2016 -0700
argon2: patch to fix build on 32-bit archs
Plus some other bug fixes from Joey.
---
p/haskell-argon2/debian/patches/series | 3 +
.../debian/patches/use-argon2_encodedlen.patch | 66 ++++++++++++++++++
.../patches/use-csize-instead-of-word64.patch | 80 ++++++++++++++++++++++
.../debian/patches/use-packcstringlen.patch | 29 ++++++++
4 files changed, 178 insertions(+)
diff --git a/p/haskell-argon2/debian/patches/series b/p/haskell-argon2/debian/patches/series
index dbed01d..1f65d6e 100644
--- a/p/haskell-argon2/debian/patches/series
+++ b/p/haskell-argon2/debian/patches/series
@@ -1,2 +1,5 @@
add-additional-C-source-files-to-cabal-file.patch
add-use-system-library-build-flag.patch
+use-csize-instead-of-word64.patch
+use-packcstringlen.patch
+use-argon2_encodedlen.patch
diff --git a/p/haskell-argon2/debian/patches/use-argon2_encodedlen.patch b/p/haskell-argon2/debian/patches/use-argon2_encodedlen.patch
new file mode 100644
index 0000000..d68fdbe
--- /dev/null
+++ b/p/haskell-argon2/debian/patches/use-argon2_encodedlen.patch
@@ -0,0 +1,66 @@
+Description: use argon2_encodedlen rather than re-implementing it
+ The haskell implementation has fallen out of sync with libargon2,
+ since v= was added to the prefix of the encoded hash.
+Author: Joey Hess <joeyh at joeyh.name>
+Date: Mon, 26 Sep 2016 13:26:28 -0400
+Forwarded: https://github.com/ocharles/argon2/pull/4
+
+---
+ src/Crypto/Argon2.hs | 15 +++++++++------
+ src/Crypto/Argon2/FFI.hsc | 2 ++
+ 2 files changed, 11 insertions(+), 6 deletions(-)
+
+diff --git a/src/Crypto/Argon2.hs b/src/Crypto/Argon2.hs
+index 1ed23fe..1cea4f6 100644
+--- a/src/Crypto/Argon2.hs
++++ b/src/Crypto/Argon2.hs
+@@ -143,10 +143,12 @@ hashEncoded' :: HashOptions
+ hashEncoded' options at HashOptions{..} password salt argon2i argon2d =
+ do let saltLen = fromIntegral (BS.length salt)
+ passwordLen = fromIntegral (BS.length password)
+- outLen =
+- (BS.length salt * 4 + 32 * 4 +
+- length ("$argon2x$m=,t=,p=$$" :: String) +
+- 3 * 3)
++ outLen <- fmap fromIntegral $ FFI.argon2_encodedlen
++ hashIterations
++ hashMemory
++ hashParallelism
++ saltLen
++ hashlen
+ out <- mallocBytes outLen
+ res <-
+ BS.useAsCString password $
+@@ -159,13 +161,14 @@ hashEncoded' options at HashOptions{..} password salt argon2i argon2d =
+ password'
+ passwordLen
+ salt'
+- saltLen
+- 64
++ (fromIntegral saltLen)
++ (fromIntegral hashlen)
+ out
+ (fromIntegral outLen)
+ handleSuccessCode res options password salt
+ fmap T.decodeUtf8 (BS.packCString out)
+ where argon2 = variant argon2i argon2d hashVariant
++ hashlen = 64
+
+ type Argon2Unencoded = Word32 -> Word32 -> Word32 -> CString -> CSize -> CString -> CSize -> CString -> CSize -> IO Int32
+
+diff --git a/src/Crypto/Argon2/FFI.hsc b/src/Crypto/Argon2/FFI.hsc
+index e9f334a..3b12938 100644
+--- a/src/Crypto/Argon2/FFI.hsc
++++ b/src/Crypto/Argon2/FFI.hsc
+@@ -21,6 +21,8 @@ foreign import ccall unsafe "argon2.h argon2i_verify" argon2i_verify :: CString
+
+ foreign import ccall unsafe "argon2.h argon2d_verify" argon2d_verify :: CString -> Ptr a -> CSize -> IO (#type int)
+
++foreign import ccall unsafe "argon2.h argon2_encodedlen" argon2_encodedlen :: (#type const uint32_t) -> (#type const uint32_t) -> (#type const uint32_t) -> (#type const uint32_t) -> (#type const uint32_t) -> IO CSize
++
+ pattern ARGON2_OK = (#const ARGON2_OK)
+ pattern ARGON2_OUTPUT_PTR_NULL = (#const ARGON2_OUTPUT_PTR_NULL)
+ pattern ARGON2_OUTPUT_TOO_SHORT = (#const ARGON2_OUTPUT_TOO_SHORT)
+--
+2.9.3
+
diff --git a/p/haskell-argon2/debian/patches/use-csize-instead-of-word64.patch b/p/haskell-argon2/debian/patches/use-csize-instead-of-word64.patch
new file mode 100644
index 0000000..a5df069
--- /dev/null
+++ b/p/haskell-argon2/debian/patches/use-csize-instead-of-word64.patch
@@ -0,0 +1,80 @@
+Description: use CSize instead of Word64 for portability to 32-bit archs
+ Note that this changes constructors of Argon2Exception which are part of
+ the exported interface.
+ .
+ (However, no packages depending on the old interface have been
+ uploaded to Debian, so it's okay to include this patch /spwhitton)
+Author: Joey Hess <joeyh at joeyh.name>
+Date: Mon, 26 Sep 2016 09:43:36 -0400
+Forwarded: https://github.com/ocharles/argon2/pull/4
+
+---
+ src/Crypto/Argon2.hs | 8 ++++----
+ src/Crypto/Argon2/FFI.hsc | 12 ++++++------
+ 2 files changed, 10 insertions(+), 10 deletions(-)
+
+diff --git a/src/Crypto/Argon2.hs b/src/Crypto/Argon2.hs
+index dccb16e..2ed8f18 100644
+--- a/src/Crypto/Argon2.hs
++++ b/src/Crypto/Argon2.hs
+@@ -117,9 +117,9 @@ variant _ b Argon2d = b
+ -- will be throw.
+ data Argon2Exception
+ = -- | The length of the supplied password is outside the range supported by @libargon2 at .
+- Argon2PasswordLengthOutOfRange !Word64 -- ^ The erroneous length.
++ Argon2PasswordLengthOutOfRange !CSize -- ^ The erroneous length.
+ | -- | The length of the supplied salt is outside the range supported by @libargon2 at .
+- Argon2SaltLengthOutOfRange !Word64 -- ^ The erroneous length.
++ Argon2SaltLengthOutOfRange !CSize -- ^ The erroneous length.
+ | -- | Either too much or too little memory was requested via 'hashMemory'.
+ Argon2MemoryUseOutOfRange !Word32 -- ^ The erroneous 'hashMemory' value.
+ | -- | Either too few or too many iterations were requested via 'hashIterations'.
+@@ -132,7 +132,7 @@ data Argon2Exception
+
+ instance Exception Argon2Exception
+
+-type Argon2Encoded = Word32 -> Word32 -> Word32 -> CString -> Word64 -> CString -> Word64 -> Word64 -> CString -> Word64 -> IO Int32
++type Argon2Encoded = Word32 -> Word32 -> Word32 -> CString -> CSize -> CString -> CSize -> CSize -> CString -> CSize -> IO Int32
+
+ hashEncoded' :: HashOptions
+ -> BS.ByteString
+@@ -167,7 +167,7 @@ hashEncoded' options at HashOptions{..} password salt argon2i argon2d =
+ fmap T.decodeUtf8 (BS.packCString out)
+ where argon2 = variant argon2i argon2d hashVariant
+
+-type Argon2Unencoded = Word32 -> Word32 -> Word32 -> CString -> Word64 -> CString -> Word64 -> CString -> Word64 -> IO Int32
++type Argon2Unencoded = Word32 -> Word32 -> Word32 -> CString -> CSize -> CString -> CSize -> CString -> CSize -> IO Int32
+
+ hash' :: HashOptions
+ -> BS.ByteString
+diff --git a/src/Crypto/Argon2/FFI.hsc b/src/Crypto/Argon2/FFI.hsc
+index 3c0b5c4..e9f334a 100644
+--- a/src/Crypto/Argon2/FFI.hsc
++++ b/src/Crypto/Argon2/FFI.hsc
+@@ -9,17 +9,17 @@ module Crypto.Argon2.FFI where
+ import Foreign
+ import Foreign.C
+
+-foreign import ccall unsafe "argon2.h argon2i_hash_encoded" argon2i_hash_encoded :: (#type const uint32_t) -> (#type const uint32_t) -> (#type const uint32_t) -> Ptr a -> (#type const size_t) -> Ptr b -> (# type const size_t) -> (#type const size_t) -> CString -> (#type const size_t) -> IO (#type int)
++foreign import ccall unsafe "argon2.h argon2i_hash_encoded" argon2i_hash_encoded :: (#type const uint32_t) -> (#type const uint32_t) -> (#type const uint32_t) -> Ptr a -> CSize -> Ptr b -> CSize -> CSize -> CString -> CSize -> IO (#type int)
+
+-foreign import ccall unsafe "argon2.h argon2i_hash_raw" argon2i_hash_raw :: (#type const uint32_t) -> (#type const uint32_t) -> (#type const uint32_t) -> Ptr a -> (#type const size_t) -> Ptr b -> (#type size_t) -> Ptr c -> (#type const size_t) -> IO (#type int)
++foreign import ccall unsafe "argon2.h argon2i_hash_raw" argon2i_hash_raw :: (#type const uint32_t) -> (#type const uint32_t) -> (#type const uint32_t) -> Ptr a -> CSize -> Ptr b -> CSize -> Ptr c -> CSize -> IO (#type int)
+
+-foreign import ccall unsafe "argon2.h argon2d_hash_encoded" argon2d_hash_encoded :: (#type const uint32_t) -> (#type const uint32_t) -> (#type const uint32_t) -> Ptr a -> (#type const size_t) -> Ptr b -> (# type const size_t) -> (#type const size_t) -> CString -> (#type const size_t) -> IO (#type int)
++foreign import ccall unsafe "argon2.h argon2d_hash_encoded" argon2d_hash_encoded :: (#type const uint32_t) -> (#type const uint32_t) -> (#type const uint32_t) -> Ptr a -> CSize -> Ptr b -> CSize -> CSize -> CString -> CSize -> IO (#type int)
+
+-foreign import ccall unsafe "argon2.h argon2d_hash_raw" argon2d_hash_raw :: (#type const uint32_t) -> (#type const uint32_t) -> (#type const uint32_t) -> Ptr a -> (#type const size_t) -> Ptr b -> (#type size_t) -> Ptr c -> (#type const size_t) -> IO (#type int)
++foreign import ccall unsafe "argon2.h argon2d_hash_raw" argon2d_hash_raw :: (#type const uint32_t) -> (#type const uint32_t) -> (#type const uint32_t) -> Ptr a -> CSize -> Ptr b -> CSize -> Ptr c -> CSize -> IO (#type int)
+
+-foreign import ccall unsafe "argon2.h argon2i_verify" argon2i_verify :: CString -> Ptr a -> (#type const size_t) -> IO (#type int)
++foreign import ccall unsafe "argon2.h argon2i_verify" argon2i_verify :: CString -> Ptr a -> CSize -> IO (#type int)
+
+-foreign import ccall unsafe "argon2.h argon2d_verify" argon2d_verify :: CString -> Ptr a -> (#type const size_t) -> IO (#type int)
++foreign import ccall unsafe "argon2.h argon2d_verify" argon2d_verify :: CString -> Ptr a -> CSize -> IO (#type int)
+
+ pattern ARGON2_OK = (#const ARGON2_OK)
+ pattern ARGON2_OUTPUT_PTR_NULL = (#const ARGON2_OUTPUT_PTR_NULL)
+--
+2.9.3
+
diff --git a/p/haskell-argon2/debian/patches/use-packcstringlen.patch b/p/haskell-argon2/debian/patches/use-packcstringlen.patch
new file mode 100644
index 0000000..cb983be
--- /dev/null
+++ b/p/haskell-argon2/debian/patches/use-packcstringlen.patch
@@ -0,0 +1,29 @@
+Description: use packCStringLen to avoid truncating the raw hash on the first NULL
+ Fixes https://github.com/ocharles/argon2/issues/3
+ .
+ hashEncoded' still uses packCString, because there the encoded string does
+ in fact end at NULL.
+From: Joey Hess <joeyh at joeyh.name>
+Date: Mon, 26 Sep 2016 10:48:55 -0400
+Forwarded: https://github.com/ocharles/argon2/pull/4
+
+---
+ src/Crypto/Argon2.hs | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/Crypto/Argon2.hs b/src/Crypto/Argon2.hs
+index 2ed8f18..1ed23fe 100644
+--- a/src/Crypto/Argon2.hs
++++ b/src/Crypto/Argon2.hs
+@@ -195,7 +195,7 @@ hash' options at HashOptions{..} password salt argon2i argon2d =
+ out
+ (fromIntegral outLen)
+ handleSuccessCode res options password salt
+- BS.packCString out
++ BS.packCStringLen (out, outLen)
+ where argon2 = variant argon2i argon2d hashVariant
+
+ handleSuccessCode :: Int32
+--
+2.9.3
+
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-haskell/DHG_packages.git
More information about the Pkg-haskell-commits
mailing list