mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
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.
This commit is contained in:
parent
d9f6cc7502
commit
ca89277cb4
40
scd/apdu.c
40
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;
|
||||
|
@ -115,13 +115,11 @@ int apdu_reset (int slot);
|
||||
int apdu_get_status (int slot, int hang,
|
||||
unsigned int *status, unsigned int *changed);
|
||||
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);
|
||||
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 pin_mode, int pinlen_min, int pinlen_max);
|
||||
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 pin_mode, int pinlen_min, int pinlen_max);
|
||||
int apdu_send_simple (int slot, int extended_mode,
|
||||
int class, int ins, int p0, int p1,
|
||||
int lc, const char *data);
|
||||
|
@ -3288,7 +3288,7 @@ ccid_transceive (ccid_driver_t handle,
|
||||
The APDU should me made up of 4 bytes without Lc.
|
||||
|
||||
PINLEN_MIN and PINLEN_MAX define the limits for the pin length. 0
|
||||
may be used t enable reasonable defaults. PIN_PADLEN should be 0.
|
||||
may be used t enable reasonable defaults.
|
||||
|
||||
When called with RESP and NRESP set to NULL, the function will
|
||||
merely check whether the reader supports the secure command for the
|
||||
@ -3297,7 +3297,6 @@ int
|
||||
ccid_transceive_secure (ccid_driver_t handle,
|
||||
const unsigned char *apdu_buf, size_t apdu_buflen,
|
||||
int pin_mode, int pinlen_min, int pinlen_max,
|
||||
int pin_padlen,
|
||||
unsigned char *resp, size_t maxresplen, size_t *nresp)
|
||||
{
|
||||
int rc;
|
||||
@ -3326,9 +3325,6 @@ ccid_transceive_secure (ccid_driver_t handle,
|
||||
if (pin_mode != 1)
|
||||
return CCID_DRIVER_ERR_NOT_SUPPORTED;
|
||||
|
||||
if (pin_padlen != 0)
|
||||
return CCID_DRIVER_ERR_NOT_SUPPORTED;
|
||||
|
||||
if (!pinlen_min)
|
||||
pinlen_min = 1;
|
||||
if (!pinlen_max)
|
||||
|
@ -94,7 +94,7 @@ int ccid_transceive (ccid_driver_t handle,
|
||||
int ccid_transceive_secure (ccid_driver_t handle,
|
||||
const unsigned char *apdu, size_t apdulen,
|
||||
int pin_mode,
|
||||
int pinlen_min, int pinlen_max, int pin_padlen,
|
||||
int pinlen_min, int pinlen_max,
|
||||
unsigned char *resp, size_t maxresplen, size_t *nresp);
|
||||
int ccid_transceive_escape (ccid_driver_t handle,
|
||||
const unsigned char *data, size_t datalen,
|
||||
|
@ -274,8 +274,7 @@ iso7816_check_keypad (int slot, int command, iso7816_pininfo_t *pininfo)
|
||||
int sw;
|
||||
|
||||
sw = apdu_check_keypad (slot, command,
|
||||
pininfo->mode, pininfo->minlen, pininfo->maxlen,
|
||||
pininfo->padlen);
|
||||
pininfo->mode, pininfo->minlen, pininfo->maxlen);
|
||||
return iso7816_map_sw (sw);
|
||||
}
|
||||
|
||||
@ -289,8 +288,7 @@ iso7816_verify_kp (int slot, int chvno, iso7816_pininfo_t *pininfo)
|
||||
int sw;
|
||||
|
||||
sw = apdu_keypad_verify (slot, 0x00, CMD_VERIFY, 0, chvno,
|
||||
pininfo->mode, pininfo->minlen, pininfo->maxlen,
|
||||
pininfo->padlen);
|
||||
pininfo->mode, pininfo->minlen, pininfo->maxlen);
|
||||
return map_sw (sw);
|
||||
}
|
||||
|
||||
@ -318,7 +316,7 @@ iso7816_change_reference_data_kp (int slot, int chvno, int is_exchange,
|
||||
sw = apdu_keypad_modify (slot, 0x00, CMD_CHANGE_REFERENCE_DATA,
|
||||
is_exchange ? 1 : 0,
|
||||
chvno, pininfo->mode, pininfo->minlen,
|
||||
pininfo->maxlen, pininfo->padlen);
|
||||
pininfo->maxlen);
|
||||
return map_sw (sw);
|
||||
}
|
||||
|
||||
|
@ -37,8 +37,6 @@ struct iso7816_pininfo_s
|
||||
int mode; /* A mode of 0 means: Do not use the keypad. */
|
||||
int minlen;
|
||||
int maxlen;
|
||||
int padlen;
|
||||
int padchar;
|
||||
};
|
||||
typedef struct iso7816_pininfo_s iso7816_pininfo_t;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user