fixes for opensc

This commit is contained in:
NIIBE Yutaka
2011-01-22 00:54:41 +09:00
parent 6e9998b052
commit 87a495885b
5 changed files with 42 additions and 15 deletions

View File

@@ -1,3 +1,12 @@
2011-01-22 NIIBE Yutaka <gniibe@fsij.org>
* src/openpgp.c (cmd_pgp_gakp): Handle case of non-extended Lc.
(cmd_select_file): Return DF name when FCI is requested.
* src/openpgp-do.c (copy_do): Don't add tag if not requested.
* src/gnuk.h (memmove): Add declaration.
2011-01-21 NIIBE Yutaka <gniibe@fsij.org>
* src/openpgp-do.c (copy_do): Fix off-by-one error.

View File

@@ -20,6 +20,7 @@ extern int strncmp(const char *s1, const char *s2, size_t n);
extern void *memcpy (void *dest, const void *src, size_t n);
extern void *memset (void *s, int c, size_t n);
extern int memcmp (const void *s1, const void *s2, size_t n);
extern void *memmove(void *dest, const void *src, size_t n);
#define EV_EXEC_FINISHED ((eventmask_t)2) /* GPG Execution finished */

View File

@@ -1146,12 +1146,15 @@ copy_do (const struct do_table_entry *do_p, int with_tag)
int i;
const uint16_t *cmp_data = (const uint16_t *)do_p->obj;
int num_components = cmp_data[0];
uint8_t *len_p;
uint8_t *len_p = NULL;
copy_tag (do_p->tag);
*res_p++ = 0x81; /* Assume it's less than 256 */
len_p = res_p;
*res_p++ = 0; /* for now */
if (with_tag)
{
copy_tag (do_p->tag);
*res_p++ = 0x81; /* Assume it's less than 256 */
len_p = res_p;
*res_p++ = 0; /* for now */
}
for (i = 0; i < num_components; i++)
{
@@ -1164,7 +1167,8 @@ copy_do (const struct do_table_entry *do_p, int with_tag)
return -1;
}
*len_p = (res_p - len_p) - 1;
if (len_p)
*len_p = res_p - len_p - 1;
break;
}
case DO_PROC_READ:

View File

@@ -44,9 +44,9 @@
static const uint8_t
select_file_TOP_result[] __attribute__ ((aligned (1))) = {
0x00, 0x00, /* unused */
0x0b, 0x10, /* number of bytes in this directory */
0x3f, 0x00, /* field of selected file: MF, 3f00 */
0x00, 0x00, /* unused */
0x00, 0x00, /* number of bytes in this directory: to be filled */
0x3f, 0x00, /* field of selected file: MF, 3f00 */
0x38, /* it's DF */
0xff, /* unused */
0xff, 0x44, 0x44, /* access conditions */
@@ -549,7 +549,12 @@ cmd_pgp_gakp (void)
if (cmd_APDU[2] == 0x81)
/* Get public key */
gpg_do_public_key (cmd_APDU[7]);
{
if (cmd_APDU[4] == 0)
gpg_do_public_key (cmd_APDU[7]);
else
gpg_do_public_key (cmd_APDU[5]);
}
else
{ /* Generate key pair */
if (!ac_check_status (AC_ADMIN_AUTHORIZED))
@@ -591,7 +596,17 @@ cmd_select_file (void)
*/
file_selection = FILE_DF_OPENPGP;
GPG_SUCCESS ();
if (cmd_APDU[3] == 0x0c) /* No FCI */
GPG_SUCCESS ();
else
{
gpg_do_get_data (0x004f, 1); /* AID */
memmove (res_APDU+2, res_APDU, res_APDU_size);
res_APDU[0] = 0x6f;
res_APDU[1] = 0x12;
res_APDU[2] = 0x84; /* overwrite: DF name */
res_APDU_size += 2;
}
}
else if (cmd_APDU[4] == 2
&& cmd_APDU[5] == 0x2f
@@ -628,7 +643,7 @@ cmd_select_file (void)
DEBUG_INFO (" - select ?? \r\n");
file_selection = FILE_NONE;
GPG_NO_FILE();
GPG_NO_FILE ();
}
}
@@ -640,7 +655,7 @@ cmd_get_data (void)
DEBUG_INFO (" - Get Data\r\n");
if (file_selection != FILE_DF_OPENPGP)
GPG_NO_RECORD();
GPG_NO_RECORD ();
gpg_do_get_data (tag, 0);
}

View File

@@ -31,8 +31,6 @@
#include "hw_config.h"
#include "usb_istr.h"
extern void *memmove(void *dest, const void *src, size_t n);
#define ICC_SET_PARAMS 0x61 /* non-ICCD command */
#define ICC_POWER_ON 0x62
#define ICC_POWER_OFF 0x63