OpenBSD Journal

rtunes 0.1 released

Contributed by mbalmer on from the so-sue-me dept.

Marcus Glocker writes

We were sitting on IRC, chatting a bit about the Apple AirPort Express device, which allows to stream audio from iTunes over wireless to your stereo. Quickly Marc Balmer mentioned that a OpenSource software called JustePorte exists, unfortunately written in C#. Jon Lech Johansen reverse engineered the inner workings of the AirTunes protocol, especially finding out the "secret" RSA public key which is, aehm was, used to lock buyers to Apple software. At the end of 2004 he wrote JustePorte to stream audio to the AirPort. After looking at that code and googling a bit arround to check how the AirPort audio streaming works, I thought it would be a nice thing to hack a free C program which we can use on our OpenBSD boxes. So, I opened a CVS repository and started hacking, and Marc Balmer joined to help out hacking. On Sunday, January 29th we had the idea, on Monday I bought an AirPort device and today the first shoot of rtunes was released.

Here's a quick explanation how the streaming works:

We have the RSA public key which Jon reverse engineered out of iTunes. On the AirPort device the RSA private key is stored. The audio stream is encoded by AES encryption, and the streaming protocol is RTSP. We choose a random AES session key, encrypt it with the RSA public key and send it to the AirPort in a RTSP ANNOUNCE body. If the RSA public key can be opened by the RSA privat key the AirPort got our AES session key, and we can start streaming the audio files AES encrypted. The streamed codec must be Apple Lossless.

Actually we have no codec converter in rtunes, what means that we just can stream Lossless files for now. The goal for further versions is to get in a mp3 to Lossless converter, so we can also stream our mp3 files. Of course other codec converters would be also nice.

The problem is, that Apple never documented the ALAC codec... We have no idea why, only wild guesses (vendor lock-in comes to my mind...).

Any ideas, patches, and volunteers, especially on the codec converting stuff, are welcome.

Tarball: rtunes-0.1.tar.gz, OpenBSD Port: rtunes-port.tar.gz


(Comments are closed)

  1. By Pete ( on

    Maybe some hint on creation of an ALAC encoder can by gleened from studying a decoder source ? At least it has a nice license anyway...


  2. By Anonymous Coward ( on

    Are there any legal issues regarding this software and the use of the key?

    1. By Anonymous Coward ( on

      It's a public key ;)

      1. By Sean Brown ( on

        Thats a technical description. The parent was asking a legal question. One often has nothing to do with the other.

        Again, if Apple is not making this key public voluntarily, is it not possible that there are legal problems to using this software?

        1. By Anonymous Coward ( on

          No. Why would there be? What kind of legal problems could there possibly be?

          1. By Anonymous Coward ( on

            Reverse engineering an encryption schema protected under the DMCA in the US for one. Not saying it is or isn't, but that pretty much the question being asked.

            1. By Anonymous Coward ( on

              This work has been done outside US legislation.

  3. By Ralf ( on Ralf-Philipp Weinmann

    I don't wanna ruin your day, but.. This has been done before, there's a tool called raop_play that works pretty good for me under Linux. It's GPL licensed however, but it plays mp3s, oggs, aacs and flacs to my AirPort Express alright. I think it supports this since version 0.4.

    1. By Marcus Glocker ( on

      Dear Ralf,

      I don't know if you ruined somebody's day, mine not in any case ;) I think it is worth to rewrite a software from scratch if it has the BSD license lable on it afterwards.

      In the meantime we figured out the ALAC encoding. It seems not be that hard, so playing MP3 and other codecs will come probably in the next version. There are many players out there which decode MP3, AAC, OGG, etc. to RAW PCM audio and sending it to STDOUT so it can just be piped to rtunes and be encoded to ALAC there ...


    2. By Anonymous Coward ( on

      Bah GPL.

  4. By Ben ( on

    Nice. A few minor tweaks and it compiles under Linux (Don't have an inside OpenBSD box.. I should throw one of my box systems at that task). However, I noticed RSTP doesn't define how to respond to a password protected stream, but Apple does define it. Hmm.. - Ben

    1. By Ben ( on

      Correction. =-) I missed the WWW-Authentication: concept in the RFC.

      - Ben

  5. By marco ( on

    now i have a feeling that i'll be fucking around with /etc/printcap on my soekris tonight

    nothing pilsner urquell won't help

  6. By Ben Goren ( on

    It'd be nice to also have something that'd act as a virtual Airport Express. That is, something that iTunes and rtunes both think is an Airport Express that one can send audio to.

    Not that I'm in any way capable of contributing, but....



  7. By Marcus Glocker ( on

    Hey Ho,

    Like promissed, we just released rtunes 0.2 some minutes ago, which is now able to encode RAW PCM audio data to Lossless, which means you can use an audio player to encode codecs to RAW PCM audio data and pipe it to rtunes stdin. I personally use 'madplay' for this, which is in the OpenBSD ports tree. Example:

    madplay -o raw:- benson.mp3 | rtunes -

    We choosed that method instead the attempt of including all codecs into rtunes itself. It felt to much like reinventing the wheel, for now :)

    Also a bug where solved which made the airport hang after playing long songs.

    As always; if you find any bugs, improvements, we appreciate patches.

    rtunes-0.2.tar.gz, rtunes-port.tar.gz




Copyright © - Daniel Hartmeier. All rights reserved. Articles and comments are copyright their respective authors, submission implies license to publish on this web site. Contents of the archive prior to as well as images and HTML templates were copied from the fabulous original with Jose's and Jim's kind permission. This journal runs as CGI with httpd(8) on OpenBSD, the source code is BSD licensed. undeadly \Un*dead"ly\, a. Not subject to death; immortal. [Obs.]