aboutsummaryrefslogtreecommitdiffstats
path: root/scd/apdu.c
diff options
context:
space:
mode:
authorNIIBE Yutaka <[email protected]>2013-01-07 05:20:55 +0000
committerNIIBE Yutaka <[email protected]>2013-02-05 04:35:44 +0000
commitca89277cb4cb9558da97a71a4cb070cb77c9b536 (patch)
treef759a3f1373fc39caf9be2398ccbf18f77301260 /scd/apdu.c
parentSCD: Add option enable-keypad-varlen and support for GEMPC_PINPAD. (diff)
downloadgnupg-ca89277cb4cb9558da97a71a4cb070cb77c9b536.tar.gz
gnupg-ca89277cb4cb9558da97a71a4cb070cb77c9b536.zip
SCD: Clean up. Remove PADLEN for keypad input.
* scd/apdu.c (struct pininfo_s): Use iso7816_pininfo_s. (struct reader_table_s): Remove last arg from check_keypad method. (check_pcsc_keypad, check_pcsc_keypad): Remove PIN_PADLEN. (pcsc_keypad_verify, pcsc_keypad_modify): Don't check PIN_PADLEN. (send_apdu_ccid, ccid_keypad_operation): Remove PIN_PADLEN. (apdu_check_keypad, apdu_keypad_verify, apdu_keypad_modify): Likewise. * scd/apdu.h (apdu_check_keypad, apdu_keypad_verify) (apdu_keypad_modify): Remove PIN_PADLEN. * scd/ccid-driver.c (ccid_transceive_secure): Remove PIN_PADLEN. * scd/ccid-driver.h (ccid_transceive_secure): Remove PIN_PADLEN. * scd/iso7816.c (iso7816_check_keypad, iso7816_verify_kp) (iso7816_change_reference_data_kp): Remove PADLEN. * scd/iso7816.h (struct iso7816_pininfo_s): Remove PADLEN, PADCHAR. -- In the OpenPGPcard specification, password comes with no padding. In GnuPG, we support keypad input for OpenPGPcard only. Thus, it is useless to try to support padding for keypad input.
Diffstat (limited to 'scd/apdu.c')
-rw-r--r--scd/apdu.c40
1 files changed, 10 insertions, 30 deletions
diff --git a/scd/apdu.c b/scd/apdu.c
index 278e08a36..f66db4d2c 100644
--- a/scd/apdu.c
+++ b/scd/apdu.c
@@ -83,15 +83,7 @@
#define DLSTDCALL
#endif
-
-/* Helper to pass parameters related to keypad based operations. */
-struct pininfo_s
-{
- int mode;
- int minlen;
- int maxlen;
- int padlen;
-};
+#define pininfo_s iso7816_pininfo_s
/* A structure to collect information pertaining to one reader
slot. */
@@ -108,7 +100,7 @@ struct reader_table_s {
int (*get_status_reader)(int, unsigned int *);
int (*send_apdu_reader)(int,unsigned char *,size_t,
unsigned char *, size_t *, struct pininfo_s *);
- int (*check_keypad)(int, int, int, int, int, int);
+ int (*check_keypad)(int, int, int, int, int);
void (*dump_status_reader)(int);
int (*set_progress_cb)(int, gcry_handler_progress_t, void*);
int (*keypad_verify)(int, int, int, int, int, struct pininfo_s *);
@@ -331,7 +323,7 @@ static int apdu_get_status_internal (int slot, int hang, int no_atr_reset,
unsigned int *status,
unsigned int *changed);
static int check_pcsc_keypad (int slot, int command, int pin_mode,
- int pinlen_min, int pinlen_max, int pin_padlen);
+ int pinlen_min, int pinlen_max);
static int pcsc_keypad_verify (int slot, int class, int ins, int p0, int p1,
struct pininfo_s *pininfo);
static int pcsc_keypad_modify (int slot, int class, int ins, int p0, int p1,
@@ -1993,7 +1985,7 @@ open_pcsc_reader (const char *portstr)
on the keypad. Return 0 on success. */
static int
check_pcsc_keypad (int slot, int command, int pin_mode,
- int pinlen_min, int pinlen_max, int pin_padlen)
+ int pinlen_min, int pinlen_max)
{
unsigned char buf[256];
size_t len = 256;
@@ -2002,7 +1994,6 @@ check_pcsc_keypad (int slot, int command, int pin_mode,
(void)pin_mode;
(void)pinlen_min;
(void)pinlen_max;
- (void)pin_padlen;
check_again:
if (command == ISO7816_VERIFY)
@@ -2069,9 +2060,6 @@ pcsc_keypad_verify (int slot, int class, int ins, int p0, int p1,
if (pininfo->mode != 1)
return SW_NOT_SUPPORTED;
- if (pininfo->padlen != 0)
- return SW_NOT_SUPPORTED;
-
if (!pininfo->minlen)
pininfo->minlen = 1;
if (!pininfo->maxlen)
@@ -2153,9 +2141,6 @@ pcsc_keypad_modify (int slot, int class, int ins, int p0, int p1,
if (pininfo->mode != 1)
return SW_NOT_SUPPORTED;
- if (pininfo->padlen != 0)
- return SW_NOT_SUPPORTED;
-
if (!pininfo->minlen)
pininfo->minlen = 1;
if (!pininfo->maxlen)
@@ -2332,7 +2317,6 @@ send_apdu_ccid (int slot, unsigned char *apdu, size_t apdulen,
pininfo->mode,
pininfo->minlen,
pininfo->maxlen,
- pininfo->padlen,
buffer, maxbuflen, buflen);
else
err = ccid_transceive (reader_table[slot].ccid.handle,
@@ -2351,14 +2335,14 @@ send_apdu_ccid (int slot, unsigned char *apdu, size_t apdulen,
parameters, see ccid-driver.c */
static int
check_ccid_keypad (int slot, int command, int pin_mode,
- int pinlen_min, int pinlen_max, int pin_padlen)
+ int pinlen_min, int pinlen_max)
{
unsigned char apdu[] = { 0, 0, 0, 0x81 };
apdu[1] = command;
return ccid_transceive_secure (reader_table[slot].ccid.handle,
apdu, sizeof apdu,
- pin_mode, pinlen_min, pinlen_max, pin_padlen,
+ pin_mode, pinlen_min, pinlen_max,
NULL, 0, NULL);
}
@@ -2379,7 +2363,6 @@ ccid_keypad_operation (int slot, int class, int ins, int p0, int p1,
err = ccid_transceive_secure (reader_table[slot].ccid.handle,
apdu, sizeof apdu,
pininfo->mode, pininfo->minlen, pininfo->maxlen,
- pininfo->padlen,
result, 2, &resultlen);
if (err)
return err;
@@ -3423,7 +3406,7 @@ apdu_get_status (int slot, int hang,
parameters, see ccid-driver.c */
int
apdu_check_keypad (int slot, int command, int pin_mode,
- int pinlen_min, int pinlen_max, int pin_padlen)
+ int pinlen_min, int pinlen_max)
{
if (slot < 0 || slot >= MAX_READER || !reader_table[slot].used )
return SW_HOST_NO_DRIVER;
@@ -3436,8 +3419,7 @@ apdu_check_keypad (int slot, int command, int pin_mode,
return sw;
sw = reader_table[slot].check_keypad (slot, command,
- pin_mode, pinlen_min, pinlen_max,
- pin_padlen);
+ pin_mode, pinlen_min, pinlen_max);
unlock_slot (slot);
return sw;
}
@@ -3448,14 +3430,13 @@ apdu_check_keypad (int slot, int command, int pin_mode,
int
apdu_keypad_verify (int slot, int class, int ins, int p0, int p1, int pin_mode,
- int pinlen_min, int pinlen_max, int pin_padlen)
+ int pinlen_min, int pinlen_max)
{
struct pininfo_s pininfo;
pininfo.mode = pin_mode;
pininfo.minlen = pinlen_min;
pininfo.maxlen = pinlen_max;
- pininfo.padlen = pin_padlen;
if (slot < 0 || slot >= MAX_READER || !reader_table[slot].used )
return SW_HOST_NO_DRIVER;
@@ -3479,14 +3460,13 @@ apdu_keypad_verify (int slot, int class, int ins, int p0, int p1, int pin_mode,
int
apdu_keypad_modify (int slot, int class, int ins, int p0, int p1, int pin_mode,
- int pinlen_min, int pinlen_max, int pin_padlen)
+ int pinlen_min, int pinlen_max)
{
struct pininfo_s pininfo;
pininfo.mode = pin_mode;
pininfo.minlen = pinlen_min;
pininfo.maxlen = pinlen_max;
- pininfo.padlen = pin_padlen;
if (slot < 0 || slot >= MAX_READER || !reader_table[slot].used )
return SW_HOST_NO_DRIVER;