pinpad support (1)
This commit is contained in:
@@ -1,3 +1,11 @@
|
||||
2011-01-04 NIIBE Yutaka <gniibe@fsij.org>
|
||||
|
||||
* src/chconf.h (CH_USE_DYNAMIC): It's TRUE now.
|
||||
|
||||
* src/usb_desc.c (gnukConfigDescriptor): Added PINPAD_SUPPORT.
|
||||
|
||||
* src/pin-cir.c (cir_timer_interrupt): Added cir_toggle support.
|
||||
|
||||
2010-12-29 NIIBE Yutaka <gniibe@fsij.org>
|
||||
|
||||
* src/pin-cir.c (cir_timer_interrupt): Support Philips RC-5 protocol.
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#define CH_USE_HEAP TRUE
|
||||
#define CH_USE_MALLOC_HEAP FALSE
|
||||
#define CH_USE_MEMPOOLS FALSE
|
||||
#define CH_USE_DYNAMIC FALSE
|
||||
#define CH_USE_DYNAMIC TRUE
|
||||
|
||||
/* Debug options */
|
||||
#define CH_DBG_ENABLE_CHECKS FALSE
|
||||
|
||||
@@ -315,4 +315,10 @@ extern void flash_do_write_internal (const uint8_t *p, int nr, const uint8_t *da
|
||||
#if defined(PINPAD_SUPPORT)
|
||||
extern void cir_ext_disable (void);
|
||||
extern void cir_ext_enable (void);
|
||||
|
||||
#define MAX_PIN_CHARS 32
|
||||
extern uint8_t pin_input_buffer[MAX_PIN_CHARS];
|
||||
extern uint8_t pin_input_len;
|
||||
|
||||
extern msg_t pin_main (void *arg);
|
||||
#endif
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* openpgp.c -- OpenPGP card protocol support
|
||||
*
|
||||
* Copyright (C) 2010 Free Software Initiative of Japan
|
||||
* Copyright (C) 2010, 2011 Free Software Initiative of Japan
|
||||
* Author: NIIBE Yutaka <gniibe@fsij.org>
|
||||
*
|
||||
* This file is a part of Gnuk, a GnuPG USB Token implementation.
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "polarssl/config.h"
|
||||
#include "polarssl/sha1.h"
|
||||
|
||||
#define INS_NOP 0x00
|
||||
#define INS_VERIFY 0x20
|
||||
#define INS_CHANGE_REFERENCE_DATA 0x24
|
||||
#define INS_PSO 0x2a
|
||||
@@ -93,6 +94,13 @@ gpg_fini (void)
|
||||
ac_fini ();
|
||||
}
|
||||
|
||||
static void
|
||||
cmd_nop (void)
|
||||
{
|
||||
DEBUG_INFO (" - VERIFY\r\n");
|
||||
GPG_SUCCESS ();
|
||||
}
|
||||
|
||||
static void
|
||||
cmd_verify (void)
|
||||
{
|
||||
@@ -100,23 +108,51 @@ cmd_verify (void)
|
||||
uint8_t p2 = cmd_APDU[3];
|
||||
int r;
|
||||
int data_start = 5;
|
||||
const uint8_t *pw;
|
||||
|
||||
DEBUG_INFO (" - VERIFY\r\n");
|
||||
DEBUG_BYTE (p2);
|
||||
|
||||
len = cmd_APDU[4];
|
||||
if (len == 0) /* extended length */
|
||||
#if defined(PINPAD_SUPPORT)
|
||||
if (cmd_APDU_size == 4)
|
||||
/* Verify with pinpad */
|
||||
{
|
||||
len = (cmd_APDU[5]<<8) | cmd_APDU[6];
|
||||
data_start = 7;
|
||||
Thread *t;
|
||||
|
||||
t = chThdCreateFromHeap (NULL, THD_WA_SIZE (128),
|
||||
NORMALPRIO, pin_main, NULL);
|
||||
if (t == NULL)
|
||||
{
|
||||
GPG_ERROR ();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
chThdWait (t);
|
||||
pw = pin_input_buffer;
|
||||
len = pin_input_len;
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
len = cmd_APDU[4];
|
||||
if (len == 0) /* extended length */
|
||||
{
|
||||
len = (cmd_APDU[5]<<8) | cmd_APDU[6];
|
||||
data_start = 7;
|
||||
}
|
||||
|
||||
pw = &cmd_APDU[data_start];
|
||||
}
|
||||
|
||||
|
||||
if (p2 == 0x81)
|
||||
r = verify_pso_cds (&cmd_APDU[data_start], len);
|
||||
r = verify_pso_cds (pw, len);
|
||||
else if (p2 == 0x82)
|
||||
r = verify_other (&cmd_APDU[data_start], len);
|
||||
r = verify_other (pw, len);
|
||||
else
|
||||
r = verify_admin (&cmd_APDU[data_start], len);
|
||||
r = verify_admin (pw, len);
|
||||
|
||||
if (r < 0)
|
||||
{
|
||||
@@ -699,6 +735,7 @@ struct command
|
||||
};
|
||||
|
||||
const struct command cmds[] = {
|
||||
{ INS_NOP, cmd_nop },
|
||||
{ INS_VERIFY, cmd_verify },
|
||||
{ INS_CHANGE_REFERENCE_DATA, cmd_change_password },
|
||||
{ INS_PSO, cmd_pso },
|
||||
@@ -737,14 +774,6 @@ msg_t
|
||||
GPGthread (void *arg)
|
||||
{
|
||||
Thread *icc_thread = (Thread *)arg;
|
||||
#if defined(PINPAD_SUPPORT)
|
||||
extern msg_t pin_main (void *arg);
|
||||
Thread *pin_thread;
|
||||
static WORKING_AREA(waPINthread, 128);
|
||||
|
||||
pin_thread = chThdCreateStatic (waPINthread, sizeof(waPINthread),
|
||||
NORMALPRIO, pin_main, NULL);
|
||||
#endif
|
||||
|
||||
gpg_init ();
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* usb-icc.c -- USB CCID/ICCD protocol handling
|
||||
*
|
||||
* Copyright (C) 2010 Free Software Initiative of Japan
|
||||
* Copyright (C) 2010, 2011 Free Software Initiative of Japan
|
||||
* Author: NIIBE Yutaka <gniibe@fsij.org>
|
||||
*
|
||||
* This file is a part of Gnuk, a GnuPG USB Token implementation.
|
||||
@@ -37,6 +37,7 @@ extern void *memmove(void *dest, const void *src, size_t n);
|
||||
#define ICC_POWER_ON 0x62
|
||||
#define ICC_POWER_OFF 0x63
|
||||
#define ICC_SLOT_STATUS 0x65 /* non-ICCD command */
|
||||
#define ICC_SECURE 0x69 /* non-ICCD command */
|
||||
#define ICC_GET_PARAMS 0x6C /* non-ICCD command */
|
||||
#define ICC_XFR_BLOCK 0x6F
|
||||
#define ICC_DATA_BLOCK_RET 0x80
|
||||
@@ -480,6 +481,7 @@ icc_send_params (void)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
static enum icc_state
|
||||
icc_handle_data (void)
|
||||
{
|
||||
@@ -536,6 +538,16 @@ icc_handle_data (void)
|
||||
else if (icc_header->msg_type == ICC_SET_PARAMS
|
||||
|| icc_header->msg_type == ICC_GET_PARAMS)
|
||||
icc_send_params ();
|
||||
else if (icc_header->msg_type == ICC_SECURE)
|
||||
{
|
||||
cmd_APDU[0] = icc_buffer[25];
|
||||
cmd_APDU[1] = icc_buffer[26];
|
||||
cmd_APDU[2] = icc_buffer[27];
|
||||
cmd_APDU[3] = icc_buffer[28];
|
||||
icc_data_size = 4;
|
||||
chEvtSignal (gpg_thread, (eventmask_t)1);
|
||||
next_state = ICC_STATE_EXECUTE;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_INFO ("ERR03\r\n");
|
||||
|
||||
@@ -104,7 +104,11 @@ static const uint8_t gnukConfigDescriptor[] = {
|
||||
0xff, /* bClassGetResponse: */
|
||||
0xff, /* bClassEnvelope: */
|
||||
0, 0, /* wLCDLayout: FIXED VALUE */
|
||||
#if defined(PINPAD_SUPPORT)
|
||||
1, /* bPinSupport: with PIN pad */
|
||||
#else
|
||||
0, /* bPinSupport: No PIN pad */
|
||||
#endif
|
||||
1, /* bMaxCCIDBusySlots: 1 */
|
||||
/*Endpoint 1 Descriptor*/
|
||||
7, /* bLength: Endpoint Descriptor size */
|
||||
|
||||
Reference in New Issue
Block a user