fixes for opensc
This commit is contained in:
@@ -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>
|
2011-01-21 NIIBE Yutaka <gniibe@fsij.org>
|
||||||
|
|
||||||
* src/openpgp-do.c (copy_do): Fix off-by-one error.
|
* src/openpgp-do.c (copy_do): Fix off-by-one error.
|
||||||
|
|||||||
@@ -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 *memcpy (void *dest, const void *src, size_t n);
|
||||||
extern void *memset (void *s, int c, 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 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 */
|
#define EV_EXEC_FINISHED ((eventmask_t)2) /* GPG Execution finished */
|
||||||
|
|
||||||
|
|||||||
@@ -1146,12 +1146,15 @@ copy_do (const struct do_table_entry *do_p, int with_tag)
|
|||||||
int i;
|
int i;
|
||||||
const uint16_t *cmp_data = (const uint16_t *)do_p->obj;
|
const uint16_t *cmp_data = (const uint16_t *)do_p->obj;
|
||||||
int num_components = cmp_data[0];
|
int num_components = cmp_data[0];
|
||||||
uint8_t *len_p;
|
uint8_t *len_p = NULL;
|
||||||
|
|
||||||
|
if (with_tag)
|
||||||
|
{
|
||||||
copy_tag (do_p->tag);
|
copy_tag (do_p->tag);
|
||||||
*res_p++ = 0x81; /* Assume it's less than 256 */
|
*res_p++ = 0x81; /* Assume it's less than 256 */
|
||||||
len_p = res_p;
|
len_p = res_p;
|
||||||
*res_p++ = 0; /* for now */
|
*res_p++ = 0; /* for now */
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < num_components; i++)
|
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;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
*len_p = (res_p - len_p) - 1;
|
if (len_p)
|
||||||
|
*len_p = res_p - len_p - 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DO_PROC_READ:
|
case DO_PROC_READ:
|
||||||
|
|||||||
@@ -45,7 +45,7 @@
|
|||||||
static const uint8_t
|
static const uint8_t
|
||||||
select_file_TOP_result[] __attribute__ ((aligned (1))) = {
|
select_file_TOP_result[] __attribute__ ((aligned (1))) = {
|
||||||
0x00, 0x00, /* unused */
|
0x00, 0x00, /* unused */
|
||||||
0x0b, 0x10, /* number of bytes in this directory */
|
0x00, 0x00, /* number of bytes in this directory: to be filled */
|
||||||
0x3f, 0x00, /* field of selected file: MF, 3f00 */
|
0x3f, 0x00, /* field of selected file: MF, 3f00 */
|
||||||
0x38, /* it's DF */
|
0x38, /* it's DF */
|
||||||
0xff, /* unused */
|
0xff, /* unused */
|
||||||
@@ -549,7 +549,12 @@ cmd_pgp_gakp (void)
|
|||||||
|
|
||||||
if (cmd_APDU[2] == 0x81)
|
if (cmd_APDU[2] == 0x81)
|
||||||
/* Get public key */
|
/* Get public key */
|
||||||
|
{
|
||||||
|
if (cmd_APDU[4] == 0)
|
||||||
gpg_do_public_key (cmd_APDU[7]);
|
gpg_do_public_key (cmd_APDU[7]);
|
||||||
|
else
|
||||||
|
gpg_do_public_key (cmd_APDU[5]);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{ /* Generate key pair */
|
{ /* Generate key pair */
|
||||||
if (!ac_check_status (AC_ADMIN_AUTHORIZED))
|
if (!ac_check_status (AC_ADMIN_AUTHORIZED))
|
||||||
@@ -591,7 +596,17 @@ cmd_select_file (void)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
file_selection = FILE_DF_OPENPGP;
|
file_selection = FILE_DF_OPENPGP;
|
||||||
|
if (cmd_APDU[3] == 0x0c) /* No FCI */
|
||||||
GPG_SUCCESS ();
|
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
|
else if (cmd_APDU[4] == 2
|
||||||
&& cmd_APDU[5] == 0x2f
|
&& cmd_APDU[5] == 0x2f
|
||||||
|
|||||||
@@ -31,8 +31,6 @@
|
|||||||
#include "hw_config.h"
|
#include "hw_config.h"
|
||||||
#include "usb_istr.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_SET_PARAMS 0x61 /* non-ICCD command */
|
||||||
#define ICC_POWER_ON 0x62
|
#define ICC_POWER_ON 0x62
|
||||||
#define ICC_POWER_OFF 0x63
|
#define ICC_POWER_OFF 0x63
|
||||||
|
|||||||
Reference in New Issue
Block a user