MCPcopy Create free account
hub / github.com/SIPp/sipp / createAuthHeaderAKAv1MD5

Function createAuthHeaderAKAv1MD5

src/auth.cpp:766–894  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

764char hexa[17] = "0123456789abcdef";
765
766static int createAuthHeaderAKAv1MD5(
767 const char* user, const char* aka_OP, const char* aka_AMF,
768 const char* aka_K, const char* method, const char* uri,
769 const char* msgbody, const char* auth, const char* algo,
770 unsigned int nonce_count, char* result, size_t result_len)
771{
772
773 char tmp[MAX_HEADER_LEN];
774 char *start, *end;
775 int has_auts = 0;
776 int written = 0;
777 char *nonce64, *nonce;
778 int noncelen;
779 AMF amf;
780 OP op;
781 RAND rnd;
782 AUTS auts_bin;
783 AUTS64 auts_hex;
784 MAC mac, xmac;
785 SQN sqn, sqnxoraka, sqn_ms;
786 K k;
787 RES res;
788 CK ck;
789 IK ik;
790 AK ak;
791 int i;
792
793 // Extract the Nonce
794 if ((start = stristr(auth, "nonce=")) == nullptr) {
795 snprintf(result, result_len, "createAuthHeaderAKAv1MD5: couldn't parse nonce");
796 return 0;
797 }
798 start = start + strlen("nonce=");
799 if (*start == '"') {
800 start++;
801 }
802 end = start + strcspn(start, " ,\"\r\n");
803 strncpy(tmp, start, end - start);
804 tmp[end - start] ='\0';
805
806 /* Compute the AKA RES */
807 nonce64 = tmp;
808 nonce = base64_decode_string(nonce64, end-start, &noncelen);
809 if (noncelen < RANDLEN + AUTNLEN) {
810 if (nonce)
811 free(nonce);
812 snprintf(
813 result, result_len,
814 "createAuthHeaderAKAv1MD5 : Nonce is too short %d < %d expected\n",
815 noncelen, RANDLEN + AUTNLEN);
816 return 0;
817 }
818 memcpy(rnd, nonce, RANDLEN);
819 memcpy(sqnxoraka, nonce + RANDLEN, SQNLEN);
820 memcpy(mac, nonce + RANDLEN + SQNLEN + AMFLEN, MACLEN);
821 memcpy(k, aka_K, KLEN);
822 memcpy(amf, aka_AMF, AMFLEN);
823 memcpy(op, aka_OP, OPLEN);

Callers 1

createAuthHeaderFunction · 0.85

Calls 7

stristrFunction · 0.85
base64_decode_stringFunction · 0.85
f2345Function · 0.85
f1Function · 0.85
createAuthHeaderMD5Function · 0.85
f5starFunction · 0.85
f1starFunction · 0.85

Tested by

no test coverage detected