uuid-crypto 1.1.0.1 → 1.1.1.0
raw patch · 3 files changed
+12/−39 lines, 3 filesdep −cryptonitedep −memorydep ~cryptoidsPVP ok
version bump matches the API change (PVP)
Dependencies removed: cryptonite, memory
Dependency ranges changed: cryptoids
API changes (from Hackage documentation)
Files
- changes.md +3/−0
- src/Data/UUID/Cryptographic.hs +7/−35
- uuid-crypto.cabal +2/−4
changes.md view
@@ -1,3 +1,6 @@+# 1.1.1.0+ - Switch to using the new 'Data.CryptoID.Poly'+ # 1.1.0.1 - Update version constraint on @cryptoids@
src/Data/UUID/Cryptographic.hs view
@@ -31,14 +31,8 @@ import Data.UUID (UUID, toByteString, fromByteString) import Data.Binary -import Data.ByteString (ByteString)-import qualified Data.ByteString as ByteString- import qualified Data.ByteString.Lazy as Lazy.ByteString -import Data.ByteArray (ByteArrayAccess)-import qualified Data.ByteArray as ByteArray- import Control.Monad.Catch import GHC.TypeLits@@ -47,20 +41,6 @@ type CryptoUUID (namespace :: Symbol) = CryptoID namespace UUID -_ciphertext :: Functor m => (a -> m b) -> CryptoID n a -> m (CryptoID n b)-_ciphertext f (CryptoID x) = CryptoID <$> f x----- | @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 :: (MonadThrow m, ByteArrayAccess a) => Int -> a -> m ByteString-pad n (ByteArray.unpack -> src)- | l > n = throwM CiphertextConversionFailed- | otherwise = return . ByteString.pack $ src ++ replicate (n - l) 0- where- l = length src- -- | Encrypt an arbitrary serializable value -- -- We only expect to fail if the given value is not serialized in such a fashion@@ -73,12 +53,7 @@ , Binary a , 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 (throwM CiphertextConversionFailed) return . fromByteString . Lazy.ByteString.fromStrict+encrypt = Poly.encrypt $ maybe (throwM CiphertextConversionFailed) return . fromByteString . Lazy.ByteString.fromStrict -- | Decrypt an arbitrary serializable value@@ -91,12 +66,9 @@ , Binary a , 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 -> throwM $ DeserializationError err- Right (rem, _, res)- | Lazy.ByteString.all (== 0) rem -> return res- | otherwise -> throwM InvalidNamespaceDetected+decrypt = Poly.decrypt $ check . decodeOrFail . toByteString+ where+ check (Left err) = throwM $ DeserializationError err+ check (Right (rem, _, res))+ | Lazy.ByteString.all (== 0) rem = return res+ | otherwise = throwM InvalidNamespaceDetected
uuid-crypto.cabal view
@@ -1,5 +1,5 @@ name: uuid-crypto-version: 1.1.0.1+version: 1.1.1.0 cabal-version: >=1.10 build-type: Simple license: BSD3@@ -22,11 +22,9 @@ build-depends: base >=4.9 && <4.11, cryptoids-types ==0.0.0,- cryptoids ==0.1.0.*,+ cryptoids ==0.2.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, exceptions >=0.8.3 && <0.9 default-language: Haskell2010