libopensc: homogenize name of 'struct sc_pkcs15_card' parameters and variables

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4090 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
viktor.tarasov 2010-03-08 12:32:35 +00:00
parent bd93c92b23
commit c837196134
2 changed files with 28 additions and 28 deletions

View File

@ -312,7 +312,7 @@ static const unsigned int odf_indexes[] = {
SC_PKCS15_AODF, SC_PKCS15_AODF,
}; };
static int parse_odf(const u8 * buf, size_t buflen, struct sc_pkcs15_card *card) static int parse_odf(const u8 * buf, size_t buflen, struct sc_pkcs15_card *p15card)
{ {
const u8 *p = buf; const u8 *p = buf;
size_t left = buflen; size_t left = buflen;
@ -328,16 +328,16 @@ static int parse_odf(const u8 * buf, size_t buflen, struct sc_pkcs15_card *card)
for (i = 0; asn1_odf[i].name != NULL; i++) for (i = 0; asn1_odf[i].name != NULL; i++)
sc_format_asn1_entry(asn1_odf + i, asn1_obj_or_path, NULL, 0); sc_format_asn1_entry(asn1_odf + i, asn1_obj_or_path, NULL, 0);
while (left > 0) { while (left > 0) {
r = sc_asn1_decode_choice(card->card->ctx, asn1_odf, p, left, &p, &left); r = sc_asn1_decode_choice(p15card->card->ctx, asn1_odf, p, left, &p, &left);
if (r == SC_ERROR_ASN1_END_OF_CONTENTS) if (r == SC_ERROR_ASN1_END_OF_CONTENTS)
break; break;
if (r < 0) if (r < 0)
return r; return r;
type = r; type = r;
r = sc_pkcs15_make_absolute_path(&card->file_app->path, &path); r = sc_pkcs15_make_absolute_path(&p15card->file_app->path, &path);
if (r < 0) if (r < 0)
return r; return r;
r = sc_pkcs15_add_df(card, odf_indexes[type], &path, NULL); r = sc_pkcs15_add_df(p15card, odf_indexes[type], &path, NULL);
if (r) if (r)
return r; return r;
} }
@ -1650,7 +1650,7 @@ err:
return r; return r;
} }
int sc_pkcs15_parse_unusedspace(const u8 * buf, size_t buflen, struct sc_pkcs15_card *card) int sc_pkcs15_parse_unusedspace(const u8 * buf, size_t buflen, struct sc_pkcs15_card *p15card)
{ {
const u8 *p = buf; const u8 *p = buf;
size_t left = buflen; size_t left = buflen;
@ -1668,8 +1668,8 @@ int sc_pkcs15_parse_unusedspace(const u8 * buf, size_t buflen, struct sc_pkcs15_
}; };
/* Clean the list if already present */ /* Clean the list if already present */
while (card->unusedspace_list) while (p15card->unusedspace_list)
sc_pkcs15_remove_unusedspace(card, card->unusedspace_list); sc_pkcs15_remove_unusedspace(p15card, p15card->unusedspace_list);
sc_format_path("3F00", &dummy_path); sc_format_path("3F00", &dummy_path);
dummy_path.index = dummy_path.count = 0; dummy_path.index = dummy_path.count = 0;
@ -1680,7 +1680,7 @@ int sc_pkcs15_parse_unusedspace(const u8 * buf, size_t buflen, struct sc_pkcs15_
while (left > 0) { while (left > 0) {
memset(&auth_id, 0, sizeof(auth_id)); memset(&auth_id, 0, sizeof(auth_id));
r = sc_asn1_decode(card->card->ctx, asn1_unusedspace, p, left, &p, &left); r = sc_asn1_decode(p15card->card->ctx, asn1_unusedspace, p, left, &p, &left);
if (r == SC_ERROR_ASN1_END_OF_CONTENTS) if (r == SC_ERROR_ASN1_END_OF_CONTENTS)
break; break;
if (r < 0) if (r < 0)
@ -1689,16 +1689,16 @@ int sc_pkcs15_parse_unusedspace(const u8 * buf, size_t buflen, struct sc_pkcs15_
* If the path length isn't included (-1) then it's against the standard * If the path length isn't included (-1) then it's against the standard
* but we'll just ignore it instead of returning an error. */ * but we'll just ignore it instead of returning an error. */
if (path.count > 0) { if (path.count > 0) {
r = sc_pkcs15_make_absolute_path(&card->file_app->path, &path); r = sc_pkcs15_make_absolute_path(&p15card->file_app->path, &path);
if (r < 0) if (r < 0)
return r; return r;
r = sc_pkcs15_add_unusedspace(card, &path, &auth_id); r = sc_pkcs15_add_unusedspace(p15card, &path, &auth_id);
if (r) if (r)
return r; return r;
} }
} }
card->unusedspace_read = 1; p15card->unusedspace_read = 1;
return 0; return 0;
} }

View File

@ -190,10 +190,10 @@ static CK_RV pkcs15_unbind(struct sc_pkcs11_card *p11card)
return sc_to_cryptoki_error(rc); return sc_to_cryptoki_error(rc);
} }
static void pkcs15_init_token_info(struct sc_pkcs15_card *card, CK_TOKEN_INFO_PTR pToken) static void pkcs15_init_token_info(struct sc_pkcs15_card *p15card, CK_TOKEN_INFO_PTR pToken)
{ {
strcpy_bp(pToken->manufacturerID, card->manufacturer_id, 32); strcpy_bp(pToken->manufacturerID, p15card->manufacturer_id, 32);
if (card->flags & SC_PKCS15_CARD_FLAG_EMULATED) if (p15card->flags & SC_PKCS15_CARD_FLAG_EMULATED)
strcpy_bp(pToken->model, "PKCS#15 emulated", 16); strcpy_bp(pToken->model, "PKCS#15 emulated", 16);
else else
strcpy_bp(pToken->model, "PKCS#15", 16); strcpy_bp(pToken->model, "PKCS#15", 16);
@ -203,13 +203,13 @@ static void pkcs15_init_token_info(struct sc_pkcs15_card *card, CK_TOKEN_INFO_PT
* _Assuming_ that the serial number is a Big Endian counter, this * _Assuming_ that the serial number is a Big Endian counter, this
* will assure that the serial within each type of card will be * will assure that the serial within each type of card will be
* unique in pkcs11 (at least for the first 8^16 cards :-) */ * unique in pkcs11 (at least for the first 8^16 cards :-) */
if (card->serial_number != NULL) { if (p15card->serial_number != NULL) {
int sn_start = strlen(card->serial_number) - 16; int sn_start = strlen(p15card->serial_number) - 16;
if (sn_start < 0) if (sn_start < 0)
sn_start = 0; sn_start = 0;
strcpy_bp(pToken->serialNumber, strcpy_bp(pToken->serialNumber,
card->serial_number + sn_start, p15card->serial_number + sn_start,
16); 16);
} }
@ -694,7 +694,7 @@ pkcs15_add_object(struct sc_pkcs11_slot *slot,
obj->base.flags &= ~SC_PKCS11_OBJECT_RECURS; obj->base.flags &= ~SC_PKCS11_OBJECT_RECURS;
} }
static void pkcs15_init_slot(struct sc_pkcs15_card *card, static void pkcs15_init_slot(struct sc_pkcs15_card *p15card,
struct sc_pkcs11_slot *slot, struct sc_pkcs11_slot *slot,
struct sc_pkcs15_object *auth) struct sc_pkcs15_object *auth)
{ {
@ -702,14 +702,14 @@ static void pkcs15_init_slot(struct sc_pkcs15_card *card,
struct sc_pkcs15_pin_info *pin_info = NULL; struct sc_pkcs15_pin_info *pin_info = NULL;
char tmp[64]; char tmp[64];
pkcs15_init_token_info(card, &slot->token_info); pkcs15_init_token_info(p15card, &slot->token_info);
slot->token_info.flags |= CKF_TOKEN_INITIALIZED; slot->token_info.flags |= CKF_TOKEN_INITIALIZED;
if (auth != NULL) if (auth != NULL)
slot->token_info.flags |= CKF_USER_PIN_INITIALIZED; slot->token_info.flags |= CKF_USER_PIN_INITIALIZED;
if (card->card->reader->capabilities & SC_READER_CAP_PIN_PAD) { if (p15card->card->reader->capabilities & SC_READER_CAP_PIN_PAD) {
slot->token_info.flags |= CKF_PROTECTED_AUTHENTICATION_PATH; slot->token_info.flags |= CKF_PROTECTED_AUTHENTICATION_PATH;
} }
if (card->card->caps & SC_CARD_CAP_RNG) if (p15card->card->caps & SC_CARD_CAP_RNG)
slot->token_info.flags |= CKF_RNG; slot->token_info.flags |= CKF_RNG;
slot->fw_data = fw_data = (struct pkcs15_slot_data *) calloc(1, sizeof(*fw_data)); slot->fw_data = fw_data = (struct pkcs15_slot_data *) calloc(1, sizeof(*fw_data));
fw_data->auth_obj = auth; fw_data->auth_obj = auth;
@ -719,9 +719,9 @@ static void pkcs15_init_slot(struct sc_pkcs15_card *card,
if (auth->label[0]) { if (auth->label[0]) {
snprintf(tmp, sizeof(tmp), "%s (%s)", snprintf(tmp, sizeof(tmp), "%s (%s)",
card->label, auth->label); p15card->label, auth->label);
} else { } else {
snprintf(tmp, sizeof(tmp), "%s", card->label); snprintf(tmp, sizeof(tmp), "%s", p15card->label);
} }
slot->token_info.flags |= CKF_LOGIN_REQUIRED; slot->token_info.flags |= CKF_LOGIN_REQUIRED;
/* FIXME: update this information during runtime */ /* FIXME: update this information during runtime */
@ -734,7 +734,7 @@ static void pkcs15_init_slot(struct sc_pkcs15_card *card,
slot->token_info.flags |= CKF_USER_PIN_COUNT_LOW; slot->token_info.flags |= CKF_USER_PIN_COUNT_LOW;
} }
} else } else
snprintf(tmp, sizeof(tmp), "%s", card->label); snprintf(tmp, sizeof(tmp), "%s", p15card->label);
strcpy_bp(slot->token_info.label, tmp, 32); strcpy_bp(slot->token_info.label, tmp, 32);
if (pin_info && pin_info->magic == SC_PKCS15_PIN_MAGIC) { if (pin_info && pin_info->magic == SC_PKCS15_PIN_MAGIC) {
@ -745,7 +745,7 @@ static void pkcs15_init_slot(struct sc_pkcs15_card *card,
slot->token_info.ulMaxPinLen = 8; slot->token_info.ulMaxPinLen = 8;
slot->token_info.ulMinPinLen = 4; slot->token_info.ulMinPinLen = 4;
} }
if (card->flags & SC_PKCS15_CARD_FLAG_EMULATED) if (p15card->flags & SC_PKCS15_CARD_FLAG_EMULATED)
slot->token_info.flags |= CKF_WRITE_PROTECTED; slot->token_info.flags |= CKF_WRITE_PROTECTED;
sc_debug(context, "Initialized token '%s' in slot 0x%lx", tmp, slot->id); sc_debug(context, "Initialized token '%s' in slot 0x%lx", tmp, slot->id);
@ -949,7 +949,7 @@ static CK_RV pkcs15_login(struct sc_pkcs11_card *p11card,
{ {
int rc; int rc;
struct pkcs15_fw_data *fw_data = (struct pkcs15_fw_data *) p11card->fw_data; struct pkcs15_fw_data *fw_data = (struct pkcs15_fw_data *) p11card->fw_data;
struct sc_pkcs15_card *card = fw_data->p15_card; struct sc_pkcs15_card *p15card = fw_data->p15_card;
struct sc_pkcs15_object *auth_object; struct sc_pkcs15_object *auth_object;
struct sc_pkcs15_pin_info *pin_info; struct sc_pkcs15_pin_info *pin_info;
@ -962,7 +962,7 @@ static CK_RV pkcs15_login(struct sc_pkcs11_card *p11card,
case CKU_SO: case CKU_SO:
/* A card with no SO PIN is treated as if no SO login /* A card with no SO PIN is treated as if no SO login
* is required */ * is required */
rc = sc_pkcs15_find_so_pin(card, &auth_object); rc = sc_pkcs15_find_so_pin(p15card, &auth_object);
/* If there's no SO PIN on the card, silently /* If there's no SO PIN on the card, silently
* accept any PIN, and lock the card if required */ * accept any PIN, and lock the card if required */
@ -1039,7 +1039,7 @@ static CK_RV pkcs15_login(struct sc_pkcs11_card *p11card,
if (sc_pkcs11_conf.lock_login && (rc = lock_card(fw_data)) < 0) if (sc_pkcs11_conf.lock_login && (rc = lock_card(fw_data)) < 0)
return sc_to_cryptoki_error(rc); return sc_to_cryptoki_error(rc);
rc = sc_pkcs15_verify_pin(card, pin_info, pPin, ulPinLen); rc = sc_pkcs15_verify_pin(p15card, pin_info, pPin, ulPinLen);
sc_debug(context, "PKCS15 verify PIN returned %d\n", rc); sc_debug(context, "PKCS15 verify PIN returned %d\n", rc);
return sc_to_cryptoki_error(rc); return sc_to_cryptoki_error(rc);
} }