- some fixes to the PKCS #11 module
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@125 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
parent
a769be2ae4
commit
5cdd262385
|
@ -144,8 +144,6 @@ static int mflex_select_file(struct sc_card *card, const struct sc_path *path,
|
|||
sc_format_path("I3F00", &tmppath);
|
||||
r = mflex_select_file(card, &tmppath, NULL);
|
||||
SC_TEST_RET(card->ctx, r, "Unable to select Master File (MF)");
|
||||
pathptr += 2;
|
||||
pathlen -= 2;
|
||||
}
|
||||
while (pathlen > 2) {
|
||||
memcpy(tmppath.value, pathptr, 2);
|
||||
|
|
|
@ -245,7 +245,7 @@ struct sc_card_operations {
|
|||
|
||||
/* select_file: Does the equivalent of SELECT FILE command specified
|
||||
* in ISO7816-4. Stores information about the selected file to
|
||||
* <file>, if not NULL. */
|
||||
* <file>, if not NULL. */
|
||||
int (*select_file)(struct sc_card *card, const struct sc_path *path,
|
||||
struct sc_file *file_out);
|
||||
int (*get_response)(struct sc_card *card, u8 * buf, size_t count);
|
||||
|
@ -340,6 +340,7 @@ int sc_lock(struct sc_card *card);
|
|||
int sc_unlock(struct sc_card *card);
|
||||
|
||||
/* ISO 7816-4 related functions */
|
||||
|
||||
int sc_select_file(struct sc_card *card, const struct sc_path *path,
|
||||
struct sc_file *file);
|
||||
int sc_read_binary(struct sc_card *card, unsigned int idx, u8 * buf,
|
||||
|
|
|
@ -272,6 +272,7 @@ int sc_pkcs15_bind(struct sc_card *card,
|
|||
err = sc_select_file(card, &tmppath, &p15card->file_dir);
|
||||
if (err) {
|
||||
error(ctx, "Error selecting EF(DIR): %s\n", sc_strerror(err));
|
||||
err = SC_ERROR_PKCS15_CARD_NOT_FOUND;
|
||||
goto error;
|
||||
}
|
||||
err = sc_read_binary(card, 0, buf, p15card->file_dir.size, 0);
|
||||
|
|
|
@ -213,11 +213,11 @@ void sc_format_path(const char *str, struct sc_path *path)
|
|||
int type = SC_PATH_TYPE_PATH;
|
||||
u8 *p = path->value;
|
||||
|
||||
if (*p == 'i' || *p == 'I') {
|
||||
if (*str == 'i' || *str == 'I') {
|
||||
type = SC_PATH_TYPE_FILE_ID;
|
||||
p++;
|
||||
str++;
|
||||
}
|
||||
while (str) {
|
||||
while (*str) {
|
||||
int byte;
|
||||
|
||||
if (sscanf(str, "%02X", &byte) != 1)
|
||||
|
|
|
@ -165,7 +165,7 @@ CK_RV C_GetSlotInfo(CK_SLOT_ID slotID, CK_SLOT_INFO_PTR pInfo)
|
|||
CK_RV C_GetTokenInfo(CK_SLOT_ID slotID, CK_TOKEN_INFO_PTR pInfo)
|
||||
{
|
||||
int r;
|
||||
|
||||
|
||||
LOG("C_GetTokenInfo(%d, 0x%x)\n", slotID, pInfo);
|
||||
if (slotID < 0 || slotID >= ctx->reader_count)
|
||||
return CKR_SLOT_ID_INVALID;
|
||||
|
@ -181,7 +181,7 @@ CK_RV C_GetTokenInfo(CK_SLOT_ID slotID, CK_TOKEN_INFO_PTR pInfo)
|
|||
pInfo->label[31] = 0;
|
||||
strncpy((char *) pInfo->manufacturerID, slot[slotID].p15card->manufacturer_id, 32);
|
||||
pInfo->manufacturerID[31] = 0;
|
||||
strcpy((char *) pInfo->model, "PKCS#15 SC");
|
||||
strcpy((char *) pInfo->model, "PKCS #15 SC");
|
||||
strncpy((char *) pInfo->serialNumber, slot[slotID].p15card->serial_number, 16);
|
||||
pInfo->serialNumber[15] = 0;
|
||||
|
||||
|
@ -210,7 +210,7 @@ CK_RV C_GetTokenInfo(CK_SLOT_ID slotID, CK_TOKEN_INFO_PTR pInfo)
|
|||
pInfo->hardwareVersion.minor = 0;
|
||||
pInfo->firmwareVersion.major = 1;
|
||||
pInfo->firmwareVersion.minor = 0;
|
||||
|
||||
|
||||
return CKR_OK;
|
||||
}
|
||||
|
||||
|
@ -248,7 +248,7 @@ CK_RV C_GetMechanismInfo(CK_SLOT_ID slotID,
|
|||
CK_MECHANISM_INFO_PTR pInfo)
|
||||
{
|
||||
LOG("C_GetMechanismInfo(%d, %d, 0x%x)\n", slotID, type, pInfo);
|
||||
return CKR_FUNCTION_NOT_SUPPORTED;
|
||||
return CKR_FUNCTION_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
CK_RV C_InitToken(CK_SLOT_ID slotID,
|
||||
|
@ -256,6 +256,6 @@ CK_RV C_InitToken(CK_SLOT_ID slotID,
|
|||
CK_ULONG ulPinLen,
|
||||
CK_CHAR_PTR pLabel)
|
||||
{
|
||||
LOG("C_InitToken(%d, '%s', %d, '%s')\n", slotID, pPin, ulPinLen, pLabel);
|
||||
return CKR_FUNCTION_NOT_SUPPORTED;
|
||||
LOG("C_InitToken(%d, '%s', %d, '%s')\n", slotID, pPin, ulPinLen, pLabel);
|
||||
return CKR_FUNCTION_NOT_SUPPORTED;
|
||||
}
|
||||
|
|
|
@ -133,10 +133,6 @@ int slot_connect(int id)
|
|||
struct sc_pkcs15_cert *cert;
|
||||
struct sc_pkcs15_cert_info *cinfo = &p15card->cert_info[c];
|
||||
|
||||
#if 0
|
||||
if (cinfo->authority)
|
||||
continue;
|
||||
#endif
|
||||
LOG("Reading '%s' certificate.\n", cinfo->com_attr.label);
|
||||
r = sc_pkcs15_read_certificate(p15card, cinfo, &cert);
|
||||
if (r)
|
||||
|
@ -144,12 +140,14 @@ int slot_connect(int id)
|
|||
LOG("Adding '%s' certificate object (id %X).\n",
|
||||
cinfo->com_attr.label, cinfo->id);
|
||||
slot_add_certificate_object(id, c, cinfo, cert);
|
||||
|
||||
for (i = 0; i < p15card->prkey_count; i++) {
|
||||
struct sc_pkcs15_prkey_info *pinfo = &p15card->prkey_info[i];
|
||||
if (sc_pkcs15_compare_id(&cinfo->id, &pinfo->id)) {
|
||||
LOG("Adding '%s' private key object (id %X).\n",
|
||||
pinfo->com_attr.label, pinfo->id);
|
||||
slot_add_private_key_object(id, i, pinfo, cert);
|
||||
pinfo->com_attr.label, pinfo->id.value[0]);
|
||||
if (slot_add_private_key_object(id, i, pinfo, cert))
|
||||
LOG("Private key addition failed.\n");
|
||||
}
|
||||
}
|
||||
sc_pkcs15_free_certificate(cert);
|
||||
|
@ -163,8 +161,10 @@ int slot_disconnect(int id)
|
|||
LOG("Disconnecting from slot %d\n", id);
|
||||
slot[id].flags = 0;
|
||||
if (slot[id].p15card != NULL) {
|
||||
struct sc_card *card = slot[id].p15card->card;
|
||||
|
||||
sc_pkcs15_unbind(slot[id].p15card);
|
||||
sc_disconnect_card(slot[id].p15card->card);
|
||||
sc_disconnect_card(card);
|
||||
slot[id].p15card = NULL;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue