mirror of
https://github.com/archlinuxarm/PKGBUILDs.git
synced 2025-03-19 00:21:40 +00:00
added community/haskell-cryptonite
This commit is contained in:
parent
620381ea1b
commit
8069687157
3 changed files with 157 additions and 0 deletions
|
@ -0,0 +1,25 @@
|
||||||
|
From 43b4b7e0dbfab08cbbf3c54bbc5816153450363c Mon Sep 17 00:00:00 2001
|
||||||
|
From: John Galt <centromere@users.noreply.github.com>
|
||||||
|
Date: Thu, 2 Jun 2016 11:35:08 -0700
|
||||||
|
Subject: [PATCH] Added x86_64 constraint for rdrand
|
||||||
|
|
||||||
|
---
|
||||||
|
cryptonite.cabal | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/cryptonite.cabal b/cryptonite.cabal
|
||||||
|
index dcdfdf8..f7092fe 100644
|
||||||
|
--- a/cryptonite.cabal
|
||||||
|
+++ b/cryptonite.cabal
|
||||||
|
@@ -241,7 +241,7 @@ Library
|
||||||
|
if arch(x86_64)
|
||||||
|
CPP-options: -DARCH_X86_64
|
||||||
|
|
||||||
|
- if flag(support_rdrand)
|
||||||
|
+ if flag(support_rdrand) && arch(x86_64)
|
||||||
|
CPP-options: -DSUPPORT_RDRAND
|
||||||
|
Other-modules: Crypto.Random.Entropy.RDRand
|
||||||
|
c-sources: cbits/cryptonite_rdrand.c
|
||||||
|
--
|
||||||
|
2.8.3
|
||||||
|
|
57
community/haskell-cryptonite/PKGBUILD
Normal file
57
community/haskell-cryptonite/PKGBUILD
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
# $Id$
|
||||||
|
# Maintainer: Felix Yan <felixonmars@archlinux.org>
|
||||||
|
# Contributor: Arch Haskell Team <arch-haskell@haskell.org>
|
||||||
|
|
||||||
|
# ALARM: Kevin Mihelich <kevin@archlinuxarm.org>
|
||||||
|
# - patch to not build rdrand on ARM
|
||||||
|
|
||||||
|
_hkgname=cryptonite
|
||||||
|
pkgname=haskell-cryptonite
|
||||||
|
pkgver=0.16
|
||||||
|
pkgrel=1
|
||||||
|
pkgdesc="Cryptography Primitives sink"
|
||||||
|
url="https://github.com/vincenthz/cryptonite"
|
||||||
|
license=("custom:BSD3")
|
||||||
|
arch=('i686' 'x86_64')
|
||||||
|
depends=("ghc=8.0.1" "haskell-memory")
|
||||||
|
source=("http://hackage.haskell.org/packages/archive/${_hkgname}/${pkgver}/${_hkgname}-${pkgver}.tar.gz"
|
||||||
|
i686.patch
|
||||||
|
0001-Added-x86_64-constraint-for-rdrand.patch)
|
||||||
|
sha256sums=('5c3bf190954986ea4af466914eb7a0c55a0b4c1c66552d00341277c89082511a'
|
||||||
|
'0bd68b7fd7caa859ca9a5dd7343c45c0dfd22c0c5cd55dec626de2dd9804abec'
|
||||||
|
'fe2216d680fda5920758b796660c4aac00994ae146bc37a013def8c1ccc456cf')
|
||||||
|
|
||||||
|
prepare() {
|
||||||
|
cd $_hkgname-$pkgver
|
||||||
|
# https://github.com/haskell-crypto/cryptonite/issues/88
|
||||||
|
patch -p1 -i ../i686.patch
|
||||||
|
|
||||||
|
patch -p1 -i ../0001-Added-x86_64-constraint-for-rdrand.patch
|
||||||
|
}
|
||||||
|
|
||||||
|
build() {
|
||||||
|
cd "${srcdir}/${_hkgname}-${pkgver}"
|
||||||
|
|
||||||
|
runhaskell Setup configure -O --enable-library-profiling --enable-shared \
|
||||||
|
--prefix=/usr --docdir="/usr/share/doc/${pkgname}" \
|
||||||
|
--libsubdir=\$compiler/site-local/\$pkgid \
|
||||||
|
-fsupport_deepseq -finteger-gmp -f-support_pclmuldq -fsupport_rdrand -fsupport_aesni -f-old_toolchain_inliner
|
||||||
|
runhaskell Setup build
|
||||||
|
runhaskell Setup haddock --hoogle --html
|
||||||
|
runhaskell Setup register --gen-script
|
||||||
|
runhaskell Setup unregister --gen-script
|
||||||
|
sed -i -r -e "s|ghc-pkg.*update[^ ]* |&'--force' |" register.sh
|
||||||
|
sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh
|
||||||
|
}
|
||||||
|
|
||||||
|
package() {
|
||||||
|
cd "${srcdir}/${_hkgname}-${pkgver}"
|
||||||
|
|
||||||
|
install -D -m744 register.sh "${pkgdir}/usr/share/haskell/register/${pkgname}.sh"
|
||||||
|
install -D -m744 unregister.sh "${pkgdir}/usr/share/haskell/unregister/${pkgname}.sh"
|
||||||
|
install -d -m755 "${pkgdir}/usr/share/doc/ghc/html/libraries"
|
||||||
|
ln -s "/usr/share/doc/${pkgname}/html" "${pkgdir}/usr/share/doc/ghc/html/libraries/${_hkgname}"
|
||||||
|
runhaskell Setup copy --destdir="${pkgdir}"
|
||||||
|
install -D -m644 "LICENSE" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
|
||||||
|
rm -f "${pkgdir}/usr/share/doc/${pkgname}/LICENSE"
|
||||||
|
}
|
75
community/haskell-cryptonite/i686.patch
Normal file
75
community/haskell-cryptonite/i686.patch
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
From f5a811e755eee253bc34897f327e096e04ad1286 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Vincent Hanquez <vincent@snarc.org>
|
||||||
|
Date: Fri, 3 Jun 2016 07:12:38 +0100
|
||||||
|
Subject: [PATCH] [rdrand] add an untested workaround for i686 machine
|
||||||
|
|
||||||
|
---
|
||||||
|
cbits/cryptonite_rdrand.c | 35 ++++++++++++++++++++++++++++-------
|
||||||
|
1 file changed, 28 insertions(+), 7 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/cbits/cryptonite_rdrand.c b/cbits/cryptonite_rdrand.c
|
||||||
|
index 54409fc..66501e5 100644
|
||||||
|
--- a/cbits/cryptonite_rdrand.c
|
||||||
|
+++ b/cbits/cryptonite_rdrand.c
|
||||||
|
@@ -65,17 +65,38 @@ static inline int crypto_random_rdrand64_step(uint64_t *buffer)
|
||||||
|
: \
|
||||||
|
: "cc")
|
||||||
|
|
||||||
|
+/* inline encoding of 'rdrand %eax' to cover old binutils
|
||||||
|
+ * - no inputs
|
||||||
|
+ * - 'cc' to the clobber list as we modify condition code.
|
||||||
|
+ * - output of rdrand in eax and have a 8 bit error condition
|
||||||
|
+ */
|
||||||
|
+#define inline_rdrand_eax(val, err) \
|
||||||
|
+ asm(".byte 0x0f,0xc7,0xf0; setc %1" \
|
||||||
|
+ : "=a" (val), "=q" (err) \
|
||||||
|
+ : \
|
||||||
|
+ : "cc")
|
||||||
|
+
|
||||||
|
+#ifdef __x86_64__
|
||||||
|
+# define RDRAND_SZ 8
|
||||||
|
+# define RDRAND_T uint64_t
|
||||||
|
+#define inline_rdrand(val, err) inline_rdrand_rax(val, err)
|
||||||
|
+#else
|
||||||
|
+# define RDRAND_SZ 4
|
||||||
|
+# define RDRAND_T uint32_t
|
||||||
|
+#define inline_rdrand(val, err) inline_rdrand_eax(val, err)
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
/* Returns the number of bytes succesfully generated */
|
||||||
|
int cryptonite_get_rand_bytes(uint8_t *buffer, size_t len)
|
||||||
|
{
|
||||||
|
- uint64_t tmp;
|
||||||
|
- int aligned = (intptr_t) buffer % 8;
|
||||||
|
+ RDRAND_T tmp;
|
||||||
|
+ int aligned = (intptr_t) buffer % RDRAND_SZ;
|
||||||
|
int orig_len = len;
|
||||||
|
- int to_alignment = 8 - aligned;
|
||||||
|
+ int to_alignment = RDRAND_SZ - aligned;
|
||||||
|
uint8_t ok;
|
||||||
|
|
||||||
|
if (aligned != 0) {
|
||||||
|
- inline_rdrand_rax(tmp, ok);
|
||||||
|
+ inline_rdrand(tmp, ok);
|
||||||
|
if (!ok)
|
||||||
|
return 0;
|
||||||
|
memcpy(buffer, (uint8_t *) &tmp, to_alignment);
|
||||||
|
@@ -83,15 +104,15 @@ int cryptonite_get_rand_bytes(uint8_t *buffer, size_t len)
|
||||||
|
len -= to_alignment;
|
||||||
|
}
|
||||||
|
|
||||||
|
- for (; len >= 8; buffer += 8, len -= 8) {
|
||||||
|
- inline_rdrand_rax(tmp, ok);
|
||||||
|
+ for (; len >= RDRAND_SZ; buffer += RDRAND_SZ, len -= RDRAND_SZ) {
|
||||||
|
+ inline_rdrand(tmp, ok);
|
||||||
|
if (!ok)
|
||||||
|
return (orig_len - len);
|
||||||
|
*((uint64_t *) buffer) = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (len > 0) {
|
||||||
|
- inline_rdrand_rax(tmp, ok);
|
||||||
|
+ inline_rdrand(tmp, ok);
|
||||||
|
if (!ok)
|
||||||
|
return (orig_len - len);
|
||||||
|
memcpy(buffer, (uint8_t *) &tmp, len);
|
Loading…
Reference in a new issue