Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

@hainesr
Copy link
Member

@hainesr hainesr commented Sep 20, 2025

The key change here is to only use the decryption classes, and DecryptedIo when we're actually needed to decrypt something.

Some other simplifications are also included.

This has been bugging me for years. Up until now, whether we need to
decrypt the stream before decompressing it or not, we've been passing
everything through some form of decryption class. In the _vast_ majority
of cases this will be a `NullDecrypter`, which simply passes data through
it untouched. This is fine, but it is still another link in the chain,
adding overhead and the potential for things to go wrong. On top of this,
decryption does need a couple of extra steps which are managed by the
`DecryptedIo` class. Again, fine, but this adds complexity that isn't
needed in the _vast_ majority of cases and `DecryptedIo` has got more
complex recently with the addition of AES decryption.

So this commit changes how we build our IO pipeline within `InputStream`
and only uses decryption, and therefore `DecryptedIo`, when we are
actually decrypting something.

Fixes rubyzip#647
We no longer need a placeholder, because we only ever wire-in decryption
when we're actually decrypting things now.
No longer needed, so let's get rid. This should be safe outside of a
major release because `NullDecrypter` was never part of the public API.
Abstract the integrity check out to decrypters so that `DecryptedIo`
can remain agnostic. This is a no-op for traditional encryption.
This feels better and simpler than querying IO#pos constantly.
No need for an accessor method for this; it just obfuscates things.
@coveralls
Copy link

Coverage Status

coverage: 96.809% (-0.05%) from 96.859%
when pulling 36b2d51 on hainesr:improve_decrypted_io
into 04b4a00 on rubyzip:main.

@hainesr hainesr merged commit acf9f4d into rubyzip:main Sep 20, 2025
34 checks passed
@hainesr hainesr deleted the improve_decrypted_io branch September 20, 2025 16:21
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

Morty Proxy This is a proxified and sanitized view of the page, visit original site.