vincenthz / hs-crypto-cipher

DEPRECATED by cryptonite; A collection of cryptographic block and stream ciphers in haskell
22 stars 14 forks source link

"cannot use with non multiple of block size" #21

Closed joeyh closed 11 years ago

joeyh commented 11 years ago

I'm trying to use the haskell DAV library on a WebDav server, and got two interesting failure modes that come from the cryptocipher library that it uses (due to using http-conduit I suppose).

One is "invalid IV length", on a system with an old version installed (0.3.5)

Then on a more up-to-date system, with 0.3.6, it fails with "cannot use with non multiple of block size".

I assume that this particular OwnCloud server is doing something weird in the SSL or SSL cert department, and thankfully the problem seems to be limited to this particular server, and not OwnCloud servers generally.

On the other hand, I can access this URL ok using Chrome, w3m, and wget.. So I suppose your library could somehow be changed to deal with it. :)

joeyh commented 11 years ago

An URL you can try to see this problem: https://owncloud.portknox.net/

Simple reproduction recipe:

cabal install DAV ~/.cabal/bin/hdav getprops https://owncloud.portknox.net/remote.php/webdav/ --username=joeyhess --password=dummy

(dummy password is ok; fails before any auth)

vincenthz commented 11 years ago

can you confirm you're actually using cryptocipher for AES and not cipher-aes ? the error seems to indicate the latter.

update: just realized that's irrelevant anyway, just re-read your description, and you're experiencing IV problem on both. Which seems to indicate that TLS is trying to decrypt/encrypt wrong TLS packet where the IV is passed to cryptocipher/cipher-aes malformed. It could well be some corner case problem in the implementation.

joeyh commented 11 years ago

Vincent Hanquez wrote:

can you confirm you're actually using cryptocipher for AES and not cipher-aes ? the error seems to indicate the latter.

Hmmm.. I found the error message in the cryptocipher source code, although I see it's also in the cipher-aes code.

I certianly don't have cipher-aes installed. The dependency chain is DAV -> http-conduit -> (tls, tls-extra) -> cryptocipher

see shy jo

vincenthz commented 11 years ago

alright i can reproduce using the debug tool, i've just improved a bit. funnily the TLS layer is not erroring when using http1.0 (which i suppose is just the server not proxying the connection to something else when using http1.0 and just HTTP erroring on his own)

./dist/build/tls-simpleclient/tls-simpleclient --uri /remote.php/webdav/ --http1.1 owncloud.portknox.net 443

vincenthz commented 11 years ago

quite an interesting bug with re-handshake with a different cipher (see commit message for more information). it's now fixed in tls 1.0.2.