Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct an issue from pycrypodome switchover. #1814

Merged
merged 1 commit into from
Oct 3, 2019

Conversation

mikepurvis
Copy link
Member

Changes from #1609 broke reindexing decrypted bags:

Traceback (most recent call last):
  File ".../bin/rosbag", line 35, in <module>
    rosbag.rosbagmain()
  File ".../lib/python3/dist-packages/rosbag/rosbag_main.py", line 1012, in rosbagmain
    cmds[cmd](argv[2:])
  File ".../lib/python3/dist-packages/rosbag/rosbag_main.py", line 611, in reindex_cmd
    bag_op(args, True, True, lambda b: b.version > 102, op, options.output_dir, options.force, options.quiet)
  File ".../lib/python3/dist-packages/rosbag/rosbag_main.py", line 726, in bag_op
    outbag.close()
  File ".../lib/python3/dist-packages/rosbag/bag.py", line 715, in close
    self._stop_writing()
  File ".../lib/python3/dist-packages/rosbag/bag.py", line 1596, in _stop_writing
    self._write_connection_record(connection_info, True)
  File ".../lib/python3/dist-packages/rosbag/bag.py", line 1699, in _write_connection_record
    self._encryptor.write_encrypted_header(_write_header, self._output_file, header)
  File ".../lib/python3/dist-packages/rosbag/bag.py", line 309, in write_encrypted_header
    cipher = AES.new(self._symmetric_key, AES.MODE_CBC, iv)
  File ".../lib/python3/dist-packages/Cryptodome/Cipher/AES.py", line 232, in new
    return _create_cipher(sys.modules[__name__], key, mode, *args, **kwargs)
  File ".../lib/python3/dist-packages/Cryptodome/Cipher/__init__.py", line 79, in _create_cipher
    return modes[mode](factory, **kwargs)
  File ".../lib/python3/dist-packages/Cryptodome/Cipher/_mode_cbc.py", line 286, in _create_cbc_cipher
    if len(iv) != factory.block_size:
TypeError: object of type 'int' has no len()

I suspect this also impacted encryption security, since the iv parameter would have been too short by a factor of 8 and filled out with the deterministic padding.

Fix is confirmed to work with rosbag reindex on an encrypted bag under Python 2 and Python 3.

@dirk-thomas
Copy link
Member

Thanks for the patch.

@dirk-thomas dirk-thomas merged commit 57d9ff3 into melodic-devel Oct 3, 2019
@dirk-thomas dirk-thomas deleted the fix-rosbag-reindex branch October 3, 2019 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants