Skip to content

ssh-cipher: impl BlockMode* for Decryptor/Encryptor#534

Merged
tarcieri merged 1 commit into
masterfrom
ssh-cipher/block-mode-traits
May 25, 2026
Merged

ssh-cipher: impl BlockMode* for Decryptor/Encryptor#534
tarcieri merged 1 commit into
masterfrom
ssh-cipher/block-mode-traits

Conversation

@tarcieri
Copy link
Copy Markdown
Member

Impls the BlockMode* traits from the cipher crate, bringing the implementation closer in line with our other block mode implementations.

This does have one weird quirk: we can't impl
BlockModeDecrypt::decrypt_with_backend for Decryptor because that only gives us access to BlockCipherDecBackend, whereas to implement CTR mode we need access to BlockCipherEncBackend too as encryption and decryption are the same operation in CTR mode.

So this foregoes such an impl with an unimplemented! and directly implements the decrypt_block and decrypt_blocks methods instead.

@tarcieri tarcieri force-pushed the ssh-cipher/block-mode-traits branch from 3f341a8 to 57ad086 Compare May 24, 2026 23:37
Impls the `BlockMode*` traits from the `cipher` crate, bringing the
implementation closer in line with our other block mode implementations.

This does have one weird quirk: we can't impl
`BlockModeDecrypt::decrypt_with_backend` for `Decryptor` because that
only gives us access to `BlockCipherDecBackend`, whereas to implement
CTR mode we need access to `BlockCipherEncBackend` too as encryption and
decryption are the same operation in CTR mode.

So this foregoes such an impl with an `unimplemented!` and directly
implements the `decrypt_block` and `decrypt_blocks` methods instead.

This doesn't currently support any form of padding, although with the
`BlockMode*` traits implemented a downstream user can provide whatever
padding they wish with `encrypt_padded`/`decrypt_padded`.
@tarcieri tarcieri force-pushed the ssh-cipher/block-mode-traits branch from 57ad086 to 2572467 Compare May 24, 2026 23:53
@tarcieri tarcieri merged commit 165274b into master May 25, 2026
22 checks passed
@tarcieri tarcieri deleted the ssh-cipher/block-mode-traits branch May 25, 2026 01:12
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.

1 participant