Skip to content

feat(encryption): Added support for AEAD encryption algorithms#6

Merged
GT-610 merged 2 commits intolollipopkit:masterfrom
GT-610:master
Mar 31, 2026
Merged

feat(encryption): Added support for AEAD encryption algorithms#6
GT-610 merged 2 commits intolollipopkit:masterfrom
GT-610:master

Conversation

@GT-610
Copy link
Copy Markdown
Collaborator

@GT-610 GT-610 commented Mar 31, 2026

Resolve lollipopkit/flutter_server_box/issues/1091.

Added the processAll extension method to AEADCipher, and selected either AEAD or standard block cipher algorithms based on the encryption type when decrypting SSH key pairs

Summary by CodeRabbit

发布说明

  • 新功能

    • 增强对 AEAD 类现代加密算法的解密支持,提升对更多密钥格式的兼容性
  • 改进

    • 改善密钥解密流程的错误处理,遇到解密失败会返回更明确的错误信息,便于诊断和恢复
    • 优化解密流程以更灵活地处理不同加密类型,提高稳定性

Added the `processAll` extension method to `AEADCipher`, and selected either AEAD or standard block cipher algorithms based on the encryption type when decrypting SSH key pairs
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 31, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 476b86b9-ce12-48c6-a62a-c9cbed5b2a99

📥 Commits

Reviewing files that changed from the base of the PR and between 9aba36e and 291739a.

📒 Files selected for processing (2)
  • lib/src/ssh_key_pair.dart
  • lib/src/ssh_transport.dart
✅ Files skipped from review due to trivial changes (1)
  • lib/src/ssh_transport.dart
🚧 Files skipped from review as they are similar to previous changes (1)
  • lib/src/ssh_key_pair.dart

📝 Walkthrough

Walkthrough

此变更在私钥解密路径中区分 AEAD 与非 AEAD 密码:当 cipher.isAead 为真时使用 cipher.createAEADCipher(..., forEncryption: false) 并调用 processAll(blob),否则保持 cipher.createCipher(..., forEncryption: false) 并调用 processAll(blob);解密调用被 try/catch 包裹,任何异常重抛为 SSHKeyDecryptError('Failed to decrypt private key', e)。同时新增 AEADCipherX 扩展,提供 Uint8List processAll(Uint8List data)。还对 SSHTransport.hasIntegrityProtection 进行了轻微格式化调整。

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题清晰准确地总结了主要变更:添加了对AEAD加密算法的支持。所有代码更改都与此目标一致,包括AEAD密码扩展和SSH密钥解密逻辑的更新。
Linked Issues check ✅ Passed 代码变更直接解决了问题#1091:通过添加AEAD密码扩展和在解密时正确区分AEAD vs非AEAD密码,修复了ED25519密钥导入时的错误。
Out of Scope Changes check ✅ Passed 所有代码更改都在范围内。ssh_transport.dart中的格式调整是为提高可读性的最小化改动,不影响功能。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

devin-ai-integration[bot]

This comment was marked as resolved.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@lib/src/ssh_key_pair.dart`:
- Around line 242-249: The file lib/src/ssh_key_pair.dart failed CI due to
formatting; run dart format on this file (or the whole project) to fix style
issues: format the method containing the cipher.isAead branch (the block that
uses cipher.createAEADCipher, cipher.createCipher, decryptCipher.processAll) so
the file passes `dart format --set-exit-if-changed .`, then re-add the formatted
file to your commit.
- Around line 243-249: The decrypt branch currently returns processAll(blob)
directly for both AEAD and non-AEAD paths (using cipher.isAead ->
cipher.createAEADCipher/createCipher), which lets AEAD failures throw raw
lower-level exceptions and bypass the later checkInt logic; wrap the decryption
call in a try/catch for both branches, catch any thrown exception from
decryptCipher.processAll(blob) and rethrow a SSHKeyDecryptError containing the
original error (preserve message/stack), then return the decrypted bytes so
subsequent checkInt runs against uniform SSHKeyDecryptError semantics.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7d6c05f1-ec5d-427b-b9cb-b8409e8aae38

📥 Commits

Reviewing files that changed from the base of the PR and between 0dfe0f8 and 9aba36e.

📒 Files selected for processing (2)
  • lib/src/ssh_key_pair.dart
  • lib/src/utils/cipher_ext.dart

…de formatting

Added error handling to the SSH key decryption process; a clear exception is now thrown when decryption fails. Additionally, code formatting was adjusted to improve readability, including line breaks and indentation.
@GT-610 GT-610 merged commit 99f2b10 into lollipopkit:master Mar 31, 2026
1 of 2 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.

Error when importing ED25519 key: 'Bad state: Use createEADCipher for AEAD modes'

1 participant