From 64f5d63d2e2da82e39d15f6cdc6c9636edea2288 Mon Sep 17 00:00:00 2001 From: +shyfire131 <116033104+shyfire-131@users.noreply.github.com> Date: Mon, 13 Mar 2023 14:00:34 -0600 Subject: [PATCH 1/2] Support for building ARM docker images (#679) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add llvm to build stage running docker build on Apple Sillicon would result in this error: #14 49.39 : error: #14 49.39 Warning: Couldn't figure out LLVM version! #14 49.39 Make sure you have installed LLVM between [9 and 13) I assume it can’t find llvm/clang? * install using unattended helper script the current haskell is hardcoded to x86, so switch to using haskell’s official helper script which supports arm also need to bump up setting the path, since ghcup is no longer in /usr/bin reference: https://www.haskell.org/ghcup/guide/#continuous-integration * add numa headers/libs docker build (specifically haskell install step) would fail with : #7 107.2 utils/ghc-cabal/dist-install/build/tmp/ghc-cabal: error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory I think this is because numa isn’t installed on arm instances of focal by default, but it is in later versions anyway this fixes that * also add numa to final The image builds at this point! But it fails to boot on arm - again with a numa error. This fixes that. * don’t specify llvm version --------- Co-authored-by: +shyfire131 --- build.Dockerfile | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/build.Dockerfile b/build.Dockerfile index c8cf42928..a7d670e25 100644 --- a/build.Dockerfile +++ b/build.Dockerfile @@ -4,16 +4,14 @@ FROM ubuntu:focal AS build ### Build stage # Install curl and git and smp-related dependencies -RUN apt-get update && apt-get install -y curl git build-essential libgmp3-dev zlib1g-dev +RUN apt-get update && apt-get install -y curl git build-essential libgmp3-dev zlib1g-dev llvm llvm-dev libnuma-dev # Install ghcup -RUN curl https://downloads.haskell.org/~ghcup/x86_64-linux-ghcup -o /usr/bin/ghcup && \ - chmod +x /usr/bin/ghcup +RUN curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | BOOTSTRAP_HASKELL_NONINTERACTIVE=1 BOOTSTRAP_HASKELL_GHC_VERSION=8.10.7 BOOTSTRAP_HASKELL_CABAL_VERSION=3.6.2.0 sh + +# Adjust PATH +ENV PATH="/root/.cabal/bin:/root/.ghcup/bin:$PATH" -# Install ghc -RUN ghcup install ghc 8.10.7 -# Install cabal -RUN ghcup install cabal # Set both as default RUN ghcup set ghc 8.10.7 && \ ghcup set cabal @@ -21,9 +19,6 @@ RUN ghcup set ghc 8.10.7 && \ COPY . /project WORKDIR /project -# Adjust PATH -ENV PATH="/root/.cabal/bin:/root/.ghcup/bin:$PATH" - # Compile smp-server RUN cabal update RUN cabal install @@ -33,7 +28,7 @@ RUN cabal install FROM final # Install OpenSSL dependency -RUN apt-get update && apt-get install -y openssl +RUN apt-get update && apt-get install -y openssl libnuma-dev # Copy compiled smp-server from build stage COPY --from=build /root/.cabal/bin/smp-server /usr/bin/smp-server From 5258fe9b7e57480ce17b66781a5c2a211c937930 Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com> Date: Fri, 17 Mar 2023 13:01:49 +0000 Subject: [PATCH 2/2] add sha512 (#691) * add sha512 * update export title --- src/Simplex/Messaging/Crypto.hs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Simplex/Messaging/Crypto.hs b/src/Simplex/Messaging/Crypto.hs index 2cbdfafca..f756d7ce6 100644 --- a/src/Simplex/Messaging/Crypto.hs +++ b/src/Simplex/Messaging/Crypto.hs @@ -126,8 +126,9 @@ module Simplex.Messaging.Crypto -- * pseudo-random bytes pseudoRandomBytes, - -- * SHA256 hash + -- * digests sha256Hash, + sha512Hash, -- * Message padding / un-padding pad, @@ -153,7 +154,7 @@ import Crypto.Cipher.AES (AES256) import qualified Crypto.Cipher.Types as AES import qualified Crypto.Cipher.XSalsa as XSalsa import qualified Crypto.Error as CE -import Crypto.Hash (Digest, SHA256 (..), hash) +import Crypto.Hash (Digest, SHA256, SHA512, hash) import qualified Crypto.MAC.Poly1305 as Poly1305 import qualified Crypto.PubKey.Curve25519 as X25519 import qualified Crypto.PubKey.Curve448 as X448 @@ -800,6 +801,10 @@ instance FromField KeyHash where fromField = blobFieldDecoder $ parseAll strP sha256Hash :: ByteString -> ByteString sha256Hash = BA.convert . (hash :: ByteString -> Digest SHA256) +-- | SHA512 digest. +sha512Hash :: ByteString -> ByteString +sha512Hash = BA.convert . (hash :: ByteString -> Digest SHA512) + -- | AEAD-GCM encryption with associated data. -- -- Used as part of double ratchet encryption.