[Pcsclite-cvs-commit] CVS muscleTool

CVS User ohme-guest ludovic.rousseau at free.fr
Sun Aug 7 15:52:51 UTC 2005


Update of /cvsroot/muscleapps/muscleTool
In directory haydn:/tmp/cvs-serv10211

Modified Files:
	AUTHORS ChangeLog INSTALL Makefile.am README configure.in 
	help.c help.h muscleTool.c muscleTool.h parser.y scanner.l 
Added Files:
	Install.w32 reconf 
Log Message:
- genkeys can generate RSA, DSA and RSA-CRT keys
- crypt supports any combination of possible key - cipher - signature
  algorithms Java Card 2.1.1 offers and the card is capable
- crypt can read from file and write output to file
- Included man page in Makefile.am
- improved autoconf checks
- general usability improved
- support for version 2.0 of MuscleCard library, MuscleCard Plug-In, Card 
  Edge 2.0
  - enter PIN with keypad
  - deletekey command
  - deletepin command
  - resume supports returns new capabilities
  - AES support
  - extended format command


--- /cvsroot/muscleapps/muscleTool/AUTHORS	2004/08/26 18:03:04	1.1
+++ /cvsroot/muscleapps/muscleTool/AUTHORS	2005/08/07 15:52:50	1.2
@@ -1,3 +1,4 @@
 David Corcoran <corcoran at linuxnet.com>
 Ludovic Rousseau <ludovic.rousseau at free.fr>
 Toni Andjelkovic <toni at soth.at>
+Karsten Ohme <k_o_ at users.sourceforge.net>
--- /cvsroot/muscleapps/muscleTool/ChangeLog	2004/08/26 18:04:10	1.1
+++ /cvsroot/muscleapps/muscleTool/ChangeLog	2005/08/07 15:52:50	1.2
@@ -1,24 +1,37 @@
 History
 =======
 
+2.0.0 - 27 May 2005, Karsten Ohme
+	- genkeys can generate RSA, DSA and RSA-CRT keys
+	- crypt supports any combination of possible key - cipher - signature
+	  algorithms Java Card 2.1.1 offers and the card is capable
+	- crypt can read from file and write output to file
+	- Included man page in Makefile.am
+	- improved autoconf checks
+	- support for version 2.0 of MuscleCard library, MuscleCard Plug-In, Card Edge 2.0
+	  - enter PIN with keypad
+	  - deletekey command
+	  - deletepin command
+	  - resume supports returns new capabilities
+	  - extended format command
+
 1.0.0 - Sa Aug 14 02:51:01 CEST 2004, Toni Andjelkovic
 	- autoconf/automake configuration
 	- lex/yacc parser
 	- separate help functions
 	- optional GNU readline support
 
-                                                                                                    
-0.9.2 - 30 september 2003, Ludovic Rousseau
-        - Corcoran: COPYING: removed advertising clause
-    - link with musclecard instead of pcsclite (the separation occured
+
+0.9.2 - 30 September 2003, Ludovic Rousseau
+	- Corcoran: COPYING: removed advertising clause
+	- link with musclecard instead of pcsclite (the separation occured
       in pcsc-lite-1.2.0-rc2)
-        - replace 0 by NULL where relevant
-        - check if second argument of 'verify [number] [value]' command is
-          non NULL
-        - added error checking to ListObjects
-        - added man page
-                                                                                                    
+	- replace 0 by NULL where relevant
+	- check if second argument of 'verify [number] [value]' command is
+      non NULL
+	- added error checking to ListObjects
+	- added man page
+
 0.9.1a - ??, David Corcoran
-                                                                                                    
- $Id: ChangeLog,v 1.1 2004/08/26 18:04:10 rousseau Exp $
+
 
--- /cvsroot/muscleapps/muscleTool/INSTALL	2004/08/26 18:03:04	1.1
+++ /cvsroot/muscleapps/muscleTool/INSTALL	2005/08/07 15:52:50	1.2
@@ -1,18 +1,236 @@
-How to build and install the package:
+Installation Instructions
+*************************
 
-	$ ./configure
-	$ make install
+Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005 Free
+Software Foundation, Inc.
 
-installs the package in the default prefix (/usr/local), so the resulting
-muscleTool binary is installed as /usr/local/bin/muscleTool.
+This file is free documentation; the Free Software Foundation gives
+unlimited permission to copy, distribute and modify it.
 
-If the musclecard library has been installed in a non-default directory,
-set the environment variable PKG_CONFIG_PATH accordingly and re-run
-"configure":
+Basic Installation
+==================
+
+These are generic installation instructions.
+
+   The `configure' shell script attempts to guess correct values for
+various system-dependent variables used during compilation.  It uses
+those values to create a `Makefile' in each directory of the package.
+It may also create one or more `.h' files containing system-dependent
+definitions.  Finally, it creates a shell script `config.status' that
+you can run in the future to recreate the current configuration, and a
+file `config.log' containing compiler output (useful mainly for
+debugging `configure').
+
+   It can also use an optional file (typically called `config.cache'
+and enabled with `--cache-file=config.cache' or simply `-C') that saves
+the results of its tests to speed up reconfiguring.  (Caching is
+disabled by default to prevent problems with accidental use of stale
+cache files.)
+
+   If you need to do unusual things to compile the package, please try
+to figure out how `configure' could check whether to do them, and mail
+diffs or instructions to the address given in the `README' so they can
+be considered for the next release.  If you are using the cache, and at
+some point `config.cache' contains results you don't want to keep, you
+may remove or edit it.
+
+   The file `configure.ac' (or `configure.in') is used to create
+`configure' by a program called `autoconf'.  You only need
+`configure.ac' if you want to change it or regenerate `configure' using
+a newer version of `autoconf'.
+
+The simplest way to compile this package is:
+
+  1. `cd' to the directory containing the package's source code and type
+     `./configure' to configure the package for your system.  If you're
+     using `csh' on an old version of System V, you might need to type
+     `sh ./configure' instead to prevent `csh' from trying to execute
+     `configure' itself.
+
+     Running `configure' takes awhile.  While running, it prints some
+     messages telling which features it is checking for.
+
+  2. Type `make' to compile the package.
+
+  3. Optionally, type `make check' to run any self-tests that come with
+     the package.
+
+  4. Type `make install' to install the programs and any data files and
+     documentation.
+
+  5. You can remove the program binaries and object files from the
+     source code directory by typing `make clean'.  To also remove the
+     files that `configure' created (so you can compile the package for
+     a different kind of computer), type `make distclean'.  There is
+     also a `make maintainer-clean' target, but that is intended mainly
+     for the package's developers.  If you use it, you may have to get
+     all sorts of other programs in order to regenerate files that came
+     with the distribution.
+
+Compilers and Options
+=====================
+
+Some systems require unusual options for compilation or linking that the
+`configure' script does not know about.  Run `./configure --help' for
+details on some of the pertinent environment variables.
+
+   You can give `configure' initial values for configuration parameters
+by setting variables in the command line or in the environment.  Here
+is an example:
+
+     ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
+
+   *Note Defining Variables::, for more details.
+
+Compiling For Multiple Architectures
+====================================
+
+You can compile the package for more than one kind of computer at the
+same time, by placing the object files for each architecture in their
+own directory.  To do this, you must use a version of `make' that
+supports the `VPATH' variable, such as GNU `make'.  `cd' to the
+directory where you want the object files and executables to go and run
+the `configure' script.  `configure' automatically checks for the
+source code in the directory that `configure' is in and in `..'.
+
+   If you have to use a `make' that does not support the `VPATH'
+variable, you have to compile the package for one architecture at a
+time in the source code directory.  After you have installed the
+package for one architecture, use `make distclean' before reconfiguring
+for another architecture.
+
+Installation Names
+==================
+
+By default, `make install' will install the package's files in
+`/usr/local/bin', `/usr/local/man', etc.  You can specify an
+installation prefix other than `/usr/local' by giving `configure' the
+option `--prefix=PREFIX'.
+
+   You can specify separate installation prefixes for
+architecture-specific files and architecture-independent files.  If you
+give `configure' the option `--exec-prefix=PREFIX', the package will
+use PREFIX as the prefix for installing programs and libraries.
+Documentation and other data files will still use the regular prefix.
+
+   In addition, if you use an unusual directory layout you can give
+options like `--bindir=DIR' to specify different values for particular
+kinds of files.  Run `configure --help' for a list of the directories
+you can set and what kinds of files go in them.
+
+   If the package supports it, you can cause programs to be installed
+with an extra prefix or suffix on their names by giving `configure' the
+option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
+
+Optional Features
+=================
+
+Some packages pay attention to `--enable-FEATURE' options to
+`configure', where FEATURE indicates an optional part of the package.
+They may also pay attention to `--with-PACKAGE' options, where PACKAGE
+is something like `gnu-as' or `x' (for the X Window System).  The
+`README' should mention any `--enable-' and `--with-' options that the
+package recognizes.
+
+   For packages that use the X Window System, `configure' can usually
+find the X include and library files automatically, but if it doesn't,
+you can use the `configure' options `--x-includes=DIR' and
+`--x-libraries=DIR' to specify their locations.
+
+Specifying the System Type
+==========================
+
+There may be some features `configure' cannot figure out automatically,
+but needs to determine by the type of machine the package will run on.
+Usually, assuming the package is built to be run on the _same_
+architectures, `configure' can figure that out, but if it prints a
+message saying it cannot guess the machine type, give it the
+`--build=TYPE' option.  TYPE can either be a short name for the system
+type, such as `sun4', or a canonical name which has the form:
+
+     CPU-COMPANY-SYSTEM
+
+where SYSTEM can have one of these forms:
+
+     OS KERNEL-OS
+
+   See the file `config.sub' for the possible values of each field.  If
+`config.sub' isn't included in this package, then this package doesn't
+need to know the machine type.
+
+   If you are _building_ compiler tools for cross-compiling, you should
+use the `--target=TYPE' option to select the type of system they will
+produce code for.
+
+   If you want to _use_ a cross compiler, that generates code for a
+platform different from the build platform, you should specify the
+"host" platform (i.e., that on which the generated programs will
+eventually be run) with `--host=TYPE'.
+
+Sharing Defaults
+================
+
+If you want to set default values for `configure' scripts to share, you
+can create a site shell script called `config.site' that gives default
+values for variables like `CC', `cache_file', and `prefix'.
+`configure' looks for `PREFIX/share/config.site' if it exists, then
+`PREFIX/etc/config.site' if it exists.  Or, you can set the
+`CONFIG_SITE' environment variable to the location of the site script.
+A warning: not all `configure' scripts look for a site script.
+
+Defining Variables
+==================
+
+Variables not defined in a site shell script can be set in the
+environment passed to `configure'.  However, some packages may run
+configure again during the build, and the customized values of these
+variables may be lost.  In order to avoid this problem, you should set
+them in the `configure' command line, using `VAR=value'.  For example:
+
+     ./configure CC=/usr/local2/bin/gcc
+
+causes the specified `gcc' to be used as the C compiler (unless it is
+overridden in the site shell script).  Here is a another example:
+
+     /bin/bash ./configure CONFIG_SHELL=/bin/bash
+
+Here the `CONFIG_SHELL=/bin/bash' operand causes subsequent
+configuration-related scripts to be executed by `/bin/bash'.
+
+`configure' Invocation
+======================
+
+`configure' recognizes the following options to control how it operates.
+
+`--help'
+`-h'
+     Print a summary of the options to `configure', and exit.
+
+`--version'
+`-V'
+     Print the version of Autoconf used to generate the `configure'
+     script, and exit.
+
+`--cache-file=FILE'
+     Enable the cache: use and save the results of the tests in FILE,
+     traditionally `config.cache'.  FILE defaults to `/dev/null' to
+     disable caching.
+
+`--config-cache'
+`-C'
+     Alias for `--cache-file=config.cache'.
+
+`--quiet'
+`--silent'
+`-q'
+     Do not print messages saying which checks are being made.  To
+     suppress all normal output, redirect it to `/dev/null' (any error
+     messages will still be shown).
+
+`--srcdir=DIR'
+     Look for the package's source code in directory DIR.  Usually
+     `configure' can determine that directory automatically.
 
-	$ PKG_CONFIG_PATH=/usr/local/pcsc/lib/pkgconfig ./configure
-
-Optional GNU readline support can be enabled with:
-
-	$ ./configure --enable-readline
+`configure' also accepts some other, not widely useful, options.  Run
+`configure --help' for more details.
 
--- /cvsroot/muscleapps/muscleTool/Makefile.am	2004/08/26 20:13:28	1.2
+++ /cvsroot/muscleapps/muscleTool/Makefile.am	2005/08/07 15:52:50	1.3
@@ -2,13 +2,15 @@
 
 bin_PROGRAMS = muscleTool
 
+SUBDIRS = man
+
 BUILT_SOURCES = parser.h
 AM_YFLAGS = -d
 muscleTool_SOURCES =  parser.y parser.h scanner.l help.c muscleTool.c
 muscleTool_CPPFLAGS = $(AM_CPPFLAGS) $(MUSCLECARD_CFLAGS)
 muscleTool_LDADD = $(AM_CPPFLAGS) $(MUSCLECARD_LIBS)
 
-EXTRA_DIST = bootstrap ChangeLog.cvs
+EXTRA_DIST = bootstrap ChangeLog.cvs win32
 
 DISTCLEANFILES = parser.h parser.c scanner.c
 MAINTAINERCLEANFILES = \
@@ -24,5 +26,7 @@
 
 ChangeLog.cvs:
 	rcs2log | perl -pe 's/rousseau /Ludovic Rousseau /; \
-	s/corcoran /David Corcoran /; s/oznet /Chris Osgood/' > $@
+	s/corcoran-guest /David Corcoran /; \
+	s/tony.guest /Toni Andjelkovic /; \
+	s/ohme-guest /Karsten Ohme /' > $@
 
--- /cvsroot/muscleapps/muscleTool/README	2004/08/26 18:08:53	1.4
+++ /cvsroot/muscleapps/muscleTool/README	2005/08/07 15:52:50	1.5
@@ -1,8 +1,89 @@
-Title  : MuscleTool
-Authors: David Corcoran, Ludovic Rousseau, Toni Andjelkovic
-License: See file COPYING
+******************************************************
+Title    : MuscleTool
+Authors  : David Corcoran
+           Ludovic Rousseau
+           Toni Andjelkovic
+           Karsten Ohme
+License  : See file COPYING
+Requires : PC/SC Lite
+           MuscleCard
+           MCardPlugin
+******************************************************
 
-This is a command line personalization tool for MuscleCard enabled smartcards.  
+This is a command line tool for MuscleCard
+enabled smartcards. The main function is to format a smart
+card, but it offers some additional MuscleCard
+functionality.
+There are key, PIN, object and general related
+functions.
 
-http://www.musclecard.com
+There are two versions depending of the compile switch VERSION2. 
+If VERSION2 is defined some new features are enabled for which 
+you need the new version 2.0 of the MuscleCard library, MuscleCard 
+Plug-In and CardEdge Applet.
+
+You can generate keys, list keys, import and export
+and use keys for cryptographic operations.
+The last import and export commands are at the moment only for testing,
+because the keys are imported and exported as key blobs, an
+internal format of the application on the smart card. You
+will need a conversion utility for getting a standard key format.
+Maybe a next release will enable with the OpenSSL library a
+usable key import and export. The crypto operations does allow also the 
+encryption of a given file in addition to a supplied user string.
+With the new version, you can also delete keys.
+
+You can create, read, write object, delete and list objects.
+
+You can create, list, change, unblock and verify and PINs.
+With the new version ypu can also delete PINs.
+
+General commands are the status command, the connect and
+release command and maybe very informative the resume command,
+which shows the capabilities of your card.
+
+You can get a short help with the "help".
+If you want to have a help for a command call "help commmand".
+
+
+Installation:
+
+Generel install instructions are in the file INSTALL.
+Installation instructions for Windows are in the file Install.w32
+
+./configure
+make
+make install
+
+If the configure file is not there you must run the script ./reconf
+
+make install installs the package in the default prefix (/usr/local), so the resulting
+muscleTool binary is installed as /usr/local/bin/muscleTool.
+
+For compiling MuscleTool you must have pkg-config installed.
+Usually pkg-config looks in the /usr/local/lib/pkgconfig directory.
+There should placed a file libmusclecard.pc containing information
+about the required libraries, header files and other information.
+If pkgconfig fails and your pkgconfig directory is at a
+different location you have to set the environment variable
+PKG_CONFIG_PATH. E.g. the Debian path for pkgconfig is /usr/lib/pkgconfig.
+
+Optional GNU readline support can be enabled with:
+
+./configure --enable-readline
+
+Other useful options are:
+
+./configure --prefix=/usr Defines the installation target for everything to
+    start with /usr instead of the default /usr/local
+./configure --help gives you a help of possible options.
+
+To compile the new MuscleTool version enable it with:
+
+./configure VERSION2
+
+For more information please refer to the mailing list
+http://lists.drizzle.com/mailman/listinfo/muscle
+
+MUSCLE Smartcard Developers: http://www.musclecard.com
 
--- /cvsroot/muscleapps/muscleTool/configure.in	2004/08/26 17:58:34	1.1
+++ /cvsroot/muscleapps/muscleTool/configure.in	2005/08/07 15:52:50	1.2
@@ -1,8 +1,9 @@
 # Require autoconf 2.52
 AC_PREREQ(2.52)
 
-AC_INIT(muscleTool, 1.0.0)
+AC_INIT(muscleTool, 2.0.0)
 AC_CONFIG_AUX_DIR(aux)
+AC_COPYRIGHT(COPYING)
 AM_INIT_AUTOMAKE([no-define])
 
 # check programs
@@ -15,20 +16,20 @@
 # check header files
 AC_HEADER_STDC
 AC_HEADER_STAT
-AC_CHECK_HEADER(stdio.h)
-AC_CHECK_HEADER(errno.h)
+AC_CHECK_HEADER(stdio.h, , [],
+[AC_MSG_ERROR([stdio.h not found.])])
+AC_CHECK_HEADER(errno.h, , [],
+[AC_MSG_ERROR([error.h not found.])])
 
 # check library functions
 AC_FUNC_STAT
 AC_FUNC_MALLOC
-AC_CHECK_FUNC(atoi)
-AC_CHECK_FUNC(fopen)
-AC_CHECK_FUNC(memcpy)
-AC_CHECK_FUNC(memset)
-AC_CHECK_FUNC(scanf)
-AC_CHECK_FUNC(snprintf)
-AC_CHECK_FUNC(strdup)
-PKG_CHECK_MODULES(MUSCLECARD, libmusclecard)
+AC_CHECK_FUNCS(atoi putenv setenv fopen memcpy memset scanf snprintf strdup strtoul, [],
+[AC_MSG_ERROR([Necessary function is not supported.])])
+
+dnl look for MuscleCard
+PKG_CHECK_MODULES(MUSCLECARD, libmusclecard, [],
+[AC_MSG_ERROR([libmusclecard not found, install libmusclecard 1.2.9-beta7 or later])])
 
 # special check for pthread support
 ACX_PTHREAD(
@@ -63,7 +64,25 @@
   fi
 fi
 
+AC_ARG_ENABLE(version2,
+[  --enable-version2          enable version 2 support.],
+[ case "${enableval}" in
+  yes)
+    version2=true ;;
+  no)
+    version2=false ;;
+  *) AC_MSG_ERROR([bad value ${enableval} for --enable-version2]) ;;
+ esac], [version2=false])
+
+if test x${version2} = xtrue ; then
+  AC_DEFINE(VERSION2, 1, [enable version 2 support.])
+fi
+
+AC_MSG_RESULT([Version 2.0 support enabled                  : $version2]) 
+
 AC_OUTPUT([
 Makefile
+man/Makefile
+man/muscleTool.1
 ])
 
--- /cvsroot/muscleapps/muscleTool/help.c	2004/08/26 17:59:48	1.1
+++ /cvsroot/muscleapps/muscleTool/help.c	2005/08/07 15:52:50	1.2
@@ -7,7 +7,7 @@
  *  Toni Andjelkovic <toni at soth.at>
  *  Ludovic Rousseau <ludovic.rousseau at free.fr>
  *
- * $Id: help.c,v 1.1 2004/08/26 17:59:48 rousseau Exp $
+ * $Id: help.c,v 1.2 2005/08/07 15:52:50 ohme-guest Exp $
  */
 
 #include <stdio.h>
@@ -32,6 +32,7 @@
 	"     changepin     Change a pin",
 	"     unblock       Unblock a pin",
 	"     listpins      List the pins",
+	"     deletepin     Deletes a pin",
 	"",
 	"Key related functions:",
 	"----------------------------------------------------",
@@ -39,7 +40,9 @@
 	"     exportkey     Export a key",
 	"     importkey     Import a key",
 	"     genkeys       Generate keys",
-	"     crypt         Perform a cipher operation",
+	"     deletekey     Deletes a key",
+	"     crypt         Perform a cipher operation on user input",
+	"     filecrypt     Perform a cipher operation on a file",
 	"",
 	"General functions:",
 	"----------------------------------------------------",
@@ -55,12 +58,14 @@
 	"     help          Show this help text",
 	"     exit          Exit the program",
 	"",
-	"Strings are either unquoted and alphanumeric or quoted",
-	"with \"\", in which case they may contain any character:",
+	"Strings are quoted with \"\":",
 	"",
-	"\tverify 0 foobar",
 	"\tverify 0 \"foo bar\"",
 	"",
+	"Use help [name] to get help about a muscleTool function:",
+	"",
+	"\thelp crypt",
+	"",
 	NULL
 };
 
@@ -165,9 +170,9 @@
 
 static char *help_exportkey_txt[] = {
 	"Export a key.",
-	"Usage: exportkey pin path",
+	"Usage: exportkey keynum path",
 	"Arguments:",
-	"    pin         pin number (num)",
+	"    keynum      key number (num)",
 	"    path        path to local file (string)",
 	NULL
 };
@@ -183,16 +188,28 @@
 
 static char *help_genkeys_txt[] = {
 	"Generate keys.",
-	"Usage: genkeys",
+	"Usage: genkeys algorithm keysize ",
+	"Arguments:",
+	"    algorithm   algorithm rsa, dsa or rsacrt (string)",
+	"    keysize     size of key (num)",
 	NULL
 };
 
 static char *help_crypt_txt[] = {
-	"Perform a cipher operation.",
-	"Usage: crypt keynum hexstr",
+	"Perform a cipher operation on user supplied text.",
+	"Usage: crypt keynum",
 	"Arguments:",
 	"    keynum      key number (num)",
-	"    hexstr      hex string (str)",
+	NULL
+};
+
+static char *help_filecrypt_txt[] = {
+	"Perform a cipher operation on a file.",
+	"Usage: crypt keynum infilename outfilename",
+	"Arguments:",
+	"    keynum      key number (num)",
+	"    filename    infilename (str)",
+	"    filename    outfilename (str)",
 	NULL
 };
 
@@ -218,6 +235,22 @@
 	NULL
 };
 
+static char *help_deletekey_txt[] = {
+	"Delete a key.",
+	"Usage: deletekey keynum",
+	"Arguments:",
+	"    keynum     key number (num)",
+	NULL
+};
+
+static char *help_deletepin_txt[] = {
+	"Delete a PIN.",
+	"Usage: deletepin pin",
+	"Arguments:",
+	"    pin        pin number (num)",
+	NULL
+};
+
 static char *help_resume_txt[] = {
 	"Get the token capabilities.",
 	"",
@@ -227,6 +260,7 @@
 	"     rsa           List RSA capabilities",
 	"     dsa           List DSA capabilities",
 	"     des           List DES capabilities",
+	"     aes           List AES capabilities",
 	"     3des          List 3DES capabilities",
 	"     keys          List key capabilities",
 	"     pins          List PIN capabilities",
@@ -258,6 +292,12 @@
 	NULL
 };
 
+static char *help_resume_aes_txt[] = {
+	"List AES capabilities.",
+	"Usage: resume aes",
+	NULL
+};
+
 static char *help_resume_3des_txt[] = {
 	"List 3DES capabilities.",
 	"Usage: resume 3des",
@@ -348,6 +388,10 @@
 	print(help_delete_txt);
 }
 
+void help_deletekey() {
+	print(help_deletekey_txt);
+}
+
 void help_write()
 {
 	print(help_write_txt);
@@ -362,7 +406,12 @@
 {
 	print(help_list_txt);
 }
-                                                                                                    
+
+void help_deletepin()
+{
+	print(help_deletepin_txt);
+}
+
 void help_verify()
 {
 	print(help_verify_txt);
@@ -413,6 +462,11 @@
 	print(help_crypt_txt);
 }
 
+void help_filecrypt()
+{
+	print(help_filecrypt_txt);
+}
+
 void help_format()
 {
 	print(help_format_txt);
@@ -458,6 +512,11 @@
 	print(help_resume_3des_txt);
 }
 
+void help_resume_aes()
+{
+	print(help_resume_aes_txt);
+}
+
 void help_resume_keys()
 {
 	print(help_resume_keys_txt);
--- /cvsroot/muscleapps/muscleTool/help.h	2004/08/26 17:59:48	1.1
+++ /cvsroot/muscleapps/muscleTool/help.h	2005/08/07 15:52:50	1.2
@@ -7,7 +7,7 @@
  *  Toni Andjelkovic <toni at soth.at>
  *  Ludovic Rousseau <ludovic.rousseau at free.fr>
  *
- * $Id: help.h,v 1.1 2004/08/26 17:59:48 rousseau Exp $
+ * $Id: help.h,v 1.2 2005/08/07 15:52:50 ohme-guest Exp $
  */
 
 void help();
@@ -23,12 +23,15 @@
 void help_changepin();
 void help_unblock();
 void help_listpins();
+void help_deletepin();
 
 void help_listkeys();
 void help_exportkey();
 void help_importkey();
 void help_genkeys();
 void help_crypt();
+void help_filecrypt();
+void help_deletekey();
 
 void help_format();
 void help_tokens();
@@ -36,6 +39,7 @@
 void help_resume();
 void help_resume_crypt();
 void help_resume_rsa();
+void help_resume_aes();
 void help_resume_dsa();
 void help_resume_3des();
 void help_resume_keys();
--- /cvsroot/muscleapps/muscleTool/muscleTool.c	2004/09/01 19:20:35	1.42
+++ /cvsroot/muscleapps/muscleTool/muscleTool.c	2005/08/07 15:52:50	1.43
@@ -1,14 +1,15 @@
  /******************************************************************
- 
+
         MUSCLE SmartCard Development ( http://www.linuxnet.com )
             Title  : muscleTool.c
             Package: MuscleTools
             Author : David Corcoran
-            Date   : 03/14/02
+                     Karsten Ohme
+            Date   : 07/31/05
             License: Copyright (C) 2002 David Corcoran
                      <corcoran at linuxnet.com>
-            Purpose: A shell for the MuscleCard framework 
- 
+            Purpose: A shell for the MuscleCard framework
+
 ********************************************************************/
 
 #include <stdio.h>
@@ -22,6 +23,10 @@
 #include <unistd.h>
 #endif
 
+#ifdef WIN32
+#include <io.h>
+#endif
+
 #include <sys/stat.h>
 #include <pthread.h>
 #ifndef __APPLE__
@@ -41,12 +46,15 @@
 MSCString connectToken = 0;		/* used for the prompt in main() */
 static int quitStat = 0;
 
-void doRelease();
+static int axtoi(char *);
+static int getChoice(char *, char *, char **, int);
+static int getStringValue(char *header, char *footer, char *stringValue, int stringValueLength);
+static int getNumberValue(char *header, char *footer, unsigned long *numberValue);
 void doPrintAUT(MSCUShort16);
 
 
 #define CHECK_ERR(cond, msg) { if (cond) { \
-  printf("ERR: %s (0x%lX %s)\n", msg, rv, msc_error(rv)); return; } }
+  printf("ERR: %s (0x%lX %s)\n", msg, rv, msc_error(rv)); goto end; } }
 
 #define PRINT_SUPPORT(cond) { if (cond) { \
   printf("X\n"); } else { printf("\n"); } }
@@ -69,6 +77,7 @@
 	}
 
 	printf("] : ");
+	return NULL;
 }
 
 
@@ -82,8 +91,6 @@
 	return 0;
 }
 
-static MSCUChar8 defaultCFlexKey[8] =
-	{ 0x2C, 0x15, 0xE5, 0x26, 0xE9, 0x3E, 0x8A, 0x19 };
 static MSCUChar8 muscleDefaultKey[8] =
 	{ 'M', 'u', 's', 'c', 'l', 'e', '0', '0' };
 
@@ -144,7 +151,7 @@
 {
 	MSCULong32 i;
 	MSCULong32 count = 0;
-	MSCUShort16 c;
+	MSCUChar8 c;
 	MSCUChar8 shortData[3];
 
 	for (i = 0; i < strlen((char *)data); i += 2)
@@ -160,6 +167,9 @@
 	return count;
 }
 
+/**
+* Pads data at the end with 0x00.
+*/
 void padData(MSCUChar8 * data, MSCULong32 inSize, MSCULong32 outSize)
 {
 	MSCULong32 i;
@@ -168,11 +178,97 @@
 		data[i] = 0;
 }
 
+/**
+* Pads data at the beginning with 0x01 and continues 0x00s so. 
+* If inSize == outSize the first byte is now allowed to be larger than
+* 0x80.
+* So the RSA modulus is smaller and the exponentiation exceeds modulus.
+* \return 1 for success, 0 if failure,
+*/
+MSC_RV padRSAData(MSCUChar8 * data, MSCULong32 inSize, MSCULong32 outSize)
+{
+	MSCULong32 i;
+	MSC_RV rv = 0;
+	MSCPUChar8 tmp = NULL;
+
+	tmp = (MSCPUChar8)malloc(outSize);
+	/* modulus must be larger than data */
+	if ((inSize == outSize) && (data[0] > 0x80)) {
+		goto end;
+	}
+	memcpy(tmp, data, outSize);
+	data[0] = 0x01;
+
+	for (i = 1; i < outSize-inSize; i++)
+		data[i] = 0;
+
+	memcpy(data+i, tmp, inSize);
+	rv = 1;
+end:
+	if (tmp)
+		free(tmp);
+	return rv;
+}
+
+void doExit() {
+	if (pConnection != 0) {
+		MSCReleaseConnection(pConnection, MSC_RESET_TOKEN);
+		free(pConnection);
+		pConnection = 0;
+	}
+	if (connectToken != 0) {
+		free(connectToken);
+		connectToken = 0;
+	}
+	if (tokenList)
+	{
+		free(tokenList);
+		tokenList = 0;
+		tokenSize = 0;
+	}
+}
+
+#ifdef VERSION2
+void doDeleteKey(int key_nb) {
+	MSCLong32 rv = 0;
+
+	CHECK_ERR(pConnection == 0, "Must Connect First !");
+
+	rv = MSCDeleteKey(pConnection, (MSCUChar8)key_nb);
+	CHECK_ERR(rv != MSC_SUCCESS, "DeleteKey Failed !");
+	printf("DeleteKey Successful\n");
+end:
+	return;
+}
+#else
+void doDeleteKey(int key_nb) {
+  printf("Not supported in MuscleTool 1.0 \n");
+  return;
+}
+#endif
+
+#ifdef VERSION2
+void doDeletePIN(int pin_nb) {
+	MSCLong32 rv = 0;
+
+	CHECK_ERR(pConnection == 0, "Must Connect First !");
+
+	rv = MSCDeletePIN(pConnection, (MSCUChar8)pin_nb);
+	CHECK_ERR(rv != MSC_SUCCESS, "DeletePIN Failed !");
+	printf("DeletePIN Successful\n");
+end:
+	return;
+}
+#else
+void doDeletePIN(int pin_nb) {
+  printf("Not supported in MuscleTool 1.0 \n");
+}
+#endif
 
 void doListTokens()
 {
 	MSCLong32 rv;
-	int i;
+	MSCULong32 i;
 
 	if (tokenList)
 	{
@@ -182,7 +278,7 @@
 	}
 
 	rv = MSCListTokens(MSC_LIST_KNOWN, tokenList, &tokenSize);
-	CHECK_ERR(rv != MSC_SUCCESS, "ListTokens Failed");
+	CHECK_ERR(rv != MSC_SUCCESS, "ListTokens Failed !");
 
 	if (tokenSize == 0)
 	{
@@ -194,14 +290,16 @@
 	CHECK_ERR(tokenList == 0, "Malloc Failed");
 
 	rv = MSCListTokens(MSC_LIST_KNOWN, tokenList, &tokenSize);
-	CHECK_ERR(rv != MSC_SUCCESS, "ListTokens Failed");
+	CHECK_ERR(rv != MSC_SUCCESS, "ListTokens Failed !");
 
 	for (i = 0; i < tokenSize; i++)
 	{
 		printf("   %d.    %s\n", i + 1, tokenList[i].tokenName);
 	}
 	printf("\n");
-
+	printf("ListTokens Success.\n");
+end:
+	return;
 }
 
 void doConnect(int tokenNumber)
@@ -210,10 +308,10 @@
 
 	CHECK_ERR(tokenList == 0, "List Tokens First !");
 
-	if (tokenNumber < 1 || tokenNumber > tokenSize)
+	if (tokenNumber < 1 || (MSCULong32)tokenNumber > tokenSize)
 	{
 		printf("ERR: Invalid choice made !\n");
-		return;
+		goto end;
 	}
 
 	if (pConnection == 0)
@@ -224,7 +322,7 @@
 	else
 	{
 		printf("ERR: Must Release Other Connection !\n");
-		return;
+		goto end;
 	}
 
 	rv = MSCEstablishConnection(&tokenList[tokenNumber - 1],
@@ -235,13 +333,16 @@
 		pConnection = 0;
 		printf("ERR: EstablishConnection Failed !\n");
 		printf("Is your card already formated?\n");
-		return;
+		goto end;
 	}
 
-	//  rv = MSCCallbackForTokenEvent(&tokenList[tokenNumber-1], 1, 
+	//  rv = MSCCallbackForTokenEvent(&tokenList[tokenNumber-1], 1,
 	//                tokenCallback, 0 );
 
 	connectToken = strdup(tokenList[tokenNumber - 1].tokenName);
+	printf("Connect Success.\n");
+end:
+	return;
 }
 
 void doRelease()
@@ -250,16 +351,21 @@
 
 	CHECK_ERR(pConnection == 0, "Must Connect First !");
 
-	//  rv = MSCCallbackCancelEvent();
-
 	rv = MSCReleaseConnection(pConnection, MSC_RESET_TOKEN);
 
-	free(pConnection);
-	pConnection = 0;
-	free(connectToken);
-	connectToken = 0;
+	if (pConnection) {
+		free(pConnection);
+		pConnection = NULL;
+	}
+	if (connectToken) {
+		free(connectToken);
+		connectToken = NULL;
+	}
 
 	CHECK_ERR(rv != MSC_SUCCESS, "ReleaseConnection Failed !");
+	printf("ReleaseConnection Success.\n");
+end:
+	return;
 }
 
 void doList()
@@ -270,6 +376,7 @@
 	CHECK_ERR(pConnection == 0, "Must Connect First !");
 
 	rv = MSCListObjects(pConnection, MSC_SEQUENCE_RESET, &objInfo);
+	CHECK_ERR((rv != MSC_SUCCESS && rv != MSC_SEQUENCE_END), "ListObjects Failed");
 
 	printf("%20s %12s %8s%8s %8s\n", "Object ID", "Object Size",
 		"READ", "WRITE", "DELETE");
@@ -279,41 +386,162 @@
 	{
 		printf("%20s   %10ld  ", objInfo.objectID, objInfo.objectSize);
 		doPrintAUT(objInfo.objectACL.readPermission),
-			doPrintAUT(objInfo.objectACL.writePermission),
-			doPrintAUT(objInfo.objectACL.deletePermission);
+		doPrintAUT(objInfo.objectACL.writePermission),
+		doPrintAUT(objInfo.objectACL.deletePermission);
 		printf("\n");
 	}
-	else
-	{
-		CHECK_ERR(rv != MSC_SUCCESS, "ListObjects Failed");
-		return;
+	if (rv == MSC_SEQUENCE_END) {
+		printf("ListObjects Success.\n");
+		goto end;
 	}
 
 	do
 	{
 		rv = MSCListObjects(pConnection, MSC_SEQUENCE_NEXT, &objInfo);
+		CHECK_ERR((rv != MSC_SUCCESS && rv != MSC_SEQUENCE_END), "ListObjects Failed");
 		if (rv == MSC_SUCCESS)
 		{
 			printf("%20s   %10ld  ", objInfo.objectID, objInfo.objectSize);
 			doPrintAUT(objInfo.objectACL.readPermission),
-				doPrintAUT(objInfo.objectACL.writePermission),
-				doPrintAUT(objInfo.objectACL.deletePermission);
+			doPrintAUT(objInfo.objectACL.writePermission),
+			doPrintAUT(objInfo.objectACL.deletePermission);
 			printf("\n");
-
 		}
-		else
-		{
-			if (rv != MSC_SEQUENCE_END && rv != MSC_OBJECT_NOT_FOUND)
-			{
-				CHECK_ERR(rv != MSC_SUCCESS, "ListObjects Failed");
+	}
+	while (rv != MSC_SEQUENCE_END);
+	printf("ListObjects Success.\n");
+end:
+	return;
+}
+
+#ifdef VERSION2
+void doPrintKeyPolicyCiphDir(MSCKeyInfo keyInfo) {
+	if (keyInfo.keyPolicy.cipherDirection == 0xFFFF) {
+		printf("%16s\n", "ANY");
+		return;
+	}
+	/* What for ??? */
+	if (keyInfo.keyPolicy.cipherDirection == 0x0000) {
+		printf("%16s\n", "NONE");
+		return;
+	}
+	if (keyInfo.keyPolicy.cipherDirection & MSC_KEYPOLICY_DIR_DECRYPT)
+		printf("%16s\n", "DECRYPT");
+	if (keyInfo.keyPolicy.cipherDirection & MSC_KEYPOLICY_DIR_ENCRYPT)
+		printf("%16s\n", "ENCRYPT");
+	if (keyInfo.keyPolicy.cipherDirection & MSC_KEYPOLICY_DIR_SIGN)
+		printf("%16s\n", "SIGN");
+	if (keyInfo.keyPolicy.cipherDirection & MSC_KEYPOLICY_DIR_VERIFY)
+		printf("%16s\n", "VERIFY");
+}
+
+void doPrintKeyPolicyCiphMode(MSCKeyInfo keyInfo) {
+	MSCUShort16 cipherSignatureMode = keyInfo.keyPolicy.cipherSignatureMode;
+	MSCUShort16 cipherCipherMode = keyInfo.keyPolicy.cipherCipherMode;
+	MSCUShort16 ciphDir = keyInfo.keyPolicy.cipherDirection;
+	if (cipherSignatureMode == 0xFFFF && cipherCipherMode == 0xFFFF) {
+		printf("%16s\n", "ANY");
+		return;
+	}
+	/* What for ??? */
+	if (cipherSignatureMode == 0x0000 && cipherCipherMode == 0x0000) {
+		printf("%16s\n", "NONE");
+		return;
+	}
+	switch (keyInfo.keyType)
+	{
+		case MSC_KEY_DSA_PUBLIC:
+		case MSC_KEY_DSA_PRIVATE:
+			if ((ciphDir & MSC_KEYPOLICY_DIR_SIGN) || (ciphDir & MSC_KEYPOLICY_DIR_VERIFY)) {
+				if (cipherSignatureMode & MSC_KEYPOLICY_MODE_DSA_SHA)
+					printf("%16s\n", "SHA");
+				}
+			break;
+		case MSC_KEY_RSA_PUBLIC:
+		case MSC_KEY_RSA_PRIVATE:
+		case MSC_KEY_RSA_PRIVATE_CRT:
+			if ((ciphDir & MSC_KEYPOLICY_DIR_SIGN) || (ciphDir & MSC_KEYPOLICY_DIR_VERIFY)) {
+				if (cipherSignatureMode & MSC_KEYPOLICY_MODE_SIGNATURE_RSA_MD5_PKCS1)
+					printf("%16s\n", "MD5 PKCS1");
+				if (cipherSignatureMode & MSC_KEYPOLICY_MODE_SIGNATURE_RSA_MD5_RFC2409)
+					printf("%16s\n", "MD5 RFC2409");
+				if (cipherSignatureMode & MSC_KEYPOLICY_MODE_SIGNATURE_RSA_RIPEMD160_ISO9796)
+					printf("%16s\n", "RIPEMD 160 ISO9796");
+				if (cipherSignatureMode & MSC_KEYPOLICY_MODE_SIGNATURE_RSA_RIPEMD160_PKCS1)
+					printf("%16s\n", "RIPEMD 160 PKCS1");
+				if (cipherSignatureMode & MSC_KEYPOLICY_MODE_SIGNATURE_RSA_SHA_ISO9796)
+					printf("%16s\n", "SHA ISO9796");
+				if (cipherSignatureMode & MSC_KEYPOLICY_MODE_SIGNATURE_RSA_SHA_PKCS1)
+					printf("%16s\n", "SHA PKCS1");
+				if (cipherSignatureMode & MSC_KEYPOLICY_MODE_SIGNATURE_RSA_SHA_RFC2409)
+					printf("%16s\n", "SHA RFC2409");
+			}
+			if ((ciphDir & MSC_KEYPOLICY_DIR_DECRYPT) || (ciphDir & MSC_KEYPOLICY_DIR_ENCRYPT)) {

[3076 lines skipped]
--- /cvsroot/muscleapps/muscleTool/muscleTool.h	2004/08/26 18:04:50	1.1
+++ /cvsroot/muscleapps/muscleTool/muscleTool.h	2005/08/07 15:52:50	1.2
@@ -6,32 +6,41 @@
  * Copyright (C) 2004
  *  Toni Andjelkovic <toni at soth.at>
  *  Ludovic Rousseau <ludovic.rousseau at free.fr>
+ *  Karsten Ohme <karsten.ohme at inf.tu-dresden.de>
  *
- * $Id: muscleTool.h,v 1.1 2004/08/26 18:04:50 rousseau Exp $
+ * $Id: muscleTool.h,v 1.2 2005/08/07 15:52:50 ohme-guest Exp $
  */
+#ifdef VERSION2
+#define PACKAGE_VERSION "2.0.0"
+#else
+#define PACKAGE_VERSION "1.0.0"
+#endif
 
 void doListTokens();
 void doFormat(int tokenNumber);
 void doConnect(int tokenNumber);
 void doRelease();
 void doList();
-void doListPIN();
+void doListPINs();
 void doListKeys();
+void doDeleteKey(int key_nb);
 void doStatus();
+void doDeletePIN(int pin_nb);
 void doLogout();
 void doVersion();
-void doVerify(int pinNumber, char *pinData);
+void doVerify(int pinNumber);
 void doChallenge(int len);
-void doUnblockPIN(int pinNumber, char *pinData);
+void doUnblockPIN(int pinNumber);
 void doResume(char *type);
 void doMakePIN(int pinNumber, char *pinData, char *pinUnblockData);
-void doChangePIN(int pinNumber, char *pinData, char *newPinData);
-void doGenKeys();
+void doChangePIN(int pinNumber);
+void doGenKeys(char *keyType, int keySize);
 void doExportKey(int keyNumber, char *fileName);
 void doImportKey(int keyNumber, char *fileName);
-void doCrypt(int keyNum, char *hexString);
+void doCrypt(int keyNum, char *inFileName, char *outFileName);
 void doCreate(char *objectID, int objectSize);
 void doDelete(char *objectID);
 void doRead(char *objectID, char *fileName);
 void doWrite(char *fileName, char *objectID);
+void doExit();
 
--- /cvsroot/muscleapps/muscleTool/parser.y	2004/08/26 20:05:03	1.3
+++ /cvsroot/muscleapps/muscleTool/parser.y	2005/08/07 15:52:50	1.4
@@ -6,8 +6,9 @@
  * Copyright (C) 2004
  *  Toni Andjelkovic <toni at soth.at>
  *  Ludovic Rousseau <ludovic.rousseau at free.fr>
+ *  Karsten Ohme <karsten.ohme at inf.tu-dresden.de>
  *
- * $Id: parser.y,v 1.3 2004/08/26 20:05:03 rousseau Exp $
+ * $Id: parser.y,v 1.4 2005/08/07 15:52:50 ohme-guest Exp $
  */
 
 %{
@@ -31,6 +32,7 @@
 
 /* used for the prompt in main() */
 extern MSCString connectToken;
+static int bye = 0;
 
 static void test(int num, char *str);
 
@@ -48,15 +50,18 @@
 }
 
 %token CREATE
-%token DELETE
+%token _DELETE
 %token WRITE
 %token READ
 %token LIST
 
 %token CRYPT
+%token FILECRYPT
 %token RSA
+%token RSACRT
 %token DSA
 %token DES
+%token AES
 %token TRIPLE_DES
 %token KEYS
 %token PINS
@@ -67,11 +72,13 @@
 %token CHANGEPIN
 %token UNBLOCK
 %token LISTPINS
+%token DELETEPIN
 
 %token LISTKEYS
 %token EXPORTKEY
 %token IMPORTKEY
 %token GENKEYS
+%token DELETEKEY
 
 %token FORMAT
 %token TOKENS
@@ -87,6 +94,7 @@
 
 %token <num> NUMBER
 %token <str> STRING
+%token HEXNUMBER
 
 %token SEPARATOR;
 %token TEST;
@@ -104,19 +112,24 @@
 
 action:		LIST				{ doList(); }
 	|	CREATE STRING NUMBER		{ doCreate($2, $3); }
-	|	DELETE STRING			{ doDelete($2); }
+	|	_DELETE STRING			{ doDelete($2); }
 	|	WRITE STRING STRING		{ doWrite($2, $3); }
 	|	READ STRING STRING		{ doRead($2, $3); }
-	|	VERIFY NUMBER STRING		{ doVerify($2, $3); }
+	|	VERIFY NUMBER 		{ doVerify($2); }
 	|	MAKEPIN NUMBER STRING STRING	{ doMakePIN($2, $3, $4); }
-	|	CHANGEPIN NUMBER STRING STRING	{ doChangePIN($2, $3, $4); }
-	|	UNBLOCK NUMBER STRING		{ doUnblockPIN($2, $3); }
-	|	LISTPINS			{ doListPIN(); }
+	|	CHANGEPIN NUMBER { doChangePIN($2); }
+	|	UNBLOCK NUMBER		{ doUnblockPIN($2); }
+	|	LISTPINS			{ doListPINs(); }
+	|	DELETEPIN NUMBER	{ doDeletePIN($2); }
 	|	LISTKEYS			{ doListKeys(); }
 	|	EXPORTKEY NUMBER STRING		{ doExportKey($2, $3); }
 	|	IMPORTKEY NUMBER STRING		{ doImportKey($2, $3); }
-	|	GENKEYS				{ doGenKeys(); }
-	|	CRYPT NUMBER STRING		{ doCrypt($2, $3); }
+	|	GENKEYS	RSA NUMBER { doGenKeys("rsa", $3); }
+	|	GENKEYS	DSA NUMBER 	{ doGenKeys("dsa", $3); }
+	|	GENKEYS	RSACRT NUMBER 	{ doGenKeys("rsacrt", $3); }
+	|	DELETEKEY NUMBER	{ doDeleteKey($2); }
+	|	FILECRYPT NUMBER STRING	STRING	{ doCrypt($2, $3, $4); }
+	|	CRYPT NUMBER 		{ doCrypt($2, NULL, NULL); }
 	|	FORMAT NUMBER			{ doFormat($2); }
 	|	TOKENS				{ doListTokens(); }
 	|	CONNECT NUMBER			{ doConnect($2); }
@@ -125,6 +138,7 @@
 	|	RESUME RSA			{ doResume("rsa"); }
 	|	RESUME DSA			{ doResume("dsa"); }
 	|	RESUME DES			{ doResume("des"); }
+	|	RESUME AES			{ doResume("aes"); }
 	|	RESUME TRIPLE_DES		{ doResume("3des"); }
 	|	RESUME KEYS			{ doResume("keys"); }
 	|	RESUME PINS			{ doResume("pins"); }
@@ -135,14 +149,15 @@
 	|	CHALLENGE NUMBER		{ doChallenge($2); }
 	|	LOGOUT				{ doLogout(); }
 	|	VERSION				{ doVersion(); }
-	|	EXIT				{ exit(0); }
+	|	EXIT				{ doExit(); bye=1; }
 	|	TEST NUMBER STRING		{ test($2, $3); }
 	;
 
 help:		HELP				{ help(); }
 	|	HELP CREATE			{ help_create(); }
-	|	HELP DELETE			{ help_delete(); }
+	|	HELP _DELETE			{ help_delete(); }
 	|	HELP WRITE			{ help_write(); }
+	|	HELP DELETEKEY		{ help_deletekey(); }
 	|	HELP READ			{ help_read(); }
 	|	HELP LIST			{ help_list(); }
 	|	HELP VERIFY			{ help_verify(); }
@@ -151,10 +166,12 @@
 	|	HELP UNBLOCK			{ help_unblock(); }
 	|	HELP LISTPINS			{ help_listpins(); }
 	|	HELP LISTKEYS			{ help_listkeys(); }
+	|	HELP DELETEPIN			{ help_deletepin(); }
 	|	HELP EXPORTKEY			{ help_exportkey(); }
 	|	HELP IMPORTKEY			{ help_importkey(); }
 	|	HELP GENKEYS			{ help_genkeys(); }
 	|	HELP CRYPT			{ help_crypt(); }
+	|	HELP FILECRYPT			{ help_filecrypt(); }
 	|	HELP FORMAT			{ help_format(); }
 	|	HELP TOKENS			{ help_tokens(); }
 	|	HELP CONNECT			{ help_connect(); }
@@ -198,11 +215,13 @@
 #endif
 	char prompt[MUSCLETOOL_PROMPT_SIZ];
 
-	if ((argc > 1) && (0 == strcmp(argv[1], "-d")))
-		setenv("MUSCLECARD_DEBUG", "1", 0);
+	if ((argc > 1) && (0 == strcmp(argv[1], "-d"))) {
+		if (getenv("MUSCLECARD_DEBUG") == NULL)
+			putenv("MUSCLECARD_DEBUG=1");
+	}
 
 	printf("MuscleCard shell - type \"help\" for help.\n");
-	while (1) {
+	while (!bye) {
 
 		if (connectToken)
 			snprintf(prompt,
--- /cvsroot/muscleapps/muscleTool/scanner.l	2004/08/26 18:00:32	1.1
+++ /cvsroot/muscleapps/muscleTool/scanner.l	2005/08/07 15:52:50	1.2
@@ -7,7 +7,7 @@
  *  Toni Andjelkovic <toni at soth.at>
  *  Ludovic Rousseau <ludovic.rousseau at free.fr>
  *
- * $Id: scanner.l,v 1.1 2004/08/26 18:00:32 rousseau Exp $
+ * $Id: scanner.l,v 1.2 2005/08/07 15:52:50 ohme-guest Exp $
  */
 
 %option noyywrap
@@ -23,7 +23,11 @@
 void my_lex_close(void);
 
 /* silence warnings */
+#ifdef WIN32
+__declspec(dllimport) extern int fileno(FILE *);
+#else
 extern int fileno(FILE *);
+#endif
 extern void yyerror(char *);
 #define YY_NO_UNPUT
 
@@ -40,15 +44,19 @@
 %%
 
 create		return CREATE;
-delete		return DELETE;
+delete		return _DELETE;
+deletekey	return DELETEKEY;
 write		return WRITE;
 read		return READ;
 list		return LIST;
 
 crypt		return CRYPT;
-rsa		return RSA;
-dsa		return DSA;
-des		return DES;
+filecrypt	return FILECRYPT;
+rsa			return RSA;
+rsacrt		return RSACRT;
+dsa			return DSA;
+des			return DES;
+aes			return AES;
 3des		return TRIPLE_DES;
 keys		return KEYS;
 pins		return PINS;
@@ -59,6 +67,7 @@
 changepin	return CHANGEPIN;
 unblock		return UNBLOCK;
 listpins	return LISTPINS;
+deletepin	return DELETEPIN;
 
 listkeys	return LISTKEYS;
 exportkey	return EXPORTKEY;

--- /cvsroot/muscleapps/muscleTool/Install.w32	2005/08/07 15:52:51	NONE
+++ /cvsroot/muscleapps/muscleTool/Install.w32	2005/08/07 15:52:51	1.1
Pre-requisite:

This will be a lot of work ...

1.	You need a Microsoft C/C++-Compiler including the libraries, includes and build tools.
	I have compiled with the compiler included in Visual Studio 6.0. You may also use the compiler
	included in Microsoft Visual Studio .NET 2003. But then maybe you will have problems with the portability,
	i.e. on systems without a installed .NET framework some libraries linked against are missing.

	For a free way to build you need:

	Microsoft Visual C++ Toolkit 2003
	http://msdn.microsoft.com/visualc/vctoolkit2003/

	to get a compiler C/C++ compiler suite.

	Windows® Server 2003 SP1 Platform SDK
	http://www.microsoft.com/downloads/details.aspx?familyid=EBA0128F-A770-45F1-86F3-7AB010B398A3&displaylang=en

	to get the libraries for linking and include files for compiling and nmake for the makefile.

	NET Framework SDK Version 1.1
	http://www.microsoft.com/downloads/details.aspx?familyid=EBA0128F-A770-45F1-86F3-7AB010B398A3&displaylang=en

	to get the file msvcrt.lib. This is a necessary runtime library, but it is not included in the two above.
	Copy this file to the lib directory of Windows® Server 2003 SP1 Platform SDK.

2.	You need the pthreads library for Windows

	http://sources.redhat.com/pthreads-win32/

	I compiled it on my own. I tested only a debug version build with
	the project file in Visual Studio 6.0. You should find the files pthreadVC.dll and pthreadVC.lib.
	There are also precompiled versions.
	Try the latest version.	In the 1.x version you will find the two files pthreadVC1.dll and pthreadVC1.lib somewhere
	and include files. In the 2.y version you will find the two files pthreadVC2.dll and
	pthreadVC2.lib somewhere and include files.
	Copy the pthreadVC.dll, pthreadVC1.dll, pthreadVC2.dll library to a location, where the application(s) using it can find it.
	This is a directory included in the %PATH% environment, usually at least e.g. Windows\System32.

3.	You need flex for Windows.

	http://gnuwin32.sourceforge.net/packages/flex.htm

4.	You need bison for Windows.

	http://gnuwin32.sourceforge.net/packages/bison.htm

Installation:

Keep in mind, that all applications should be compiled and linked with the same debugging properties
and against the same libraries. That means if you have downloaded a pre-built version of the pthread
library, then you also have to build a release version. If you want to compile pthread with debugging
information open the Visual Studio project of the pthread library and build a debug version.

1.	Set the environment (This are include files and libraries and programms of the building environment)
	for compilation and open a command prompt. If you have Microsoft Visual Studio 6.0
	or .NET 2003 there is a file vcvars32.bat which does this for you
	and opens a command prompt.
	If you have installed Microsoft Visual C++ Toolkit 2003 and the
	Windows Server 2003 SP1 Platform SDK then change into the the Microsoft Platform SDK directory, open a
	console and run the SetEnv.Cmd. Now change into the Microsoft Visual C++ Toolkit directory and run
	vcvars32.bat. Now you should have a environment with the necessary tools, include and library directories.

2. 	Change into libmusclecard\win32 subdirectory.

3. 	Run nmake -f MuscleTools.mak to build a release version without debugging information.
	or run nmake -f MuscleTools DEBUG= to build a debug version with debugging information.
	There are some arguments which are displayed in the beginning of the makefile. You
	can change them if you specify them on the command line or in the makefile.

	This arguments are:

	MUSCLECARD_INC - Path to MuscleCard includes
	MUSCLECARD_LIB - Path to MuscleCard link library (.lib)
	PCSC_INC       - The path to the headers for PC/SC Lite
	PTHREADS_INC   - The path of the include files of the pthread library
	PTHREADS_LIB   - The path of the library file of the pthread library
	PTHREADS_NAME  - The name of the pthread library
	FLEX           - The path including file name of the executable of flex.
	FLEX_INC	   - Some includes shipped with flex.
	BISON          - Path including file name of the bison executable

	E.g. nmake -f PCSC.mak PTHREADS_INC=C:\pthreads\Pre-build\include PTHREADS_LIB=C:\pthreads\Pre-build\lib
		 PTHREADS_NAME=pthreadVC1 FLEX=C:\Program Files\GnuWin32\bin\flex.exe FLEX_INC=C:\Program Files\GnuWin32\include PCSC_INC=C:\Program Files\Muscle\Includes BISON=C:\Program Files\GnuWin32\bin\bison.exe MUSCLECARD_INC=C:\Program Files\Muscle\Includes MUSCLECARD_LIB=C:\Program Files\Muscle\Libraries


4.	Copy the file MuscleTool.exe to a adequate directory.

5.	(optional)
	Run nmake -f MuscleTools.mak clean to delete the Debug and Release directories.--- /cvsroot/muscleapps/muscleTool/reconf	2005/08/07 15:52:51	NONE
+++ /cvsroot/muscleapps/muscleTool/reconf	2005/08/07 15:52:51	1.1
#!/bin/sh

set -v
if [ -e Makefile ]
then
	make distclean
fi

# use with --force when autoconf/automake/libtool change
autoreconf --verbose --install $@



More information about the Pcsclite-cvs-commit mailing list