Just a quick hack to dump a private key to an unsigned char[]. Basically copied
and pasted the equivalent bit from x509.c. Seems to work ok (famous last words
aside.)

Cheers,

//oscar

diff -r1.31 rsa.c
82a83
>  * -C           - print out C code forms
99c100
<       int informat,outformat,text=0,check=0,noout=0;
---
>       int informat,outformat,text=0,C=0,check=0,noout=0;
167a169,170
>               else if (strcmp(*argv,"-C") == 0)
>                       C=1;
199a203,205
> 
>               BIO_printf(bio_err," -C              print out C code forms\n");
> 
315a322,350
> 
>       if (C)
>         {
>           int len = 0, iter = 0;
>           unsigned char *buffer = 0;
> 
>           len = i2d_RSAPrivateKey(rsa, NULL);
>           buffer = OPENSSL_malloc(len);
>           i2d_RSAPrivateKey(rsa, &buffer);
> 
>           buffer -= len;
> 
>           BIO_printf(out, "unsigned char XXX_private_key[%d]={\n", len);
>           for (iter = 0; iter < len; ++iter)
>             {
>               BIO_printf(out, "0x%02X,", buffer[iter]);
>               if (0x0f == (iter & 0x0f))
>                 {
>                   BIO_printf(out, "\n");
>                 }
>             }
>           if (0 != (iter % 16))
>             {
>               BIO_printf(out, "\n");
>             }
>           BIO_printf(out, "};\n");
> 
>           OPENSSL_free(buffer);
>         }
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to