ECC Programming in Java Card: Abstract-Elliptic Curve Cryptography (ECC) Is A Branch
ECC Programming in Java Card: Abstract-Elliptic Curve Cryptography (ECC) Is A Branch
Abstract—Elliptic Curve Cryptography (ECC) is a branch ECC applications in Java Card. In order to facilitate the
of public-key cryptography based on the arithmetic of el- understanding of the example, we have included the script
liptic curves. Given its mathematical characteristics, ECC needed to execute it and the console output obtained when
is currently one of the best options for protecting sensitive
information. The lastest version of the Java Card platform running the applet in a simulator.
includes several classes related to elliptic curves. However, The rest of this paper is organized as follows: Section II
potential developers are discouraged by the peculiarities of presents a brief mathematical introduction to elliptic curves.
its programming model and the scarce information available. In Section III, we review some important concepts about
In this work, we present an up to date and extensive review of smart cards. Section IV describes the most relevant charac-
the ECC support in Java Card. In addition to that, we offer to
the reader the complete code of two applications that will allow
teristics of Java Card, including the new features presented
programmers to understand and test the entire application by each version. Section V details the ECC functionality
development process in Java Card. included in the different Java Card releases. In Section VI,
we offer two code examples which demonstrate how to
Keywords-elliptic curves; information security; Java Card;
public key cryptography; smart cards; create digital signatures and produce a shared secret using a
key agreement procedure. Finally, Section VII summarizes
As it is well known, in 1985 Miller [1] and Koblitz our conclusions about this topic.
[2] independently proposed a cryptosystem based on the
ECDLP (Elliptic Curve Discrete Logarithm Problem). This I. E LLIPTIC C URVE C RYPTOGRAPHY
field of cryptography is usually known as ECC (Elliptic
Curve Cryptography). In comparison with other public- An elliptic curve E over the field F is a regular projective
key cryptosystems, ECC uses significantly shorter keys to curve of genus 1 with at least one rational point ([5] and
achieve the same level of security [3]. This makes ECC the [6]). Every elliptic curve admits a canonical equation called
perfect choice for devices with limited resources [4]. the general Weierstrass form. That equation in homogeneous
coordinates is
In 1996, the smart card sector witnessed the appearance of
a new technology named Java Card. Java Card is the smallest Y 2 Z +a1 XY Z +a3 Y Z 2 = X 3 +a2 X 2 Z +a4 XZ 2 +a6 Z 3 ,
of the Java platforms, and it allows to develop and install
a specific type of Java-based application (called applet) in with a1 , a2 , a3 , a4 , a6 ∈ F and ∆ ̸= 0, where ∆ is the
smart cards compliant with the Java Card specifications. discriminant of E.
This card technology is widely used in several sectors, for The homogeneous Weierstrass equation defines a projec-
example in the cell phone and banking industries. In those tive plane curve which has a special point, the point at
sectors security is essential, so the integration of crypto- infinity, which is denoted as O = [0 : 1 : 0]. In principle that
graphic capabilities is a typical application requirement. curve does not have to be elliptic, as it could have singular
Although Java Card is derived from the Java language, points. Due to that fact, the condition ∆ ̸= 0 assures that the
its programming model has several important particularities, curve is regular, which is equivalent to stating that there are
so most Java programmers are not able to develop applets no curve points where the first derivatives of the function
unless they are provided the proper training. Unfortunately, are cancelled [7].
the number of learning resources about this technology In practice, instead of the general Weierstrass equation,
is limited, which makes the development of Java Card two short Weierstrass forms depending on the characteristic
applications a complex and resource-consuming operation of the finite field Fq are typically used:
for most software companies. • If the finite field is a prime field, i.e. F = Fp , where
This contribution analyses the ECC capabilities in every p > 3 is a prime number, the equation defining the
Java Card version released so far, including all the classes (non-supersingular) elliptic curve becomes
and ECC functions implemented. In addition to that, we
provide a complete code example that shows how to develop y 2 = x3 + ax + b.
Figure 1. Command APDU Figure 2. Response APDU
• If the finite field is a binary field, i.e. F = F2m , where • Data (variable length, optional): information returned
m is an integer number, then the equation of the (non- by the card application.
supersingular) elliptic curve is • SW1 (1 byte): first status byte, which provides general
information about the result of the command execution.
y 2 + xy = x3 + ax2 + b. • SW2 (1 byte): second status byte.
→ 00A4040006C9AA4E15B3A2
ACKNOWLEDGMENT
← 9000
→ 00D1000000 This work has been partially supported by Ministerio
← 9000 de Ciencia e Innovación (Spain) under the grant TIN2011-
22668.
R EFERENCES
[1] V. S. Miller, “Use of elliptic curves in cryptography,” Lecture
Notes Comput. Sci., vol. 218, pp. 417–426, 1986.
[14] Oracle Corp. (2013) Java Card development quick start guide.
https://netbeans.org/kb/docs/javame/java-card.html.