5

This is my first question here as before I found all workarounds from another questions.

The question is very short: Does anyone know if there is any Diffie-Hellman implementation for iOS? I mean...the idea is to share between 2 devices (one is iOS and the other a java web service) a secret key, and I think the best idea should be that method.

If not, can anyone suggest me another option?

I'm not an advanced developer, that's why i'm trying to check for a framework for this.

Thanks in advance everyone!

user1138682
  • 51
  • 1
  • 3
  • In case you are not aware, there are restrictions on using encryption that will affect your app's approval when you submit to the App Store. See for example http://stackoverflow.com/questions/2128927/using-ssl-in-an-iphone-app-export-compliance – Clafou Jan 09 '12 at 13:16

5 Answers5

4

Apple has an implementation of Diffie-Hellman in iOS as part of Secure Transport. Here is the Secure Transport Reference

I'm posting this answer on a very old question because it's still relevant and other questions might link to this one. Improving this question's completeness may help answer newer questions.

1

A quick google gives;

http://www.chilkatsoft.com/dh-objc.asp

You should really look into just using SSL though instead of inventing your own security protocol.

Joachim Isaksson
  • 176,943
  • 25
  • 281
  • 294
  • 1
    yeah I forgot to mention I found that chilkat implementation. Problem is that it appears almost in every google result and its not free. – user1138682 Jan 09 '12 at 13:04
  • 1
    Free was not a requirement in the question :) Still, inventing your own security protocol when SSL is available sounds dodgy. Is there any special requirement that excludes SSL? – Joachim Isaksson Jan 09 '12 at 13:06
  • not at all, I'm just a newby in security development. I read that with SSL i'm enable to make a secure connection (which I think ASIHTTPRequest would be giving you this quiet easy) but it doesnt provide me a method to encrypt something and decrypt it from the other side right? – user1138682 Jan 09 '12 at 13:16
  • Communicating over a properly set up SSL connection encrypts everything, both server-to-client and client-to-server communication without you needing to do anything about it. – Joachim Isaksson Jan 09 '12 at 13:22
0

You can include openssl as a static library in your app project and use its Diffie-Hellman functions. As Joachim rightly says though, if you're communicating to a web service the easiest and best approach is to use SSL.

0

There is a Diffie-Hellman implementation for iOS in github. You can use it. https://github.com/benjholla/Diffie-Hellman-iOS Also you can use openssl with ios. Considering openssl is a proven library, it is better to use openssl for this purpose.

deltaaruna
  • 528
  • 6
  • 24
-1

There is a Diffie-Hellman implementation for iOS SWIFT-4 on github with complete example code. You can use it. https://github.com/raoarafat/DeffieHelmanKeyExchange-Swift. Just download & use it.

SWIFT-4 Compatible.

Enjoy...

Rao
  • 1