views:

1231

answers:

2

Hello,

I know almost nothing about cryptography, but I would like to figure out how to encrypt an HTTP live stream and decrypt it on an iphone.

The apple docs for HTTP encryption read as follows:

////////////////////////////

Media files containing stream segments may be individually encrypted. When encryption is employed, references to the corresponding key files appear in the index file so that the client can retrieve the keys for decryption.

When a key file is listed in the index file, the key file contains a cipher key that must be used to decrypt subsequent media files listed in the index file. Currently HTTP Live Streaming supports AES-128 encryption using 16-octet keys. The format of the key file is a packed array of these 16 octets in binary format.

The media stream segmenter available from Apple provides encryption and supports three modes for configuring encryption.

The first mode allows you to specify a path to an existing key file on disk. In this mode the segmenter inserts the URL of the existing key file in the index file. It encrypts all media files using this key.

The second mode instructs the segmenter to generate a random key file, save it in a specified location, and reference it in the index file. All media files are encrypted using this randomly generated key.

The third mode instructs the segmenter to generate a random key file, save it in a specified location, reference it in the index file, and then regenerate and reference a new key file every n files. This mode is referred to as key rotation. Each group of n files is encrypted using a different key.

You can serve key files using either HTTP or HTTPS. You may also choose to protect the delivery of the key files using your own session-based authentication scheme.

/////////////////////////////////////////

Using encryption method 1, this is what I think I need to do:

  1. generate a key, using a cipher, and make key available to segmenter
  2. segmenter inserts URL of key into index file
  3. store this cipher in iphone (keychain?)
  4. point movie player to URL of m3u8 playlist which references this index file
  5. enter the cipher somehow to automatically decrypt stream?

Can anyone help lift the fog here?

Thanks!!!!

A: 

Is using HTTPs a possibility?

jessecurry
Thanks. HTTPS is possible if no user input is required to make the connection. i.e. if the device can use a key for the HTTPS connection that would allow the connection to authorize without user input. The plan would be to send this HTTPS key base64 encodedin the in app purchase Product object, when the user purchases the content.
Jacko
Ah, so the goal is to protect the content in transit to ensure that the user has the right to view it?
jessecurry
yes, that is correct.
Jacko
In theory HTTPS and this encryption are the same (and encrypted file). However the encrypted file can be served over HTTP, which has better caching than HTTPS
Rory
A: 

This pretty much nails how to handle encrypted streaming:

http://developer.apple.com/iphone/library/qa/qa2009/qa1661.html

Also, the app should connect to the https domain before running the movie, so that it can pass its credentials, and these credentials can be cached for MPMoviePlayer.

The player supports digest authentication, but not SSL client authentication using client certificates.

Jacko