CTR cipher modes are missing

Bug #54476 reported by Robey Pointer
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
paramiko
Fix Released
Low
Robey Pointer

Bug Description

pycrypto supports CTR cipher chaining, and the ssh2 protocol defines ciphers of this type, but paramiko doesn't get implement it. it should be a simple matter of hooking it up in the right places.

CVE References

Robey Pointer (robey)
Changed in paramiko:
assignee: nobody → robey
importance: Untriaged → Low
status: Unconfirmed → Confirmed
Revision history for this message
Denis Bernard (db47h) wrote :

Here's a patch against paramiko 1.7.4 that implements aes128-ctr, aes256-ctr, arcfour128 and arcfour256

RFCs: 4344 (AES-CTR), and 4345 (arcfour128, arcfour256)

Support of the CTR modes has become critical now that the CTR modes are about to become mandatory (and CBC optional) and that some SSH servers do not support the CBC modes anymore (like on OpenSolaris 2009.06).

About the patch:

For arcfour, It was only a matter of handling the Crypto.Cipher.ARC4.new() for that specific case (and finding out the appropriate block sizes)

For the AES CTR modes, a stateful counter has to be passed as a 4th argument to Crypto.Cipher.AES.new(), and initialize it with the IV. I've implemented it as Transport._Counter, but it can be moved anywhere.

Other CTR modes should be easily implemented as long as pycrypto supports them.

Note that the counter is called for every block, so the performance is probably nothing spectacular, but it works with pycrypto 2.0.1. For people who need performance, the GIT version of pycrypto has a counter implemented in C.

Last thing, I did only some very limited testing (i.e. works for me, your mileage may vary).

Enjoy!

Revision history for this message
Denis Bernard (db47h) wrote :

Modified version of the previous patch. The idea is to be able to use Crypto.Util.Counter if available, and fall back to our own implementation if necessary.

The CTR counter has been moved from Transport to paramiko.util and the API is now similar to Crypto.Util.Counter (although it only takes nbits, initial_value and overflow for now).

Basically, when upgrading to a version of pycrypto that provides its own stateful counter implementation (like the current git version does), paramiko would automatically take advantage of it without requiring any code changes.

In regards to testing, this code has only been tested on Python 2.5.2.

Revision history for this message
Robey Pointer (robey) wrote :

patch applied -- thanks!

Changed in paramiko:
milestone: none → 1.7.5
status: Confirmed → Fix Committed
Robey Pointer (robey)
Changed in paramiko:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.