Secure Key exchange using javacard applet I am working on a javacard applet project where i need...


Secure communication between two applets let say there is applet A
and applet B. Let say both applet has their own RSA key pairs. 
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.
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.