summaryrefslogtreecommitdiffstats
path: root/scd/iso7816.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2009-09-03 12:57:23 +0200
committerWerner Koch <wk@gnupg.org>2009-09-03 12:57:23 +0200
commit983f91937c7401c3ce575eee25ba8be8b41857d3 (patch)
treef05c775379fea0b8ce7167e7ccec45c9e5ce7938 /scd/iso7816.c
parentUpdate estream. (diff)
downloadgnupg2-983f91937c7401c3ce575eee25ba8be8b41857d3.tar.xz
gnupg2-983f91937c7401c3ce575eee25ba8be8b41857d3.zip
Fix for extended length Le in decipher
Diffstat (limited to 'scd/iso7816.c')
-rw-r--r--scd/iso7816.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/scd/iso7816.c b/scd/iso7816.c
index f1ee0daef..e3f2c1beb 100644
--- a/scd/iso7816.c
+++ b/scd/iso7816.c
@@ -15,8 +15,6 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
- *
- * $Id$
*/
#include <config.h>
@@ -460,7 +458,7 @@ iso7816_get_data (int slot, int extended_mode, int tag,
bytes. */
gpg_error_t
iso7816_put_data (int slot, int extended_mode, int tag,
- const unsigned char *data, size_t datalen)
+ const void *data, size_t datalen)
{
int sw;
@@ -473,7 +471,7 @@ iso7816_put_data (int slot, int extended_mode, int tag,
/* Same as iso7816_put_data but uses an odd instruction byte. */
gpg_error_t
iso7816_put_data_odd (int slot, int extended_mode, int tag,
- const unsigned char *data, size_t datalen)
+ const void *data, size_t datalen)
{
int sw;
@@ -545,10 +543,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 +558,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 +572,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)
{