Search code examples
javaandroidc++diffie-hellman

Diffie-Hellman Library for c++ and java


I want to exchange a public key between a c++ application and and android application. I decided to use Diffie-Hellman. On the C++ side this library looks promising for generating the keys with c++. Now I am looking for an implementation for java to generate the keys on the android smartphone.

What libraries would you suggest, also on the c++ side? In the end i want to share the public key as a string via UDP.

kind regards


Solution

  • A long time ago I used Crypto++ for the C++ which worked well for me and has support for many different algorithms.

    http://www.cryptopp.com/

    For android the KeyAgreement class can be used on some JavaVM, it is initialized with a String to choose the algorithm. You could try to instantiate it with "DiffieHellman" and see if you get an instance.

    According to Java7 docs, http://docs.oracle.com/javase/7/docs/api/javax/crypto/KeyAgreement.html - "Every implementation of the Java platform is required to support the following standard KeyAgreement algorithm: DiffieHellman"

    Test it and see if that includes dalvik or not.