0

I register an upload with an application. I get this back:

{'enabled': 'true', 'cipher': 'aes-128-cbc', 'key': 'baa47c89079830de8cc0685374391280', 'iv': '4ba4dcfde54a05296392706f9200b1fe'}

Then I do:

UPLOAD_ENCRYPTION = UPLOAD["encryption"]
print(UPLOAD_ENCRYPTION)
UPLOAD_KEY = UPLOAD_ENCRYPTION["key"]
UPLOAD_CIPHER = UPLOAD_ENCRYPTION["cipher"]
UPLOAD_IV = UPLOAD_ENCRYPTION["iv"]
ENCRYPT = AES.new(UPLOAD_KEY, AES.MODE_CBC, UPLOAD_IV)

...and I get:

    self._cipher = factory.new(key, *args, **kwargs)
ValueError: IV must be 16 bytes long

Is the place I'm trying to upload to giving me bad info out or am I missing something? Any help would be greatly appreciated!

Thanks!

Daniel Dow
  • 487
  • 1
  • 7
  • 20
  • 3
    Hex-encoded strings need to be decoded to bytes objects. Easiest method is probably calling [`bytes.fromhex()`](https://docs.python.org/3/library/stdtypes.html#bytes.fromhex) – President James K. Polk Dec 15 '19 at 00:33
  • 1
    Also goes for the key, otherwise you get AES-256 with the wrong key: invalid ciphertext but no error before decryption. – Maarten Bodewes Dec 15 '19 at 02:43

0 Answers0