7

I can use my private key to generate a public key for use with ssh. I can use the same private key to generate a CSR, to generate a CLIENT certificate for HTTPS.

Specifically, my SSH public key is:

ssh-rsa 
AAAAB3NzaC1yc2EAAAADAQABAAAAQQCwYzCxnKg/YrnEp7whFTwKytweCGIUGQFHJvFi/SKhN/q/pmRRxjyODpqiMR77g3oF8uD36n2Bl/719BAcXUVv

And my HTTPS public key (Client Certificate) is:

Modulus (1024 bits):
a8 88 9e 0f 46 98 3e 6a c0 6d 4a ca dd fa 69 cd 
6c 19 d8 ff 44 92 e5 75 7a 37 2d ad 2f 6c ea f1 
e5 b4 28 6e 80 d3 3e 57 09 d7 20 56 1e 54 0d 8d 
f0 3e 06 49 46 8f c2 2d 20 d3 d0 c6 8d f3 af 91 
aa 70 a7 60 be 7d 56 bc e4 48 8e b4 66 f8 9e 95 
20 de 91 b5 cb 8f 0e d9 5e 9a c4 f4 5b 93 16 9d 
80 73 1b c5 72 ae aa fe 4b 18 23 79 4a f2 76 b9 
a2 d1 59 d9 4a c3 a6 70 2e 8d f3 2d 5b 97 27 df

So my question is: what is the relationship between these public keys? It is not obvious to me (by inspection) that they are the same, but I'm wondering if there is some transformation I can do to get from one public key to the other. Is it possible to have a SSH-public-key and a HTTPS-public-key that are the same value?

1
  • The way of encondings the key will be varied for each application. The encodings are BER, DER,etc. Anyway you can use the same public key to encrypt and decrypt via the same private key as its mathematical relational.
    – user45475
    Commented Apr 11, 2015 at 8:43

1 Answer 1

4

The two keys you show are encoded differently - obviously, the first is base64 encoded, and the second is hexadecimal encoding. You would need to determine the formats used and their encoding to determine how to reconcile the two. And in both cases it's a packed structure, not just raw key data but discrete bits of data like key type, exponent, and modulus.

Fortunately for you, somebody already figured out how to convert between the two. Lars Kellogg-Stedman walks through the RFC 5246 format of the SSH key, and uses the PyASN1 Python module to convert to PKCS#1 format.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .