Last minute fixes

This commit is contained in:
Werner Koch 2009-09-02 17:30:53 +00:00
parent d890215d18
commit 5f9caad6f1
6 changed files with 41 additions and 19 deletions

View File

@ -1,5 +1,8 @@
2009-09-02 Werner Koch <wk@g10code.com>
* app-openpgp.c (do_decipher): Compute required Le.
* iso7816.c (iso7816_decipher): Add new arg LE.
* compress-bz2.c (do_uncompress): Detect unexpected EOF. Fixes
bug#1011.

View File

@ -3316,7 +3316,7 @@ do_decipher (app_t app, const char *keyidstr,
const char *s;
int n;
const char *fpr = NULL;
int exmode;
int exmode, le_value;
if (!keyidstr || !*keyidstr || !indatalen)
return gpg_error (GPG_ERR_INV_VALUE);
@ -3399,16 +3399,22 @@ do_decipher (app_t app, const char *keyidstr,
indatalen = fixuplen + indatalen;
padind = -1; /* Already padded. */
}
if (app->app_local->cardcap.ext_lc_le && indatalen > 254 )
exmode = 1; /* Extended length w/o a limit. */
{
exmode = 1; /* Extended length w/o a limit. */
le_value = app->app_local->extcap.max_rsp_data;
}
else if (app->app_local->cardcap.cmd_chaining && indatalen > 254)
exmode = -254; /* Command chaining with max. 254 bytes. */
{
exmode = -254; /* Command chaining with max. 254 bytes. */
le_value = 0;
}
else
exmode = 0;
exmode = le_value = 0;
rc = iso7816_decipher (app->slot, exmode,
indata, indatalen, padind,
indata, indatalen, le_value, padind,
outdata, outdatalen);
xfree (fixbuf);
}

View File

@ -545,10 +545,11 @@ iso7816_compute_ds (int slot, int extended_mode,
indicator to be used. It should be 0 if no padding is required, a
value of -1 suppresses the padding byte. On success 0 is returned
and the plaintext is available in a newly allocated buffer stored
at RESULT with its length stored at RESULTLEN. */
at RESULT with its length stored at RESULTLEN. For LE see
do_generate_keypair. */
gpg_error_t
iso7816_decipher (int slot, int extended_mode,
const unsigned char *data, size_t datalen,
const unsigned char *data, size_t datalen, int le,
int padind, unsigned char **result, size_t *resultlen)
{
int sw;
@ -559,6 +560,11 @@ iso7816_decipher (int slot, int extended_mode,
*result = NULL;
*resultlen = 0;
if (!extended_mode)
le = 256; /* Ignore provided Le and use what apdu_send uses. */
else if (le >= 0 && le < 256)
le = 256;
if (padind >= 0)
{
/* We need to prepend the padding indicator. */
@ -568,18 +574,18 @@ iso7816_decipher (int slot, int extended_mode,
*buf = padind; /* Padding indicator. */
memcpy (buf+1, data, datalen);
sw = apdu_send (slot, extended_mode,
0x00, CMD_PSO, 0x80, 0x86,
datalen+1, (char*)buf,
result, resultlen);
sw = apdu_send_le (slot, extended_mode,
0x00, CMD_PSO, 0x80, 0x86,
datalen+1, (char*)buf, le,
result, resultlen);
xfree (buf);
}
else
{
sw = apdu_send (slot, extended_mode,
0x00, CMD_PSO, 0x80, 0x86,
datalen, (const char *)data,
result, resultlen);
sw = apdu_send_le (slot, extended_mode,
0x00, CMD_PSO, 0x80, 0x86,
datalen, (const char *)data, le,
result, resultlen);
}
if (sw != SW_SUCCESS)
{

View File

@ -99,7 +99,7 @@ gpg_error_t iso7816_compute_ds (int slot, int extended_mode,
unsigned char **result, size_t *resultlen);
gpg_error_t iso7816_decipher (int slot, int extended_mode,
const unsigned char *data, size_t datalen,
int padind,
int le, int padind,
unsigned char **result, size_t *resultlen);
gpg_error_t iso7816_internal_authenticate (int slot, int extended_mode,
const unsigned char *data, size_t datalen,

View File

@ -1,3 +1,8 @@
2009-09-02 Werner Koch <wk@g10code.com>
* Makefile.am (gpgkeys_curl_SOURCES, gpgkeys_ldap_SOURCES)
(gpgkeys_finger_SOURCES): Add ksmalloc.c only with non-faked cURL.
2009-08-25 Werner Koch <wk@g10code.com>
* ksmalloc.c: New

View File

@ -28,9 +28,9 @@ gpglibexec_SCRIPTS = @GPGKEYS_MAILTO@
noinst_SCRIPTS = gpgkeys_test
gpgkeys_ldap_SOURCES = gpgkeys_ldap.c ksutil.c ksutil.h ksmalloc.c
gpgkeys_hkp_SOURCES = gpgkeys_hkp.c ksutil.c ksutil.h ksmalloc.c
gpgkeys_hkp_SOURCES = gpgkeys_hkp.c ksutil.c ksutil.h
gpgkeys_finger_SOURCES = gpgkeys_finger.c ksutil.c ksutil.h
gpgkeys_curl_SOURCES = gpgkeys_curl.c ksutil.c ksutil.h ksmalloc.c
gpgkeys_curl_SOURCES = gpgkeys_curl.c ksutil.c ksutil.h
other_libs = $(LIBICONV) $(LIBINTL) $(CAPLIBS)
@ -45,8 +45,10 @@ gpgkeys_curl_LDADD = ../util/libutil.a @NETLIBS@ @DNSLIBS@ $(other_libs) @GETOPT
gpgkeys_hkp_SOURCES += curl-shim.c curl-shim.h
gpgkeys_hkp_LDADD = ../util/libutil.a @NETLIBS@ @DNSLIBS@ $(other_libs) @GETOPT@ @W32LIBS@
else
gpgkeys_curl_SOURCES += ksmalloc.c
gpgkeys_curl_CPPFLAGS = @LIBCURL_CPPFLAGS@
gpgkeys_curl_LDADD = ../util/libcompat.a @LIBCURL@ @GETOPT@
gpgkeys_hkp_SOURCES += ksmalloc.c
gpgkeys_hkp_CPPFLAGS = @LIBCURL_CPPFLAGS@
gpgkeys_hkp_LDADD = ../util/libcompat.a @DNSLIBS@ @LIBCURL@ @GETOPT@
gpgkeys_finger_CPPFLAGS = @LIBCURL_CPPFLAGS@