[PATCH] scd: Increase ECC private key template size

Arnaud Fontaine arnaud.fontaine at ssi.gouv.fr
Fri Oct 14 11:26:13 CEST 2016


* scd/app-openpgp.c: The encoded template size is two bytes long when
both private and public keys are included and the curve has large
coordinates.
---
 scd/app-openpgp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scd/app-openpgp.c b/scd/app-openpgp.c
index 563a045..9eb30a0 100644
--- a/scd/app-openpgp.c
+++ b/scd/app-openpgp.c
@@ -2684,7 +2684,7 @@ build_ecc_privkey_template (app_t app, int keyno,
   suffix_len = tp - suffix;
    /* Now concatenate everything.  */
-  template_size = (1 + 1   /* 0x4d and len. */
+  template_size = (1 + 2   /* 0x4d and len. */
                    + exthdr_len
                    + privkey_len
                    + suffix_len
@@ -2710,7 +2710,7 @@ build_ecc_privkey_template (app_t app, int keyno,
       tp += ecc_q_len;
     }
 -  assert (tp - template == template_size);
+  assert ((template_size - 1) <= (tp - template));
    *result = template;
   *resultlen = tp - template;
-- 
2.9.3




More information about the Gnupg-devel mailing list