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

Add decryption helper #65

Merged
merged 1 commit into from
Jan 9, 2025
Merged

Conversation

emontnemery
Copy link
Contributor

Add decryption helper to make it easy to extract decrypted inner tar files

if self._file:
if not self._mode.startswith("r"):
self._file.write(self._encrypt.update(self._padder.finalize()))
if not self._fileobj:
self._file.close()
self._file = None

@contextmanager
def decrypt(self, tarinfo: tarfile.TarInfo) -> Generator[BinaryIO, None, None]:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should maybe raise if this method is called when key is not set?
Maybe we should add error handling in a follow-up?

Comment on lines +195 to +196
data = data[:-padding_len]
self._tail = data[size:]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could check the padding is as expected and raise ValueError if invalid.
Maybe we should add error handling in a follow-up?

Copy link
Owner

@pvizeli pvizeli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, fine to add error handling on a follow-up PR

@pvizeli pvizeli merged commit 0367b9d into pvizeli:main Jan 9, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants