PKCS15-OpenPGP: Declare DATA objects.
Begin to support read/write DATA object for PKCS-OpenPGP binding. This object is used by TrueCrypt.
This commit is contained in:
parent
c81eab5a70
commit
24e3bdb872
|
@ -32,6 +32,7 @@
|
|||
#include "log.h"
|
||||
|
||||
int sc_pkcs15emu_openpgp_init_ex(sc_pkcs15_card_t *, sc_pkcs15emu_opt_t *);
|
||||
static int sc_pkcs15emu_openpgp_add_data(sc_pkcs15_card_t *);
|
||||
|
||||
|
||||
#define PGP_USER_PIN_FLAGS (SC_PKCS15_PIN_FLAG_CASE_SENSITIVE \
|
||||
|
@ -41,6 +42,8 @@ int sc_pkcs15emu_openpgp_init_ex(sc_pkcs15_card_t *, sc_pkcs15emu_opt_t *);
|
|||
| SC_PKCS15_PIN_FLAG_UNBLOCK_DISABLED \
|
||||
| SC_PKCS15_PIN_FLAG_SO_PIN)
|
||||
|
||||
#define PGP_NUM_PRIVDO 4
|
||||
|
||||
typedef struct _pgp_pin_cfg {
|
||||
const char *label;
|
||||
int reference;
|
||||
|
@ -355,6 +358,9 @@ sc_pkcs15emu_openpgp_init(sc_pkcs15_card_t *p15card)
|
|||
goto failed;
|
||||
}
|
||||
|
||||
/* PKCS#15 DATA object from OpenPGP private DOs */
|
||||
r = sc_pkcs15emu_openpgp_add_data(p15card);
|
||||
|
||||
return 0;
|
||||
|
||||
failed: sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Failed to initialize OpenPGP emulation: %s\n",
|
||||
|
@ -362,6 +368,35 @@ failed: sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Failed to initialize OpenPGP e
|
|||
return r;
|
||||
}
|
||||
|
||||
static int
|
||||
sc_pkcs15emu_openpgp_add_data(sc_pkcs15_card_t *p15card)
|
||||
{
|
||||
sc_context_t *ctx = p15card->card->ctx;
|
||||
int i, r;
|
||||
|
||||
LOG_FUNC_CALLED(ctx);
|
||||
/* There is 4 private DO from 0101 to 0104 */
|
||||
for (i = 1; i <= PGP_NUM_PRIVDO; i++) {
|
||||
sc_pkcs15_data_info_t dat_info;
|
||||
sc_pkcs15_object_t dat_obj;
|
||||
char name[8];
|
||||
char path[9];
|
||||
memset(&dat_info, 0, sizeof(dat_info));
|
||||
memset(&dat_obj, 0, sizeof(dat_obj));
|
||||
|
||||
sprintf(name, "PrivDO%d", i);
|
||||
sprintf(path, "3F00010%d", i);
|
||||
|
||||
sc_format_path(path, &dat_info.path);
|
||||
strlcpy(dat_obj.label, name, sizeof(dat_obj.label));
|
||||
strlcpy(dat_info.app_label, name, sizeof(dat_info.app_label));
|
||||
|
||||
sc_log(ctx, "Add %s data object", name);
|
||||
r = sc_pkcs15emu_add_data_object(p15card, &dat_obj, &dat_info);
|
||||
}
|
||||
LOG_FUNC_RETURN(ctx, r);
|
||||
}
|
||||
|
||||
static int openpgp_detect_card(sc_pkcs15_card_t *p15card)
|
||||
{
|
||||
if (p15card->card->type == SC_CARD_TYPE_OPENPGP_V1 || p15card->card->type == SC_CARD_TYPE_OPENPGP_V2
|
||||
|
|
Loading…
Reference in New Issue