Error encrypting string data
Werner Koch
wk@gnupg.org
Fri, 18 Jul 2003 13:20:24 +0200
On Thu, 17 Jul 2003 13:37:25 +0200, Ralf Schneider said:
> x = gcry_mpi_new (0);
> gcry_mpi_set_opaque (x, text, strlen(text));
You can't use opaque becuase that won't yield a valid MPI which can be
passed to other MPI functions. Opaque is a hack to allow for
encrypted MPI values.
To convert a string into an MPI, use this:
gcry_mpi_t a;
int rc;
const char string[] = "Is that all you've got to show for seven "
"and a half million years' work?";
rc = gcry_mpi_scan (&a, GCRYMPI_FMT_USG, string, strlen (string));
if (rc)
bug ("oops: mpi_scan failed: %s\n", gpg_strerror (rc));
foo (a)
gcry_mpi_release (a);
However, using this is not secure as proper padding is required for
most public key algorithms; see the HAC for details.
Salam-Shalom,
Werner
--
Werner Koch <wk@gnupg.org>
The GnuPG Experts http://g10code.com
Free Software Foundation Europe http://fsfeurope.org