From 269d97d1ed10d54033ab310616d8edab99bbbe14 Mon Sep 17 00:00:00 2001 From: Nedithgar Amirka <150447520+nedithgar@users.noreply.github.com> Date: Tue, 14 Oct 2025 11:14:12 +0800 Subject: [PATCH 1/2] feat: enhance EncryptionCipher struct with Identifiable and CaseIterable conformance --- .../Formats/OpenSSH/OpenSSHPrivateKey.swift | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/Sources/SwiftKeyGen/Formats/OpenSSH/OpenSSHPrivateKey.swift b/Sources/SwiftKeyGen/Formats/OpenSSH/OpenSSHPrivateKey.swift index aae375a..61a49bb 100644 --- a/Sources/SwiftKeyGen/Formats/OpenSSH/OpenSSHPrivateKey.swift +++ b/Sources/SwiftKeyGen/Formats/OpenSSH/OpenSSHPrivateKey.swift @@ -59,14 +59,32 @@ public struct OpenSSHPrivateKey { /// an `enum` to allow forward- and backward-compatibility as OpenSSH /// evolves. Known ciphers are provided as static constants, and arbitrary /// cipher names can be created via `init(rawValue:)`. - public struct EncryptionCipher: RawRepresentable, Hashable, ExpressibleByStringLiteral, Sendable { + /// + /// This type also conforms to `CaseIterable` and `Identifiable`: + /// - `CaseIterable`: ``allCases`` returns the library’s ``known`` ciphers in + /// a deterministic order suitable for UI pickers. + /// - `Identifiable`: ``id`` is the wire-format cipher name (``rawValue``), + /// providing a stable identity for collection diffing. + public struct EncryptionCipher: RawRepresentable, Hashable, ExpressibleByStringLiteral, Sendable, CaseIterable, Identifiable { + /// The OpenSSH wire-format cipher name (e.g., "aes256-gcm@openssh.com"). public let rawValue: String + + /// Creates a cipher from its OpenSSH wire-format name. + /// + /// - Parameter rawValue: The canonical cipher name used on the wire. public init(rawValue: String) { self.rawValue = rawValue } + + /// Creates a cipher from a string literal representing its wire-format name. + /// + /// - Parameter value: The canonical cipher name used on the wire. public init(stringLiteral value: String) { self.rawValue = value } /// OpenSSH wire-format name. public var name: String { rawValue } + /// Stable identifier for `Identifiable` conformance (the cipher name). + public var id: String { rawValue } + // Known cipher constants (stable API surface) public static let aes128ctr = EncryptionCipher(rawValue: "aes128-ctr") public static let aes192ctr = EncryptionCipher(rawValue: "aes192-ctr") @@ -99,6 +117,11 @@ public struct OpenSSHPrivateKey { .chacha20poly1305, ] } + + /// All known cases for `CaseIterable` conformance. + /// + /// Mirrors ``known`` to ensure a single source of truth and stable ordering. + public static var allCases: [EncryptionCipher] { known } } // OpenSSH private key format constants private static let MARK_BEGIN = "-----BEGIN OPENSSH PRIVATE KEY-----" From f90adc0c1d565d7f46e9f4bf5751a939a4fed70a Mon Sep 17 00:00:00 2001 From: Nedithgar Amirka <150447520+nedithgar@users.noreply.github.com> Date: Tue, 14 Oct 2025 11:20:43 +0800 Subject: [PATCH 2/2] chore: update version to 0.1.8 --- Sources/SwiftKeyGenCLI/main.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/SwiftKeyGenCLI/main.swift b/Sources/SwiftKeyGenCLI/main.swift index b5a8856..daa429e 100644 --- a/Sources/SwiftKeyGenCLI/main.swift +++ b/Sources/SwiftKeyGenCLI/main.swift @@ -3,7 +3,7 @@ import SwiftKeyGen struct SwiftKeyGenCLI { // Update this value when publishing a new release (match the git tag) - private static let version = "0.1.7" + private static let version = "0.1.8" static func main() { let arguments = CommandLine.arguments