mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-03 12:11:33 +01:00
scd: Add 0x41 prefix for x-coordinate only result.
* scd/app-openpgp.c (do_decipher): When it's x-coordinate only, add the prefix 0x41. -- Card should return fixed size bytes, either in format of (04 || X || Y) or (X, x-coordinate only). Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
parent
b648f28f9f
commit
6bbd97d6c7
@ -4406,20 +4406,29 @@ do_decipher (app_t app, const char *keyidstr,
|
|||||||
indata, indatalen, le_value, padind,
|
indata, indatalen, le_value, padind,
|
||||||
outdata, outdatalen);
|
outdata, outdatalen);
|
||||||
xfree (fixbuf);
|
xfree (fixbuf);
|
||||||
if (app->app_local->keyattr[1].key_type == KEY_TYPE_ECC
|
if (app->app_local->keyattr[1].key_type == KEY_TYPE_ECC)
|
||||||
&& (app->app_local->keyattr[1].ecc.flags & ECC_FLAG_DJB_TWEAK))
|
{
|
||||||
{ /* Add the prefix 0x40 */
|
unsigned char prefix = 0;
|
||||||
fixbuf = xtrymalloc (*outdatalen + 1);
|
|
||||||
if (!fixbuf)
|
if (app->app_local->keyattr[1].ecc.flags & ECC_FLAG_DJB_TWEAK)
|
||||||
{
|
prefix = 0x40;
|
||||||
|
else if ((*outdatalen % 2) == 0) /* No 0x04 -> x-coordinate only */
|
||||||
|
prefix = 0x41;
|
||||||
|
|
||||||
|
if (prefix)
|
||||||
|
{ /* Add the prefix */
|
||||||
|
fixbuf = xtrymalloc (*outdatalen + 1);
|
||||||
|
if (!fixbuf)
|
||||||
|
{
|
||||||
|
xfree (*outdata);
|
||||||
|
return gpg_error_from_syserror ();
|
||||||
|
}
|
||||||
|
fixbuf[0] = prefix;
|
||||||
|
memcpy (fixbuf+1, *outdata, *outdatalen);
|
||||||
xfree (*outdata);
|
xfree (*outdata);
|
||||||
return gpg_error_from_syserror ();
|
*outdata = fixbuf;
|
||||||
|
*outdatalen = *outdatalen + 1;
|
||||||
}
|
}
|
||||||
fixbuf[0] = 0x40;
|
|
||||||
memcpy (fixbuf+1, *outdata, *outdatalen);
|
|
||||||
xfree (*outdata);
|
|
||||||
*outdata = fixbuf;
|
|
||||||
*outdatalen = *outdatalen + 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gpg_err_code (rc) == GPG_ERR_CARD /* actual SW is 0x640a */
|
if (gpg_err_code (rc) == GPG_ERR_CARD /* actual SW is 0x640a */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user