aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNIIBE Yutaka <gniibe@fsij.org>2020-11-02 15:34:03 +0900
committerNIIBE Yutaka <gniibe@fsij.org>2020-11-02 15:34:03 +0900
commit8211d0bc3ba5ed15d0668050c08a6e28228b08a4 (patch)
tree405acd0c8dc48e591b905655892c2fc3be687e57
parent90c3d623ce37695a1eb29c0a7276b23490d14603 (diff)
downloadgnupg-8211d0bc3ba5ed15d0668050c08a6e28228b08a4.tar.gz
kbx: Don't put zero-byte for ECC.
* kbx/keybox-openpgp.c (parse_key): Only put zero for non-ECC. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
-rw-r--r--kbx/keybox-openpgp.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/kbx/keybox-openpgp.c b/kbx/keybox-openpgp.c
index 0835909e6..43e811215 100644
--- a/kbx/keybox-openpgp.c
+++ b/kbx/keybox-openpgp.c
@@ -369,23 +369,24 @@ parse_key (const unsigned char *data, size_t datalen,
/* Note: Starting here we need to jump to leave on error. */
- /* Make sure the MPIs are unsigned. */
- for (i=0; i < npkey; i++)
- {
- if (!keyparm[i].len || (keyparm[i].mpi[0] & 0x80))
- {
- helpmpibuf[i] = xtrymalloc (1+keyparm[i].len);
- if (!helpmpibuf[i])
- {
- err = gpg_error_from_syserror ();
- goto leave;
- }
- helpmpibuf[i][0] = 0;
- memcpy (helpmpibuf[i]+1, keyparm[i].mpi, keyparm[i].len);
- keyparm[i].mpi = helpmpibuf[i];
- keyparm[i].len++;
- }
- }
+ /* For non-ECC, make sure the MPIs are unsigned. */
+ if (!is_ecc)
+ for (i=0; i < npkey; i++)
+ {
+ if (!keyparm[i].len || (keyparm[i].mpi[0] & 0x80))
+ {
+ helpmpibuf[i] = xtrymalloc (1+keyparm[i].len);
+ if (!helpmpibuf[i])
+ {
+ err = gpg_error_from_syserror ();
+ goto leave;
+ }
+ helpmpibuf[i][0] = 0;
+ memcpy (helpmpibuf[i]+1, keyparm[i].mpi, keyparm[i].len);
+ keyparm[i].mpi = helpmpibuf[i];
+ keyparm[i].len++;
+ }
+ }
err = keygrip_from_keyparm (algorithm, keyparm, ki->grip);
if (err)