Advertisement
Guest User

Untitled

a guest
May 7th, 2017
572
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #!/bin/sh
  2. set -e -u
  3.  
  4. username="00001112"
  5. realm="193.28.87.182"
  6. password="123test"
  7. method=INVITE
  8. digestURI="sip:000999667@193.28.87.182"
  9. nonce="3ef574f083cc65c645ca929b21c7df5ebcc0"
  10. nonceCount=
  11. clientNonce=
  12. qop=
  13.  
  14.  
  15. # HA1=MD5(username:realm:password)
  16. # HA2=MD5(method:digestURI)
  17. # response=MD5(HA1:nonce:HA2)
  18. # response=MD5(HA1:nonce:nonceCount:clientNonce:qop:HA2) # when qop is given
  19. DEBUG() {
  20. : "$@" >&2
  21. }
  22.  
  23. MD5() {
  24. for arg; do DEBUG printf ' "%s"' "$arg"; done
  25. DEBUG echo
  26. printf "$@" | md5sum | cut -d' ' -f1 | tr -d '\n'
  27. }
  28.  
  29. HA1=$(MD5 '%s:%s:%s' "$username" "$realm" "$password")
  30. HA2=$(MD5 '%s:%s' "$method" "$digestURI")
  31.  
  32. if [ -z "$qop" ]; then
  33. MD5 "%s:%s:%s" "$HA1" "$nonce" "$HA2"
  34. else
  35. MD5 "%s:%s:%s:%s:%s:%s" \
  36. "$HA1" "$nonce" "$nonceCount" "$clientNonce" "$qop" "$HA2"
  37. fi
  38. echo
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement