aboutsummaryrefslogtreecommitdiffstats
path: root/agent/cvt-openpgp.c
diff options
context:
space:
mode:
Diffstat (limited to 'agent/cvt-openpgp.c')
-rw-r--r--agent/cvt-openpgp.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/agent/cvt-openpgp.c b/agent/cvt-openpgp.c
index c43809f90..3da553f95 100644
--- a/agent/cvt-openpgp.c
+++ b/agent/cvt-openpgp.c
@@ -1159,14 +1159,31 @@ apply_protection (gcry_mpi_t *array, int npkey, int nskey,
ndata = 20; /* Space for the SHA-1 checksum. */
for (i = npkey, j = 0; i < nskey; i++, j++ )
{
- err = gcry_mpi_aprint (GCRYMPI_FMT_USG, bufarr+j, narr+j, array[i]);
+ if (gcry_mpi_get_flag (array[i], GCRYMPI_FLAG_OPAQUE))
+ {
+ p = gcry_mpi_get_opaque (array[i], &nbits[j]);
+ narr[j] = (nbits[j] + 7)/8;
+ data = xtrymalloc_secure (narr[j]);
+ if (!data)
+ err = gpg_error_from_syserror ();
+ else
+ {
+ memcpy (data, p, narr[j]);
+ bufarr[j] = data;
+ err = 0;
+ }
+ }
+ else
+ {
+ err = gcry_mpi_aprint (GCRYMPI_FMT_USG, bufarr+j, narr+j, array[i]);
+ nbits[j] = gcry_mpi_get_nbits (array[i]);
+ }
if (err)
{
for (i = 0; i < j; i++)
xfree (bufarr[i]);
return err;
}
- nbits[j] = gcry_mpi_get_nbits (array[i]);
ndata += 2 + narr[j];
}