fix base32 decoding
This commit is contained in:
parent
5e9a7e4c3c
commit
4d91394475
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user