[Cryptography] SSH key text format:

Jan Schaumann jschauma at netmeister.org
Thu Jan 10 12:10:07 EST 2019


jamesd at echeque.com wrote:
> An SSH ed25519 public key in text format looks like this:
> AAAAC3NzaC1lZDI1NTE5AAAAIPgXkBezz5jt2hlJwdqjJ5sbN5SlmxCYcNeNXGqMCPUf
> 
> 
> And the corresponding private key in text format looks like this:
> AAAAIAGYxPxNy0vT+BYZrhtvi8D9ZxNDQlyPccHhnz0Wi3jn
> 
> Where are these formats, and their conversion to and from binary, defined?
> Where is the source code - yes, I figure that since putty and openssh is
> open source, it is somewhere in there, but perhaps I am being stupid, since
> "where" is not altogether obvious to me.  Kind of hoping to find not just
> the code, but the reasons for the code.

IIRC the formats used by OpenSSH are not defined anywhere but in their
code.  (I once went through that when trying to figure out how to
convert between RFC4716 and OpenSSH formats:
https://www.netmeister.org/blog/ssh2pkcs8.html)

> And what with the AAAA fields?

The format is base64 encoded tuples of four bytes of length of field
followed by field, I think.  So the leading 'AAAAC3NzaC1lZDI1NTE5'
becomes

00 00 00 0b                        = length 11

73 73 68 2d  65 64 32 35 35 31 39  = ssh-ed25519

etc. etc.

-Jan


More information about the cryptography mailing list