Is there any alternative to GlobalPlatform Shell for Java Cards? - javacard

I know that GP Shell is a tool for testing I/O to Java Cards.
But, it is very cumbersome to work with.
Is there any alternative to GP Shell which doesn't need written scripts?

Yes, there is.
1-
You can use GlobalPlatformPro.It's an opensource, well-documented and easy use tool for card's content management.
Quoted from its website:
Load and manage applets on compatible > JavaCards from command line or from
your Java project with a Do What I Mean
approach.
2-
For sending APDU commands and communicating with the card you can use another opensource easy use tool named OpenSC-Tool.
Quoted from its website:
The opensc-tool utility can be used
from the command line to perform
miscellaneous smart card operations such
as getting the card ATR or sending
arbitrary APDU commands to a card.
3-
There is another GUI tool named JCmanager for installing applets on the card and managing authentication keys. But this tool is old and not meant to be used anymore (It still works fine by the way.)
4-
You can also make your application to communicate with smart cards using available libraries. Java has javax.smartcardio package, and Python has PySCard library.

You can use the tool pyApduTool to manage your smart card resource:
List packages/applets;
Upload package;
Install applet instance;
Delete packages /applets;
Select applet / card manager;
Send other apdu command to your card;
Run APDU script in *.scr file;
Change GP key to your own;
Link to pyApduTool

A complete list of tools for managing JavaCards was compiled here by Martin P. creator of GlobalPlatform Pro (the best tool by these testimonials):
This is a copy-paste, refer to GlobalPlatform Pro page for latest updates
• gpj (the grandparent) - http://gpj.sf.net (LGPL)
o written in Java
o continued as GlobalPlatformPro
o harder to use from the command line
o no new features or standards
• GPShell + globalplatform library - http://sourceforge.net/projects/globalplatform/ (LGPL)
o written in C
o often referred to as the de facto open source GlobalPlatform implementation
o several components need to be compiled and installed before usage
o requires more complex "script files" and does not provide a direct command line utility
• jcManager - http://www.brokenmill.com/2010/03/java-secure-card-manager/ (LGPL)
o written in Java
o has a basic GUI
o old and not maintained
• gpjNG - https://github.com/SimplyTapp/gpjNG (LGPL)
o fork of gpj with minor additions, mostly a "script mode" that makes it similar to GPShell
• Ruby smartcard module - http://smartcard.rubyforge.org/classes/Smartcard/Gp/GpCardMixin.html (MIT)
o written in Ruby
o does not seem to expose all functionality (key diversification, key change etc)
o no command line utility
• JGPShell - https://sourceforge.net/projects/jgpshell/ (GPL2)
o written in Java
o GPShell-style scripting goal
o not really usable and also abandoned
• OPAL - https://bitbucket.org/ssd/opal (CeCILL, GPLv2 compatible)
o written in Java
o claims to have SCP03 support (but no tested cards)
o looks "heavy" and over-engineered
o smoke tests give exceptions and doesn't work on OSX nor Debian.
• gpcomm - https://code.google.com/p/gpcomm/
o written in Java
o incomplete and abandoned
• globalplatform.net - https://github.com/sepulo/globalplatform.net
o written in c#
o unclear license (missing)
o only supports SCP01 and SCP02
• GlobalPlatform.NET - https://github.com/jamesharling/GlobalPlatform.NET (GPLv3)
o wirtten in c#
o only supports SCP02
o fluent interface
• asterix - https://github.com/suma12/asterix (LGPL 2.1)
o written in Python
o SCP02, SCP03
• LuaGP - https://github.com/bondhan/LuaGP
o written in Lua
o unclear license (missing)
• JCOP tools, RADIII, JCardManager4, JLoad, PyApduTool etc
o not publicly available cross-platform open source projects and thus not suitable for this comparision

Related

About writing C ++ RedHawk startup program

We are using RedHawk v2.1 on xilinx Zynq7035 Platform. Based on the following URL, I built it with a project from which Python was deleted.
https://github.com/Axios-Engineering/openembedded-hawk#features--options
Prior to using this project, Python described the startup program. But there is not Python on current Project. Could you tell us how to write the following Python functions for RedHawk in C ++?
dom = redhawk.attach('REDHAWK_DEV')
wave0 = dom.createApplication
dom.devices[0].connect
wave0.start()
dom.devices[0].start()
You should review example 3 in the omniORB documentation. It should provide you with an example of resolving a CORBA object from the naming service and making the IDL calls on it. Documentation here

What is maskgen tool in JavaCard

In JavaCard, can somebody please tell me what is the purpose of the maskgen tool?
What I have heard from my senior colleagues that it is the tool which converts the Java codes into C code for that particular JavaCard platform. But is answer seems to broad and lacking the exact particularity. If the above mentioned purpose is correct then my few questions are
1. How does it convert the java source code into C code ?
2. How can I see the source code of this maskgen tool ?
3. How can I convert my Java card source code using maskgen tool?
Quoted from Java Card 3 Platform Development Kit User Guide:
What id Maskgen tool?
The maskgen tool produces a mask file from a set of Java Card Assembly
files produced by the Converter. The format of the output mask file is
targeted to a specific platform. The plug-ins that produce each
different maskgen output format are called generators. The supported
generators are cref, which supports the Java Card RE, and size, which
reports size statistics for the mask. Other generators that are not
supported in this release include jref, which supports the Java
programming language Java Card RE, and a51, which supports the Keil
A51 assembly language interpreter. Java Card Assembly Syntax Example
provides additional information about the contents of a Java Card
Assembly file.
Where I can find Maskgen tool source?
The maskgen tool is not available or of use outside of a source
release bundle, so [...] if you do not have a source release of the
development kit you would have maskgen tool. If you have a source
release, you can localize locale-specific data associated with the
maskgen tool, see Localizing With The Development Kit.
How to convert Java Card sources using Maskgen tool?
Check Running Maskgen oracle page:
maskgen Example
This example uses a text file (args.txt) to pass command line
arguments to maskgen:
maskgen -o mask.c cref #args.txt
where the contents of the file args.txt is:
first.jca second.jca third.jca
This is equivalent to the command line:
maskgen -o mask.c cref first.jca second.jca third.jca
This command produces an output file mask.c that is compiled with a C
compiler to produce mask.o, which is linked with the Java Card RE
interpreter. Refer to Using the Reference Implementation for more
information about this target platform.
Above ".JCA" (Java Card Assembly) files are generated using Converter tool. Here is its manual.
Some related quoted info from here:
maskgen actually generates a mask.c file which contains VM bytecodes
that are interpreted by the JCVM and the applet is executed. The
mask.c file should be loaded onto the card. This method is used only
for static use of JavaCard.
And
Maskgen takes the CAP file (which is generated by the converter ), and
generates a mask.c file which will be a part of the cref in static
cards. The parameters for memory configuration of your MCU/processor
can be set in maskgen.cfg file.
Anyway, you need a binary release of JCDK to have this tool and its source.

which plugin does RedHawk 1.10 use for IDL editing

RedHawk installs JARs for eclipse plugins from redhawk-yum-1.10.2-5-el6-x86_64.tar.gz. In RedHawk 1.9 it only installed 4 JARs for IDL parsing and editing, but in RedHawk 1.10 it installs these 4 but also 2 from Eclipse Corba Package.
gov.redhawk.eclipsecorba.idl_7.1.0.201501292343.jar
gov.redhawk.eclipsecorba.idl.source_7.1.0.201501292343.jar
gov.redhawk.eclipsecorba.idl.edit_4.1.0.201501292343.jar
gov.redhawk.eclipsecorba.idl.edit.source_4.1.0.201501292343.jar
net.sf.eclipsecorba.idl_0.7.0.218.jar
net.sf.eclipsecorba.idl.edit_0.7.0.218.jar
Many java files have the same names but there are also many differences.
From comments in the source java files it appears that the gov jars used JavaCC to build the parser while those from ECP used SableCC.
Which ones are actually used in RedHawk 1.10 or are they both used for different purposes?
I am trying to look into a parser bug and would like to know which parser to look at.
Sorry, I am not familiar with Eclipse plugin development and have not figured out how to tell what plugins are actually loaded or how they are used.
Redhawk uses the Eclipse Corba Plugin (ECP) project to provide an editor for IDL files:
http://eclipsecorba.sourceforge.net/
The editor does not support constant IDL expresions (e.g. const foo = bar + 1). Unfortunately, the project is not maintained any more (last release in 2008).
For all other IDL functions in the IDE, such as displaying IDLs under the "Target SDR" in the explorer view, the Redhawk IDE has its own parser code which handles this. The IDE's parser currently has the same limitation - it does not recognize constant IDL expressions.
RedHawk uses three distinct IDL parsers. 1) omnicpp (omniorbs version of idl2cpp) uses its own parser. 2) the code that builds a tree for the IDL Repository in Target SDR uses a plugin in gov.redhawk.eclipsecorba.idl.* which has a parser based on JavaCC compiler-compiler. 3) the IDL editor that was introduced in RedHawk 1.9 uses a different plugin in net.sf.eclipsecorba.idl.* which as a parser based on SableCC, a different compiler-compiler.

How to generate a .so file

I am writing an extension for the Scratch text editor application on Elementary OS Luna. But the documentation is practically non-existent for extension creation and I have no idea how to proceed after writing my main code for the extension.
I've already written the extension. I cannot use or test it yet as it needs to be "installed". I spent hours looking for docs but they do not exist. I did however, find a comment on the scratch launchpad page that says
Generally you have to generate a pluginname.so file and put it in
lib/scratch/plugins/pluginname with a pluginname.plugin file
Great. This seems like the last part of creating an extension for Scratch. What is a .so file, and how do I generate one? I've already created the other necessary files like the .plugin file and the .vala file.
Yes, I have searched for .so files but all I found were random things about it like using it with C, or C++ headers but obviously that won't work for me, since I'm using Vala?
How do I generate a .so file? What do I generate it from?
I think the The Vala tutorial could be helpful on creating the actual Shared library or Shared Object.
You can use the autotools, cmake or you can compile and link a shared library directly from the command line, quoted from the Vala tutorial:
Compilation and linking using Command Line
Vala is not yet capable of directly creating dynamic or static
libraries. To create a library, proceed with the -c (compile only)
switch and link the object files with your favourite linker, i.e.
libtool or ar.
$ valac -c ...(source files)
$ ar cx ...(object files)
or by compiling the intermediate C code with gcc
$ valac -C ...(source files)
$ gcc -o my-best-library.so --shared -fPIC ...(compiled C code files)...
From the Scratch Wiki
Due to browser security restrictions, Scratch 2.0 cannot interact with
hardware devices directly. Instead, hardware extensions come with a
helper app, a separate application that the user must install and run
on their computer. Scratch communicates with the helper app via HTTP
requests, and the helper app talks to the hardware. In the future,
some extensions may package their helper apps as browser plugins.
Here are the steps for creating and testing a Scratch extension:
Create an extension description file
Create your helper app and start it
Open the Scratch 2 Offline Editor
Import the extension description (shift-click on "File" and select "Import Experimental Extension" from the menu)
The new extension blocks will appear in the More Blocks palette
Test your extension and iterate!
Helper apps can be written in any language that supports server sockets, such as Python, Node.js, Java, C, etc.
Like you I've chased around the wiki but I cannot find an example with source. So all I can do is to address your question generally.
If you look at Build .so file from .c file using gcc command line you'll see how a simple .so can be created. However what code goes into a Scratch extension I don't know. Sorry.
Edit: More googling and I've found a sample from Nathan Dinsmore on GitHub that doesn't use C rather it uses JavaScript, and though it doesn't create a .so extension, it does have what appears to be a full description of creating an extension. He also provides a couple of tutorials.
Edit++ : And here is another sample written in Java.

Linux+Language for video capture & Display

Very soon we are going to work on a project with open source s/w that does many things and one of the modules concerns with capturing live feed from a usb based camera for upto 48 hours and overwriting it in a nonstop loop. This would be going on in parallel with other operations in the application. We also have to display the captured feed of the least 48 hours to the user as a menu option.
I would like you all to suggest a suitable open source technology stack taking into account the audio/video part of the module, without this feature I can definitely use Qt to do my stuff but with this feature that becomes a difficult proposition. I have developed GUI applications with Qt on Linux platform but haven't been able to come up with something that can record and display video in an application. Qt has phonon but setting it up is a nightmare. Earlier some of you had suggest v4linux. I tried to compile the sample program capture.c on RHEL 4 machine and it gave the following errors.
usr/src/kernels/2.6.9-5.EL-i686/include/linux/videodev2.h:436: warning: no semicolon at end of struct or union
/usr/src/kernels/2.6.9-5.EL-i686/include/linux/videodev2.h:436: error: syntax error before '*' token
/usr/src/kernels/2.6.9-5.EL-i686/include/linux/videodev2.h:438: error: syntax error before '*' token
/usr/src/kernels/2.6.9-5.EL-i686/include/linux/videodev2.h:438: warning: data definition has no type or storage class
/usr/src/kernels/2.6.9-5.EL-i686/include/linux/videodev2.h:439: error: syntax error before '}' token
/usr/src/kernels/2.6.9-5.EL-i686/include/linux/videodev2.h:810: error: field `win' has incomplete type
So hit a dead end, besides I haven't come up with concrete workable examples for the same. Also the website isn't being updated frequently suggesting a stagnancy in development process.
Since the application will be graphical with menu based user interaction, it would need to use Qt or something similar to it for the graphical part. The headache is I haven't been able to figure out, how I can implement/integrate the video capture/display feature in a dummy application (my try was with Qt may be some of you have done it with some other library or language).
EDIT:
Was able to compile the program by importing a local copy of videodev2.h and adding define statement to include a __user macro. But now it won't run as it cannot find /dev/video device. So again stuck at a dead end in video4linux
You could try the FFmpeg family of libraries. As of fairly recently (I think), it also comes with the libavdevice library that supports V4L and V4L2 for video capture, and it shouldn't be very difficult to build a FFmpeg pipeline to read video from an avdevice source and write it using avcodec and avformat into a file...
gstreamer is a very capable multimedia stack for capturing, and pygst and PyQt4 bindings exist for use in Python.
If it said "can't find /dev/video", that is because Linux numbers the devices.
If you would have looked in the .c file you would have seen there were several arg_opts
as -d ... (where ... would become /dev/video0) or you can go in the .c file and add a 0 to /dev/video, you'll find it somewhere about line 590 in the beginning of int main.

Resources