Skip to content

Loading…

Blowfish from s2k #23

Closed
singpolyma opened this Issue · 3 comments

2 participants

@singpolyma

I'm implementing string2key stuff for OpenPGP, and Blowfish reports a keysize of 56, but wants 72 bytes for the Serialize.decode instance. If I use buildKey it "works", but the key I get seems to be the wrong one (stuff encrypted with GPG does not decrypt).

The AES instances work fine either way.

@singpolyma

Hmm, ok, I solved it like this:

newtype Blowfish128 = Blowfish128 Blowfish

instance Serialize.Serialize Blowfish128 where
   put (Blowfish128 b) = Serialize.put b
   get = fmap Blowfish128 Serialize.get

instance BlockCipher Blowfish128 where
   blockSize = retag (blockSize :: Tagged Blowfish BitLength)
   encryptBlock (Blowfish128 k) = encryptBlock k
   decryptBlock (Blowfish128 k) = decryptBlock k
   buildKey = fmap Blowfish128 . buildKey
   keyLength = Tagged 128
@singpolyma singpolyma closed this
@vincenthz
Owner

Why is that not in a form of a bugfix for the original instance instead of redefining on your side the instance ?

@vincenthz vincenthz reopened this
@singpolyma

@vincenthz because your instance isn't really broken, it's just that Blowfish works for multiple keysizes and your type is for a different size than I needed.

@vincenthz vincenthz added a commit that closed this issue
@vincenthz remove dodgy instance (and most likely useless instance) of blowfish …
…for crypto-api.

Blowfish support many key type, so it's up to the user to define
instance that make sense. for example "Blowfish128" with a keysize of 128.

closes #23.
18f1a8d
@vincenthz vincenthz closed this in 18f1a8d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.