Take the 2-minute tour ×
Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. It's 100% free, no registration required.

My Friend and I have been generating a few ssh2-rsa keys and noticed that all the public keys began with "AAAAB3NzaC1yc". The similarity extended to "AAAAB3NzaC1yc2EAAAABIwAAAQEA" between two keys I generated on the same machine on two successive attempts. I can even google "AAAAB3Nz" and end up getting a few hits.

Is this normal? Or are we doing something wrong while generating? Suffering from insufficient randomness?

share|improve this question
    
What are you using to generate them? Openssl, openssh, pgp? It is probably an encoding. –  mikeazo Jan 8 '13 at 17:39
    
We used puTTYgen on two different windows machine and ssh-keygen on a linux machine. –  Lord Loh. Jan 8 '13 at 18:23
add comment

1 Answer 1

up vote 23 down vote accepted

The public key blob doesn't consist of just the numbers that make up the public key: it begins with a header that says “this is an SSH public key”. The repeated prefix encodes this header.

RFC 4254 specifies the encoding of public key in SSH key format.

The "ssh-rsa" key format has the following specific encoding:

 string    "ssh-rsa"
 mpint     e
 mpint     n

Here the 'e' and 'n' parameters form the signature key blob.

The string is encoded as 32-bit big endian length followed by the literal string:

0,0,0,7,'s','s','h','-','r','s','a'

Encoding this sequence of bytes in Base64 gives:

AAAAB3NzaC1yc2E

The public exponent is also usually the same, so the common prefix is even longer. The bulk of the key is the public modulus, and that is completely different in different keys.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.