- Initial support for TokenUpdate;;lastUpdate field. Change pkcs15 caching
code to use the card serial number and lastUpdate field (if present) to specify the cache file. - consistently use unsigned data types to specify object types - make sc_pkcs15emu_get_df a local function (it's not used outside pkcs15-syn.c and honestly I see no reason to export it). - start of a new ChangeLog file (with some intial entries) git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2466 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
parent
b3992394fc
commit
44384eccbf
22
ChangeLog
22
ChangeLog
|
@ -1,2 +1,20 @@
|
|||
See http://www.opensc.org/files/ChangeLog-opensc for
|
||||
automatically up-to-date version.
|
||||
Changes between 0.9.6 and 0.9.7 [XX xxx XXXX]
|
||||
|
||||
*) add support for TokenInfo::lastUpdate entry (currently
|
||||
the generalizedTime variant). Change pkcs15 cache
|
||||
functions to use the lastUpdate field (if present) and
|
||||
the card serial number to identify cached files.
|
||||
[Nils Larsch]
|
||||
|
||||
*) add support (card driver and PKCS#15 emulation) for the
|
||||
A-Trust ACos card.
|
||||
[Franz Brandl <brandl@a-trust.at>]
|
||||
|
||||
*) add partial PKCS#15 emulation support for GemSAFE cards
|
||||
[Douglas E. Engert <deengert@anl.gov>]
|
||||
|
||||
*) add PKCS#15 emulation support for Italian Actalis card.
|
||||
[Andrea Frigido <andrea@frisoft.it>]
|
||||
|
||||
*) add PKCS#15 emulation support for Italian Postecert and Cnipa card.
|
||||
[Antonino Iacono <ant_iacono@tin.it>]
|
||||
|
|
|
@ -55,12 +55,19 @@ static int generate_cache_filename(struct sc_pkcs15_card *p15card,
|
|||
}
|
||||
for (i = 0; i < pathlen; i++)
|
||||
sprintf(pathname + 2*i, "%02X", pathptr[i]);
|
||||
r = snprintf(buf, bufsize, "%s/%s_%s_%s_%s", dir,
|
||||
p15card->manufacturer_id, p15card->label,
|
||||
if (p15card->serial_number != NULL) {
|
||||
if (p15card->last_update != NULL)
|
||||
r = snprintf(buf, bufsize, "%s/%s_%s_%s", dir,
|
||||
p15card->serial_number, p15card->last_update,
|
||||
pathname);
|
||||
else
|
||||
r = snprintf(buf, bufsize, "%s/%s_DATE_%s", dir,
|
||||
p15card->serial_number, pathname);
|
||||
if (r < 0)
|
||||
return SC_ERROR_BUFFER_TOO_SMALL;
|
||||
return 0;
|
||||
} else
|
||||
return SC_ERROR_INVALID_ARGUMENTS;
|
||||
return SC_SUCCESS;
|
||||
}
|
||||
|
||||
int sc_pkcs15_read_cached_file(struct sc_pkcs15_card *p15card,
|
||||
|
|
|
@ -64,6 +64,8 @@ static struct {
|
|||
};
|
||||
|
||||
static int parse_emu_block(sc_pkcs15_card_t *, scconf_block *);
|
||||
static sc_pkcs15_df_t * sc_pkcs15emu_get_df(sc_pkcs15_card_t *p15card,
|
||||
unsigned int type);
|
||||
|
||||
static const char *builtin_name = "builtin";
|
||||
static const char *func_name = "sc_pkcs15_init_func";
|
||||
|
@ -258,8 +260,8 @@ static int parse_emu_block(sc_pkcs15_card_t *p15card, scconf_block *conf)
|
|||
return r;
|
||||
}
|
||||
|
||||
sc_pkcs15_df_t *
|
||||
sc_pkcs15emu_get_df(sc_pkcs15_card_t *p15card, int type)
|
||||
static sc_pkcs15_df_t * sc_pkcs15emu_get_df(sc_pkcs15_card_t *p15card,
|
||||
unsigned int type)
|
||||
{
|
||||
sc_pkcs15_df_t *df;
|
||||
sc_file_t *file;
|
||||
|
@ -383,7 +385,7 @@ sc_pkcs15emu_add_object(sc_pkcs15_card_t *p15card, int type,
|
|||
const sc_pkcs15_id_t *auth_id, int obj_flags)
|
||||
{
|
||||
sc_pkcs15_object_t *obj;
|
||||
int df_type;
|
||||
unsigned int df_type;
|
||||
|
||||
obj = (sc_pkcs15_object_t *) calloc(1, sizeof(*obj));
|
||||
if (!obj)
|
||||
|
|
|
@ -29,20 +29,24 @@
|
|||
|
||||
|
||||
static const struct sc_asn1_entry c_asn1_toki[] = {
|
||||
{ "version", SC_ASN1_INTEGER, ASN1_INTEGER, 0, NULL },
|
||||
{ "serialNumber", SC_ASN1_OCTET_STRING, ASN1_OCTET_STRING, 0, NULL },
|
||||
{ "manufacturerID", SC_ASN1_UTF8STRING, ASN1_UTF8STRING, SC_ASN1_OPTIONAL, NULL },
|
||||
{ "label", SC_ASN1_UTF8STRING, SC_ASN1_CTX | 0, SC_ASN1_OPTIONAL, NULL },
|
||||
{ "tokenflags", SC_ASN1_BIT_FIELD, ASN1_BIT_STRING, 0, NULL },
|
||||
{ "seInfo", SC_ASN1_SEQUENCE, SC_ASN1_CONS | ASN1_SEQUENCE, SC_ASN1_OPTIONAL, NULL },
|
||||
{ "recordInfo", SC_ASN1_STRUCT, SC_ASN1_CONS | SC_ASN1_CTX | 1, SC_ASN1_OPTIONAL, NULL },
|
||||
{ "supportedAlgorithms", SC_ASN1_STRUCT, SC_ASN1_CONS | SC_ASN1_CTX | 2, SC_ASN1_OPTIONAL, NULL },
|
||||
{ NULL }
|
||||
{ "version", SC_ASN1_INTEGER, ASN1_INTEGER, 0, NULL, NULL },
|
||||
{ "serialNumber", SC_ASN1_OCTET_STRING, ASN1_OCTET_STRING, 0, NULL, NULL },
|
||||
{ "manufacturerID", SC_ASN1_UTF8STRING, ASN1_UTF8STRING, SC_ASN1_OPTIONAL, NULL, NULL },
|
||||
{ "label", SC_ASN1_UTF8STRING, SC_ASN1_CTX | 0, SC_ASN1_OPTIONAL, NULL, NULL },
|
||||
{ "tokenflags", SC_ASN1_BIT_FIELD, ASN1_BIT_STRING, 0, NULL, NULL },
|
||||
{ "seInfo", SC_ASN1_SEQUENCE, SC_ASN1_CONS | ASN1_SEQUENCE, SC_ASN1_OPTIONAL, NULL, NULL },
|
||||
{ "recordInfo", SC_ASN1_STRUCT, SC_ASN1_CONS | SC_ASN1_CTX | 1, SC_ASN1_OPTIONAL, NULL, NULL },
|
||||
{ "supportedAlgorithms", SC_ASN1_STRUCT, SC_ASN1_CONS | SC_ASN1_CTX | 2, SC_ASN1_OPTIONAL, NULL, NULL },
|
||||
{ "issuerId", SC_ASN1_UTF8STRING, SC_ASN1_CTX | 3, SC_ASN1_OPTIONAL, NULL, NULL },
|
||||
{ "holderId", SC_ASN1_UTF8STRING, SC_ASN1_CTX | 4, SC_ASN1_OPTIONAL, NULL, NULL },
|
||||
{ "lastUpdate", SC_ASN1_GENERALIZEDTIME, SC_ASN1_CTX | 5, SC_ASN1_OPTIONAL, NULL, NULL },
|
||||
{ "preferredLanguage", SC_ASN1_PRINTABLESTRING, ASN1_PRINTABLESTRING, SC_ASN1_OPTIONAL, NULL, NULL },
|
||||
{ NULL, 0, 0, 0, NULL, NULL }
|
||||
};
|
||||
|
||||
static const struct sc_asn1_entry c_asn1_tokeninfo[] = {
|
||||
{ "TokenInfo", SC_ASN1_STRUCT, SC_ASN1_CONS | ASN1_SEQUENCE, 0, NULL },
|
||||
{ NULL }
|
||||
{ "TokenInfo", SC_ASN1_STRUCT, SC_ASN1_CONS | ASN1_SEQUENCE, 0, NULL, NULL },
|
||||
{ NULL, 0, 0, 0, NULL, NULL }
|
||||
};
|
||||
|
||||
static void parse_tokeninfo(struct sc_pkcs15_card *card, const u8 * buf, size_t buflen)
|
||||
|
@ -55,9 +59,12 @@ static void parse_tokeninfo(struct sc_pkcs15_card *card, const u8 * buf, size_t
|
|||
size_t mnfid_len = sizeof(mnfid);
|
||||
u8 label[SC_PKCS15_MAX_LABEL_SIZE];
|
||||
size_t label_len = sizeof(label);
|
||||
u8 last_update[32];
|
||||
size_t lupdate_len = sizeof(last_update) - 1;
|
||||
size_t flags_len = sizeof(card->flags);
|
||||
struct sc_asn1_entry asn1_toki[9], asn1_tokeninfo[3];
|
||||
struct sc_asn1_entry asn1_toki[13], asn1_tokeninfo[3];
|
||||
|
||||
memset(last_update, 0, sizeof(last_update));
|
||||
sc_copy_asn1_entry(c_asn1_toki, asn1_toki);
|
||||
sc_copy_asn1_entry(c_asn1_tokeninfo, asn1_tokeninfo);
|
||||
sc_format_asn1_entry(asn1_toki + 0, &card->version, NULL, 0);
|
||||
|
@ -65,6 +72,13 @@ static void parse_tokeninfo(struct sc_pkcs15_card *card, const u8 * buf, size_t
|
|||
sc_format_asn1_entry(asn1_toki + 2, mnfid, &mnfid_len, 0);
|
||||
sc_format_asn1_entry(asn1_toki + 3, label, &label_len, 0);
|
||||
sc_format_asn1_entry(asn1_toki + 4, &card->flags, &flags_len, 0);
|
||||
sc_format_asn1_entry(asn1_toki + 5, NULL, NULL, 0);
|
||||
sc_format_asn1_entry(asn1_toki + 6, NULL, NULL, 0);
|
||||
sc_format_asn1_entry(asn1_toki + 7, NULL, NULL, 0);
|
||||
sc_format_asn1_entry(asn1_toki + 8, NULL, NULL, 0);
|
||||
sc_format_asn1_entry(asn1_toki + 9, NULL, NULL, 0);
|
||||
sc_format_asn1_entry(asn1_toki + 10, last_update, &lupdate_len, 0);
|
||||
sc_format_asn1_entry(asn1_toki + 11, NULL, NULL, 0);
|
||||
sc_format_asn1_entry(asn1_tokeninfo, asn1_toki, NULL, 0);
|
||||
|
||||
r = sc_asn1_decode(card->card->ctx, asn1_tokeninfo, buf, buflen, NULL, NULL);
|
||||
|
@ -99,6 +113,8 @@ static void parse_tokeninfo(struct sc_pkcs15_card *card, const u8 * buf, size_t
|
|||
else
|
||||
card->label = strdup("(unknown)");
|
||||
}
|
||||
if (asn1_toki[10].flags & SC_ASN1_PRESENT)
|
||||
card->last_update = strdup((char *)last_update);
|
||||
return;
|
||||
err:
|
||||
if (card->serial_number == NULL)
|
||||
|
@ -113,39 +129,51 @@ int sc_pkcs15_encode_tokeninfo(sc_context_t *ctx,
|
|||
u8 **buf, size_t *buflen)
|
||||
{
|
||||
int r;
|
||||
u8 serial[128];
|
||||
size_t serial_len = 0;
|
||||
size_t mnfid_len;
|
||||
size_t label_len;
|
||||
size_t flags_len;
|
||||
int version = card->version;
|
||||
|
||||
struct sc_asn1_entry asn1_toki[9], asn1_tokeninfo[2];
|
||||
struct sc_asn1_entry asn1_toki[13], asn1_tokeninfo[2];
|
||||
|
||||
sc_copy_asn1_entry(c_asn1_toki, asn1_toki);
|
||||
sc_copy_asn1_entry(c_asn1_tokeninfo, asn1_tokeninfo);
|
||||
version--;
|
||||
sc_format_asn1_entry(asn1_toki + 0, &version, NULL, 1);
|
||||
if (card->serial_number != NULL) {
|
||||
u8 serial[128];
|
||||
size_t serial_len = 0;
|
||||
if (strlen(card->serial_number)/2 > sizeof(serial))
|
||||
return SC_ERROR_BUFFER_TOO_SMALL;
|
||||
serial_len = sizeof(serial);
|
||||
if (sc_hex_to_bin(card->serial_number, serial, &serial_len) < 0)
|
||||
return SC_ERROR_INVALID_ARGUMENTS;
|
||||
sc_format_asn1_entry(asn1_toki + 1, serial, &serial_len, 1);
|
||||
}
|
||||
} else
|
||||
sc_format_asn1_entry(asn1_toki + 1, NULL, NULL, 0);
|
||||
if (card->manufacturer_id != NULL) {
|
||||
mnfid_len = strlen(card->manufacturer_id);
|
||||
size_t mnfid_len = strlen(card->manufacturer_id);
|
||||
sc_format_asn1_entry(asn1_toki + 2, card->manufacturer_id, &mnfid_len, 1);
|
||||
}
|
||||
} else
|
||||
sc_format_asn1_entry(asn1_toki + 2, NULL, NULL, 0);
|
||||
if (card->label != NULL) {
|
||||
label_len = strlen(card->label);
|
||||
size_t label_len = strlen(card->label);
|
||||
sc_format_asn1_entry(asn1_toki + 3, card->label, &label_len, 1);
|
||||
}
|
||||
} else
|
||||
sc_format_asn1_entry(asn1_toki + 3, NULL, NULL, 0);
|
||||
if (card->flags) {
|
||||
flags_len = sizeof(card->flags);
|
||||
size_t flags_len = sizeof(card->flags);
|
||||
sc_format_asn1_entry(asn1_toki + 4, &card->flags, &flags_len, 1);
|
||||
}
|
||||
} else
|
||||
sc_format_asn1_entry(asn1_toki + 4, NULL, NULL, 0);
|
||||
sc_format_asn1_entry(asn1_toki + 5, NULL, NULL, 0);
|
||||
sc_format_asn1_entry(asn1_toki + 6, NULL, NULL, 0);
|
||||
sc_format_asn1_entry(asn1_toki + 7, NULL, NULL, 0);
|
||||
sc_format_asn1_entry(asn1_toki + 8, NULL, NULL, 0);
|
||||
sc_format_asn1_entry(asn1_toki + 9, NULL, NULL, 0);
|
||||
if (card->last_update != NULL) {
|
||||
size_t len = strlen(card->last_update);
|
||||
sc_format_asn1_entry(asn1_toki + 10, card->last_update, &len, 1);
|
||||
} else
|
||||
sc_format_asn1_entry(asn1_toki + 10, NULL, NULL, 0);
|
||||
sc_format_asn1_entry(asn1_toki + 11, NULL, NULL, 0);
|
||||
sc_format_asn1_entry(asn1_tokeninfo, asn1_toki, NULL, 1);
|
||||
|
||||
r = sc_asn1_encode(ctx, asn1_tokeninfo, buf, buflen);
|
||||
|
@ -157,11 +185,11 @@ int sc_pkcs15_encode_tokeninfo(sc_context_t *ctx,
|
|||
}
|
||||
|
||||
static const struct sc_asn1_entry c_asn1_ddo[] = {
|
||||
{ "oid", SC_ASN1_OBJECT, ASN1_OBJECT, 0, NULL },
|
||||
{ "odfPath", SC_ASN1_PATH, SC_ASN1_CONS | ASN1_SEQUENCE, SC_ASN1_OPTIONAL, NULL },
|
||||
{ "tokenInfoPath", SC_ASN1_PATH, SC_ASN1_CONS | SC_ASN1_CTX | 0, SC_ASN1_OPTIONAL, NULL },
|
||||
{ "unusedPath", SC_ASN1_PATH, SC_ASN1_CONS | SC_ASN1_CTX | 1, SC_ASN1_OPTIONAL, NULL },
|
||||
{ NULL }
|
||||
{ "oid", SC_ASN1_OBJECT, ASN1_OBJECT, 0, NULL, NULL },
|
||||
{ "odfPath", SC_ASN1_PATH, SC_ASN1_CONS | ASN1_SEQUENCE, SC_ASN1_OPTIONAL, NULL, NULL },
|
||||
{ "tokenInfoPath", SC_ASN1_PATH, SC_ASN1_CONS | SC_ASN1_CTX | 0, SC_ASN1_OPTIONAL, NULL, NULL },
|
||||
{ "unusedPath", SC_ASN1_PATH, SC_ASN1_CONS | SC_ASN1_CTX | 1, SC_ASN1_OPTIONAL, NULL, NULL },
|
||||
{ NULL, 0, 0, 0, NULL, NULL }
|
||||
};
|
||||
|
||||
static int parse_ddo(struct sc_pkcs15_card *p15card, const u8 * buf, size_t buflen)
|
||||
|
@ -228,18 +256,18 @@ static int encode_ddo(struct sc_pkcs15_card *p15card, u8 **buf, size_t *buflen)
|
|||
#endif
|
||||
|
||||
static const struct sc_asn1_entry c_asn1_odf[] = {
|
||||
{ "privateKeys", SC_ASN1_STRUCT, SC_ASN1_CTX | 0 | SC_ASN1_CONS, 0, NULL },
|
||||
{ "publicKeys", SC_ASN1_STRUCT, SC_ASN1_CTX | 1 | SC_ASN1_CONS, 0, NULL },
|
||||
{ "trustedPublicKeys", SC_ASN1_STRUCT, SC_ASN1_CTX | 2 | SC_ASN1_CONS, 0, NULL },
|
||||
{ "certificates", SC_ASN1_STRUCT, SC_ASN1_CTX | 4 | SC_ASN1_CONS, 0, NULL },
|
||||
{ "trustedCertificates", SC_ASN1_STRUCT, SC_ASN1_CTX | 5 | SC_ASN1_CONS, 0, NULL },
|
||||
{ "usefulCertificates", SC_ASN1_STRUCT, SC_ASN1_CTX | 6 | SC_ASN1_CONS, 0, NULL },
|
||||
{ "dataObjects", SC_ASN1_STRUCT, SC_ASN1_CTX | 7 | SC_ASN1_CONS, 0, NULL },
|
||||
{ "authObjects", SC_ASN1_STRUCT, SC_ASN1_CTX | 8 | SC_ASN1_CONS, 0, NULL },
|
||||
{ NULL }
|
||||
{ "privateKeys", SC_ASN1_STRUCT, SC_ASN1_CTX | 0 | SC_ASN1_CONS, 0, NULL, NULL },
|
||||
{ "publicKeys", SC_ASN1_STRUCT, SC_ASN1_CTX | 1 | SC_ASN1_CONS, 0, NULL, NULL },
|
||||
{ "trustedPublicKeys", SC_ASN1_STRUCT, SC_ASN1_CTX | 2 | SC_ASN1_CONS, 0, NULL, NULL },
|
||||
{ "certificates", SC_ASN1_STRUCT, SC_ASN1_CTX | 4 | SC_ASN1_CONS, 0, NULL, NULL },
|
||||
{ "trustedCertificates", SC_ASN1_STRUCT, SC_ASN1_CTX | 5 | SC_ASN1_CONS, 0, NULL, NULL },
|
||||
{ "usefulCertificates", SC_ASN1_STRUCT, SC_ASN1_CTX | 6 | SC_ASN1_CONS, 0, NULL, NULL },
|
||||
{ "dataObjects", SC_ASN1_STRUCT, SC_ASN1_CTX | 7 | SC_ASN1_CONS, 0, NULL, NULL },
|
||||
{ "authObjects", SC_ASN1_STRUCT, SC_ASN1_CTX | 8 | SC_ASN1_CONS, 0, NULL, NULL },
|
||||
{ NULL, 0, 0, 0, NULL, NULL }
|
||||
};
|
||||
|
||||
static const int odf_indexes[] = {
|
||||
static const unsigned int odf_indexes[] = {
|
||||
SC_PKCS15_PRKDF,
|
||||
SC_PKCS15_PUKDF,
|
||||
SC_PKCS15_PUKDF_TRUSTED,
|
||||
|
@ -257,8 +285,8 @@ static int parse_odf(const u8 * buf, size_t buflen, struct sc_pkcs15_card *card)
|
|||
int r, i;
|
||||
sc_path_t path;
|
||||
struct sc_asn1_entry asn1_obj_or_path[] = {
|
||||
{ "path", SC_ASN1_PATH, SC_ASN1_CONS | SC_ASN1_SEQUENCE, 0, &path },
|
||||
{ NULL }
|
||||
{ "path", SC_ASN1_PATH, SC_ASN1_CONS | SC_ASN1_SEQUENCE, 0, &path, NULL },
|
||||
{ NULL, 0, 0, 0, NULL, NULL }
|
||||
};
|
||||
struct sc_asn1_entry asn1_odf[9];
|
||||
|
||||
|
@ -284,8 +312,8 @@ int sc_pkcs15_encode_odf(sc_context_t *ctx,
|
|||
{
|
||||
sc_path_t path;
|
||||
struct sc_asn1_entry asn1_obj_or_path[] = {
|
||||
{ "path", SC_ASN1_PATH, SC_ASN1_CONS | SC_ASN1_SEQUENCE, 0, &path },
|
||||
{ NULL }
|
||||
{ "path", SC_ASN1_PATH, SC_ASN1_CONS | SC_ASN1_SEQUENCE, 0, &path, NULL },
|
||||
{ NULL, 0, 0, 0, NULL, NULL }
|
||||
};
|
||||
struct sc_asn1_entry *asn1_paths = NULL;
|
||||
struct sc_asn1_entry *asn1_odf = NULL;
|
||||
|
@ -353,7 +381,9 @@ struct sc_pkcs15_card * sc_pkcs15_card_new()
|
|||
|
||||
void sc_pkcs15_card_free(struct sc_pkcs15_card *p15card)
|
||||
{
|
||||
assert(p15card != NULL && p15card->magic == SC_PKCS15_CARD_MAGIC);
|
||||
if (p15card == NULL)
|
||||
return;
|
||||
assert(p15card->magic == SC_PKCS15_CARD_MAGIC);
|
||||
while (p15card->obj_list)
|
||||
sc_pkcs15_remove_object(p15card, p15card->obj_list);
|
||||
while (p15card->df_list)
|
||||
|
@ -365,52 +395,60 @@ void sc_pkcs15_card_free(struct sc_pkcs15_card *p15card)
|
|||
if (p15card->file_odf != NULL)
|
||||
sc_file_free(p15card->file_odf);
|
||||
p15card->magic = 0;
|
||||
if (p15card->label)
|
||||
if (p15card->label != NULL)
|
||||
free(p15card->label);
|
||||
if (p15card->serial_number)
|
||||
if (p15card->serial_number != NULL)
|
||||
free(p15card->serial_number);
|
||||
if (p15card->manufacturer_id)
|
||||
if (p15card->manufacturer_id != NULL)
|
||||
free(p15card->manufacturer_id);
|
||||
if (p15card->preferred_language)
|
||||
if (p15card->last_update != NULL)
|
||||
free(p15card->last_update);
|
||||
if (p15card->preferred_language != NULL)
|
||||
free(p15card->preferred_language);
|
||||
free(p15card);
|
||||
}
|
||||
|
||||
void sc_pkcs15_card_clear(sc_pkcs15_card_t *p15card)
|
||||
{
|
||||
if (p15card == NULL)
|
||||
return;
|
||||
p15card->version = 0;
|
||||
p15card->flags = 0;
|
||||
while (p15card->obj_list)
|
||||
while (p15card->obj_list != NULL)
|
||||
sc_pkcs15_remove_object(p15card, p15card->obj_list);
|
||||
p15card->obj_list = NULL;
|
||||
while (p15card->df_list)
|
||||
while (p15card->df_list != NULL)
|
||||
sc_pkcs15_remove_df(p15card, p15card->df_list);
|
||||
p15card->df_list = NULL;
|
||||
if (p15card->file_app) {
|
||||
if (p15card->file_app != NULL) {
|
||||
sc_file_free(p15card->file_app);
|
||||
p15card->file_app = NULL;
|
||||
}
|
||||
if (p15card->file_tokeninfo) {
|
||||
if (p15card->file_tokeninfo != NULL) {
|
||||
sc_file_free(p15card->file_tokeninfo);
|
||||
p15card->file_tokeninfo = NULL;
|
||||
}
|
||||
if (p15card->file_odf) {
|
||||
if (p15card->file_odf != NULL) {
|
||||
sc_file_free(p15card->file_odf);
|
||||
p15card->file_odf = NULL;
|
||||
}
|
||||
if (p15card->label) {
|
||||
if (p15card->label != NULL) {
|
||||
free(p15card->label);
|
||||
p15card->label = NULL;
|
||||
}
|
||||
if (p15card->serial_number) {
|
||||
if (p15card->serial_number != NULL) {
|
||||
free(p15card->serial_number);
|
||||
p15card->serial_number = NULL;
|
||||
}
|
||||
if (p15card->manufacturer_id) {
|
||||
if (p15card->manufacturer_id != NULL) {
|
||||
free(p15card->manufacturer_id);
|
||||
p15card->manufacturer_id = NULL;
|
||||
}
|
||||
if (p15card->preferred_language) {
|
||||
if (p15card->last_update != NULL) {
|
||||
free(p15card->last_update);
|
||||
p15card->last_update = NULL;
|
||||
}
|
||||
if (p15card->preferred_language != NULL) {
|
||||
free(p15card->preferred_language);
|
||||
p15card->preferred_language = NULL;
|
||||
}
|
||||
|
@ -642,7 +680,7 @@ int sc_pkcs15_unbind(struct sc_pkcs15_card *p15card)
|
|||
|
||||
static int
|
||||
__sc_pkcs15_search_objects(sc_pkcs15_card_t *p15card,
|
||||
unsigned int class_mask, int type,
|
||||
unsigned int class_mask, unsigned int type,
|
||||
int (*func)(sc_pkcs15_object_t *, void *),
|
||||
void *func_arg,
|
||||
sc_pkcs15_object_t **ret, size_t ret_size)
|
||||
|
@ -718,8 +756,8 @@ __sc_pkcs15_search_objects(sc_pkcs15_card_t *p15card,
|
|||
return match_count;
|
||||
}
|
||||
|
||||
int sc_pkcs15_get_objects(struct sc_pkcs15_card *p15card, int type,
|
||||
struct sc_pkcs15_object **ret, int ret_size)
|
||||
int sc_pkcs15_get_objects(struct sc_pkcs15_card *p15card, unsigned int type,
|
||||
struct sc_pkcs15_object **ret, size_t ret_size)
|
||||
{
|
||||
return sc_pkcs15_get_objects_cond(p15card, type, NULL, NULL, ret, ret_size);
|
||||
}
|
||||
|
@ -847,7 +885,7 @@ static int compare_obj_key(struct sc_pkcs15_object *obj, void *arg)
|
|||
}
|
||||
|
||||
static int find_by_key(struct sc_pkcs15_card *p15card,
|
||||
int type, struct sc_pkcs15_search_key *sk,
|
||||
unsigned int type, struct sc_pkcs15_search_key *sk,
|
||||
struct sc_pkcs15_object **out)
|
||||
{
|
||||
int r;
|
||||
|
@ -870,17 +908,17 @@ sc_pkcs15_search_objects(sc_pkcs15_card_t *p15card, sc_pkcs15_search_key_t *sk,
|
|||
ret, ret_size);
|
||||
}
|
||||
|
||||
int sc_pkcs15_get_objects_cond(struct sc_pkcs15_card *p15card, int type,
|
||||
int sc_pkcs15_get_objects_cond(struct sc_pkcs15_card *p15card, unsigned int type,
|
||||
int (* func)(struct sc_pkcs15_object *, void *),
|
||||
void *func_arg,
|
||||
struct sc_pkcs15_object **ret, int ret_size)
|
||||
struct sc_pkcs15_object **ret, size_t ret_size)
|
||||
{
|
||||
return __sc_pkcs15_search_objects(p15card, 0, type,
|
||||
func, func_arg, ret, ret_size);
|
||||
}
|
||||
|
||||
int sc_pkcs15_find_object_by_id(sc_pkcs15_card_t *p15card,
|
||||
int type, const sc_pkcs15_id_t *id,
|
||||
unsigned int type, const sc_pkcs15_id_t *id,
|
||||
sc_pkcs15_object_t **out)
|
||||
{
|
||||
sc_pkcs15_search_key_t sk;
|
||||
|
@ -1066,7 +1104,7 @@ void sc_pkcs15_free_object(struct sc_pkcs15_object *obj)
|
|||
}
|
||||
|
||||
int sc_pkcs15_add_df(struct sc_pkcs15_card *p15card,
|
||||
int type, const sc_path_t *path,
|
||||
unsigned int type, const sc_path_t *path,
|
||||
const sc_file_t *file)
|
||||
{
|
||||
struct sc_pkcs15_df *p = p15card->df_list, *newdf;
|
||||
|
|
|
@ -291,7 +291,7 @@ typedef struct sc_pkcs15_pubkey_info sc_pkcs15_pubkey_info_t;
|
|||
#define SC_PKCS15_SEARCH_CLASS_AUTH 0x0040U
|
||||
|
||||
struct sc_pkcs15_object {
|
||||
int type;
|
||||
unsigned int type;
|
||||
/* CommonObjectAttributes */
|
||||
char label[SC_PKCS15_MAX_LABEL_SIZE]; /* zero terminated */
|
||||
unsigned int flags;
|
||||
|
@ -325,7 +325,8 @@ struct sc_pkcs15_df {
|
|||
struct sc_file *file;
|
||||
|
||||
struct sc_path path;
|
||||
int record_length, type;
|
||||
int record_length;
|
||||
unsigned int type;
|
||||
int enumerated;
|
||||
|
||||
struct sc_pkcs15_df *next, *prev;
|
||||
|
@ -340,6 +341,7 @@ typedef struct sc_pkcs15_card {
|
|||
/* fields from TokenInfo: */
|
||||
int version;
|
||||
char *serial_number, *manufacturer_id;
|
||||
char *last_update;
|
||||
unsigned int flags;
|
||||
struct sc_pkcs15_algorithm_info alg_info[1];
|
||||
|
||||
|
@ -376,13 +378,13 @@ int sc_pkcs15_bind(struct sc_card *card,
|
|||
* memory allocations done on the card object. */
|
||||
int sc_pkcs15_unbind(struct sc_pkcs15_card *card);
|
||||
|
||||
int sc_pkcs15_get_objects(struct sc_pkcs15_card *card, int type,
|
||||
struct sc_pkcs15_object **ret, int ret_count);
|
||||
int sc_pkcs15_get_objects_cond(struct sc_pkcs15_card *card, int type,
|
||||
int sc_pkcs15_get_objects(struct sc_pkcs15_card *card, unsigned int type,
|
||||
struct sc_pkcs15_object **ret, size_t ret_count);
|
||||
int sc_pkcs15_get_objects_cond(struct sc_pkcs15_card *card, unsigned int type,
|
||||
int (* func)(struct sc_pkcs15_object *, void *),
|
||||
void *func_arg,
|
||||
struct sc_pkcs15_object **ret, int ret_count);
|
||||
int sc_pkcs15_find_object_by_id(sc_pkcs15_card_t *, int,
|
||||
struct sc_pkcs15_object **ret, size_t ret_count);
|
||||
int sc_pkcs15_find_object_by_id(sc_pkcs15_card_t *, unsigned int,
|
||||
const sc_pkcs15_id_t *,
|
||||
sc_pkcs15_object_t **);
|
||||
|
||||
|
@ -554,7 +556,7 @@ int sc_pkcs15_add_object(struct sc_pkcs15_card *p15card,
|
|||
void sc_pkcs15_remove_object(struct sc_pkcs15_card *p15card,
|
||||
struct sc_pkcs15_object *obj);
|
||||
int sc_pkcs15_add_df(struct sc_pkcs15_card *p15card,
|
||||
int type, const sc_path_t *path,
|
||||
unsigned int type, const sc_path_t *path,
|
||||
const struct sc_file *file);
|
||||
void sc_pkcs15_remove_df(struct sc_pkcs15_card *p15card,
|
||||
struct sc_pkcs15_df *df);
|
||||
|
@ -628,9 +630,6 @@ typedef struct sc_pkcs15emu_opt {
|
|||
|
||||
extern int sc_pkcs15_bind_synthetic(sc_pkcs15_card_t *);
|
||||
|
||||
sc_pkcs15_df_t *sc_pkcs15emu_get_df(sc_pkcs15_card_t *p15card,
|
||||
int type);
|
||||
|
||||
int sc_pkcs15emu_object_add(sc_pkcs15_card_t *p15card, unsigned int type,
|
||||
const sc_pkcs15_object_t *obj, const void *data);
|
||||
/* some wrapper functions for sc_pkcs15emu_object_add */
|
||||
|
|
Loading…
Reference in New Issue