fix ambiguous occurrences
This commit is contained in:
parent
509158793d
commit
1752d03fe7
@ -106,7 +106,7 @@ instance Binary CryptoIDKey where
|
|||||||
-- that parses)
|
-- that parses)
|
||||||
getKey (KeySizeFixed n) = getByteString n
|
getKey (KeySizeFixed n) = getByteString n
|
||||||
getKey (KeySizeEnum ns) = asum [ getKey $ KeySizeFixed n | n <- sortOn Down ns ]
|
getKey (KeySizeEnum ns) = asum [ getKey $ KeySizeFixed n | n <- sortOn Down ns ]
|
||||||
getKey (KeySizeRange min max) = getKey $ KeySizeEnum [min .. max]
|
getKey (KeySizeRange min' max') = getKey $ KeySizeEnum [min' .. max']
|
||||||
|
|
||||||
|
|
||||||
-- | Error cases that can be encountered during 'encrypt' and 'decrypt'
|
-- | Error cases that can be encountered during 'encrypt' and 'decrypt'
|
||||||
@ -169,7 +169,7 @@ genKey = CryptoIDKey <$> liftIO (getEntropy keySize)
|
|||||||
keySize
|
keySize
|
||||||
| KeySizeFixed n <- keySize' = n
|
| KeySizeFixed n <- keySize' = n
|
||||||
| KeySizeEnum ns <- keySize' = maximum ns
|
| KeySizeEnum ns <- keySize' = maximum ns
|
||||||
| KeySizeRange _ max <- keySize' = max
|
| KeySizeRange _ max' <- keySize' = max'
|
||||||
|
|
||||||
-- | Try to read a 'CryptoIDKey' from a file.
|
-- | Try to read a 'CryptoIDKey' from a file.
|
||||||
-- If the file does not exist, securely generate a key (using 'genKey') and
|
-- If the file does not exist, securely generate a key (using 'genKey') and
|
||||||
|
|||||||
@ -76,14 +76,14 @@ decrypt :: forall a m c namespace.
|
|||||||
, MonadThrow m
|
, MonadThrow m
|
||||||
, Binary a
|
, Binary a
|
||||||
) => (c -> m ByteString) -> CryptoIDKey -> CryptoID namespace c -> m a
|
) => (c -> m ByteString) -> CryptoIDKey -> CryptoID namespace c -> m a
|
||||||
decrypt decode key cID = do
|
decrypt dcode key cID = do
|
||||||
cID' <- _ciphertext decode cID
|
cID' <- _ciphertext dcode cID
|
||||||
plaintext <- Lazy.ByteString.fromStrict <$> ByteString.decrypt key cID'
|
plaintext <- Lazy.ByteString.fromStrict <$> ByteString.decrypt key cID'
|
||||||
|
|
||||||
case decodeOrFail plaintext of
|
case decodeOrFail plaintext of
|
||||||
Left _ -> throwM DeserializationError
|
Left _ -> throwM DeserializationError
|
||||||
Right (rem, _, res)
|
Right (rem', _, res)
|
||||||
| Lazy.ByteString.all (== 0) rem -> return res
|
| Lazy.ByteString.all (== 0) rem' -> return res
|
||||||
| otherwise -> throwM InvalidNamespaceDetected
|
| otherwise -> throwM InvalidNamespaceDetected
|
||||||
|
|
||||||
instance ( MonadCrypto m
|
instance ( MonadCrypto m
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user