More instructions, and pycsc patch

git-svn-id: svn+ssh://localhost/home/henryk/svn/cyberflex-shell/trunk@99 f711b948-2313-0410-aaa9-d29f33439f0b
This commit is contained in:
hploetz 2006-07-12 05:21:42 +00:00
parent 6fa60ca512
commit 4280fb0731
2 changed files with 121 additions and 3 deletions

47
README
View File

@ -1,8 +1,49 @@
This is a simple smartcard shell that has evolved from a more convenient way
to enter APDUs (compare: pcsc-tool scriptor) through a tool to open a secure
to enter APDUs (compare: pcsc-tools scriptor) through a tool to open a secure
channel to a cyberflex card (hence the name) to a more generic tool to act
on smart-cards.
It is written in Python (you might need 2.4 or up) and needs pycsc to
communicate with the smart card terminal (with PC/SC, e.g. pcsc-lite).
It is written in Python (you might need 2.4 or up) and needs pycsc 0.3 (or up)
to communicate with the smart card terminal (with PC/SC, e.g. pcsc-lite).
You can get pycsc from http://homepage.mac.com/jlgiraud/pycsc/Pycsc.html
NOTE: pycsc might not compile out of the box with current pcsc-lite (e.g.
1.3.*). You should use the included pycsc-0.0.3_new-pcsc.patch in that
case.
The shell has only been tested on a Linux system but should be platform
independent, if you have Python, PC/SC and pycsc for your target platform.
I am however unable to give support for any platform but Linux.
Some of the shell functionality (history, tab-completion, etc.) is
provided by python's readline module which is not available for all
platforms, IIRC.
INSTRUCTIONS:
Simply start cyberflex-shell.py. You may also call it with parameter -l
to list all detected readers or parameter -r to select one of the readers.
Within the shell you may enter APDUs (in hex, case ignored, white space
ignored) and press enter to send them and see the response.
Use the commands connect, disconnect or reconnect to open, close or open-
and-close the connection to a smart-card. This is especially helpful when
you want to change the card without exiting from the shell.
For some card types there are card drivers provided in the cards/ directory,
and the shell will try to automatically load the right driver(s). (I made
the story rather complicated, see cards/__init__.py.)
You should be able to load and unload drivers using the driver_load and
driver_unload commands at will, but that is a new and experimental feature.
Most card drivers provide additional commands to simplify working with
the card in question. Use the help command to see the set of currently
available commands.
Note that this is an educational tool and not for security purposes. All
commands are written to the shell history (${HOME}/.cyberflex-shell.history)
so be aware that your PINs and other sensitive data might end up on your
hard-disk.
Have fun
-- Henryk Plötz <henryk@ploetzli.ch>, July 2006

View File

@ -0,0 +1,77 @@
diff -u pycsc-0.0.3_/pycsc.c pycsc-0.0.3/pycsc.c
--- pycsc-0.0.3_/pycsc.c 2004-06-21 02:54:29.000000000 +0200
+++ pycsc-0.0.3/pycsc.c 2006-05-03 04:51:51.000000000 +0200
@@ -23,7 +23,7 @@
#endif
/* Internal tool */
-static LONG getReaderList(SCARDCONTEXT hContext, LPSTR* pmszReaders,
+static LONG getReaderList(SCARDCONTEXT hContext, LPTSTR* pmszReaders,
DWORD *pdwReaders);
#ifdef _WINDOWS_
@@ -256,14 +256,14 @@
BYTE pbAtr[MAX_ATR_SIZE];
DWORD dwAtrLen, dwProt=0, dwState=0;
DWORD dwReaderLen;
- LPSTR pcReaders;
+ LPTSTR pcReaders;
LONG rv;
PyObject *ret_value;
dwReaderLen = 10000;
dwAtrLen = 0;
/* Dry run to get the length of the reader name */
- rv = SCardStatus( object->hCard, (LPSTR) NULL, &dwReaderLen,
+ rv = SCardStatus( object->hCard, (LPTSTR) NULL, &dwReaderLen,
&dwState, &dwProt, NULL, &dwAtrLen );
if ( rv != SCARD_S_SUCCESS )
@@ -499,8 +499,8 @@
static PyObject * pycscobject_pycsc(PyObject *self, PyObject * args, PyObject *keywds)
{
/* No reader name in args, connect to the first reader */
- LPSTR mszReaders = NULL;
- LPSTR szRequestedReader = "";
+ LPTSTR mszReaders = NULL;
+ LPTSTR szRequestedReader = "";
DWORD dwReaders;
DWORD dwMode = SCARD_SHARE_SHARED;
DWORD eProtocol; /* effective protocol */
@@ -611,8 +611,8 @@
static PyObject * pycscobject_listReader(PyObject *self, PyObject * args)
{
SCARDCONTEXT hContext;
- LPSTR mszReaders = NULL;
- LPSTR mszReadersScan;
+ LPTSTR mszReaders = NULL;
+ LPTSTR mszReadersScan;
DWORD dwReaders;
LONG rv;
@@ -941,10 +941,10 @@
}
/* Internal tool */
-static LONG getReaderList(SCARDCONTEXT hContext, LPSTR* pmszReaders, DWORD *pdwReaders)
+static LONG getReaderList(SCARDCONTEXT hContext, LPTSTR* pmszReaders, DWORD *pdwReaders)
{
- LPCSTR mszGroups = 0;
- LPSTR mszReaders = NULL;
+ LPCTSTR mszGroups = 0;
+ LPTSTR mszReaders = NULL;
LONG dwReaders;
LONG rv;
diff -u pycsc-0.0.3_/setup.py pycsc-0.0.3/setup.py
--- pycsc-0.0.3_/setup.py 2004-01-19 17:09:32.000000000 +0100
+++ pycsc-0.0.3/setup.py 2006-05-03 04:48:34.000000000 +0200
@@ -31,7 +31,7 @@
include = []
else:
libs = ["pcsclite"]
- include = ["/usr/include/pcsc"]
+ include = ["/usr/include/PCSC"]
setup(name="pycsc", version="0.3",