Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- set -e -u
- username="00001112"
- realm="193.28.87.182"
- password="123test"
- method=INVITE
- digestURI="sip:000999667@193.28.87.182"
- nonce="3ef574f083cc65c645ca929b21c7df5ebcc0"
- nonceCount=
- clientNonce=
- qop=
- # HA1=MD5(username:realm:password)
- # HA2=MD5(method:digestURI)
- # response=MD5(HA1:nonce:HA2)
- # response=MD5(HA1:nonce:nonceCount:clientNonce:qop:HA2) # when qop is given
- DEBUG() {
- : "$@" >&2
- }
- MD5() {
- for arg; do DEBUG printf ' "%s"' "$arg"; done
- DEBUG echo
- printf "$@" | md5sum | cut -d' ' -f1 | tr -d '\n'
- }
- HA1=$(MD5 '%s:%s:%s' "$username" "$realm" "$password")
- HA2=$(MD5 '%s:%s' "$method" "$digestURI")
- if [ -z "$qop" ]; then
- MD5 "%s:%s:%s" "$HA1" "$nonce" "$HA2"
- else
- MD5 "%s:%s:%s:%s:%s:%s" \
- "$HA1" "$nonce" "$nonceCount" "$clientNonce" "$qop" "$HA2"
- fi
- echo
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement