django-fields icon indicating copy to clipboard operation
django-fields copied to clipboard

Update Path for MODE_CBC deprecation warning

Open imagescape opened this issue 10 years ago • 0 comments

Hi all. What's the proper update path to fix the following deprecation warning?

https://github.com/svetlyak40wt/django-fields/blob/master/src/django_fields/fields.py#L41

"Default usage of pycrypto's AES block type defaults has been "
"deprecated and will be removed in 0.3.0 (default will become "
"MODE_CBC). Please specify a secure block_type, such as CBC.",
DeprecationWarning,

I tried changing all of the encrypted fields in my app to add "block_type=BLOCK_TYPE" to the model and resyncing the database, but got the following error. I think that this is because the new block type makes encrypted values larger than the field can store.

  File "/home/jjasinski/Sites/osf/local/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 350, in get_db_prep_save
 prepared=False)
 File "/home/jjasinski/Sites/osf/local/lib/python2.7/site-packages/django_fields/fields.py", line 164, in get_db_prep_value
 str(len(value)) + " > " + str(self.unencrypted_length)
ValueError: Field value longer than max allowed: 37 > 12

imagescape avatar Oct 02 '14 16:10 imagescape