Skip to content

Commit

Permalink
Makeing it iOS 6 compatibel using Net:SDP
Browse files Browse the repository at this point in the history
  • Loading branch information
hendrikw82 committed Jul 8, 2012
1 parent f1fd87f commit 8b24711
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions shairport.pl
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 8b24711

Please sign in to comment.