From b0afce01c72690aaeafdb1577e320580596b8661 Mon Sep 17 00:00:00 2001 From: Nedithgar Amirka <150447520+nedithgar@users.noreply.github.com> Date: Tue, 14 Oct 2025 11:59:51 +0800 Subject: [PATCH 1/2] feat: add Codable conformance and human-readable names to EncryptionCipher --- .../Formats/OpenSSH/OpenSSHPrivateKey.swift | 42 ++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/Sources/SwiftKeyGen/Formats/OpenSSH/OpenSSHPrivateKey.swift b/Sources/SwiftKeyGen/Formats/OpenSSH/OpenSSHPrivateKey.swift index 61a49bb..2c7eb19 100644 --- a/Sources/SwiftKeyGen/Formats/OpenSSH/OpenSSHPrivateKey.swift +++ b/Sources/SwiftKeyGen/Formats/OpenSSH/OpenSSHPrivateKey.swift @@ -65,7 +65,7 @@ public struct OpenSSHPrivateKey { /// 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 { + public struct EncryptionCipher: RawRepresentable, Hashable, ExpressibleByStringLiteral, Sendable, CaseIterable, Identifiable, Codable { /// The OpenSSH wire-format cipher name (e.g., "aes256-gcm@openssh.com"). public let rawValue: String @@ -122,6 +122,46 @@ public struct OpenSSHPrivateKey { /// /// Mirrors ``known`` to ensure a single source of truth and stable ordering. public static var allCases: [EncryptionCipher] { known } + + /// A human-readable name for display purposes. + public var humanReadableName: String { + switch self { + case .aes128ctr: + return "AES-128-CTR" + case .aes192ctr: + return "AES-192-CTR" + case .aes256ctr: + return "AES-256-CTR" + case .aes128cbc: + return "AES-128-CBC" + case .aes192cbc: + return "AES-192-CBC" + case .aes256cbc: + return "AES-256-CBC" + case .aes128gcm: + return "AES-128-GCM" + case .aes256gcm: + return "AES-256-GCM" + case .des3cbc: + return "3DES-CBC" + case .chacha20poly1305: + return "ChaCha20-Poly1305" + default: + return rawValue + } + } + + // Codable conformance: encode/decode as a single string value (the wire-format name) + public init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + let value = try container.decode(String.self) + self.init(rawValue: value) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + try container.encode(self.rawValue) + } } // OpenSSH private key format constants private static let MARK_BEGIN = "-----BEGIN OPENSSH PRIVATE KEY-----" From b8654c01151f93daa01384242cefb61d3a00a09d Mon Sep 17 00:00:00 2001 From: Nedithgar Amirka <150447520+nedithgar@users.noreply.github.com> Date: Tue, 14 Oct 2025 12:00:22 +0800 Subject: [PATCH 2/2] chore: update version to 0.1.9 --- 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 daa429e..8529054 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.8" + private static let version = "0.1.9" static func main() { let arguments = CommandLine.arguments