Skip to content

Commit

Permalink
Merge pull request abrasive#152 from hendrikw82/master
Browse files Browse the repository at this point in the history
ios6 airplay announce message parsing bugfix  - Using Net:SDP
  • Loading branch information
albertz committed Sep 27, 2012
2 parents 7df1fa7 + 8b24711 commit 151b50f
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions shairport.pl
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
use Digest::MD5 qw(md5 md5_hex);
use POSIX qw(:sys_wait_h setsid);
eval "use IO::Socket::INET6;";
use Net::SDP;

my $shairportversion = "0.05";

Expand Down Expand Up @@ -630,20 +631,23 @@ sub conn_handle_request {
last;
};

/^ANNOUNCE$/ && do {
my $sdptext = $req->content;
my @sdplines = split /[\r\n]+/, $sdptext;
my %sdp = map { ($1, $2) if /^a=([^:]+):(.+)/ } @sdplines;
die("no AESIV") unless my $aesiv = decode_base64($sdp{aesiv});
die("no AESKEY") unless my $rsaaeskey = decode_base64($sdp{rsaaeskey});
$rsa->use_pkcs1_oaep_padding;
my $aeskey = $rsa->decrypt($rsaaeskey) || die "RSA decrypt failed";

$conn->{aesiv} = $aesiv;
$conn->{aeskey} = $aeskey;
$conn->{fmtp} = $sdp{fmtp};
last;
};
/^ANNOUNCE$/ && do {
my $sdp = Net::SDP->new($req->content);
my $audio = $sdp->media_desc_of_type('audio');

print $audio->as_string();
print $audio->attribute('aesiv');

die("no AESIV") unless my $aesiv = decode_base64($audio->attribute('aesiv'));
die("no AESKEY") unless my $rsaaeskey = decode_base64($audio->attribute('rsaaeskey'));
$rsa->use_pkcs1_oaep_padding;
my $aeskey = $rsa->decrypt($rsaaeskey) || die "RSA decrypt failed";

$conn->{aesiv} = $aesiv;
$conn->{aeskey} = $aeskey;
$conn->{fmtp} = $audio->attribute('fmtp');
last;
};

/^SETUP$/ && do {
my $transport = $req->header('Transport');
Expand Down

0 comments on commit 151b50f

Please sign in to comment.