format of encrypted data in sexpr

Orm Finnendahl o.finnendahl at mh-freiburg.de
Thu May 28 22:42:30 CEST 2009


Hi,

 I'm encoding a file in chunks of 128 Bytes (1024 bit rsa with
public/private key encryption) and everything seems to work well.

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.

Is there a way to specify (force) one of the two formats (I'd
much prefer the hex string to the regular string)?

Here is the relevant part of the code I'm using:

  sprintf(buf, "(data (flags raw) (value %s))", hexstring);
  err = gcry_sexp_build (&sexp, NULL, buf);
  err = gcry_pk_encrypt (&decr, sexp, pkey);
  gcry_sexp_sprint (decr, GCRYSEXP_FMT_ADVANCED,
                      buf, MAXLENGTH);
  extract_a_from_sexp (decr, decryptstr);

As I said, everything works. It's just a little tedious to deal with
the string representation (especially as it sometimes contains escaped
characters, like hex values or newlines etc.).

Thanks,
Orm



More information about the Gcrypt-devel mailing list