Add sc_ctx_use_reader as a reader driver operation.

It is used by cardmod to pass in pointers to the PC/SC handles 
provided by the caller of cardmod. Other drivers will return
an error if this routine called. 


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5190 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
dengert 2011-02-09 14:33:52 +00:00
parent 025da6d0f5
commit d3b3faa91a
6 changed files with 28 additions and 0 deletions

View File

@ -677,6 +677,16 @@ int sc_context_create(sc_context_t **ctx_out, const sc_context_param_t *parm)
return SC_SUCCESS;
}
/* use by cardmod to pass in provided handles to reader-pcsc */
int sc_ctx_use_reader(sc_context_t *ctx, void * pcsc_context_handle, void * pcsc_card_handle)
{
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
if (ctx->reader_driver->ops->use_reader != NULL)
return ctx->reader_driver->ops->use_reader(ctx, pcsc_context_handle, pcsc_card_handle);
return SC_ERROR_NOT_SUPPORTED;
}
/* Following two are only implemented with internal PC/SC and don't consume a reader object */
int sc_cancel(sc_context_t *ctx)
{

View File

@ -71,6 +71,7 @@ sc_ctx_get_reader
sc_ctx_get_reader_by_id
sc_ctx_get_reader_by_name
sc_ctx_get_reader_count
sc_ctx_use_reader
sc_decipher
sc_delete_file
sc_delete_record

View File

@ -388,6 +388,8 @@ struct sc_reader_operations {
int timeout, void **reader_states);
/* Reset a reader */
int (*reset)(struct sc_reader *, int);
/* used to pass in reader handles in cardmod mode */
int (*use_reader)(struct sc_context *ctx, void * pcsc_context_handle, void * pcsc_card_handle);
};
/*
@ -726,6 +728,17 @@ int sc_ctx_detect_readers(sc_context_t *ctx);
*/
sc_reader_t *sc_ctx_get_reader(sc_context_t *ctx, unsigned int i);
/**
* Pass in pointers to handles to be used for the pcsc reader.
* This is used by cardmod to pass in handles provided by BaseCSP
*
* @param ctx pointer to a sc_context_t
* @param pcsc_context_handle pointer to the new context_handle to use
* @param pcsc_card_handle pointer to the new card_handle to use
* @return SC_SUCCESS on success and an error code otherwise.
*/
int sc_ctx_use_reader(sc_context_t *ctx, void * pcsc_context_handle, void * pcsc_card_handle);
/**
* Returns a pointer to the specified sc_reader_t object
* @param ctx OpenSC context

View File

@ -563,6 +563,7 @@ struct sc_reader_driver * sc_get_ctapi_driver(void)
ctapi_ops.connect = ctapi_connect;
ctapi_ops.disconnect = ctapi_disconnect;
ctapi_ops.perform_verify = ctbcs_pin_cmd;
ctapi_ops.use_reader = NULL;
return &ctapi_drv;
}

View File

@ -450,6 +450,7 @@ struct sc_reader_driver *sc_get_openct_driver(void)
openct_ops.perform_verify = openct_reader_perform_verify;
openct_ops.lock = openct_reader_lock;
openct_ops.unlock = openct_reader_unlock;
openct_ops.use_reader = NULL;
return &openct_reader_driver;
}

View File

@ -1535,6 +1535,7 @@ struct sc_reader_driver * sc_get_pcsc_driver(void)
pcsc_ops.wait_for_event = pcsc_wait_for_event;
pcsc_ops.cancel = pcsc_cancel;
pcsc_ops.reset = pcsc_reset;
pcsc_ops.use_reader = NULL;
return &pcsc_drv;
}
@ -1926,6 +1927,7 @@ struct sc_reader_driver * sc_get_cardmod_driver(void)
/* cardmod_ops.perform_verify = ; */
cardmod_ops.wait_for_event = NULL;
cardmod_ops.reset = NULL;
cardmod_ops.use_reader = NULL; /* TODO Replace with entry point with major changes to cardmod */
return &cardmod_drv;
}