Add RSA and Ed25519 key tests, implement ChaCha20-Poly1305 methods#22
Add RSA and Ed25519 key tests, implement ChaCha20-Poly1305 methods#22
Conversation
…nd update references
There was a problem hiding this comment.
Pull Request Overview
This PR adds comprehensive test coverage for RSA and Ed25519 key encryption with various ciphers, implements ChaCha20-Poly1305 OpenSSH encryption methods, and bumps the version to 0.1.10.
- Adds Ed25519 key parsing tests for multiple encryption algorithms (AES-CTR, AES-CBC, AES-GCM, 3DES-CBC, and ChaCha20-Poly1305)
- Implements new ChaCha20-Poly1305 OpenSSH encryption and decryption methods with test coverage
- Adds RSA 2048 key round-trip testing
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| Tests/SwiftKeyGenTests/Integration/OpenSSHFormatIntegrationTests.swift | Adds Ed25519 encryption tests and RSA round-trip test |
| Tests/SwiftKeyGenTests/Cryptography/Ciphers/ChaCha20-Poly1305UnitTests.swift | Adds worked example tests for ChaCha20-Poly1305 |
| Sources/SwiftKeyGenCLI/main.swift | Version bump to 0.1.10 |
| Sources/SwiftKeyGen/Cryptography/Ciphers/Cipher.swift | Updates comment to reference new file name |
| Sources/SwiftKeyGen/Cryptography/Ciphers/ChaCha20Poly1305OpenSSH.swift | New ChaCha20-Poly1305 implementation |
| Sources/SwiftKeyGen/Cryptography/Ciphers/ChaCha20Poly1305.swift | Removed old implementation |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| aadLength: ChaCha20Poly1305Fixtures.aadLength | ||
| ) | ||
|
|
||
| #expect(encrypted.count == vectors.fullCiphertext.count) |
There was a problem hiding this comment.
The count comparison on line 60 is redundant since the equality check on line 61 already verifies the data matches completely, which includes the count.
| #expect(encrypted.count == vectors.fullCiphertext.count) |
| private static func clampAADLength(_ requested: Int, dataLength: Int) -> Int { | ||
| if requested <= 0 { | ||
| return 0 | ||
| } | ||
| return min(requested, dataLength) | ||
| } |
There was a problem hiding this comment.
[nitpick] The function name 'clampAADLength' could be more descriptive. Consider renaming to 'validateAADLength' or 'normalizeAADLength' to better convey its purpose of ensuring the AAD length doesn't exceed the data length.
Introduce round-trip tests for RSA 2048 key generation, enhance Ed25519 key parsing tests, and implement ChaCha20-Poly1305 encryption and decryption methods with worked example tests. Update version to 0.1.10.