encodeOpenSshPrivateKey

fun encodeOpenSshPrivateKey(keyPair: KeyPair, password: String? = null): String(source)

Encode a KeyPair to OpenSSH format (BEGIN OPENSSH PRIVATE KEY). ML-DSA-44/Ed25519 composites require exportable seeds. Pure ML-DSA has no defined OpenSSH private-key layout; use encodePemPrivateKey instead.

Return

OpenSSH-formatted private key string

Parameters

keyPair

JCA key pair to encode

password

Optional passphrase to encrypt the key (AES-256-CTR with bcrypt KDF)

Throws

if the key type is unsupported