Commit Graph

179 Commits

Author SHA1 Message Date
Peter Popovec 539c89e581 opensc-explorer: show tag 0x82 for unknown files
For reserved/unknown file type print value of 0x82 tag, instead of "???" string.

closes #918
2016-12-18 12:50:11 +01:00
Ludovic Rousseau e7cbc3ba82 opensc-explorer.c: fix compiler warning
opensc-explorer.c:1727:8: warning: comparison of integers of different signs:
      'int' and 'size_t' (aka 'unsigned long') [-Wsign-compare]
                if(r > len) {
                   ~ ^ ~~~
2016-02-29 20:19:42 +01:00
Wouter Verhelst 5de1ec4518 Allow ASN.1 decoding if the file seems incomplete
Some cards (e.g., BELPIC) have a hardcoded file length that does not
match the actual file length (e.g., 65535 bytes), and simply return the
data that is actually on the card when asked.

It is useful to still be able to do an ASN.1 decode in that case.

Signed-off-by: Wouter Verhelst <w@uter.be>
2015-12-01 16:20:17 +01:00
Frank Morgner 5e352ea477 Merge pull request #504 from frankmorgner/find_tags
Find tags with GET DATA
2015-08-04 10:32:23 +02:00
Frank Morgner 24d91acf69 opensc-explorer: added command find_tags 2015-07-30 11:29:14 +02:00
Frank Morgner 7cec500e54 added flags to sc_context_t
- is initialized in sc_context_create with parm->flags
- removes members paranoid_memory and enable_default_driver
2015-07-22 17:30:21 +02:00
Frank Morgner 0790969b97 recognize short EF identifier 2015-03-31 18:48:57 +02:00
Viktor Tarasov 1fe9ba1b2f opensc-explorer: if available, print DF name 2013-12-29 19:46:56 +01:00
Frank Morgner 3d0064e983 don't expect the card to specify the file length in generic tools
if sc_file_t.size == 0 we try to read 1024 bytes by default.
2013-09-29 18:52:48 +02:00
Viktor Tarasov 1a972920f0 By default 'default' card driver is disabled ...
'Default' card driver is explicitely enabled for 'opensc-explorer' and 'opensc-tool' tools.
https://github.com/OpenSC/OpenSC/pull/175
2013-08-02 22:01:51 +02:00
Viktor Tarasov 4c1c39f3e4 opensc-tool: add 'call-SM-handler' command
'open' and 'close' handlers of the card's SM driver can be called
2013-01-06 13:13:08 +01:00
Viktor Tarasov 9e9b3d0bd8 tool: in 'do_apdu' increase size of send/receive buffers 2012-11-28 11:09:36 +01:00
Viktor Tarasov 41861e42b0 no 'pace' in common part
'PACE' is extremely card specific protocol and has not to be ostensibly
present in the common part of OpenSC:
 * currently in OpenSC there is no card driver that supports or uses this protocol;
 * amazing content of the common 'sc_perform_pace' -- beside the verbose logs
   the only substantial action is to call the card/reader specific handler.
   According to the current sources and the pull request 83
   this 'common' procedure is called by the card driver or
   card specific tool/operation.
 * currently the 'PACE' can be thouroghly tested only by one person (Frank Morgner),
   and only using the OpenSSL patched with the PACE specific patch.
   So, at least a dedicated configuration option could be introduced when comiting PACE to the common part.
 * common 'sc_perfom_pace' has the same role as the 'initialize-SM' handler of the existing SM framework
   and can be implemented as card specific SM, as the others cards do.
   This confirmed by Frank Morgner, the author of PACE commits and nPA card driver, himself.
   (https://github.com/OpenSC/OpenSC/pull/83)
2012-08-30 18:51:42 +02:00
Peter Marschall feb2b96127 opensc-explorer: allow filename-pattern as argument to 'ls'
Make ls more flexible and more similar to the UNIX ls.
2012-08-19 21:31:32 +02:00
Peter Marschall 4035245649 opensc-explorer: allow longer PINs in CHANGE & UNBLOCK
Harmonize the allowed PIN length in CHANGE & UNBLOCK with the one in VERIFY,
making sure they are large enough for OpenPGP, which allows up ro 32 characters,
and giving additional security margin for other cards.
2012-08-11 21:33:36 +02:00
Viktor Tarasov 71ec763604 opensc-explorer: warnings when compiling with Windows VC
opensc-explorer.c(447) : warning C4101: 'count' : unreferenced local variable
opensc-explorer.c(940) : warning C4013: 'strlcpy' undefined; assuming extern returning int
opensc-explorer.c(1683) : warning C4013: '_isatty' undefined; assuming extern returning int
opensc-explorer.c(1726) : warning C4090: 'function' : different 'const' qualifiers
2012-08-11 20:48:58 +02:00
Peter Marschall 7f22ede919 opensc-explorer: show text message for APDU result 2012-08-11 20:48:58 +02:00
Peter Marschall 95cbfbb799 opensc-explorer: increase allowed bytes in RANDOM
Allow to fetch up to 256 random bytes from the card -
236 being the maximal value for Le in short APDUs.
2012-08-11 20:48:58 +02:00
Peter Marschall ea8a64d95a opensc-explorer: allow entering the PIN interactively
In VERIFY, allow the user to enter the PIN unteractively if it was not given
on the command line, and if the card reader does not support PIN input.

If it was not given on the command line and the card reader supports PIN input,
then the bahaviour is unchanged: enter PIN via card reader.
2012-08-11 20:48:58 +02:00
Peter Marschall 322e3cf403 opensc-explorer: convert CHANGE & UNBLOCK to sc_pin_cmd 2012-08-11 20:48:58 +02:00
Peter Marschall 81695df211 opensc-explorer: use standard usage() everywhere
With the improvements of the man page, there is no need any more to have
local help texts for functions.
2012-08-11 20:48:58 +02:00
Peter Marschall a56bebd952 opensc-explorer: clean-up help text
"asn1 file" -> "ASN.1 file"
2012-06-08 20:32:33 +02:00
Nguyễn Hồng Quân f3955e2475 opensc-explorer: implement put_data
opensc-explorer: use larger buffer for put_data
2012-06-08 20:17:35 +02:00
Viktor Tarasov fbc9bb35dc opensc-explorer: when printing file content read entire file
When reading and printing file content, do not read it by small chunks,
but read an entire file.
It allows to verify how card driver reads the data of maximal size
that is allowed for one transaction ('max_recv_size').
2012-06-01 16:58:47 +02:00
Peter Marschall aca314b1f8 opensc-explorer: remove outdated usage text for verify
Wuth the key types explicitly listed in the usage line,
it is not necessary to list them separately.
2012-05-30 09:39:12 +02:00
Peter Marschall 367ebd94d4 tools: allow arguments to be printed in usage message
Extend util_print_usage_and_die() by a string argument that describes
further arguments to the program.

1st user: opensc-explorer
2012-05-30 09:39:12 +02:00
Peter Marschall 965d44ec40 opensc-explorer: use case-insensitive pin types in PACE 2012-05-30 09:39:12 +02:00
Peter Marschall cd2cdf77f6 opensc-explorer: explicitly mention key types 2012-05-30 09:39:12 +02:00
Peter Marschall 2276c7e7e4 opensc-explorer: do not use hard-coded string length
Determine length of prefix dynamically instead of using a hard-coded, common
value for all prefixes.
2012-05-30 09:39:12 +02:00
Peter Marschall 38be3c1a4a opensc-explorer: better names for some functions 2012-05-20 18:20:24 +02:00
Peter Marschall 1f70902da5 opensc-explorer: add 'echo' command
Add 'echo' command that simply displays its arguments.

With the recently committed script interpreter feature and this echo command,
nice litte scripts can be written, like e.g.

 $ cat opengpg-userinfo
 #!/usr/bin/opensc-explorer
 cd 0065
 echo Name:
 cat 005B
 echo Language:
 cat 5F2D
 echo Gender:
 cat 5F35
 quit
2012-05-20 18:19:48 +02:00
Peter Marschall f8f02dbd65 opensc-explorer: allow acting as script interpreter
Take a filename as argument and interpret the commands in it.
2012-05-20 17:12:14 +02:00
Frank Morgner 59b214ec23 opensc-explorer: implemented `pace` 2012-05-03 12:58:45 +02:00
Frank Morgner 7b630962c1 opensc-explorer: `find [<start fid> [<end fid>]]` 2012-05-03 12:58:34 +02:00
Viktor Tarasov cb13633634 remove trailing whitespaces
inspired by
http://www.opensc-project.org/pipermail/opensc-devel/2012-March/017883.html

Change-Id: If170e830d8d9587a31742feffb6fff54cfdf75b4
2012-04-03 00:00:56 +02:00
Peter Marschall 6c24bd5cff opensc-explorer: silence compiler warnings 2011-06-16 09:30:55 +03:00
Peter Marschall 2faad42325 opensc-explorer: consolidate filename generation
* add new function path_to_filename() that converts a path into
  filename, and returns a static buffer to it
* convert all occurrences where file names get generated
  to using this function

Signed-off-by: Peter Marschall <peter@adpm.de>
2011-06-11 09:33:30 +02:00
Peter Marschall c03eedde54 opensc-explorer: use util_hex_dump() in do_info()
Use standard function util_hex_dump() in do_info() instead of
enumerating lists of bytes ourselves.

Signed-off-by: Peter Marschall <peter@adpm.de>
2011-06-11 09:33:30 +02:00
Peter Marschall 12fce0f329 opensc-explorer: replace if..else with ?:
Use the easier to read & shorter expression
  path->type = (is_id) ? SC_PATH_TYPE_FILE_ID : SC_PATH_TYPE_PATH;
nstead of the longer, but equivalent if () .. else construction.

Signed-off-by: Peter Marschall <peter@adpm.de>
2011-06-11 09:33:30 +02:00
Peter Marschall 52b601ee53 opensc-explorer: re-factor do_apdu()
* allow double-quoted strings besides hexdata in ADPU generation
* detect errors in parameter parsing
* use utility function to print bytes sent,
  fixing an error that only showed parts of the APDU wheni
  it was generated from multiple arguments

Signed-off-by: Peter Marschall <peter@adpm.de>
2011-06-11 09:33:30 +02:00
Peter Marschall 81aa02d598 opensc-explorer: convert all mapping tables to id2str_t
Use type id2str_t for all mapping tables mapping IDs<->names.

Signed-off-by: Peter Marschall <peter@adpm.de>
2011-06-11 09:33:30 +02:00
Peter Marschall 1c437c049c opensc-explorer: simplify arg parsing in do_change() & do_unblock()
Simplify argument handling in do_change() and do_unblock(),
making the functions shorter and deasier to understand.,

Signed-off-by: Peter Marschall <peter@adpm.de>
2011-06-11 09:33:30 +02:00
Peter Marschall 61855ebd22 opensc-explorer: remove unnecessary var's in do_update_*()
The variables "in_str" in do_update_binary() & do_update_record()
do not serve a purpose: use argv[x] directly & remove them.

Signed-off-by: Peter Marschall <peter@adpm.de>
2011-06-11 09:33:30 +02:00
Peter Marschall 291ec6bf1c opensc-explorer: remove hex2binary()
With the last users gone, there's no need to keep hex2binary().

Signed-off-by: Peter Marschall <peter@adpm.de>
2011-06-11 09:33:30 +02:00
Peter Marschall 4cc1ab41ff opensc-explorer: detect AID conversion errors in arg_to_path()
Convert arg_to_path() to using the standard sc_hex_to_binary() instead of
the local hex2binary().
While at it, return erros on failed conversions.

Signed-off-by: Peter Marschall <peter@adpm.de>
2011-06-11 09:33:30 +02:00
Peter Marschall c3ba355531 opensc-explorer: consolidate string parsing in do_update_record()
Update do_update_record() to use parse_string_or_hexdata() instead of the old
hex2binary().
This change allows to use double-quoted strings in the "update_record" command.

Signed-off-by: Peter Marschall <peter@adpm.de>
2011-06-11 09:33:30 +02:00
Peter Marschall aa7a5ae5f8 opensc-explorer: fix argc checks in do_update_*()
do_update_binary() and do_update_record() expect a fixed number of parameters
each: adapt the checks for argc so that they do the right thing.

Signed-off-by: Peter Marschall <peter@adpm.de>
2011-06-11 09:33:30 +02:00
Peter Marschall 081bf9fc7e opensc-explorer: consolidate string/hexdata parsing
* add new function parse_string_or_hexdata() that parses
  a double-quoted string or a hex-data string (e.g: AA:BB:CC)
  into a buffer
* use parse_string_or_hexdata() wherever strings or hexdata
  gets parsed into a buffer

Signed-off-by: Peter Marschall <peter@adpm.de>
2011-06-11 09:33:30 +02:00
Peter Marschall 9c9317d11b opensc-explorer: centralize usage
* extend cmds struct by a new element args for a description of the arguments
* use args in help texts
* new function usage() for centralited dispaly of usage info
* harmonize argument strings for usage / help texts
* re-sort cmd list shown in help texts
* add function "help" to cwallow asking for for help
* space-police

Signed-off-by: Peter Marschall <peter@adpm.de>
2011-06-11 09:33:30 +02:00
Peter Marschall 78838812fb opensc-explorer: convert do_info() to using tables
* use ID<->name tables instead of arrays of strings where
  the index was treated like some "magic" constant.
  With the new mapping tables, the meaning is obvious.

* fix a bug with ac_ops_df[]: before the conversion, it was a list
  of pointers to strings but was in one case treated like it was a mapping table.
  With the conversion to a mapping table, and the adaption of other code parts
  this bug got fixed "automagically" ;-)

* use common code to cleanly print ACLs for DFs & EFs

* harmonize EF structure names to the ones used in ISO 7816-4

Signed-off-by: Peter Marschall <peter@adpm.de>
2011-06-11 09:33:30 +02:00