Skip to content

Ed25519 key and signature support#218

Open
Snoldinator wants to merge 3 commits intoapple:mainfrom
Comraich:ed25519-key-and-algo-support
Open

Ed25519 key and signature support#218
Snoldinator wants to merge 3 commits intoapple:mainfrom
Comraich:ed25519-key-and-algo-support

Conversation

@Snoldinator
Copy link
Copy Markdown

Summary
• Adds support for Ed25519 keys and signatures across the relevant SSH message types and validation paths.
• Enables using Ed25519 for user and host keys, including reading, validating, and using Ed25519-signed certificates where applicable.
• Keeps backward compatibility with existing RSA/ECDSA flows.

Scope of changes
• Key handling: Accept and validate Ed25519 public/private keys and signatures.
• Certificate handling: Parse and validate Ed25519-certified keys where supported.
• Tests: Extend coverage to include Ed25519 keys/certificates and signatures; all tests pass locally.

Rationale
• Ed25519 is widely adopted for SSH due to its strong security properties, small key sizes, and performance.
• Adding Ed25519 aligns with modern SSH usage and improves interoperability with common SSH tooling.

Compatibility
• No breaking changes to existing APIs.
• Existing key types (e.g., ECDSA, RSA) remain fully supported.

Testing
• Ran:
• swift build -v
• swift test -v
• Verified new Ed25519 test cases (load/serialize, validation, certificate parsing/validation) pass.
• No regressions observed in existing test suites.

Notes
• If maintainers prefer, I can add a brief README note listing supported key/signature algorithms (now including Ed25519).

Motivation:
Many Linux distros (notably Ubuntu and Debian) use ed25519 keys by default. I want to add support for this to Swift-nio-ssh
Modifications:
I have added support for Ed25519 keys and algorithm in specific new files for this, in addition to updating the Package.swift file and new testfiles that test the changes.

Result:
After this change, Ed25519 support will be available in Swift-nio-ssh.
//
// This source file is part of the SwiftNIO open source project
//
//===----------------------------------------------------------------------===//
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This header isn't correct: please provide the complete header block.

// swift-nio-ssh
//
// Created by Simon Bruce-Cassidy on 08/12/2025.
//
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This doesn't look like it belongs.


// If the Ed25519 representation is not directly available, throw for now.
// Replace this with the appropriate internal initializer for your codebase.
throw NIOSSHError.protocolViolation(protocolName: "ssh-ed25519", violation: "ed25519 key construction not implemented")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This function doesn't actually work.

@@ -0,0 +1,106 @@
import Foundation

public enum OpenSSHKey {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why are we declaring a new namespace here?

@@ -0,0 +1,106 @@
import Foundation
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

License header file is missing.

name: "swift-nio-ssh",
platforms: [
.macOS(.v10_15),
.macOS(.v14),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There doesn't appear to be any motivating reason for this change.

/// - Parameter pem: The PEM text including BEGIN/END OPENSSH PRIVATE KEY markers.
/// - Returns: Ed25519Components (seed + public key)
/// - Throws: If the key is not in the expected format or is encrypted.
public static func decodeEd25519Unencrypted(fromPEM pem: String) throws -> Ed25519Components {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It would be useful to demonstrate that this does work. Can you wire up a unit test here?

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