Error encrypting string data
Ralf Schneider
ralf@tapfere-schneiderleins.de
Tue, 22 Jul 2003 15:59:08 +0200
=2D----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Am Dienstag, 22. Juli 2003 12:01 schrieb Moritz Schulte:
> Ralf Schneider <ralf@tapfere-schneiderleins.de> writes:
> > How can I then restore the key when I recover the MPI values? Is it
> > simply the other way round:
> >
> > 1. Create a new data set (gcry_ac_data_new)
> > 2. Set the MPI values (gcry_ac_data_set)
> > 3. Create the key from the data set (gcry_ac_key_init)
>
> This is correct.
Unfortunately, it does not work. I implemented the above sequence, but the=
=20
recovered key is not valid. I execute the following statements in a loop ov=
er=20
all base64 encode MPI values:
rc =3D gcry_mpi_scan (&x3, GCRYMPI_FMT_STD, restkey.data(), &restkeylen=
);
if (rc)
{
...
}
if (gcry_ac_data_set (keyData, mpiName, x3))
{
...
}
restkey is an object of class QByteArray (I use Qt). I compared these byte=
=20
arrays (after decoding the base64 string) with the ones when extracting the=
=20
MPI values out of the original key (before encoding to base64) and they are=
=20
equal. So I assume that the encoding and decoding worked correctly.
After that I restore the key:
gcry_ac_key_t restPrivKey;
if (gcry_ac_key_init (&restPrivKey, hd, GCRY_AC_KEY_SECRET, keyData))
{
...
}
I looked into the structures with the debugger and found out the there's a=
=20
difference in the first MPI value (named n). In the original key the value =
of=20
mpi->alloced is 33 and in the recovered key it is 32. All the other value a=
re=20
the same.
Any idea what's going wrong?
Best regards,
Ralf.
=2D----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)
iD8DBQE/HUMs7YyyfykA0YkRAolqAJ9NGKEgd72Ukk5Yz55qx+ZfrJVGDgCfcD6c
Y7QkyVZIZBNOcAlJvyDr0WY=3D
=3DDsal
=2D----END PGP SIGNATURE-----