Thanks all for your help - I've finally managed to read the keys (now I have to also write a code that will write keys in the same format, but that shouldn't be much of
a problem).

Documents which helped me were the PKCS#1 v2.1 specification (for the format of
the key certificates) and the recommendation X.690 (for DER/ASN.1 encoding).

Regards,
Tomasz Kaźmierczak

Kyle Hamilton pisze:
For information on how they're encoded, please see ITU recommendation
X.690 (DER).  The full documentation on ASN.1 (the notation language)
can be found in ITU recommendation X.680; you can also see
http://www.oss.com/asn1/dubuisson.html (for a complete overview) and
http://www.oss.com/asn1/larmouth.html (for a complete reference).

Please note that trying to read the documents published by the ITU is
like trying to wikipath through 40 links to get to the information
you're looking for.  I wholeheartedly recommend staying away from them
unless you absolutely need them.

-Kyle H

On Tue, Feb 10, 2009 at 2:46 PM, Tomasz Kaźmierczak <tome...@wp.eu> wrote:
I've managed to base64 decode a public key (at least I think so;).
Now I'm trying to understand how to interpret the key data. I've found the
definitions of RSAPublicKey and RSAPrivateKey structures (in the
"PKCS #1: RSA Cryptography Standard"), but there is no information
about what are the lengths of those structures' fields.

The keys I'm dealing with are 1024 bit keys. The RSAPublicKey structure
consists only of the modulus (n) and the public exponent (e), so I assume
that first 128 bytes of the structure is the modulus and the rest 12 bytes
is the exponent (the structure as a whole has 140 bytes). Is this assumption
right?
And what if I didn't know that the key is 1024 bits long, how would I know
how many bytes represent the modulus and how many represent the
exponent?

The RSAPrivateKey is a bigger problem - the structure consists of more
fields. How do I know what are their sizes in bytes (again, in my case, the
modulus should be 140 bytes and exponents - 12 bytes each, but there
are some more fields...)? In particular, what's the size of the "version"
field?


Dr. Stephen Henson pisze:
On Fri, Feb 06, 2009, Tomasz Ka??mierczak wrote:


Ok. And it is of course base64 encoded, right?
And what about the public key (-----BEGIN RSA PUBLIC KEY-----)? It looks
the same way as the private key file, but it is shorter.


As I said in the other message thats an RSAPublicKey structure, see
PKCS#1.

Steve.
--
Dr Stephen N. Henson. Email, S/MIME and PGP keys: see homepage
OpenSSL project core developer and freelance consultant.
Homepage: http://www.drh-consultancy.demon.co.uk
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           majord...@openssl.org



______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           majord...@openssl.org

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           majord...@openssl.org


______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           majord...@openssl.org

Reply via email to