<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>On the road to Bandol &#187; Framework</title>
	<atom:link href="http://javacard.vetilles.com/category/java-card-2x/framework/feed/" rel="self" type="application/rss+xml" />
	<link>http://javacard.vetilles.com</link>
	<description>A weblog on Java Card, security, and other things personal</description>
	<lastBuildDate>Mon, 18 Aug 2025 06:48:26 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.0.32</generator>
	<item>
		<title>Java Card RMI is useless</title>
		<link>http://javacard.vetilles.com/2007/01/28/java-card-rmi-is-useless/</link>
		<comments>http://javacard.vetilles.com/2007/01/28/java-card-rmi-is-useless/#comments</comments>
		<pubDate>Sun, 28 Jan 2007 21:08:14 +0000</pubDate>
		<dc:creator><![CDATA[Eric Vétillard]]></dc:creator>
				<category><![CDATA[Framework]]></category>
		<category><![CDATA[IdÃ©es reÃ§ues]]></category>
		<category><![CDATA[Java Card 2.x]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://javacard.vetilles.com/2007/01/28/java-card-rmi-is-useless/</guid>
		<description><![CDATA[When we first presented GemXpresso in 1997, it was made by a bunch of (Gemplus) researchers. We were all very happy, because it was a very nice card, and because it was very simple to program, thanks to Remote Method Invocation (RMI), which freed us from these damn APDU&#8217;s. It was possible to generate automatically [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>When we first presented GemXpresso in 1997, it was made by a bunch of (Gemplus) researchers. We were all very happy, because it was a very nice card, and because it was very simple to program, thanks to Remote Method Invocation (RMI), which freed us from these damn APDU&#8217;s. It was possible to generate automatically the code that interfaces the card application with its client application on the terminal.<br />
<span id="more-56"></span><br />
10 years later, RMI on Java Card has been a great success. It generated a few publications, got us to San Francisco and JavaOne a few times, and it was even incorporated in the Java Card 2.2 standard as a <em>mandatory</em> feature, a few years ago. Even better, it was mentioned in <a href="http://www.jcp.org/en/jsr/detail?id=177" title="Security and Trust Services for Java ME" class="liexternal">JSR-177</a> as one of the ways to communicate between a phone and a smart card. This made us all very proud.</p>
<p>But nobody ever used it. Nobody.</p>
<p>Why so? Because it solved the wrong problems. My passion at the time was to make developers&#8217; life easier, and this passion was shared by many other members of the original GemXpresso team. We believed that making smart card application development available to many developers in a simple way would necessarily generate the next &#8220;killer app&#8221;. Of course, it didn&#8217;t, because the problem is not with the developers.</p>
<p>A smart card is not the Internet, and the next killer app will come from somebody who has a great idea about a novel way to establish trust between two entities, or something like that. And that guy will then subcontract the development to one of the happy few guys in the world who know how to write good Java Card code, optimized and secure.</p>
<p>So now, Java Card RMI mostly represents a few kilobytes of dead code in every Java Card on the market. Maybe that one of your cards is able to do RMI and you don&#8217;t even know it. Don&#8217;t worry for the future, the designers of Java Card RMI are still very much involved in the design of Java Card 3. We will most likely make a few mistakes in our design, but not this one.</p>
<p>To end with a happy note, it has been said that Java Card 3 would be fully backward compatible with Java Card 2.x, and it most likely will be true. Java Card RMI will then lie dormant in many more cards of the next generation. And maybe someone will use it.</p>
]]></content:encoded>
			<wfw:commentRss>http://javacard.vetilles.com/2007/01/28/java-card-rmi-is-useless/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Status words in ISO7816</title>
		<link>http://javacard.vetilles.com/2006/09/26/status-words-in-iso7816/</link>
		<comments>http://javacard.vetilles.com/2006/09/26/status-words-in-iso7816/#comments</comments>
		<pubDate>Tue, 26 Sep 2006 16:28:42 +0000</pubDate>
		<dc:creator><![CDATA[Eric Vétillard]]></dc:creator>
				<category><![CDATA[Framework]]></category>
		<category><![CDATA[Java Card 2.x]]></category>

		<guid isPermaLink="false">http://javacard.vetilles.com/2006/09/26/status-words-in-iso7816/</guid>
		<description><![CDATA[Status words are very important in the ISO7816 specification, since they are used to indicate specific conditions. The ISO7816-3 specification states the following: 60 is the NULL byte, used to get additional time. Status words starting by 6X (except 60) have a &#8220;meaning [that is] independent of the application&#8221;. Status words starting by 9X (except [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Status words are very important in the ISO7816 specification, since they are used to indicate specific conditions. The ISO7816-3 specification states the following:</p>
<ul>
<li><code>60</code> is the NULL byte, used to get additional time.</li>
<li>Status words starting by <code>6X</code> (except <code>60</code>) have a &#8220;meaning [that is] independent of the application&#8221;.</li>
<li>Status words starting by <code>9X</code> (except <code>9000</code>) have a &#8220;meaning [that] relates to the application itself&#8221;.</li>
</ul>
<p>What that means is that the GSM specs are correctly defined, as they use 9X status words for application-specific statuses, but the Java Card spec is not correct, since it defines the <code>6999</code> status word, which is reserved by ISO7816 for future use. On the other hand, one can argue that the meaning of <code>6999</code> is independent of the application. Still, not perfectly clean.<br />
<span id="more-37"></span><br />
The ISO7816-3 specification provides meanings for a few <code>6X</code> status words, and the ISO7816-4 specification provide a few more. The list provided in ISO7816-4 is as follows:</p>
<ul>
<li><code>61XX</code>: Normal processing, XX indicates the amount of data to be retrieved.</li>
<li><code>62XX</code>: Warning, the state of persistent memory is unchanged. The command succeeded, possibly with restrictions. Typically used to signal blocked applications.</li>
<li><code>63XX</code>: Warning, the state of persistent memory is changed. Typically used to indicate the number of attempts left on a PIN code after a failure.</li>
<li><code>64XX</code>: Execution error, the state of persistent memory is unchanged.</li>
<li><code>65XX</code>: Execution error, the state of persistent memory is changed.</li>
<li><code>66XX</code>: Security-related issues.</li>
<li><code>6700</code>: Transport error. The length is incorrect.</li>
<li><code>68XX</code>: Functions in CLA not supported (since 2005).</li>
<li><code>69XX</code>: Command not allowed.</li>
<li><code>6AXX</code>: Wrong parameters P1-P2 (with details).</li>
<li><code>6B00</code>: Wrong parameters P1-P2.</li>
<li><code>6CXX</code>: Wrong Le field. <code>XX</code> indicates the appropriate length.</li>
<li><code>6D00</code>: The instruction code is not supported (usually with XX=00).</li>
<li><code>6E00</code>: The instruction class is not supported (usually with XX=00).</li>
<li><code>6F00</code>: No precise diagnosis is given</li>
</ul>
<p>The ISO7816-4 defines many more SW2 values (around 40), and it also defined a few important rules, which can be used as good guidelines:</p>
<ul>
<li><code>61XX</code> and <code>6CXX</code> are different. When a command returns 61XX, its process is normally completed, and it indicates the number of available bytes; it then expects a GET RESPONSE command with the appropriate length. When a command returns <code>6CXX</code>, its process has been aborted, and it expects the command to be reissued. As mentioned above, <code>61XX</code> indicates a normal completion, and <code>6CXX</code> is considered as a transport error (defined in ISO7817-3).</li>
<li>Except for <code>63XX</code> and <code>65XX</code>, which warn that the persistent content has been changed, other status word should be used when the persistent content of the application is unchanged.</li>
<li>Status words <code>67XX</code>, <code>6BXX</code>, <code>6DXX</code>, <code>6EXX</code>, and <code>6FXX</code>, where <code>XX</code> is not 0, are proprietary status words, as well as <code>9YYY</code>, where <code>YYY</code> is not <code>000</code>.</li>
</ul>
<p>Note that the last point extends the realm of the status words that can be defined in a proprietary way. However, Java Card&#8217;s <code>6999</code> remains a violation of the rule.</p>
]]></content:encoded>
			<wfw:commentRss>http://javacard.vetilles.com/2006/09/26/status-words-in-iso7816/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Exception handling in install</title>
		<link>http://javacard.vetilles.com/2006/09/05/exception-handling-in-install/</link>
		<comments>http://javacard.vetilles.com/2006/09/05/exception-handling-in-install/#comments</comments>
		<pubDate>Tue, 05 Sep 2006 20:25:30 +0000</pubDate>
		<dc:creator><![CDATA[Eric Vétillard]]></dc:creator>
				<category><![CDATA[Framework]]></category>
		<category><![CDATA[Open issues]]></category>

		<guid isPermaLink="false">http://javacard.vetilles.com/2006/09/05/exception-handling-in-install/</guid>
		<description><![CDATA[The JCRE specification does not describe how the exceptions thrown from the install command should be handled. The reason for this is that these exceptions are supposed to be handled by an installer application, and the JCRE specification (&#182;11.1.5)explicitly states: Java Card RE implementers shall also define other behaviors of their Installer, including (&#8230;) what [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>The <acronym title="Java Card Runtime Environment">JCRE</acronym> specification does not describe how the exceptions thrown from the install command should be handled. The reason for this is that these exceptions are supposed to be handled by an installer application, and the <acronym title="Java Card Runtime Environment">JCRE</acronym> specification (&para;11.1.5)explicitly states:</p>
<blockquote><p>
Java Card RE implementers shall also define other behaviors of their Installer, including (&#8230;) what happens if an exception, reset, or power fail occurs during installation.
</p></blockquote>
<p>In most Java Card implementations, the <a href="http://www.globalplatform.org" title="The GlobalPlatform Consortium" class="liexternal">GlobalPlatform</a> card specification is used as a reference for the implementation of the Installer. An applet&#8217;s <code>install</code> method is invoked during the execution of an INSTALL [for install] command, and the definition of this command does not define any precise behavior if the installation of the application fails.</p>
<p><span id="more-9"></span><br />
In practice, many different cases may occur. First, it depends on when the application fails</p>
<ul>
<li>The application throws an exception before to invoke <code>Applet.register</code>. In that case, according to the Java Card specification, the installation is deemed unsuccessful. The INSTALL command shall therefore fail.</li>
<li>The application throws an exception after invoking successfully <code>Applet.register</code>. In that case, according to the Java Card specification, the installation is deemed successful, despite the exception. In that case, the outcome of the INSTALL command is not completely clear.</li>
</ul>
<ul>
<li>The application throws an <code>ISOException</code>. If this occurs in the <code>Applet.process</code> method, the exception&#8217;s <code>reason</code> is returned as status word.</li>
<li>The application throws any other exception. If this occurs in the <code>Applet.process</code> method, the Java Card RE returns the status word <code>6F00</code> (Unknown error).</li>
</ul>
<p>These different cases lead platform developers to make two choices: whether or not to the INSTALL command shall succeed if an exception is thrown after successful registration, and which status word to return when the INSTALL command fails. On the first issue, there are two possible interpretations:</p>
<ul>
<li><strong>The INSTALL command should fail whenever the install method ends with an exception.</strong> The rationale behind this choice is that an error should never go unnoticed, and that the user needs to be warned of the error.</li>
<li><strong>The INSTALL command should succeed whenever the applet instance has been successfully registered.</strong> The rationale behind this choice is that the result of the INSTALL command shall reflect the overall result of the execution, <em>i.e.</em> the fact that the instance has been registered.</li>
</ul>
<p>About the exception to be returned, there also are several possible interpretations:</p>
<ul>
<li><strong>The INSTALL command should return the same status word as the Java Card RE would return from the <code>Applet.process</code> method.</strong> The argument is here that the information provided by the application about the reason of the failure should not be lost.</li>
<li><strong>The INSTALL command should always return a status word listed in its specification.</strong> This means that the status code implied by the exception shall be ignored, and that a standard GlobalPlatform exception shall be returned, for instance <code>6400</code> (No specific diagnosis) or <code>6985</code> (Conditions of use not satisfied).	The argument is here that a GlobalPlatform command should not return status words that the terminals may not expect.</li>
</ul>
<p>In both cases, the arguments from both sides are acceptable, which means that there is no strong decision to take. My own opinion is that the INSTALL command should succeed whenever the applet instance has been successfully registered, and it should always return a status word listed in its specification.</p>
<p>The conclusion is that an application should not rely on any of these behaviors if it needs to be portable between platforms. The best solution is to avoid throwing exceptions (a simple <code>return</code> before registration is enough to abort the installation), and to avoid putting code after the call to <code>Applet.register</code>. This is easy to do, except for SIM Toolkit applications, which usually need to do some operations after the applet&#8217;s registration. We&#8217;ll see how to do that correctly in another post.</p>
]]></content:encoded>
			<wfw:commentRss>http://javacard.vetilles.com/2006/09/05/exception-handling-in-install/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Throwing exceptions</title>
		<link>http://javacard.vetilles.com/2006/09/04/throwing-exceptions/</link>
		<comments>http://javacard.vetilles.com/2006/09/04/throwing-exceptions/#comments</comments>
		<pubDate>Mon, 04 Sep 2006 20:22:42 +0000</pubDate>
		<dc:creator><![CDATA[Eric Vétillard]]></dc:creator>
				<category><![CDATA[Framework]]></category>

		<guid isPermaLink="false">http://javacard.vetilles.com/2006/09/04/throwing-exceptions/</guid>
		<description><![CDATA[Exceptions are a nice feature of the Java language, which is available to Java Card developers. The nice thing about exceptions is that you don&#8217;t have to deal with error codes. We here recall a few good practices about the use of exceptions in Java Card applications. In Java Card like in Java, exceptions have [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Exceptions are a nice feature of the Java language, which is available to Java Card developers. The nice thing about exceptions is that you don&#8217;t have to deal with error codes. We here recall a few good practices about the use of exceptions in Java Card applications.<br />
<span id="more-7"></span>In Java Card like in Java, exceptions have two main uses:</p>
<ul>
<li>The runtime environment uses exceptions to signal errors such as null pointers, attempts to access an array outside of its bounds, or more specific details like attempting to allocate a crypto engine that is not supported.</li>
<li>The application uses exceptions to signal its own errors, and abort the execution of the currently executing code.</li>
</ul>
<p>In the case of Java Card, there is one additional use for exceptions:</p>
<ul>
<li>The <code>ISOException</code> type is used to return a status word to the card terminal if the execution of the application ends with an instance of it. Any other exception yields a <code>6F00</code> status word (meaning &#8220;Unknown error&#8221;, not very useful).</li>
</ul>
<p>We will here focus on the use of exceptions by applications as means of internal communication (<em>i.e.</em>, excluding the use of <code>ISOException</code>). The following rules can be considered as good practice:</p>
<ul>
<li>Catch all the exceptions you throw.<br />
As a stray exception will trigger a <code>6F00</code> status word, this seems quite natural.</li>
<li>Use checked exceptions / Don&#8217;t use runtime exceptions.<br />
These two guidelines are the same. Using checked exceptions guarantees that exceptions must be declared. Runtime exceptions, beyond the fact that they are not checked, are the exceptions used by the runtime environment, and it is better not to confuse the exceptions.</li>
<li>Don&#8217;t define new exception classes.<br />
Defining an exception class is difficult in Java Card. In addition, the exception instances managed by the <acronym title="Java Card Runtime Environment">JCRE</acronym> are all JCRE entry-point objects, which can be very practical in many situations.</li>
</ul>
<p>This sounds quite difficult, but Java Card offers a solution, which is to use the <code>UserException</code> class. It is a standard exception, it is a checked exception, and you have to catch all instances. The following example can be considered as good practice:</p>
<pre>public static final short RS_LOW_BALANCE ;

public short debit(short value) throws UserException
{
  if (value > balance)
    UserException.throwIt(RS_LOW_BALANCE) ;
  balance -= value ;
}</pre>
<p>The important thing is here that the throws <code>UserException</code> clause is mandatory (otherwise the compiler wil fail). Since the <code>Applet.process</code> method does not have such a clause, it means that the compiler will ensure that all exceptions are caught, enforcing the good usage guidelines all by itself.</p>
<p>Exceptions also need to be caught. It is possible to do it as soon as possible (in the same method, or in the calling method), or to do it much later. But this is another discussion, for another post.</p>
]]></content:encoded>
			<wfw:commentRss>http://javacard.vetilles.com/2006/09/04/throwing-exceptions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
