From c782bc44deab041ca34b88384d8000ab911e80f6 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Thu, 9 Apr 2020 18:27:07 +0200 Subject: [PATCH] Avoid unnecessary OpenSSL deps --- ghcup.cabal | 14 +++++++++----- lib/GHCup/Download.hs | 5 +++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/ghcup.cabal b/ghcup.cabal index 1213069..82603d1 100644 --- a/ghcup.cabal +++ b/ghcup.cabal @@ -47,6 +47,9 @@ common attoparsec common base build-depends: base >=4.12 && <5 +common base16-bytestring + build-depends: base16-bytestring >= 0.1.1.6 + common binary build-depends: binary >=0.8.6.0 @@ -65,6 +68,9 @@ common concurrent-output common containers build-depends: containers >=0.6 +common cryptohash-sha256 + build-depends: cryptohash-sha256 >= 0.11.101.0 + common generics-sop build-depends: generics-sop >=0.5 @@ -74,9 +80,6 @@ common haskus-utils-types common haskus-utils-variant build-depends: haskus-utils-variant >=3.0 -common hopenssl - build-depends: hopenssl >=2.2.4 - common hpath build-depends: hpath >=0.11 @@ -223,7 +226,7 @@ library import: config , base - , HsOpenSSL + , base16-bytestring , aeson , ascii-string , async @@ -234,10 +237,10 @@ library , case-insensitive , concurrent-output , containers + , cryptohash-sha256 , generics-sop , haskus-utils-types , haskus-utils-variant - , hopenssl , hpath , hpath-directory , hpath-filepath @@ -301,6 +304,7 @@ library if !flag(curl) import: + , HsOpenSSL , http-io-streams , io-streams , terminal-progress-bar diff --git a/lib/GHCup/Download.hs b/lib/GHCup/Download.hs index d617e50..f24efef 100644 --- a/lib/GHCup/Download.hs +++ b/lib/GHCup/Download.hs @@ -45,7 +45,6 @@ import GHC.IO.Exception import HPath import HPath.IO as HIO import Haskus.Utils.Variant.Excepts -import OpenSSL.Digest import Optics import Prelude hiding ( abs , readFile @@ -54,6 +53,8 @@ import Prelude hiding ( abs import System.IO.Error import URI.ByteString +import qualified Crypto.Hash.SHA256 as SHA256 +import qualified Data.ByteString.Base16 as B16 import qualified Data.ByteString.Lazy as L import qualified Data.CaseInsensitive as CI import qualified Data.Map.Strict as M @@ -400,7 +401,7 @@ checkDigest dli file = do let p' = toFilePath file lift $ $(logInfo) [i|verifying digest of: #{p'}|] c <- liftIO $ readFile file - let cDigest = E.decodeUtf8 . toHex . digest (digestByName "sha256") $ c + let cDigest = E.decodeUtf8 . B16.encode . SHA256.hashlazy $ c eDigest = view dlHash dli when ((cDigest /= eDigest) && verify) $ throwE (DigestError cDigest eDigest)