fix ambiguous occurrences

This commit is contained in:
Sarah Vaupel 2025-07-14 12:19:10 +02:00
parent 509158793d
commit 1752d03fe7
2 changed files with 6 additions and 6 deletions

View File

@ -106,7 +106,7 @@ instance Binary CryptoIDKey where
-- that parses)
getKey (KeySizeFixed n) = getByteString n
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'
@ -169,7 +169,7 @@ genKey = CryptoIDKey <$> liftIO (getEntropy keySize)
keySize
| KeySizeFixed n <- keySize' = n
| KeySizeEnum ns <- keySize' = maximum ns
| KeySizeRange _ max <- keySize' = max
| KeySizeRange _ max' <- keySize' = max'
-- | Try to read a 'CryptoIDKey' from a file.
-- If the file does not exist, securely generate a key (using 'genKey') and

View File

@ -76,14 +76,14 @@ decrypt :: forall a m c namespace.
, MonadThrow m
, Binary a
) => (c -> m ByteString) -> CryptoIDKey -> CryptoID namespace c -> m a
decrypt decode key cID = do
cID' <- _ciphertext decode cID
decrypt dcode key cID = do
cID' <- _ciphertext dcode cID
plaintext <- Lazy.ByteString.fromStrict <$> ByteString.decrypt key cID'
case decodeOrFail plaintext of
Left _ -> throwM DeserializationError
Right (rem, _, res)
| Lazy.ByteString.all (== 0) rem -> return res
Right (rem', _, res)
| Lazy.ByteString.all (== 0) rem' -> return res
| otherwise -> throwM InvalidNamespaceDetected
instance ( MonadCrypto m