aboutsummaryrefslogtreecommitdiffstats
path: root/scd/app-openpgp.c
diff options
context:
space:
mode:
authorNIIBE Yutaka <[email protected]>2017-08-29 05:35:47 +0000
committerNIIBE Yutaka <[email protected]>2017-08-29 05:35:47 +0000
commitff7ccd284c327a5b1c89603f157089177dac9d13 (patch)
tree1c6eac22e5dc2996c0dd4d40b6d84a5d12cabb83 /scd/app-openpgp.c
parentPost release updates (diff)
downloadgnupg-ff7ccd284c327a5b1c89603f157089177dac9d13.tar.gz
gnupg-ff7ccd284c327a5b1c89603f157089177dac9d13.zip
scd: Fix for large ECC keys.
* scd/app-openpgp.c (do_decipher): Support larger length. -- Reported-by: Achim Pietig <[email protected]> Signed-off-by: NIIBE Yutaka <[email protected]>
Diffstat (limited to 'scd/app-openpgp.c')
-rw-r--r--scd/app-openpgp.c40
1 files changed, 32 insertions, 8 deletions
diff --git a/scd/app-openpgp.c b/scd/app-openpgp.c
index f9d07ac46..6fcec3e4e 100644
--- a/scd/app-openpgp.c
+++ b/scd/app-openpgp.c
@@ -4575,19 +4575,43 @@ do_decipher (app_t app, const char *keyidstr,
}
}
- fixuplen = 7;
+ n = 0;
+ if (indatalen < 128)
+ fixuplen = 7;
+ else
+ fixuplen = 10;
+
fixbuf = xtrymalloc (fixuplen + indatalen);
if (!fixbuf)
return gpg_error_from_syserror ();
/* Build 'Cipher DO' */
- fixbuf[0] = '\xa6';
- fixbuf[1] = (char)(indatalen+5);
- fixbuf[2] = '\x7f';
- fixbuf[3] = '\x49';
- fixbuf[4] = (char)(indatalen+2);
- fixbuf[5] = '\x86';
- fixbuf[6] = (char)indatalen;
+ fixbuf[n++] = '\xa6';
+ if (indatalen < 128)
+ fixbuf[n++] = (char)(indatalen+5);
+ else
+ {
+ fixbuf[n++] = 0x81;
+ fixbuf[n++] = (char)(indatalen+7);
+ }
+ fixbuf[n++] = '\x7f';
+ fixbuf[n++] = '\x49';
+ if (indatalen < 128)
+ fixbuf[n++] = (char)(indatalen+2);
+ else
+ {
+ fixbuf[n++] = 0x81;
+ fixbuf[n++] = (char)(indatalen+3);
+ }
+ fixbuf[n++] = '\x86';
+ if (indatalen < 128)
+ fixbuf[n++] = (char)indatalen;
+ else
+ {
+ fixbuf[n++] = 0x81;
+ fixbuf[n++] = (char)indatalen;
+ }
+
if (old_format_len)
{
memset (fixbuf+fixuplen, 0, 32 - old_format_len);