File: srtp-debug-helper

package info (click to toggle)
rtpengine 13.5.1.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,676 kB
  • sloc: ansic: 86,764; perl: 59,422; python: 3,193; sh: 1,030; makefile: 693; asm: 211
file content (39 lines) | stat: -rwxr-xr-x 1,275 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/perl

use strict;
use warnings;
use MIME::Base64;
use NGCP::Rtpclient::SRTP;

my $cs = $NGCP::Rtpclient::SRTP::crypto_suites{$ARGV[0]} or die;
my $inline_key = $ARGV[1] or die;
my ($key, $salt) = NGCP::Rtpclient::SRTP::decode_inline_base64($inline_key, $cs);
my ($skey, $sauth, $ssalt) = NGCP::Rtpclient::SRTP::gen_rtp_session_keys($key, $salt);
print("Master key:           " . unpack("H*", $key) . "\n");
print("Master salt:          " . unpack("H*", $salt) . "\n");
print("RTP session key:      " . unpack("H*", $skey) . "\n");
print("RTP session auth key: " . unpack("H*", $sauth) . "\n");
print("RTP session salt:     " . unpack("H*", $ssalt) . "\n");

my $pack = $ARGV[2];
my @pack;
if ($pack =~ /:/) {
	my @pack = split(/:/, $pack);
	$pack = join('', (map {chr(hex($_))} @pack));
}
else {
	$pack = pack("H*", $pack);
}

my $in_roc = $ARGV[3] // 0;

print("Packet length:        " . length($pack) . " bytes\n");

my ($dec, $out_roc, $tag, $hmac) = NGCP::Rtpclient::SRTP::decrypt_rtp($cs, $skey, $ssalt, $sauth, $in_roc, $pack);

print("Auth tag from packet: " . unpack("H*", $tag) . "\n");
print("Computed auth tag:    " . unpack("H*", $hmac) . "\n");
print("Decoded packet:       " . unpack("H*", $dec) . "\n");
print("ROC:                  $out_roc\n");