[Asterisk-cvs] asterisk/channels chan_sip.c,1.661,1.662
markster at lists.digium.com
markster at lists.digium.com
Thu Feb 17 23:30:31 CST 2005
Update of /usr/cvsroot/asterisk/channels
In directory mongoose.digium.com:/tmp/cvs-serv30288/channels
Modified Files:
chan_sip.c
Log Message:
Add OEJ's md5 app (bug #3604)
Index: chan_sip.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v
retrieving revision 1.661
retrieving revision 1.662
diff -u -d -r1.661 -r1.662
--- chan_sip.c 14 Feb 2005 23:20:01 -0000 1.661
+++ chan_sip.c 18 Feb 2005 05:29:31 -0000 1.662
@@ -31,7 +31,6 @@
#include <asterisk/manager.h>
#include <asterisk/callerid.h>
#include <asterisk/cli.h>
-#include <asterisk/md5.h>
#include <asterisk/app.h>
#include <asterisk/musiconhold.h>
#include <asterisk/dsp.h>
@@ -4966,21 +4965,6 @@
list_route(p->route);
}
-/*--- md5_hash: Produce MD5 hash of value. Used for authentication ---*/
-static void md5_hash(char *output, char *input)
-{
- struct MD5Context md5;
- unsigned char digest[16];
- char *ptr;
- int x;
- MD5Init(&md5);
- MD5Update(&md5, input, strlen(input));
- MD5Final(digest, &md5);
- ptr = output;
- for (x=0;x<16;x++)
- ptr += sprintf(ptr, "%2.2x", digest[x]);
-}
-
/*--- check_auth: Check user authorization from peer definition ---*/
/* Some actions, like REGISTER and INVITEs from peers require
authentication (if peer have secret set) */
@@ -5114,10 +5098,10 @@
if (!ast_strlen_zero(md5secret))
snprintf(a1_hash, sizeof(a1_hash), "%s", md5secret);
else
- md5_hash(a1_hash, a1);
- md5_hash(a2_hash, a2);
+ ast_md5_hash(a1_hash, a1);
+ ast_md5_hash(a2_hash, a2);
snprintf(resp, sizeof(resp), "%s:%s:%s", a1_hash, randdata, a2_hash);
- md5_hash(resp_hash, resp);
+ ast_md5_hash(resp_hash, resp);
/* resp_hash now has the expected response, compare the two */
@@ -7107,15 +7091,15 @@
if (!ast_strlen_zero(p->peermd5secret))
strncpy(a1_hash, p->peermd5secret, sizeof(a1_hash) - 1);
else
- md5_hash(a1_hash,a1);
- md5_hash(a2_hash,a2);
+ ast_md5_hash(a1_hash,a1);
+ ast_md5_hash(a2_hash,a2);
/* XXX We hard code the nonce-number to 1... What are the odds? Are we seriously going to keep
track of every nonce we've seen? Also we hard code to "auth"... XXX */
if (!ast_strlen_zero(p->qop))
snprintf(resp,sizeof(resp),"%s:%s:%s:%s:%s:%s",a1_hash,p->nonce, "00000001", cnonce, "auth", a2_hash);
else
snprintf(resp,sizeof(resp),"%s:%s:%s",a1_hash,p->nonce,a2_hash);
- md5_hash(resp_hash,resp);
+ ast_md5_hash(resp_hash,resp);
/* XXX We hard code our qop to "auth" for now. XXX */
if (!ast_strlen_zero(p->qop))
snprintf(digest,digest_len,"Digest username=\"%s\", realm=\"%s\", algorithm=MD5, uri=\"%s\", nonce=\"%s\", response=\"%s\", opaque=\"%s\", qop=\"%s\", cnonce=\"%s\", nc=%s",p->authname,p->realm,uri,p->nonce,resp_hash, p->opaque, "auth", cnonce, "00000001");
More information about the svn-commits
mailing list