PEM binary format - Openssl

This is a discussion on PEM binary format - Openssl ; Hello! I want to use openssl generated rsa keys in my custom rsa implementation. In order to do this, I have to interpret the binary file created by: (host.key is the rsa key file) $ openssl enc -d -base64 -in ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: PEM binary format

  1. PEM binary format

    Hello!

    I want to use openssl generated rsa keys in my custom rsa
    implementation. In order to do this, I have to interpret the
    binary file created by: (host.key is the rsa key file)

    $ openssl enc -d -base64 -in host.key

    I suppose the funny outputs are the bignums from the

    struct rsa_st (crypto/rsa/rsa.h)

    However, if I display the key file in human readable format,

    $ openssl rsa -text -in host.key

    open the binary output from the prior command in a hex editor
    and search for, e.g., the modulus, I cannot find it. In brief,
    the hexadecimal representation and the binary representation do
    converge.

    Thus, I conclude that there is some format in place, respectively
    how do I know where a bignum starts and where it ends?

    I tried to find a clue by browsing the sources, but I gave up
    confused by all the asn1 parse and nested bio print functions.

    Can some one please put me into the right direction? I appreciate
    help and comments!

    -Armin

    ps: My custom rsa library is built on gmp, so I want to convert the
    binary data to the mpz_t type later on.
    __________________________________________________ ____________________
    OpenSSL Project http://www.openssl.org
    User Support Mailing List openssl-users@openssl.org
    Automated List Manager majordomo@openssl.org


  2. RE: PEM binary format


    > Thus, I conclude that there is some format in place, respectively
    > how do I know where a bignum starts and where it ends?


    The format is ANSI X.690, also knows as BER or DER, somtimes (slightly
    erroneously) referred to as ASN.1.

    > I tried to find a clue by browsing the sources, but I gave up
    > confused by all the asn1 parse and nested bio print functions.
    >
    > Can some one please put me into the right direction? I appreciate
    > help and comments!


    X.690 is an ITU standard. It is, in fact, still the preferred protocol for
    the interchange of binary data. Googling "X.690" should find you lots of
    information.

    http://asn1.elibel.tm.fr/standards/

    DS


    __________________________________________________ ____________________
    OpenSSL Project http://www.openssl.org
    User Support Mailing List openssl-users@openssl.org
    Automated List Manager majordomo@openssl.org


+ Reply to Thread