2

Apple has some really nice tools to segmenting solid media files to HLS and adding AES-128 encryption. However, they only run on Mac's and thus aren't very useful in a typical cloud environment where the machines run on Linux.

I'm looking for any existing tools and libraries that will help in adding AES-128 encryption to pre-segmented HLS. I don't believe this would be super complicated to implement. I'd like to write it in Ruby. Does anyone know of any tools or resources that will help?

Andrew Russell
  • 26,924
  • 7
  • 58
  • 104
Brian
  • 7,204
  • 12
  • 51
  • 84
  • AES encrypting anything is not that hard indeed. Coming up with a secure protocol *is*. Without prior experience, you are very likely to fail to invent one yourself that is secure. You should come up with one before you start programming. Unfortunately, that part is off topic here on stackoverflow... – Maarten Bodewes Apr 16 '13 at 22:53
  • Not sure I follow what you're saying? I'm just taking existing transport stream files and encrypting with AES-128. They will be served over HTTP/HTTPS – Brian Apr 17 '13 at 00:39
  • 1
    @owlstead the OP is talking about [HTTP Live Streaming Content Protection](http://developer.apple.com/library/ios/#documentation/networkinginternet/conceptual/streamingmediaguide/UsingHTTPLiveStreaming/UsingHTTPLiveStreaming.html), it's DRM. – jbtule Apr 19 '13 at 21:04
  • possible duplicate of [Using openssl encryption for Apple's HTTP Live Streaming](http://stackoverflow.com/questions/3010638/using-openssl-encryption-for-apples-http-live-streaming) – jbtule Apr 19 '13 at 21:04

3 Answers3

1

You can fork and exec openssl to do the actual encryption. You most likely don't want to do the AES encryption in ruby because it will be ridiculously slow.

You can model your program after this shell script: https://stackoverflow.com/a/3600805/759140

Community
  • 1
  • 1
vipw
  • 7,593
  • 4
  • 25
  • 48
  • Thanks. I was able to get it working in Ruby and it seems very quick. It doesn't need to be that fast for my current needs, but it's good to know that others got it working with CLI openssl. – Brian Apr 18 '13 at 15:19
  • It would only be slow in Ruby if the entire AES algorithm would be implemented in Ruby. But the OpenSSL extension wraps native code for the most part and is therefore almost as fast as "the real thing". – emboss Apr 18 '13 at 18:14
  • @emboss Yeah, that's probably the best way to go. – vipw Apr 19 '13 at 09:22
1

You can use the OpenSSL::Cipher class in Ruby. Since the OpenSSL extension is basically a wrapper for native OpenSSL, this is really fast.

emboss
  • 38,880
  • 7
  • 101
  • 108
0

FFMPEG can transcode and encrypt HLS files

ffmpeg -y -i <file in> -hsl_time 10 -hls_key_info_file <key info file> -hls_segment_filename "encrupted-%d.ts" encrypted.m3u

You can find more info here: FFMPEG Encryption

AVCONV should also be able to, but I did not yet get it to work.

Thomas
  • 648
  • 5
  • 9