From d5ad5ff7850ca40016141ea79d8c0d6223bb8507 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Mon, 15 Jan 2018 14:44:02 +0100 Subject: [PATCH] Switch to hpack & get rid of encoding --- .gitignore | 4 ++ cryptoids-types/cryptoids-types.cabal | 30 ------------- cryptoids-types/package.yaml | 33 ++++++++++++++ cryptoids/cryptoids.cabal | 37 --------------- cryptoids/package.yaml | 37 +++++++++++++++ filepath-crypto/changes.md | 3 ++ filepath-crypto/filepath-crypto.cabal | 45 ------------------- filepath-crypto/package.yaml | 44 ++++++++++++++++++ .../src/System/FilePath/Cryptographic.hs | 7 ++- gup/Gupfile | 4 +- gup/cryptoids.nix.gup | 21 +++++++++ gup/hpack.gup | 8 ++++ stack.yaml | 3 +- uuid-crypto/package.yaml | 39 ++++++++++++++++ uuid-crypto/uuid-crypto.cabal | 38 ---------------- 15 files changed, 196 insertions(+), 157 deletions(-) delete mode 100644 cryptoids-types/cryptoids-types.cabal create mode 100644 cryptoids-types/package.yaml delete mode 100644 cryptoids/cryptoids.cabal create mode 100644 cryptoids/package.yaml delete mode 100644 filepath-crypto/filepath-crypto.cabal create mode 100644 filepath-crypto/package.yaml create mode 100755 gup/cryptoids.nix.gup create mode 100755 gup/hpack.gup create mode 100644 uuid-crypto/package.yaml delete mode 100644 uuid-crypto/uuid-crypto.cabal diff --git a/.gitignore b/.gitignore index ea2592b..a94e1e9 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,11 @@ **/.stack-work **/dist +cryptoids/cryptoids.cabal cryptoids/cryptoids.nix +cryptoids-types/cryptoids-types.cabal cryptoids-types/cryptoids-types.nix +filepath-crypto/filepath-crypto.cabal filepath-crypto/filepath-crypto.nix +uuid-crypto/uuid-crypto.cabal uuid-crypto/uuid-crypto.nix diff --git a/cryptoids-types/cryptoids-types.cabal b/cryptoids-types/cryptoids-types.cabal deleted file mode 100644 index 6553ee0..0000000 --- a/cryptoids-types/cryptoids-types.cabal +++ /dev/null @@ -1,30 +0,0 @@ -name: cryptoids-types -synopsis: Shared types for encrypting internal object identifiers before exposure -version: 0.0.0 -license: BSD3 -license-file: LICENSE -author: Gregor Kleen -maintainer: aethoago@141.li -category: Web -build-type: Simple -cabal-version: >=1.10 -extra-source-files: changes.md -source-repository head - type: git - location: https://git.rheperire.org/cryptoids - subdir: cryptoids-types - -library - exposed-modules: Data.CryptoID - default-extensions: KindSignatures - , DataKinds - , GeneralizedNewtypeDeriving - , DeriveGeneric - , DeriveDataTypeable - build-depends: base >=4.9 && <4.11 - , binary >=0.8.3.0 && <0.9 - , path-pieces >=0.2.1 && <0.3 - , http-api-data >=0.3.7.1 && <0.4 - hs-source-dirs: src - default-language: Haskell2010 - ghc-options: -Wall -fno-warn-name-shadowing diff --git a/cryptoids-types/package.yaml b/cryptoids-types/package.yaml new file mode 100644 index 0000000..84454d4 --- /dev/null +++ b/cryptoids-types/package.yaml @@ -0,0 +1,33 @@ +name: cryptoids-types +synopsis: Shared types for encrypting internal object identifiers before exposure +version: 0.0.0 +license: BSD3 +license-file: LICENSE +author: Gregor Kleen +maintainer: Gregor Kleen +category: Web +extra-doc-files: + - changes.md +git: https://git.rheperire.org/cryptoids/cryptoids-types + +default-extensions: + - KindSignatures + - DataKinds + - GeneralizedNewtypeDeriving + - DeriveGeneric + - DeriveDataTypeable + +ghc-options: + - -Wall + - -fno-warn-name-shadowing + +dependencies: + - base + - binary + - path-pieces + - http-api-data + +library: + source-dirs: src + exposed-modules: + - Data.CryptoID diff --git a/cryptoids/cryptoids.cabal b/cryptoids/cryptoids.cabal deleted file mode 100644 index e27c527..0000000 --- a/cryptoids/cryptoids.cabal +++ /dev/null @@ -1,37 +0,0 @@ -name: cryptoids -version: 0.4.0.0 -synopsis: Reversable and secure encoding of object ids as a bytestring -license: BSD3 -license-file: LICENSE -author: Gregor Kleen -maintainer: aethoago@141.li -category: cryptography -build-type: Simple -cabal-version: >=1.10 -extra-source-files: changes.md -source-repository head - type: git - location: https://git.rheperire.org/cryptoids - subdir: cryptoids - -library - exposed-modules: Data.CryptoID.Poly - , Data.CryptoID.ByteString - default-extensions: RankNTypes - , DataKinds - , GeneralizedNewtypeDeriving - , ViewPatterns - , RecordWildCards - , FlexibleContexts - build-depends: base >=4.9.1.0 && <4.11 - , cryptoids-types ==0.0.0 - , cryptonite >=0.23 && <0.25 - , bytestring >=0.10.8.1 && <0.11 - , binary >=0.8.3.0 && <0.9 - , memory >=0.14.6 && <0.15 - , exceptions >=0.8.3 && <0.9 - , filepath >=1.4.1.1 && <1.5 - , directory >=1.3.0.0 && <1.4 - hs-source-dirs: src - default-language: Haskell2010 - ghc-options: -Wall -fno-warn-name-shadowing diff --git a/cryptoids/package.yaml b/cryptoids/package.yaml new file mode 100644 index 0000000..8028532 --- /dev/null +++ b/cryptoids/package.yaml @@ -0,0 +1,37 @@ +name: cryptoids +version: 0.4.0.0 +synopsis: Reversable and secure encoding of object ids as a bytestring +category: cryptography +author: Gregor Kleen +maintainer: Gregor Kleen +license: BSD3 +git: https://git.rheperire.org/cryptoids/cryptoids +extra-doc-files: + - changes.md + +default-extensions: + - RankNTypes + - DataKinds + - GeneralizedNewtypeDeriving + - ViewPatterns + - RecordWildCards + - FlexibleContexts +ghc-options: + - -Wall + - -fno-warn-name-shadowing +dependencies: + - base + - cryptoids-types + - cryptonite + - bytestring + - binary + - memory + - exceptions + - filepath + - directory + +library: + source-dirs: src + exposed-modules: + - Data.CryptoID.Poly + - Data.CryptoID.ByteString diff --git a/filepath-crypto/changes.md b/filepath-crypto/changes.md index 0c551fc..1763ba6 100644 --- a/filepath-crypto/changes.md +++ b/filepath-crypto/changes.md @@ -1,3 +1,6 @@ +# 0.0.0.3 + - Got rid of `encoding` + # 0.0.0.2 - Improved documentation diff --git a/filepath-crypto/filepath-crypto.cabal b/filepath-crypto/filepath-crypto.cabal deleted file mode 100644 index 59084fb..0000000 --- a/filepath-crypto/filepath-crypto.cabal +++ /dev/null @@ -1,45 +0,0 @@ -name: filepath-crypto -version: 0.0.0.2 -synopsis: Reversable and secure encoding of object ids as filepaths -license: BSD3 -license-file: LICENSE -author: Gregor Kleen -maintainer: aethoago@141.li -category: cryptography -build-type: Simple -cabal-version: >=1.10 -extra-source-files: changes.md -source-repository head - type: git - location: https://git.rheperire.org/cryptoids - subdir: filepath-crypto - -library - exposed-modules: System.FilePath.Cryptographic - , Data.Binary.SerializationLength - , Data.Binary.SerializationLength.TH - other-modules: Data.Binary.SerializationLength.Class - default-extensions: KindSignatures - , ViewPatterns - , FlexibleContexts - , GeneralizedNewtypeDeriving - , PatternGuards - , RecordWildCards - , DataKinds - , DeriveDataTypeable - , DeriveGeneric - other-extensions: ScopedTypeVariables - build-depends: base >=4.9 && <4.11 - , cryptoids-types ==0.0.0 - , cryptoids ==0.4.0.* - , filepath >=1.4.1.1 && <1.5 - , sandi >=0.4.1 && <0.5 - , case-insensitive >=1.2.0.10 && <1.3 - , binary >=0.8.3.0 && <0.9 - , bytestring >=0.10.8.1 && <0.11 - , exceptions >=0.8.3 && <0.9 - , encoding >=0.8.2 && <0.9 - , template-haskell >=2.11.0.0 && <2.13 - hs-source-dirs: src - default-language: Haskell2010 - ghc-options: -Wall -fno-warn-name-shadowing diff --git a/filepath-crypto/package.yaml b/filepath-crypto/package.yaml new file mode 100644 index 0000000..debc70c --- /dev/null +++ b/filepath-crypto/package.yaml @@ -0,0 +1,44 @@ +name: filepath-crypto +version: 0.0.0.3 +synopsis: Reversable and secure encoding of object ids as filepaths +category: cryptography +author: Gregor Kleen +maintainer: Gregor Kleen +license: BSD3 +git: https://git.rheperire.org/cryptoids/filepath-crypto +extra-doc-files: + - changes.md + +default-extensions: + - KindSignatures + - ViewPatterns + - FlexibleContexts + - GeneralizedNewtypeDeriving + - PatternGuards + - RecordWildCards + - DataKinds + - DeriveDataTypeable + - DeriveGeneric +other-extensions: + - ScopedTypeVariables +ghc-options: + - -Wall + - -fno-warn-name-shadowing +dependencies: + - base + - cryptoids-types + - cryptoids + - filepath + - sandi + - case-insensitive + - binary + - bytestring + - exceptions + - template-haskell + +library: + source-dirs: src + exposed-modules: + - System.FilePath.Cryptographic + - Data.Binary.SerializationLength + - Data.Binary.SerializationLength.TH diff --git a/filepath-crypto/src/System/FilePath/Cryptographic.hs b/filepath-crypto/src/System/FilePath/Cryptographic.hs index 8500269..be93cb1 100644 --- a/filepath-crypto/src/System/FilePath/Cryptographic.hs +++ b/filepath-crypto/src/System/FilePath/Cryptographic.hs @@ -47,14 +47,13 @@ import Data.CaseInsensitive (CI) import qualified Data.CaseInsensitive as CI import Data.Binary import Data.Binary.SerializationLength -import Data.Encoding.UTF8 -import Data.Encoding (decodeStrictByteString, encodeStrictByteString) import Data.Char (toUpper) import Data.Ratio ((%)) import Data.List import qualified Data.ByteString as ByteString +import qualified Data.ByteString.Char8 as ByteString.Char8 import Control.Monad import Control.Monad.Catch @@ -88,7 +87,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 (== '=') . decodeStrictByteString UTF8 $ Base32.encode str + encode str = CI.mk . dropWhileEnd (== '=') . ByteString.Char8.unpack $ Base32.encode str -- | Decrypt an arbitrary serializable value @@ -102,7 +101,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) . encodeStrictByteString UTF8 . padding (natVal (Proxy :: Proxy (SerializationLength a))) . map toUpper . CI.original +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 where padding l str = str ++ replicate (genericIndex paddingTable $ l' `mod` 5) '=' where diff --git a/gup/Gupfile b/gup/Gupfile index 67efea3..c50809b 100644 --- a/gup/Gupfile +++ b/gup/Gupfile @@ -1,2 +1,4 @@ cabal2nix.gup: - **/*.nix \ No newline at end of file + **/*.nix +hpack.gup: + **/*.cabal \ No newline at end of file diff --git a/gup/cryptoids.nix.gup b/gup/cryptoids.nix.gup new file mode 100755 index 0000000..d654968 --- /dev/null +++ b/gup/cryptoids.nix.gup @@ -0,0 +1,21 @@ +#! /usr/bin/env nix-shell +#! nix-shell -i zsh -p zsh + +exec 1>${1} + +gup -u \ + ./cryptoids-types/cryptoids-types.nix \ + ./uuid-crypto/uuid-crypto.nix \ + ./filepath-crypto/filepath-crypto.nix \ + ./cryptoids/cryptoids.nix + + <${1} \ No newline at end of file diff --git a/stack.yaml b/stack.yaml index 430eb93..ee66e5b 100644 --- a/stack.yaml +++ b/stack.yaml @@ -15,7 +15,7 @@ # resolver: # name: custom-snapshot # location: "./custom-snapshot.yaml" -resolver: lts-9.9 +resolver: lts-10.3 # User packages to be built. # Various formats can be used as shown in the example below. @@ -44,7 +44,6 @@ packages: # (e.g., acme-missiles-0.3) extra-deps: - regex-compat-0.93.1 - - encoding-0.8.2 # Override default flag values for local packages and extra-deps flags: {} diff --git a/uuid-crypto/package.yaml b/uuid-crypto/package.yaml new file mode 100644 index 0000000..9ebe53d --- /dev/null +++ b/uuid-crypto/package.yaml @@ -0,0 +1,39 @@ +name: uuid-crypto +version: 1.3.1.0 +synopsis: Reversable and secure encoding of object ids as uuids +category: cryptography +author: Gregor Kleen +maintainer: Gregor Kleen +license: BSD3 +git: https://git.rheperire.org/cryptoids/uuid-crypto +extra-doc-files: + - changes.md + +default-extensions: + - KindSignatures + - ViewPatterns + - FlexibleContexts + - GeneralizedNewtypeDeriving + - PatternGuards + - RecordWildCards + - DataKinds + - DeriveDataTypeable + - DeriveGeneric +other-extensions: + - ScopedTypeVariables +ghc-options: + - -Wall + - -fno-warn-name-shadowing +dependencies: + - base + - cryptoids-types + - cryptoids + - uuid + - binary + - bytestring + - exceptions + +library: + source-dirs: src + exposed-modules: + - Data.UUID.Cryptographic diff --git a/uuid-crypto/uuid-crypto.cabal b/uuid-crypto/uuid-crypto.cabal deleted file mode 100644 index 686474b..0000000 --- a/uuid-crypto/uuid-crypto.cabal +++ /dev/null @@ -1,38 +0,0 @@ -name: uuid-crypto -version: 1.3.1.0 -synopsis: Reversable and secure encoding of object ids as uuids -license: BSD3 -license-file: LICENSE -author: Gregor Kleen -maintainer: aethoago@141.li -category: cryptography -build-type: Simple -cabal-version: >=1.10 -extra-source-files: changes.md -source-repository head - type: git - location: https://git.rheperire.org/cryptoids - subdir: uuid-crypto - -library - exposed-modules: Data.UUID.Cryptographic - default-extensions: KindSignatures - , ViewPatterns - , FlexibleContexts - , GeneralizedNewtypeDeriving - , PatternGuards - , RecordWildCards - , DataKinds - , DeriveDataTypeable - , DeriveGeneric - other-extensions: ScopedTypeVariables - build-depends: base >=4.9 && <4.11 - , cryptoids-types ==0.0.0 - , cryptoids ==0.4.0.* - , uuid >=1.3.13 && <1.4 - , binary >=0.8.3.0 && <0.9 - , bytestring >=0.10.8.1 && <0.11 - , exceptions >=0.8.3 && <0.9 - hs-source-dirs: src - default-language: Haskell2010 - ghc-options: -Wall -fno-warn-name-shadowing