Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Apply patch from Redhat to secure pycrypto that otherwise could allow…
… an attacker to determine contents of the encrypted payload (but is unable to modify).
  • Loading branch information
bbangert committed Aug 7, 2012
1 parent 066299c commit 91becae
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions beaker/crypto/pycrypto.py
Expand Up @@ -15,17 +15,18 @@ def aesEncrypt(data, key):

except ImportError:
from Crypto.Cipher import AES
from Crypto.Util import Counter

def aesEncrypt(data, key):
cipher = AES.new(key)
cipher = AES.new(key, AES.MODE_CTR,
counter=Counter.new(128, initial_value=0))

data = data + (" " * (16 - (len(data) % 16)))
return cipher.encrypt(data)

def aesDecrypt(data, key):
cipher = AES.new(key)

return cipher.decrypt(data).rstrip()
cipher = AES.new(key, AES.MODE_CTR,
counter=Counter.new(128, initial_value=0))
return cipher.decrypt(data)

def getKeyLength():
return 32

0 comments on commit 91becae

Please sign in to comment.