Support aes256-gcm@openssh.com and aes128-gcm@openssh.com for key dec…#479
Merged
kruton merged 2 commits intoconnectbot:mainfrom Mar 22, 2026
Merged
Support aes256-gcm@openssh.com and aes128-gcm@openssh.com for key dec…#479kruton merged 2 commits intoconnectbot:mainfrom
kruton merged 2 commits intoconnectbot:mainfrom
Conversation
…ryption OpenSSH keys encrypted with AES-GCM ciphers (e.g., via ssh-keygen -Z aes256-gcm@openssh.com) could not be imported, failing with "Cannot decrypt, unknown cipher". This adds GCM support to CommonDecoder using JCE's AES/GCM/NoPadding, and fixes OpenSSHKeyDecoder to read the AEAD authentication tag stored after the private section blob. Fixes connectbot/connectbot#1984 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
kruton
requested changes
Mar 22, 2026
| // For AEAD ciphers (e.g., aes256-gcm@openssh.com), the authentication | ||
| // tag is stored after the private section blob in the key file. | ||
| // Read it and append to dataBytes so the cipher can verify it. | ||
| if (tr.remain() > 0) { |
Member
There was a problem hiding this comment.
This changes the behavior of the program for non-AEAD ciphers. It should check the cipherName here to avoid problems.
Contributor
Author
There was a problem hiding this comment.
I beleieve that it is fixed by a new commit.
Guard the trailing-bytes read with an isAeadCipher() check so non-AEAD ciphers (CBC, CTR) are not affected. Add a regression test that appends garbage bytes to a non-AEAD key to verify they are ignored. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
kruton
approved these changes
Mar 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes connectbot/connectbot#1984
Issue: Ed25519 keys encrypted with aes256-gcm@openssh.com couldn't be imported — the CommonDecoder didn't recognize GCM ciphers, throwing "Cannot decrypt, unknown cipher".
Root cause: Two problems:
Fix (3 files in sshlib, branch fix_ed25519aes256gcm based on main):