summaryrefslogtreecommitdiffstats
path: root/g10/export.c
diff options
context:
space:
mode:
authorNIIBE Yutaka <gniibe@fsij.org>2021-03-22 08:55:29 +0100
committerNIIBE Yutaka <gniibe@fsij.org>2021-03-22 08:55:29 +0100
commit0b45c5a9941094bd4529c3bf5b1cb8ce2584b9a4 (patch)
tree1b98c65cbe48d1e81da39e374e9db72c3c35df0f /g10/export.c
parentcard: Support OpenPGP.1 and OpenPGP.2 for readcert and writecert. (diff)
downloadgnupg2-0b45c5a9941094bd4529c3bf5b1cb8ce2584b9a4.tar.xz
gnupg2-0b45c5a9941094bd4529c3bf5b1cb8ce2584b9a4.zip
gpg: Fix exporting SSH key.
* g10/export.c (export_one_ssh_key): Finish base 64 encoder before writing out the comment string. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
Diffstat (limited to 'g10/export.c')
-rw-r--r--g10/export.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/g10/export.c b/g10/export.c
index d24fd16a4..ac12ccddb 100644
--- a/g10/export.c
+++ b/g10/export.c
@@ -2267,21 +2267,26 @@ export_one_ssh_key (estream_t fp, PKT_public_key *pk)
if (err)
goto leave;
- err = b64enc_start_es (&b64_state, fp, "");
- if (err)
- goto leave;
-
blob = get_membuf (&mb, &bloblen);
if (blob)
{
+ struct b64state b64_state;
+
es_fprintf (fp, "%s ", identifier);
+ err = b64enc_start_es (&b64_state, fp, "");
+ if (err)
+ {
+ xfree (blob);
+ goto leave;
+ }
+
err = b64enc_write (&b64_state, blob, bloblen);
+ b64enc_finish (&b64_state);
+
es_fprintf (fp, " openpgp:0x%08lX\n", (ulong)keyid_from_pk (pk, NULL));
xfree (blob);
}
- b64enc_finish (&b64_state);
-
leave:
xfree (get_membuf (&mb, NULL));
return err;