1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-02-01 16:33:02 +01:00

scd: Fix KEYTOCARD handling for ECC key.

* scd/app-openpgp.c (ecc_writekey): Only public key can be native
format.
This commit is contained in:
NIIBE Yutaka 2015-09-19 16:27:36 +09:00
parent 8499c4f84a
commit 708b7eccde

View File

@ -3243,11 +3243,12 @@ ecc_writekey (app_t app, gpg_error_t (*pincb)(void*, const char *, char **),
{ {
const unsigned char **buf2; const unsigned char **buf2;
size_t *buf2len; size_t *buf2len;
int native = flag_djb_tweak;
switch (*tok) switch (*tok)
{ {
case 'q': buf2 = &ecc_q; buf2len = &ecc_q_len; break; 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; default: buf2 = NULL; buf2len = NULL; break;
} }
if (buf2 && *buf2) if (buf2 && *buf2)
@ -3257,14 +3258,17 @@ ecc_writekey (app_t app, gpg_error_t (*pincb)(void*, const char *, char **),
} }
if ((err = parse_sexp (&buf, &buflen, &depth, &tok, &toklen))) if ((err = parse_sexp (&buf, &buflen, &depth, &tok, &toklen)))
goto leave; goto leave;
if (tok && buf2 && !flag_djb_tweak) if (tok && buf2)
/* It's MPI. Strip off leading zero bytes and save. */ {
if (!native)
/* Strip off leading zero bytes and save. */
for (;toklen && !*tok; toklen--, tok++) for (;toklen && !*tok; toklen--, tok++)
; ;
*buf2 = tok; *buf2 = tok;
*buf2len = toklen; *buf2len = toklen;
} }
}
/* Skip until end of list. */ /* Skip until end of list. */
last_depth2 = depth; last_depth2 = depth;
while (!(err = parse_sexp (&buf, &buflen, &depth, &tok, &toklen)) while (!(err = parse_sexp (&buf, &buflen, &depth, &tok, &toklen))