# extracting mpi from a S-exp crypted with RSA

flebool flebool at libero.it
Tue Apr 19 21:00:14 CEST 2005

```I haven't understood correctly the model for crypted keys:
in the documentation, i've found that,if i crypt with the rsa algorythm a
S-exp TEXT in the form:

(data
(flags raw)
(value MPI))

the crypted S-exp CRYPTED is represented as:

(enc-val
(rsa
(a A-MPI)))

Calling the function:
int legth=gcrypt_sexp_length(CRYPTED);
I get length=2.

i want to get the mpi (a A-MPI),(that i've understood to be the crypted text
in MPI format) but the function

gcry_mpi_t internal_mpi = gcry_sexp_nth_mpi(CRYPTED,1,GCRYMPI_FMT_USG);

fails.

for completeness,i post the output of a
writt= gcry_sexp_sprint ( CRYPTED , GCRYSEXP_FMT_DEFAULT , buf_test2 ,(size_t)
500);

(i do it only to show that it seems (at least to me) to be a good S-exp in the
format described in the documentation)

the results are: writt=166,buf_test2[500]="\000à\004\b@Ü\004\b(7:enc-val\n
(3:rsa\n  (1:a128:
\212zýJ¦\222\f\037\2269\eÉÏ¼×d\025ª\234\$)\n"

i'm not a good coder, neither a good english writer, so sorry if i haven't
been clear, or if i haven't understood well the documentation.

thanks in advance for any help.

Flebool

PS if you prefer i can post a source of an example program.