views:

124

answers:

5

I need to send data from my iPhone application to my webserver, and back. To do this securely, I'm using an encryption algorithm. It requires a key that must be known by both the server and the user so that decryption can take place. I was thinking about just using a simple static string in my app and on the server as the key, but then I remembered that compiled code can still be disassembled and viewed, but only to a certain extent.

So, how safe would I be by placing the encryption methods and "secret" string in the source code of my app? Are there any other ways to accomplish communication between an app and server securely?

Thanks.

+4  A: 

What "certain extent" do you think that is exactly? Every instruction and every piece of data your application contains is open to possible viewing. Besides, using the same key for every device is the ultimate in cryptographic insanity.

Just use HTTPS. SSL/TLS is a secure, proven technology built into every major HTTP server and every major HTTP client library.

Nicholas Knight
+5  A: 

Yes, it can be found rather easily. Run the strings program on your executable and you'll probably find it. Besides, anything in your program can be "found", since it's necessarily open for reading.

Use SSL for secure connections. It uses asymmetric encryption, which means the key to encrypt the data is not the same that will be required to decrypt it. That way, even if attackers find out your encryption key, they still can't use it to decode. All major HTTP servers and client libraries support HTTPS, and that's what it does.

zneak
Thanks, SSL seems like the simplest to implement yet most secure way, after looking at how unsymetric algorithms work...
pop850
+2  A: 

You use a symmetric algorithm. Maybe you should consider to have an unsymetric method if you need a high security. That way you could even recreate the keys at i.e. every session and only need to exchange the public key.

Here some examples:

  • RSA
  • Diffie-Hellman
  • ElGamal
  • ECDSA
  • XTR
schoetbi
A: 

As others have said, what you're proposing is completely insecure. If anyone cares about your app, they'll publish the secret key on the Internet within 10 minutes of its release.

Things you need to research are:

  1. Asymetric encryption algorithms
  2. Diffie-Hellman key exchange

(Note - I'm not saying those are the solution to your problem, but learning about them will educate you in the issues involved and better prepare you to pick a solution)

On an additional note, why can't you just use an HTTPS connection?

Finally, if this encryption scheme is protecting critical data, you'd probably be well served to hire a consultant to help you, since as a newbie to the subject, you're sure to make basic mistakes.

Wade Williams
+1  A: 

iOS has Keychain Services for storing things like encryption keys securely and (relatively) easily. Check out Keychain Services Programming.

All of the crypto APIs you're likely to need are also available in the CommonCrypto library included in libSystem. In short, there is no need to take shortcuts when it comes to securing your iOS applications.

Kaelin Colclasure