From 5e9a7e4c3c9905d192185c9f70528b5d2b9e0bd9 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Mon, 17 Aug 2020 17:35:23 +0200 Subject: [PATCH] Remove dependency on sandi --- cryptoids-class/package.yaml | 1 + filepath-crypto/package.yaml | 2 +- .../src/System/FilePath/Cryptographic.hs | 6 +++--- stack.yaml.lock | 19 +++++++++++++++++++ 4 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 stack.yaml.lock diff --git a/cryptoids-class/package.yaml b/cryptoids-class/package.yaml index 51ea355..ea69ad2 100644 --- a/cryptoids-class/package.yaml +++ b/cryptoids-class/package.yaml @@ -18,6 +18,7 @@ default-extensions: - FlexibleContexts - ConstraintKinds - PatternSynonyms + - TypeFamilyDependencies ghc-options: - -Wall diff --git a/filepath-crypto/package.yaml b/filepath-crypto/package.yaml index 897c9d2..fb3803b 100644 --- a/filepath-crypto/package.yaml +++ b/filepath-crypto/package.yaml @@ -34,12 +34,12 @@ dependencies: - cryptoids-class >=0.0.0 && <0.1 - cryptoids >=0.5 && <0.6 - filepath >=1.4.1 && <1.5 - - sandi >=0.4.0 && <0.6 - case-insensitive >=1.2.0 && <1.3 - binary >=0.8.3 && <0.11 - bytestring >=0.10.8 && <0.11 - exceptions >=0.8.3 && <0.11 - template-haskell >=2.11.1 && <2.16 + - base32 <0.3.0.0 library: source-dirs: src diff --git a/filepath-crypto/src/System/FilePath/Cryptographic.hs b/filepath-crypto/src/System/FilePath/Cryptographic.hs index ce18b03..eeca2ac 100644 --- a/filepath-crypto/src/System/FilePath/Cryptographic.hs +++ b/filepath-crypto/src/System/FilePath/Cryptographic.hs @@ -44,7 +44,7 @@ import Data.CryptoID.Class (HasCryptoID) import qualified Data.CryptoID.Class as Class (HasCryptoID(..)) import System.FilePath (FilePath) -import qualified Codec.Binary.Base32 as Base32 +import Data.ByteString.Base32 import Data.CaseInsensitive (CI) import qualified Data.CaseInsensitive as CI import Data.Binary @@ -90,7 +90,7 @@ encrypt = Poly.encrypt determineLength $ return . encode unless (fromIntegral l == natVal (Proxy :: Proxy (SerializationLength a))) $ throwM $ CiphertextConversionFailed str return . Just $ paddedLength l - encode str = CI.mk . dropWhileEnd (== '=') . ByteString.Char8.unpack $ Base32.encode str + encode str = CI.mk . ByteString.Char8.unpack $ encodeBase32Unpadded' str -- | Decrypt an arbitrary serializable value @@ -104,7 +104,7 @@ decrypt :: forall a m namespace. , MonadThrow m , HasFixedSerializationLength a ) => CryptoIDKey -> CryptoFileName namespace -> m a -decrypt = Poly.decrypt $ (\str -> either (const . throwM $ CiphertextConversionFailed str) return $ Base32.decode str) . ByteString.Char8.pack . padding (natVal (Proxy :: Proxy (SerializationLength a))) . map toUpper . CI.original +decrypt = Poly.decrypt $ (\str -> either (const . throwM $ CiphertextConversionFailed str) return $ decodeBase32Unpadded str) . ByteString.Char8.pack . padding (natVal (Proxy :: Proxy (SerializationLength a))) . map toUpper . CI.original where padding l str = str ++ replicate (genericIndex paddingTable $ l' `mod` 5) '=' where diff --git a/stack.yaml.lock b/stack.yaml.lock new file mode 100644 index 0000000..0b66420 --- /dev/null +++ b/stack.yaml.lock @@ -0,0 +1,19 @@ +# This file was autogenerated by Stack. +# You should not edit this file by hand. +# For more information, please see the documentation at: +# https://docs.haskellstack.org/en/stable/lock_files + +packages: +- completed: + hackage: sandi-0.5@sha256:b278d072ca717706ea38f9bd646e023f7f2576a778fb43565b434f93638849aa,3010 + pantry-tree: + size: 3455 + sha256: 5ca7ce4bc22ab9d4427bb149b5e283ab9db43375df14f7131fdfd48775f36350 + original: + hackage: sandi-0.5 +snapshots: +- completed: + size: 498186 + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/13/22.yaml + sha256: d4f07dc3d5658260c2fe34266ad7618f6c84d34decf559c9c786ac1cfccf4e7b + original: lts-13.22