summaryrefslogtreecommitdiff
path: root/net-misc/asterisk/files/1.6.2/sip_calc_auth
blob: 3f050ada5738edc4e0928377afe23fdedfe8c51e (plain)
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
#! /bin/bash

[ $# -lt 7 ] && echo "USAGE: $0 username realm password method uri algorithm nonce" && exit 1

un=$1
realm=$2
pw=$3
method=$4
uri=$5
alg=$6
nonce=$7

echo "Using $un@$realm (secret $pw) for method $method to $uri with nonce $nonce (alg=$alg)"

a1=$un:$realm:$pw
a2=$method:$uri
ha1=$(echo -n "$a1" | openssl $alg)
ha2=$(echo -n "$a2" | openssl $alg)
resp=$(echo -n "$ha1:$nonce:$ha2" | openssl $alg)

echo "a1=$a1"
echo "a2=$a2"
echo "ha1=$ha1"
echo "ha2=$ha2"
echo "resp=$resp"