Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

My ENIGMAtic Java Ring

Using the model of an old wartime encryption machine, find out how to fashion your own secret encoder ring

  • Digg
  • Reddit
  • SlashDot
  • Stumble
  • del.icio.us
  • Technorati
  • dzone
For me, the highlight of the JavaOne Developer Conference in San Francisco last March was Dallas Semiconductor's iButton with Java -- aka the Java Ring, a wearable computer that ran Java. It allegedly had a high-performance encryption engine, an exciting prospect indeed, until I discovered that the encryption unit wasn't accessible on the ring. Dallas Semiconductor later confirmed that it couldn't be enabled at all, which really dampened my enthusiasm for the whole concept.

I am resourceful though, and since Dallas Semiconductor had promised that a fully functional Java Ring was going to be available eventually, all I needed to do was wait. And while I was waiting, what better to do but learn the ins and outs of programming my new piece of "smart" jewelry?

Of course this pursuit of knowledge did raise the question of what, exactly, I should program into my ring.

I pondered this question for a while, until I came up with what was, for me, the ideal solution: I would program my ring to simulate the most important piece of cryptographic equipment used in the second World War -- the German ENIGMA machine. The ENIGMA was used by German commanders to encrypt all of their important plans and orders to the field marshalls. But first I had to figure out what the heck an APDU was!

The Java Card applet model

The Java Ring is in fact a Java smart card, and the ring's virtual machine is based on the Java virtual machine (JVM) that was proposed as the Java Card 2.0 standard. I've seen some wonderful technical discussions on how to program these devices (see the Resources section for pointers), but, to be perfectly honest, the descriptions were quite opaque to me. I was looking for linkages between the JVM on the ring and the JVM on a PC and finding nothing beyond descriptions of a rather peculiar serial interface that connected them. I then realized that what really connected the ring to the "outside" world was not a serial port but a network protocol. Allow me to explain.

The Java Card architecture has taken client/server architectures to a new place -- one where the "server" is a small piece of software on an extremely small system, and the client is a potentially huge piece of software on a potentially much larger system. The network protocol is encapsulated in packets that are called application program data units, or APDUs for short.

Unlike packets in the TCP/IP world, these APDU packets don't carry any sort of addressing information. Instead, they are implicitly addressed to the computer on the other end of the serial link. However, like their big-brother packets in the TCP/IP world, APDUs do carry a few bytes that are common to all packets. These can be used by the smart card infrastructure to decide when to send the APDUs to the server on the smart card, and when to interpret them directly.

This understanding provided an answer to one of my first questions about the Java Ring: How come a broken applet doesn't make the ring unusable? The answer is that the smart card runtime code gets the first crack at decoding the APDUs as they arrive on the serial interface. Further, there are predefined APDUs that tell the runtime to select an applet, delete applets, load applets, and so on. Thus, errant applets are simply deleted by the developer once it's ascertained that they aren't responding correctly to the APDUs they receive.

  • Digg
  • Reddit
  • SlashDot
  • Stumble
  • del.icio.us
  • Technorati
  • dzone
Comment
Login
Forgot your account info?
Add comment
Anonymous comments subject to approval. Register here for member benefits.
Have a JavaWorld account? Log in here. Register now for a free account.
Resources
  • Enigma.java is the ENIGMA applet http://www.javaworld.com/jw-08-1998/indepth/Enigma.java
  • Rotor.java is the implementation of an ENIGMA rotor http://www.javaworld.com/jw-08-1998/indepth/Rotor.java
  • Home page for the Dallas Semiconductor iButton http://www.ibutton.com
  • Pictures of the ENIGMA machine http://www.math.arizona.edu/~dsl/ephotos.htm
  • More pictures of the ENIGMA machine http://cs.oberlin.edu/classes/cs115/lect30n.html
  • A nice description of the ENIGMA machine http://www.math.arizona.edu/~dsl/enigma.htm
  • Another good description of the ENIGMA machine http://www.trincoll.edu/~cpsc/cryptography/enigma.html
  • Java applet that emulates the ENIGMA machine http://www.attlabs.att.co.uk/andyc/enigma/enigma_j.html
  • Patent for the ENIGMA machine http://www.patents.ibm.com/details?patent_number=3984922
  • Breaking the ENIGMA algorithm and decrypting messages that are ENIGMA encrypted http://www.cs.miami.edu/~harald/enigma/enigma.html
  • A description of many modern cryptographic algorithms http://www.mach5.com/crypto/algorithms.html
  • Previous Java In Depth articles http://www.javaworld.com/topicalindex/jw-ti-indepth.html