From 4d91394475b144ea5bf7ba111f93756cc0de8a3f Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Tue, 18 Aug 2020 11:08:04 +0200 Subject: [PATCH] fix base32 decoding --- filepath-crypto/src/System/FilePath/Cryptographic.hs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/filepath-crypto/src/System/FilePath/Cryptographic.hs b/filepath-crypto/src/System/FilePath/Cryptographic.hs index eeca2ac..31d2dfe 100644 --- a/filepath-crypto/src/System/FilePath/Cryptographic.hs +++ b/filepath-crypto/src/System/FilePath/Cryptographic.hs @@ -102,14 +102,8 @@ decrypt :: forall a m namespace. ( KnownSymbol namespace , Binary a , MonadThrow m - , HasFixedSerializationLength a ) => CryptoIDKey -> CryptoFileName namespace -> m a -decrypt = Poly.decrypt $ (\str -> either (const . throwM $ CiphertextConversionFailed str) return $ decodeBase32Unpadded 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 - l' = paddedLength l - paddingTable = [0, 6, 4, 3, 1] +decrypt = Poly.decrypt $ (\str -> either (const . throwM $ CiphertextConversionFailed str) return $ decodeBase32Unpadded str) . ByteString.Char8.pack . map toUpper . CI.original instance ( MonadCrypto m , MonadCryptoKey m ~ CryptoIDKey