1
$\begingroup$

It may seem that this is a programming question, but I just need advice on the cryptography side of the question. I want to implement the Diffie-Hellman key exchange algorithm on iOS (since no free library with easy integration exists). I'm wondering how the implementation would be if the parameters would be – for example – 128 bytes of data, instead of integers.

I'm looking for instructions so that I find out how I should implement it because performing such operations on non-integers is quite ambiguous to me.

Sorry if it's a newbie question, but I'm new to this concept.

Any suggestions is really appreciated.

$\endgroup$
4
  • 1
    $\begingroup$ "I want to implement the Diffie-Hellman key exchange algorithm on iOS (since no free library with easy integration exists)."- Crypto++ (boost license) supports iOS and offers (EC)DH... (Disclaimer: I'm a helper with them). $\endgroup$
    – SEJPM
    Commented Jan 19, 2016 at 10:02
  • $\begingroup$ @SEJPM I compiled Crypto++ to use its methods for Diffie-Hellman key exchange. However there's not much about how to use crypto++ library with iOS SDK in the community, and most of the links inside Wiki and FAQ pages on Cryptopp website is broken and missing. I have no idea how to start. It would be great if we can chat a few minutes about some basic concepts on Crypto++. $\endgroup$
    – Sepehrom
    Commented Jan 22, 2016 at 11:00
  • $\begingroup$ So go ahead and create a new chat room (on chat.stackexchange.com ) and post the link here. I'll join asap and be at your disposal (chances are good I'll be there within 3 hours and ping you) $\endgroup$
    – SEJPM
    Commented Jan 22, 2016 at 16:17
  • $\begingroup$ Thank you very much Looking forward to see you in the room : chat.stackexchange.com/rooms/34744/… $\endgroup$
    – Sepehrom
    Commented Jan 23, 2016 at 12:04

1 Answer 1

1
$\begingroup$

Diffie-Hellman relies on a mathematical problem on positive integers. To use it with bytes you just have to convert the bytes to - or use the bytes as - an integer. Usually this would be a unsigned big-endian (or network order) integer.

For Diffie-Hellman the parameters consist of the modulus and the base. The public value could be 1024 bits (128 bytes). 1024 bit cryptography is considered "legacy strength" for discrete logarithm related problems though.


With Java for instance the conversion can be as easy as new BigInteger(1, data) where 1 indicates a positive integer and data is a byte array.

$\endgroup$
4
  • $\begingroup$ Did I already warn against implementing your own crypto? If not, consider yourself warned. $\endgroup$
    – Maarten Bodewes
    Commented Jan 19, 2016 at 0:01
  • 2
    $\begingroup$ Diffie Hellman does not rely on a mathematical problem of positive integers. It relies on a problem (CDH) in discrete log hard groups. It happens that among such groups (besides elliptic curve groups) are the multiplicative groups of prime fields of large prime characteristic $p$ and that are the integers from $1$ to $p-1$. $\endgroup$
    – DrLecter
    Commented Jan 19, 2016 at 7:20
  • $\begingroup$ @DrLecter In relation to the question, isn't it true that these logarithmic-hard groups are represented by positive integers? You are right of course, but I'm trying to make the answer as readable as possible... $\endgroup$
    – Maarten Bodewes
    Commented Jan 19, 2016 at 8:29
  • $\begingroup$ Yes thats true for one class of suitable groups (as stated at the end of my comment). But the first sentence in your answer is not correct. You should rather say: Diffie Hellman is used in a setting where one represents the involved elements as positive integers. $\endgroup$
    – DrLecter
    Commented Jan 19, 2016 at 8:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.