OpenSshPrivateKey class

Represents the OpenSSH private key format.

Format

This is proprietary format that is not been officially documented.

Unofficial documentation can be found in a blog post on The OpenSSH Private Key Format. by A. J. O'Neal, which says the format is:

"openssh-key-v1"0x00    # NULL-terminated "Auth Magic" string
32-bit length, "none"   # ciphername length and string
32-bit length, "none"   # kdfname length and string
32-bit length, nil      # kdf (0 length, no kdf)
32-bit 0x01             # number of keys, hard-coded to 1 (no length)
32-bit length, sshpub   # public key in ssh format
    32-bit length, keytype
    32-bit length, pub0
    32-bit length, pub1
32-bit length for rnd+prv+comment+pad
    64-bit dummy checksum?  # a random 32-bit int, repeated
    32-bit length, keytype  # the private key (including public)
    32-bit length, pub0     # Public Key parts
    32-bit length, pub1
    32-bit length, prv0     # Private Key parts
    ...                     # (number varies by type)
    32-bit length, comment  # comment string
    padding bytes 0x010203  # pad to blocksize (see notes below)

More details are in the blog post.

The most correct source of information on this format is the OpenSSH source code or from the Portable OpenSSH fork of it.

Implemented types

Constructors

OpenSshPrivateKey(String cipherName, String kdfName, Uint8List kdf, Uint8List publicKeyBytes, Uint8List privateKeyBytes, [PvtTextSource? source])
Default constructor
OpenSshPrivateKey.decode(Uint8List bytes, {PvtTextSource? source})
Decode from a sequence of bytes.
factory

Properties

cipherName String
Name of encryption cipher
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
kdf Uint8List
Key definition function parameters
getter/setter pair
kdfName String
Name of the key definition function
getter/setter pair
privateKeyBytes Uint8List
Bytes containing the private key
getter/setter pair
privateKeyType String
The key-type (extracted from the bytes of the private key)
no setter
publicKeyBytes Uint8List
Bytes containing the public key
getter/setter pair
publicKeyType String
The key-type (extracted from the bytes of the public key)
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
source PvtTextSource?
Text source from where the private key was decoded from
final

Methods

encode() Uint8List
Encode into bytes.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Constants

magicVersionId → const String
Expected magic value