format of encrypted data in sexpr

Werner Koch wk at
Tue Jun 2 10:55:24 CEST 2009

On Thu, 28 May 2009 22:42, o.finnendahl at said:

> The gcry_sexp_sprint function below sometimes returns a hex string
> (enclosed with hashmarks) and sometimes a string (enclosed in double
> quotes) in some random order for reasons not immediately obvious to
> me.

That is just a human readable format which uses a heuristic to decide
how to print it out.  See libgcrypt/src/sexp.c:suitable_encoding .

For machine based parsing it is way easier to use the canonical
S-expression format; see
for details on S-expressions.

>   gcry_sexp_sprint (decr, GCRYSEXP_FMT_ADVANCED,

Use GCRYSEXP_FMT_CANON .  gnupg/common/sexp-parse.h has fucntions to
parse a canonical encoded S-expression.



Die Gedanken sind frei.  Auschnahme regelt ein Bundeschgesetz.

More information about the Gcrypt-devel mailing list