aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNIIBE Yutaka <[email protected]>2015-09-19 07:27:36 +0000
committerNIIBE Yutaka <[email protected]>2015-09-19 07:27:36 +0000
commit708b7eccdef8d274bd5578b9a5fd908e9685c795 (patch)
tree9d6923e895f3e22d5e556d407ebb89641300a674
parentcommon: Add new function strlist_length. (diff)
downloadgnupg-708b7eccdef8d274bd5578b9a5fd908e9685c795.tar.gz
gnupg-708b7eccdef8d274bd5578b9a5fd908e9685c795.zip
scd: Fix KEYTOCARD handling for ECC key.
* scd/app-openpgp.c (ecc_writekey): Only public key can be native format.
-rw-r--r--scd/app-openpgp.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/scd/app-openpgp.c b/scd/app-openpgp.c
index 8f7c8b016..d43db5b69 100644
--- a/scd/app-openpgp.c
+++ b/scd/app-openpgp.c
@@ -3243,11 +3243,12 @@ ecc_writekey (app_t app, gpg_error_t (*pincb)(void*, const char *, char **),
{
const unsigned char **buf2;
size_t *buf2len;
+ int native = flag_djb_tweak;
switch (*tok)
{
case 'q': buf2 = &ecc_q; buf2len = &ecc_q_len; break;
- case 'd': buf2 = &ecc_d; buf2len = &ecc_d_len; break;
+ case 'd': buf2 = &ecc_d; buf2len = &ecc_d_len; native = 0; break;
default: buf2 = NULL; buf2len = NULL; break;
}
if (buf2 && *buf2)
@@ -3257,13 +3258,16 @@ ecc_writekey (app_t app, gpg_error_t (*pincb)(void*, const char *, char **),
}
if ((err = parse_sexp (&buf, &buflen, &depth, &tok, &toklen)))
goto leave;
- if (tok && buf2 && !flag_djb_tweak)
- /* It's MPI. Strip off leading zero bytes and save. */
- for (;toklen && !*tok; toklen--, tok++)
- ;
+ if (tok && buf2)
+ {
+ if (!native)
+ /* Strip off leading zero bytes and save. */
+ for (;toklen && !*tok; toklen--, tok++)
+ ;
- *buf2 = tok;
- *buf2len = toklen;
+ *buf2 = tok;
+ *buf2len = toklen;
+ }
}
/* Skip until end of list. */
last_depth2 = depth;