uuid-crypto 1.0.0 → 1.1.0
raw patch · 3 files changed
+14/−11 lines, 3 filesdep +exceptionsdep −mtldep ~cryptoidsPVP ok
version bump matches the API change (PVP)
Dependencies added: exceptions
Dependencies removed: mtl
Dependency ranges changed: cryptoids
API changes (from Hackage documentation)
- Data.UUID.Cryptographic: decrypt :: forall a m namespace. (KnownSymbol namespace, Binary a, MonadError CryptoIDError m) => CryptoIDKey -> CryptoUUID namespace -> m a
+ Data.UUID.Cryptographic: decrypt :: forall a m namespace. (KnownSymbol namespace, Binary a, MonadThrow m) => CryptoIDKey -> CryptoUUID namespace -> m a
- Data.UUID.Cryptographic: encrypt :: forall a m namespace. (KnownSymbol namespace, Binary a, MonadError CryptoIDError m) => CryptoIDKey -> a -> m (CryptoUUID namespace)
+ Data.UUID.Cryptographic: encrypt :: forall a m namespace. (KnownSymbol namespace, Binary a, MonadThrow m) => CryptoIDKey -> a -> m (CryptoUUID namespace)
Files
- changes.md +3/−0
- src/Data/UUID/Cryptographic.hs +8/−8
- uuid-crypto.cabal +3/−3
changes.md view
@@ -1,3 +1,6 @@+# 1.1.0+ - Switch to using 'MonadThrow' instead of 'MonadError'+ # 1.0.0 First published version
src/Data/UUID/Cryptographic.hs view
@@ -39,7 +39,7 @@ import Data.ByteArray (ByteArrayAccess) import qualified Data.ByteArray as ByteArray -import Control.Monad.Except+import Control.Monad.Catch import GHC.TypeLits @@ -54,9 +54,9 @@ -- | @pad err size src@ appends null bytes to @src@ until it has length @size@. -- -- If @src@ is already longer than @size@ @err@ is thrown instead.-pad :: (MonadError CryptoIDError m, ByteArrayAccess a) => Int -> a -> m ByteString+pad :: (MonadThrow m, ByteArrayAccess a) => Int -> a -> m ByteString pad n (ByteArray.unpack -> src)- | l > n = throwError CiphertextConversionFailed+ | l > n = throwM CiphertextConversionFailed | otherwise = return . ByteString.pack $ src ++ replicate (n - l) 0 where l = length src@@ -71,14 +71,14 @@ encrypt :: forall a m namespace. ( KnownSymbol namespace , Binary a- , MonadError CryptoIDError m+ , MonadThrow m ) => CryptoIDKey -> a -> m (CryptoUUID namespace) encrypt key val = do plaintext <- pad 16 . Lazy.ByteString.toStrict $ encode val _ciphertext uuidConversion =<< Poly.encrypt key plaintext where- uuidConversion = maybe (throwError CiphertextConversionFailed) return . fromByteString . Lazy.ByteString.fromStrict+ uuidConversion = maybe (throwM CiphertextConversionFailed) return . fromByteString . Lazy.ByteString.fromStrict -- | Decrypt an arbitrary serializable value@@ -89,14 +89,14 @@ decrypt :: forall a m namespace. ( KnownSymbol namespace , Binary a- , MonadError CryptoIDError m+ , MonadThrow m ) => CryptoIDKey -> CryptoUUID namespace -> m a decrypt key cId = do cId' <- _ciphertext (return . Lazy.ByteString.toStrict . toByteString) cId plaintext <- Lazy.ByteString.fromStrict <$> Poly.decrypt key cId' case decodeOrFail plaintext of- Left err -> throwError $ DeserializationError err+ Left err -> throwM $ DeserializationError err Right (rem, _, res) | Lazy.ByteString.all (== 0) rem -> return res- | otherwise -> throwError InvalidNamespaceDetected+ | otherwise -> throwM InvalidNamespaceDetected
uuid-crypto.cabal view
@@ -1,5 +1,5 @@ name: uuid-crypto-version: 1.0.0+version: 1.1.0 cabal-version: >=1.10 build-type: Simple license: BSD3@@ -22,13 +22,13 @@ build-depends: base >=4.9 && <4.11, cryptoids-types ==0.0.0,- cryptoids ==0.0.0,+ cryptoids ==0.1.0, uuid >=1.3.13 && <1.4, cryptonite >=0.23 && <0.25, binary >=0.8.3.0 && <0.9, memory >=0.14.6 && <0.15, bytestring >=0.10.8.1 && <0.11,- mtl >=2.2.1 && <2.3+ exceptions >=0.8.3 && <0.9 default-language: Haskell2010 default-extensions: KindSignatures ViewPatterns FlexibleContexts GeneralizedNewtypeDeriving PatternGuards RecordWildCards DataKinds