0

I am working on a javacard applet project where i need...

  1. Secure communication between two applets let say there is applet A and applet B. Let say both applet has their own RSA key pairs.
  2. Now I want to perform Diffie-Hellman key exchange between these applet.So that both applet can talk securely.

How to perform above mentioned functionality if anyone can also suggest other than this where two applets can communicate by using asymmetric crypto.

Any help on this topic will be highly appreciated.

2 Answers2

3

You can use ephemeral Diffie-Hellman and then use RSA to authenticate the parameters and established key seed the same way as TLS does. Java Card implementations usually contain an implementation of ECDH key agreement. An advantage is that you don't need very large key sizes to be reasonably secure. Furhtermore, ECDH operation and key pair generation is plenty fast.

Note that Java Card 3.0.5 contains enhancements both with regards to Diffie-Hellman as well as handling Elliptic Curves and parameters in RAM. Furthermore implementations may contain authenticated ciphers making it easier to define your own efficient secure messaging channel.

[Historical] This is however probably only of concern to future readers, as I don't think any 3.0.5 implementations are out yet.

By now there should be 3.0.5 implementations available.

Maarten Bodewes
  • 96,351
  • 14
  • 169
  • 323
2

Both RSA and DH have a similarity which is the Modulus Exponential (modexp) function (RSA encrypt/decrypt function). Since both RSA and DH uses the same modexp function, you can make full use of the Cipher for ALG_RSA_NOPAD in JavaCard's crypto API.

I have sat down and taken time to adapt the RSA crypto functions for traditional non-ECC type of DH functions and you can find the open source applet code here (https://github.com/ASKGLab/DHApplet/blob/master/src/dhapplet/DH.java).

I have not yet done up the APDU commands to create a full fledge demo but I guess if you study the DH.java codes, it should be more than enough to give you a head start. I have included a ton of commends in the source code on how to adapt it to different scenarios and the thought process as well when designing the entire DH class and it's significance.

thotheolh
  • 254
  • 1
  • 12