Mailing List Archive

seperate public key, private key
hi again,
I need to separate the public key and the private key from the GCRY_SEXP
struct because I want to save the private key crypted and the public key
readable.

How can I separate the keys and how can I put them together again?

And how can I convert a unsigned char * or char * string into a GCRY_SEXP
struct?
Re: seperate public key, private key [ In reply to ]
On Sun May 19 2002; 13:19, Rüdiger Sonderfeld wrote:

> I need to separate the public key and the private key from the GCRY_SEXP
> struct because I want to save the private key crypted and the public key
> readable.

I'm not sure if I understand what you mean. The keys should be
separated all of the time. Which means you need to store them in
two GCRY_SEXP contexts from the begin.


> How can I separate the keys and how can I put them together again?

You can read the public key packet and put it into one context and
then you do the same with the secret key. Or do you mean you want
to store the public key part of the secret key?


> And how can I convert a unsigned char * or char * string into a
> GCRY_SEXP struct?

Let's say you use a GCRY_MPI which based on the byte buffer,
then you can use the following syntax:

gcry_mpi_scan( &my_mpi, GCRYMPI_FMT_PGP, my_buf, my_buflen );
gcry_sexp_build( &sexp, NULL, "(private-key(elg(p%m)(g%m)(y%m)(x%m)))",
my_mpi[0], my_mpi[1], my_mpi[2], my_mpi[3] );

...and then you can do the same with the public-key part.


Timo
Re: seperate public key, private key [ In reply to ]
Am Sonntag, 19. Mai 2002 14:37 schrieben Sie:
> On Sun May 19 2002; 13:19, Rüdiger Sonderfeld wrote:
> > I need to separate the public key and the private key from the GCRY_SEXP
> > struct because I want to save the private key crypted and the public key
> > readable.
>
> I'm not sure if I understand what you mean. The keys should be
> separated all of the time. Which means you need to store them in
> two GCRY_SEXP contexts from the begin.

when I use the gcry_pk_genkey() function I recive only one GCRY_SEXP
structue...
Re: seperate public key, private key [ In reply to ]
On Mon May 20 2002; 15:00, Rüdiger Sonderfeld wrote:

> when I use the gcry_pk_genkey() function I recive only one GCRY_SEXP
> structue...

You should take a closer look to the gcry_sexp_xxx functions. With them
you can extract the values for the public and the secret key values.
If you don't have an idea about the structure, use gcry_sexp_dump.


Timo