Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

RodThePlod

macrumors 6502a
Original poster
Sep 7, 2005
838
499
London
Hey all,

I'm writing an app that will connect to my server and download XML content which it will then display to the user.

Thing is, I'd like to secure this in such a way only my app can access the feed. For example, I don't want other iPhone apps (or websites, etc.) to be able to access and use my feed for free. Maybe at some point, though, I may want to charge and allow them access.

What's the best method to achieve this? Shall I hash it? Some other technique?

I want to get the design of this right at the start rather than implement something and then have to go making major changes down the line.

Any advice appreciated.

Rod
 

jnic

macrumors 6502a
Oct 24, 2008
567
0
Cambridge
Thing is, I'd like to secure this in such a way only my app can access the feed. For example, I don't want other iPhone apps (or websites, etc.) to be able to access and use my feed for free. Maybe at some point, though, I may want to charge and allow them access.

What's the best method to achieve this? Shall I hash it? Some other technique?

Sounds like you're asking for perfect DRM, which I'm afraid is impossible. Someone can always reverse-engineer your app and imitate it to your server.

Your best option is probably to implement something imperfect but difficult to reverse-engineer, so (for example) you could implement some fairly heavy encryption at both ends and break the key up in memory on the device so that it's difficult to extract with a debugger.
 

ace2600

macrumors member
Mar 16, 2008
71
0
Austin, Texas
One way would be sending UDID, timestamp, and HASH(secret_key, UDID, timestamp) in your request. The UDID would identify each device, the timestamp would harden against replay attacks, and the secret key would be known only by your app and the server. The server would create its own hash and compare to the hash in the request.

This is for securing requests, but you would still need to encrypt the XML if that's a security concern.
 

RodThePlod

macrumors 6502a
Original poster
Sep 7, 2005
838
499
London
Thanks for the quick replies.

I'll check out the Apache HTTP authentication and also look into the hashing/encryption methods.

Whatever system I use, I want to be able to potentially offer the ability for collaboration in the future (third parties accessing the feeds) - so I guess I'll have to make a trade off between security and convenience/ease of access in the future.

OK - thanks again for these pointers - much appreciated.

Rod.
 

jnic

macrumors 6502a
Oct 24, 2008
567
0
Cambridge
One way would be sending UDID, timestamp, and HASH(secret_key, UDID, timestamp) in your request. The UDID would identify each device, the timestamp would harden against replay attacks, and the secret key would be known only by your app and the server. The server would create its own hash and compare to the hash in the request.

This is for securing requests, but you would still need to encrypt the XML if that's a security concern.

What is the purpose of preventing replay attacks in this system? Also, given that the only way the server knows about UDIDs is from user requests, what's to stop me forging the UDID? This means we're back to preventing key extraction from memory, but with a pointless layer of hashing.
 

RodThePlod

macrumors 6502a
Original poster
Sep 7, 2005
838
499
London
This means we're back to preventing key extraction from memory, but with a pointless layer of hashing.

jnic, I'll go have a look through the Apple documentation. Do you happen to know if there are sections which touch on this?

Also - regarding the strong encryption that you mentioned previously, would you expect to see any significant performance hits on the device side with this?

Cheers,

Rod.
 

ace2600

macrumors member
Mar 16, 2008
71
0
Austin, Texas
What is the purpose of preventing replay attacks in this system? Also, given that the only way the server knows about UDIDs is from user requests, what's to stop me forging the UDID? This means we're back to preventing key extraction from memory, but with a pointless layer of hashing.
Without the timestamp, another party could copy the request and reuse (replay) it from their website, other app, whatever and whenever. So I don't follow your logic about the hash being unnecessary.

The UDID can absolutely be forged, but is included in the hash with the secret key so it would have to from a previous message. The UDID is probably optional. I was including it as a way to make sure the same request was not sent twice.

I am under the impression the OP's concern is preventing a website from requesting the XML feeds, not actually securing the XML feeds in transit. I agree there's still an issue about how to secure the secret key.
 

jnic

macrumors 6502a
Oct 24, 2008
567
0
Cambridge
@ace2600: Ah, my mistake; I'd implicitly assumed that this would be over SSL, whereas of course implementing the protocol yourself might mean you don't include a nonce in the exchange by default.

@RodThePlod: There's unlikely to be much on hiding keys in memory (though plenty around the web on breaking DRM); however this may well be overkill as Pring suggests, in which case all you need is a client-side SSL library (there'll be plenty around in C).

would you expect to see any significant performance hits on the device side with this?

AES is very quick and has existed since long before computers were as fast as an iPhone. A standard C implementation will be plenty fast enough.
 

RodThePlod

macrumors 6502a
Original poster
Sep 7, 2005
838
499
London
I am under the impression the OP's concern is preventing a website from requesting the XML feeds, not actually securing the XML feeds in transit.

Correct!

@RodThePlod: There's unlikely to be much on hiding keys in memory (though plenty around the web on breaking DRM); however this may well be overkill as Pring suggests, in which case all you need is a client-side SSL library (there'll be plenty around in C).

AES is very quick and has existed since long before computers were as fast as an iPhone. A standard C implementation will be plenty fast enough.

OK Cool. Thanks guys. I think I know which direction I'm heading in now!

:)

Rod.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.