src/py_emv.c File Reference

#include <ccid.h>
#include <emv.h>
#include <Python.h>
#include <structmember.h>
#include "py_ccid.h"
Include dependency graph for py_emv.c:

Go to the source code of this file.

Data Structures

struct  cp_emv
struct  cp_app
struct  cp_data
struct  key_cb
struct  dol_cb

Defines

#define _INT_CONST(m, c)   PyModule_AddIntConstant(m, #c, EMV_ ## c)

Functions

static PyObject * data_dict (struct cp_emv *, emv_data_t *, unsigned int)
static void set_err (emv_t e)
static PyObject * bcd_convert (const uint8_t *ptr, size_t len)
static PyObject * binary_convert (const uint8_t *ptr, size_t len)
static PyObject * date_convert (const uint8_t *ptr, size_t len)
static PyObject * cp_data_repr (struct cp_data *self)
static PyObject * cp_data_value (struct cp_data *self, PyObject *args)
static PyObject * cp_data_children (struct cp_data *self, PyObject *args)
static PyObject * cp_data_type (struct cp_data *self, PyObject *args)
static PyObject * cp_data_tag (struct cp_data *self, PyObject *args)
static PyObject * cp_data_tag_label (struct cp_data *self, PyObject *args)
static PyObject * cp_data_sda (struct cp_data *self, PyObject *args)
static void cp_data_dealloc (struct cp_data *self)
static void cp_app_dealloc (struct cp_app *self)
static PyObject * cp_app_rid (struct cp_app *self, PyObject *args)
static PyObject * cp_app_aid (struct cp_app *self, PyObject *args)
static PyObject * cp_app_label (struct cp_app *self, PyObject *args)
static PyObject * cp_app_pname (struct cp_app *self, PyObject *args)
static PyObject * cp_app_prio (struct cp_app *self, PyObject *args)
static PyObject * cp_app_confirm (struct cp_app *self, PyObject *args)
static int cp_emv_init (struct cp_emv *self, PyObject *args, PyObject *kwds)
static void dirty_applist (struct cp_emv *self)
static void cp_emv_dealloc (struct cp_emv *self)
static PyObject * app_list (struct cp_emv *self)
static int set_current (struct cp_emv *self)
static PyObject * cp_appsel_pse (struct cp_emv *self, PyObject *args)
static PyObject * cp_select_pse (struct cp_emv *self, PyObject *args)
static PyObject * cp_select_aid (struct cp_emv *self, PyObject *args)
static PyObject * cp_select_aid_next (struct cp_emv *self, PyObject *args)
static PyObject * cp_current_app (struct cp_emv *self, PyObject *args)
static PyObject * cp_init (struct cp_emv *self, PyObject *args)
static PyObject * data_list (struct cp_emv *owner, emv_data_t *elem, unsigned int nmemb)
static PyObject * cp_read_app_data (struct cp_emv *self, PyObject *args)
static const uint8_t * get_mod (void *priv, unsigned int idx, size_t *len)
static const uint8_t * get_exp (void *priv, unsigned int idx, size_t *len)
static PyObject * cp_sda (struct cp_emv *self, PyObject *args)
static PyObject * cp_dda (struct cp_emv *self, PyObject *args)
static PyObject * cp_cvm_pin (struct cp_emv *self, PyObject *args)
static PyObject * cp_pin_try_counter (struct cp_emv *self, PyObject *args)
static PyObject * cp_atc (struct cp_emv *self, PyObject *args)
static PyObject * cp_oatc (struct cp_emv *self, PyObject *args)
static PyObject * ac2tuple (const uint8_t *ptr, size_t len)
static PyObject * cp_gen_ac (struct cp_emv *self, PyObject *args)
static int dol_cbfn (uint16_t tag, uint8_t *ptr, size_t len, void *priv)
static PyObject * do_dol (struct cp_emv *self, PyObject *args, int create)
static PyObject * cp_dol_read (struct cp_emv *self, PyObject *args)
static PyObject * cp_dol_create (struct cp_emv *self, PyObject *args)
PyMODINIT_FUNC initemv (void)

Variables

static PyMethodDef cp_data_methods []
static PyTypeObject data_pytype
static PyMethodDef cp_app_methods []
static PyTypeObject app_pytype
static PyMethodDef cp_emv_methods []
static PyTypeObject emv_pytype
static PyMethodDef methods []

Define Documentation

#define _INT_CONST ( m,
 )     PyModule_AddIntConstant(m, #c, EMV_ ## c)

Definition at line 891 of file py_emv.c.


Function Documentation

static PyObject* ac2tuple ( const uint8_t *  ptr,
size_t  len 
) [static]

Definition at line 695 of file py_emv.c.

Referenced by cp_gen_ac().

Here is the caller graph for this function:

static PyObject* app_list ( struct cp_emv self  )  [static]

Definition at line 393 of file py_emv.c.

References cp_app::app, cp_app::cur, cp_app::dirty, emv_appsel_pse_first(), emv_appsel_pse_next(), and cp_app::owner.

Referenced by cp_appsel_pse().

Here is the call graph for this function:

Here is the caller graph for this function:

static PyObject* bcd_convert ( const uint8_t *  ptr,
size_t  len 
) [static]

Definition at line 75 of file py_emv.c.

Referenced by cp_data_repr().

Here is the caller graph for this function:

static PyObject* binary_convert ( const uint8_t *  ptr,
size_t  len 
) [static]

Definition at line 90 of file py_emv.c.

Referenced by cp_data_repr().

Here is the caller graph for this function:

static PyObject* cp_app_aid ( struct cp_app self,
PyObject *  args 
) [static]

Definition at line 270 of file py_emv.c.

References EMV_AID_LEN, and emv_app_aid().

Here is the call graph for this function:

static PyObject* cp_app_confirm ( struct cp_app self,
PyObject *  args 
) [static]

Definition at line 309 of file py_emv.c.

References emv_app_confirm().

Here is the call graph for this function:

static void cp_app_dealloc ( struct cp_app self  )  [static]

Definition at line 251 of file py_emv.c.

References emv_app_delete().

Here is the call graph for this function:

static PyObject* cp_app_label ( struct cp_app self,
PyObject *  args 
) [static]

Definition at line 282 of file py_emv.c.

References emv_app_label().

Here is the call graph for this function:

static PyObject* cp_app_pname ( struct cp_app self,
PyObject *  args 
) [static]

Definition at line 291 of file py_emv.c.

References emv_app_pname().

Here is the call graph for this function:

static PyObject* cp_app_prio ( struct cp_app self,
PyObject *  args 
) [static]

Definition at line 300 of file py_emv.c.

References emv_app_prio().

Here is the call graph for this function:

static PyObject* cp_app_rid ( struct cp_app self,
PyObject *  args 
) [static]

Definition at line 259 of file py_emv.c.

References emv_app_rid(), and EMV_RID_LEN.

Here is the call graph for this function:

static PyObject* cp_appsel_pse ( struct cp_emv self,
PyObject *  args 
) [static]

Definition at line 448 of file py_emv.c.

References app_list(), dirty_applist(), emv_appsel_pse(), and set_err().

Here is the call graph for this function:

static PyObject* cp_atc ( struct cp_emv self,
PyObject *  args 
) [static]

Definition at line 685 of file py_emv.c.

References emv_trm_atc().

Here is the call graph for this function:

static PyObject* cp_current_app ( struct cp_emv self,
PyObject *  args 
) [static]

Definition at line 522 of file py_emv.c.

static PyObject* cp_cvm_pin ( struct cp_emv self,
PyObject *  args 
) [static]

Definition at line 664 of file py_emv.c.

References emv_cvm_pin(), and set_err().

Here is the call graph for this function:

static PyObject* cp_data_children ( struct cp_data self,
PyObject *  args 
) [static]

Definition at line 151 of file py_emv.c.

References data_dict(), and emv_data_children().

Here is the call graph for this function:

static void cp_data_dealloc ( struct cp_data self  )  [static]

Definition at line 193 of file py_emv.c.

static PyObject* cp_data_repr ( struct cp_data self  )  [static]

Definition at line 115 of file py_emv.c.

References bcd_convert(), binary_convert(), date_convert(), emv_data(), EMV_DATA_BCD, EMV_DATA_BINARY, EMV_DATA_DATE, emv_data_int(), EMV_DATA_INT, EMV_DATA_TEXT, and emv_data_type().

Here is the call graph for this function:

static PyObject* cp_data_sda ( struct cp_data self,
PyObject *  args 
) [static]

Definition at line 182 of file py_emv.c.

References emv_data_sda().

Here is the call graph for this function:

static PyObject* cp_data_tag ( struct cp_data self,
PyObject *  args 
) [static]

Definition at line 165 of file py_emv.c.

References emv_data_tag().

Here is the call graph for this function:

static PyObject* cp_data_tag_label ( struct cp_data self,
PyObject *  args 
) [static]

Definition at line 170 of file py_emv.c.

References emv_data_tag_label().

Here is the call graph for this function:

static PyObject* cp_data_type ( struct cp_data self,
PyObject *  args 
) [static]

Definition at line 160 of file py_emv.c.

References emv_data_type().

Here is the call graph for this function:

static PyObject* cp_data_value ( struct cp_data self,
PyObject *  args 
) [static]

Definition at line 142 of file py_emv.c.

References emv_data().

Here is the call graph for this function:

static PyObject* cp_dda ( struct cp_emv self,
PyObject *  args 
) [static]

Definition at line 648 of file py_emv.c.

References emv_authenticate_dynamic(), key_cb::exp, get_exp(), get_mod(), key_cb::mod, and set_err().

Here is the call graph for this function:

static PyObject* cp_dol_create ( struct cp_emv self,
PyObject *  args 
) [static]

Definition at line 878 of file py_emv.c.

References do_dol().

Here is the call graph for this function:

static PyObject* cp_dol_read ( struct cp_emv self,
PyObject *  args 
) [static]

Definition at line 873 of file py_emv.c.

References do_dol().

Here is the call graph for this function:

static void cp_emv_dealloc ( struct cp_emv self  )  [static]

Definition at line 386 of file py_emv.c.

References dirty_applist(), and emv_fini().

Here is the call graph for this function:

static int cp_emv_init ( struct cp_emv self,
PyObject *  args,
PyObject *  kwds 
) [static]

Definition at line 345 of file py_emv.c.

References emv_init(), and cp_chipcard::slot.

Here is the call graph for this function:

static PyObject* cp_gen_ac ( struct cp_emv self,
PyObject *  args 
) [static]

Definition at line 721 of file py_emv.c.

References ac2tuple(), emv_generate_ac(), hex_dump(), and set_err().

Here is the call graph for this function:

static PyObject* cp_init ( struct cp_emv self,
PyObject *  args 
) [static]

Definition at line 527 of file py_emv.c.

References emv_app_aip(), emv_app_init(), and set_err().

Here is the call graph for this function:

static PyObject* cp_oatc ( struct cp_emv self,
PyObject *  args 
) [static]

Definition at line 690 of file py_emv.c.

References emv_trm_last_online_atc().

Here is the call graph for this function:

static PyObject* cp_pin_try_counter ( struct cp_emv self,
PyObject *  args 
) [static]

Definition at line 680 of file py_emv.c.

References emv_pin_try_counter().

Here is the call graph for this function:

static PyObject* cp_read_app_data ( struct cp_emv self,
PyObject *  args 
) [static]

Definition at line 576 of file py_emv.c.

References data_list(), emv_read_app_data(), emv_retrieve_records(), and set_err().

Here is the call graph for this function:

static PyObject* cp_sda ( struct cp_emv self,
PyObject *  args 
) [static]

Definition at line 632 of file py_emv.c.

References emv_authenticate_static_data(), key_cb::exp, get_exp(), get_mod(), key_cb::mod, and set_err().

Here is the call graph for this function:

static PyObject* cp_select_aid ( struct cp_emv self,
PyObject *  args 
) [static]

Definition at line 481 of file py_emv.c.

References emv_app_select_aid(), set_current(), and set_err().

Here is the call graph for this function:

static PyObject* cp_select_aid_next ( struct cp_emv self,
PyObject *  args 
) [static]

Definition at line 501 of file py_emv.c.

References cp_app::app, emv_app_select_aid_next(), set_current(), and set_err().

Here is the call graph for this function:

static PyObject* cp_select_pse ( struct cp_emv self,
PyObject *  args 
) [static]

Definition at line 462 of file py_emv.c.

References cp_app::app, emv_app_select_pse(), set_current(), and set_err().

Here is the call graph for this function:

static PyObject * data_dict ( struct cp_emv owner,
emv_data_t elem,
unsigned int  nmemb 
) [static]

Definition at line 227 of file py_emv.c.

References cp_data::data, emv_data_tag(), and cp_data::owner.

Referenced by cp_data_children().

Here is the call graph for this function:

Here is the caller graph for this function:

static PyObject* data_list ( struct cp_emv owner,
emv_data_t elem,
unsigned int  nmemb 
) [static]

Definition at line 555 of file py_emv.c.

References cp_data::data, and cp_data::owner.

Referenced by cp_read_app_data().

Here is the caller graph for this function:

static PyObject* date_convert ( const uint8_t *  ptr,
size_t  len 
) [static]

Definition at line 107 of file py_emv.c.

Referenced by cp_data_repr().

Here is the caller graph for this function:

static void dirty_applist ( struct cp_emv self  )  [static]

Definition at line 364 of file py_emv.c.

References cp_app::app, and cp_app::dirty.

Referenced by cp_appsel_pse(), and cp_emv_dealloc().

Here is the caller graph for this function:

static PyObject* do_dol ( struct cp_emv self,
PyObject *  args,
int  create 
) [static]

Definition at line 837 of file py_emv.c.

References dol_cb::dict, dol_cbfn(), emv_construct_dol(), and dol_cb::list.

Referenced by cp_dol_create(), and cp_dol_read().

Here is the call graph for this function:

Here is the caller graph for this function:

static int dol_cbfn ( uint16_t  tag,
uint8_t *  ptr,
size_t  len,
void *  priv 
) [static]

Definition at line 795 of file py_emv.c.

References dol_cb::dict, and dol_cb::list.

Referenced by do_dol().

Here is the caller graph for this function:

static const uint8_t* get_exp ( void *  priv,
unsigned int  idx,
size_t *  len 
) [static]

Definition at line 613 of file py_emv.c.

References key_cb::exp.

Referenced by cp_dda(), and cp_sda().

Here is the caller graph for this function:

static const uint8_t* get_mod ( void *  priv,
unsigned int  idx,
size_t *  len 
) [static]

Definition at line 594 of file py_emv.c.

References key_cb::mod.

Referenced by cp_dda(), and cp_sda().

Here is the caller graph for this function:

PyMODINIT_FUNC initemv ( void   ) 

Definition at line 892 of file py_emv.c.

References _INT_CONST.

static int set_current ( struct cp_emv self  )  [static]

Definition at line 422 of file py_emv.c.

References cp_app::app, cp_app::cur, cp_app::dirty, emv_current_app(), cp_app::owner, and set_err().

Referenced by cp_select_aid(), cp_select_aid_next(), and cp_select_pse().

Here is the call graph for this function:

Here is the caller graph for this function:

static void set_err ( emv_t  e  )  [static]

Definition at line 36 of file py_emv.c.

References code, EMV_ERR_CCID, EMV_ERR_SYSTEM, emv_error(), emv_error_additional(), emv_error_string(), emv_error_type(), and str.

Referenced by cp_appsel_pse(), cp_cvm_pin(), cp_dda(), cp_gen_ac(), cp_init(), cp_read_app_data(), cp_sda(), cp_select_aid(), cp_select_aid_next(), cp_select_pse(), and set_current().

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

PyTypeObject app_pytype [static]
Initial value:
 {
        PyObject_HEAD_INIT(NULL)
        .tp_name = "emv.app",
        .tp_basicsize = sizeof(struct cp_app),
        .tp_flags = Py_TPFLAGS_DEFAULT,
        .tp_new = PyType_GenericNew,
        .tp_dealloc = (destructor)cp_app_dealloc,
        .tp_methods = cp_app_methods,
        .tp_doc = "EMV application",
}

Definition at line 334 of file py_emv.c.

PyMethodDef cp_app_methods[] [static]
Initial value:
 {
        {"rid",(PyCFunction)cp_app_rid, METH_NOARGS,
                "app.rid() - Registered application ID"},
        {"aid",(PyCFunction)cp_app_aid, METH_NOARGS,
                "app.aid() - Application ID"},
        {"label",(PyCFunction)cp_app_label, METH_NOARGS,
                "app.name() - Label"},
        {"pname",(PyCFunction)cp_app_pname, METH_NOARGS,
                "app.pname() - Preferred name"},
        {"prio",(PyCFunction)cp_app_prio, METH_NOARGS,
                "app.prio() - Application priority"},
        {"confirm",(PyCFunction)cp_app_confirm, METH_NOARGS,
                "app.confirm() - Application confirmation indicator"},
        {NULL, }
}

Definition at line 318 of file py_emv.c.

PyMethodDef cp_data_methods[] [static]
Initial value:
 {
        {"type",(PyCFunction)cp_data_type, METH_NOARGS,
                "data.type() - Data element type"},
        {"tag",(PyCFunction)cp_data_tag, METH_NOARGS,
                "data.type() - Data element BER tag"},
        {"tag_label",(PyCFunction)cp_data_tag_label, METH_NOARGS,
                "data.type() - Data element tag name if known, None if not"},
        {"children",(PyCFunction)cp_data_children, METH_NOARGS,
                "data.children() - Returns dictionary of child elements"},
        {"value",(PyCFunction)cp_data_value, METH_NOARGS,
                "data.value() - Retrieve value of data element"},
        {"sda",(PyCFunction)cp_data_sda, METH_NOARGS,
                "data.sda() - Returns True if SDA protected"},
        {NULL,},
}

Definition at line 199 of file py_emv.c.

PyMethodDef cp_emv_methods[] [static]

Definition at line 744 of file py_emv.c.

PyTypeObject data_pytype [static]
Initial value:
 {
        PyObject_HEAD_INIT(NULL)
        .tp_name = "emv.data",
        .tp_basicsize = sizeof(struct cp_data),
        .tp_flags = Py_TPFLAGS_DEFAULT,
        .tp_new = PyType_GenericNew,
        .tp_dealloc = (destructor)cp_data_dealloc,
        .tp_methods = cp_data_methods,
        .tp_repr = (reprfunc)cp_data_repr,
        .tp_doc = "EMV data element",
}

Definition at line 215 of file py_emv.c.

PyTypeObject emv_pytype [static]
Initial value:
 {
        PyObject_HEAD_INIT(NULL)
        .tp_name = "emv.card",
        .tp_basicsize = sizeof(struct cp_emv),
        .tp_flags = Py_TPFLAGS_DEFAULT,
        .tp_new = PyType_GenericNew,
        .tp_init = (initproc)cp_emv_init,
        .tp_dealloc = (destructor)cp_emv_dealloc,
        .tp_methods = cp_emv_methods,
        .tp_doc = "EMV chip",
}

Definition at line 778 of file py_emv.c.

PyMethodDef methods[] [static]
Initial value:
 {
        {"dol_read",(PyCFunction)cp_dol_read, METH_VARARGS,
                "dol_read(str) - returns list of (tag, len) tuples"},
        {"dol_create",(PyCFunction)cp_dol_create, METH_VARARGS,
                "dol_create(str) - returns the constructed binary data item"},
        {NULL, }
}

Definition at line 883 of file py_emv.c.

Generated on Sun Jan 2 08:35:55 2011 for ccid-utils by  doxygen 1.6.3