1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-01-26 15:37:03 +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:
NIIBE Yutaka 2013-01-07 14:20:55 +09:00
parent 7c110e997a
commit 3d863c298b
6 changed files with 21 additions and 51 deletions

View File

@ -82,15 +82,7 @@
#define DLSTDCALL #define DLSTDCALL
#endif #endif
#define pininfo_s iso7816_pininfo_s
/* Helper to pass parameters related to keypad based operations. */
struct pininfo_s
{
int mode;
int minlen;
int maxlen;
int padlen;
};
/* A structure to collect information pertaining to one reader /* A structure to collect information pertaining to one reader
slot. */ slot. */
@ -107,7 +99,7 @@ struct reader_table_s {
int (*get_status_reader)(int, unsigned int *); int (*get_status_reader)(int, unsigned int *);
int (*send_apdu_reader)(int,unsigned char *,size_t, int (*send_apdu_reader)(int,unsigned char *,size_t,
unsigned char *, size_t *, struct pininfo_s *); 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); void (*dump_status_reader)(int);
int (*set_progress_cb)(int, gcry_handler_progress_t, void*); int (*set_progress_cb)(int, gcry_handler_progress_t, void*);
int (*keypad_verify)(int, int, int, int, int, struct pininfo_s *); int (*keypad_verify)(int, int, int, int, int, struct pininfo_s *);
@ -313,7 +305,7 @@ static int apdu_get_status_internal (int slot, int hang, int no_atr_reset,
unsigned int *status, unsigned int *status,
unsigned int *changed); unsigned int *changed);
static int check_pcsc_keypad (int slot, int command, int pin_mode, 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, static int pcsc_keypad_verify (int slot, int class, int ins, int p0, int p1,
struct pininfo_s *pininfo); struct pininfo_s *pininfo);
static int pcsc_keypad_modify (int slot, int class, int ins, int p0, int p1, static int pcsc_keypad_modify (int slot, int class, int ins, int p0, int p1,
@ -2023,7 +2015,7 @@ open_pcsc_reader (const char *portstr)
on the keypad. Return 0 on success. */ on the keypad. Return 0 on success. */
static int static int
check_pcsc_keypad (int slot, int command, int pin_mode, 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]; unsigned char buf[256];
size_t len = 256; size_t len = 256;
@ -2032,7 +2024,6 @@ check_pcsc_keypad (int slot, int command, int pin_mode,
(void)pin_mode; (void)pin_mode;
(void)pinlen_min; (void)pinlen_min;
(void)pinlen_max; (void)pinlen_max;
(void)pin_padlen;
check_again: check_again:
if (command == ISO7816_VERIFY) if (command == ISO7816_VERIFY)
@ -2099,9 +2090,6 @@ pcsc_keypad_verify (int slot, int class, int ins, int p0, int p1,
if (pininfo->mode != 1) if (pininfo->mode != 1)
return SW_NOT_SUPPORTED; return SW_NOT_SUPPORTED;
if (pininfo->padlen != 0)
return SW_NOT_SUPPORTED;
if (!pininfo->minlen) if (!pininfo->minlen)
pininfo->minlen = 1; pininfo->minlen = 1;
if (!pininfo->maxlen) if (!pininfo->maxlen)
@ -2181,9 +2169,6 @@ pcsc_keypad_modify (int slot, int class, int ins, int p0, int p1,
if (pininfo->mode != 1) if (pininfo->mode != 1)
return SW_NOT_SUPPORTED; return SW_NOT_SUPPORTED;
if (pininfo->padlen != 0)
return SW_NOT_SUPPORTED;
if (!pininfo->minlen) if (!pininfo->minlen)
pininfo->minlen = 1; pininfo->minlen = 1;
if (!pininfo->maxlen) if (!pininfo->maxlen)
@ -2360,7 +2345,6 @@ send_apdu_ccid (int slot, unsigned char *apdu, size_t apdulen,
pininfo->mode, pininfo->mode,
pininfo->minlen, pininfo->minlen,
pininfo->maxlen, pininfo->maxlen,
pininfo->padlen,
buffer, maxbuflen, buflen); buffer, maxbuflen, buflen);
else else
err = ccid_transceive (reader_table[slot].ccid.handle, err = ccid_transceive (reader_table[slot].ccid.handle,
@ -2379,14 +2363,14 @@ send_apdu_ccid (int slot, unsigned char *apdu, size_t apdulen,
parameters, see ccid-driver.c */ parameters, see ccid-driver.c */
static int static int
check_ccid_keypad (int slot, int command, int pin_mode, 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 }; unsigned char apdu[] = { 0, 0, 0, 0x81 };
apdu[1] = command; apdu[1] = command;
return ccid_transceive_secure (reader_table[slot].ccid.handle, return ccid_transceive_secure (reader_table[slot].ccid.handle,
apdu, sizeof apdu, apdu, sizeof apdu,
pin_mode, pinlen_min, pinlen_max, pin_padlen, pin_mode, pinlen_min, pinlen_max,
NULL, 0, NULL); NULL, 0, NULL);
} }
@ -2407,7 +2391,6 @@ ccid_keypad_operation (int slot, int class, int ins, int p0, int p1,
err = ccid_transceive_secure (reader_table[slot].ccid.handle, err = ccid_transceive_secure (reader_table[slot].ccid.handle,
apdu, sizeof apdu, apdu, sizeof apdu,
pininfo->mode, pininfo->minlen, pininfo->maxlen, pininfo->mode, pininfo->minlen, pininfo->maxlen,
pininfo->padlen,
result, 2, &resultlen); result, 2, &resultlen);
if (err) if (err)
return err; return err;
@ -3318,7 +3301,7 @@ apdu_get_status (int slot, int hang,
parameters, see ccid-driver.c */ parameters, see ccid-driver.c */
int int
apdu_check_keypad (int slot, int command, int pin_mode, 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 ) if (slot < 0 || slot >= MAX_READER || !reader_table[slot].used )
return SW_HOST_NO_DRIVER; return SW_HOST_NO_DRIVER;
@ -3331,8 +3314,7 @@ apdu_check_keypad (int slot, int command, int pin_mode,
return sw; return sw;
sw = reader_table[slot].check_keypad (slot, command, sw = reader_table[slot].check_keypad (slot, command,
pin_mode, pinlen_min, pinlen_max, pin_mode, pinlen_min, pinlen_max);
pin_padlen);
unlock_slot (slot); unlock_slot (slot);
return sw; return sw;
} }
@ -3343,14 +3325,13 @@ apdu_check_keypad (int slot, int command, int pin_mode,
int int
apdu_keypad_verify (int slot, int class, int ins, int p0, int p1, int pin_mode, 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; struct pininfo_s pininfo;
pininfo.mode = pin_mode; pininfo.mode = pin_mode;
pininfo.minlen = pinlen_min; pininfo.minlen = pinlen_min;
pininfo.maxlen = pinlen_max; pininfo.maxlen = pinlen_max;
pininfo.padlen = pin_padlen;
if (slot < 0 || slot >= MAX_READER || !reader_table[slot].used ) if (slot < 0 || slot >= MAX_READER || !reader_table[slot].used )
return SW_HOST_NO_DRIVER; return SW_HOST_NO_DRIVER;
@ -3374,14 +3355,13 @@ apdu_keypad_verify (int slot, int class, int ins, int p0, int p1, int pin_mode,
int int
apdu_keypad_modify (int slot, int class, int ins, int p0, int p1, int pin_mode, 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; struct pininfo_s pininfo;
pininfo.mode = pin_mode; pininfo.mode = pin_mode;
pininfo.minlen = pinlen_min; pininfo.minlen = pinlen_min;
pininfo.maxlen = pinlen_max; pininfo.maxlen = pinlen_max;
pininfo.padlen = pin_padlen;
if (slot < 0 || slot >= MAX_READER || !reader_table[slot].used ) if (slot < 0 || slot >= MAX_READER || !reader_table[slot].used )
return SW_HOST_NO_DRIVER; return SW_HOST_NO_DRIVER;

View File

@ -113,13 +113,11 @@ int apdu_reset (int slot);
int apdu_get_status (int slot, int hang, int apdu_get_status (int slot, int hang,
unsigned int *status, unsigned int *changed); unsigned int *status, unsigned int *changed);
int apdu_check_keypad (int slot, int command, int pin_mode, 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 apdu_keypad_verify (int slot, int class, int ins, int p0, int p1,
int pin_mode, int pinlen_min, int pinlen_max, int pin_mode, int pinlen_min, int pinlen_max);
int pin_padlen);
int apdu_keypad_modify (int slot, int class, int ins, int p0, int p1, 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_mode, int pinlen_min, int pinlen_max);
int pin_padlen);
int apdu_send_simple (int slot, int extended_mode, int apdu_send_simple (int slot, int extended_mode,
int class, int ins, int p0, int p1, int class, int ins, int p0, int p1,
int lc, const char *data); int lc, const char *data);

View File

@ -3289,7 +3289,7 @@ ccid_transceive (ccid_driver_t handle,
The APDU should me made up of 4 bytes without Lc. The APDU should me made up of 4 bytes without Lc.
PINLEN_MIN and PINLEN_MAX define the limits for the pin length. 0 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 When called with RESP and NRESP set to NULL, the function will
merely check whether the reader supports the secure command for the merely check whether the reader supports the secure command for the
@ -3298,7 +3298,6 @@ int
ccid_transceive_secure (ccid_driver_t handle, ccid_transceive_secure (ccid_driver_t handle,
const unsigned char *apdu_buf, size_t apdu_buflen, const unsigned char *apdu_buf, size_t apdu_buflen,
int pin_mode, int pinlen_min, int pinlen_max, int pin_mode, int pinlen_min, int pinlen_max,
int pin_padlen,
unsigned char *resp, size_t maxresplen, size_t *nresp) unsigned char *resp, size_t maxresplen, size_t *nresp)
{ {
int rc; int rc;
@ -3327,9 +3326,6 @@ ccid_transceive_secure (ccid_driver_t handle,
if (pin_mode != 1) if (pin_mode != 1)
return CCID_DRIVER_ERR_NOT_SUPPORTED; return CCID_DRIVER_ERR_NOT_SUPPORTED;
if (pin_padlen != 0)
return CCID_DRIVER_ERR_NOT_SUPPORTED;
if (!pinlen_min) if (!pinlen_min)
pinlen_min = 1; pinlen_min = 1;
if (!pinlen_max) if (!pinlen_max)

View File

@ -94,7 +94,7 @@ int ccid_transceive (ccid_driver_t handle,
int ccid_transceive_secure (ccid_driver_t handle, int ccid_transceive_secure (ccid_driver_t handle,
const unsigned char *apdu, size_t apdulen, const unsigned char *apdu, size_t apdulen,
int pin_mode, 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); unsigned char *resp, size_t maxresplen, size_t *nresp);
int ccid_transceive_escape (ccid_driver_t handle, int ccid_transceive_escape (ccid_driver_t handle,
const unsigned char *data, size_t datalen, const unsigned char *data, size_t datalen,

View File

@ -274,8 +274,7 @@ iso7816_check_keypad (int slot, int command, iso7816_pininfo_t *pininfo)
int sw; int sw;
sw = apdu_check_keypad (slot, command, sw = apdu_check_keypad (slot, command,
pininfo->mode, pininfo->minlen, pininfo->maxlen, pininfo->mode, pininfo->minlen, pininfo->maxlen);
pininfo->padlen);
return iso7816_map_sw (sw); return iso7816_map_sw (sw);
} }
@ -289,8 +288,7 @@ iso7816_verify_kp (int slot, int chvno, iso7816_pininfo_t *pininfo)
int sw; int sw;
sw = apdu_keypad_verify (slot, 0x00, CMD_VERIFY, 0, chvno, sw = apdu_keypad_verify (slot, 0x00, CMD_VERIFY, 0, chvno,
pininfo->mode, pininfo->minlen, pininfo->maxlen, pininfo->mode, pininfo->minlen, pininfo->maxlen);
pininfo->padlen);
return map_sw (sw); 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, sw = apdu_keypad_modify (slot, 0x00, CMD_CHANGE_REFERENCE_DATA,
is_exchange ? 1 : 0, is_exchange ? 1 : 0,
chvno, pininfo->mode, pininfo->minlen, chvno, pininfo->mode, pininfo->minlen,
pininfo->maxlen, pininfo->padlen); pininfo->maxlen);
return map_sw (sw); return map_sw (sw);
} }

View File

@ -37,8 +37,6 @@ struct iso7816_pininfo_s
int mode; /* A mode of 0 means: Do not use the keypad. */ int mode; /* A mode of 0 means: Do not use the keypad. */
int minlen; int minlen;
int maxlen; int maxlen;
int padlen;
int padchar;
}; };
typedef struct iso7816_pininfo_s iso7816_pininfo_t; typedef struct iso7816_pininfo_s iso7816_pininfo_t;