From: Jean-Marc Pigeon (Delson) Date: Mon, 7 Jul 2025 01:04:06 +0000 (-0400) Subject: Change dig_checkresp to be dig_hashresp X-Git-Tag: tag-0.12~11 X-Git-Url: https://jmp-git.ovh.safe.ca/?a=commitdiff_plain;h=7d9363029ea620f2039f789ed07463974de3e52f;p=jmp%2Fmailleur Change dig_checkresp to be dig_hashresp --- diff --git a/lib/unidig.c b/lib/unidig.c index 0fd8dbc..88f42df 100644 --- a/lib/unidig.c +++ b/lib/unidig.c @@ -386,23 +386,21 @@ return challenge; /* reponse available within RSPTYP record. */ /* */ /********************************************************/ -_Bool dig_checkresp(RSPTYP *resp,char *secret) +PUBLIC char *dig_hashresp(RSPTYP *resp,char *mode,char *secret) { -_Bool isok; +char *HA0; char *HA1; char *HA2; -char *HA3; char seq[400]; int phase; _Bool proceed; -isok=false; -(void) memset(seq,'\000',sizeof(seq)); +HA0=(char *)0; HA1=(char *)0; HA2=(char *)0; -HA3=(char *)0; +(void) memset(seq,'\000',sizeof(seq)); phase=0; proceed=(resp!=(RSPTYP *)0); while (proceed==true) { @@ -430,35 +428,30 @@ while (proceed==true) { case 1 : { //computing HA2 MD5TYP *A2; - (void) snprintf(seq,sizeof(seq),"AUTHENTICATE:%s",resp->digesturi); + (void) snprintf(seq,sizeof(seq),"%s:%s",mode,resp->digesturi); A2=dig_hashmd5((unsigned char *)seq,strlen(seq)); HA2=cnv_tohexa((char *)A2,sizeof(MD5TYP)); (void) free(A2); } break; case 2 : { //computing response - MD5TYP *A3; + MD5TYP *A0; (void) snprintf(seq,sizeof(seq),"%s:%s:%08lx:%s:%s:%s", HA1,resp->nonce,resp->nc, resp->cnonce,resp->qop,HA2); - A3=dig_hashmd5((unsigned char *)seq,strlen(seq)); - HA3=cnv_tohexa((char *)A3,sizeof(MD5TYP)); - (void) free(A3); + A0=dig_hashmd5((unsigned char *)seq,strlen(seq)); + HA0=cnv_tohexa((char *)A0,sizeof(MD5TYP)); + (void) free(A0); } break; - case 3 : //comparing annoced response versus computed response - if (strcmp(HA3,resp->response)==0) - isok=true; - break; default : //SAFE Guard proceed=false; break; } phase++; } -HA3=rou_freestr(HA3); HA2=rou_freestr(HA2); HA1=rou_freestr(HA1); -return isok; +return HA0; } diff --git a/lib/unidig.h b/lib/unidig.h index 1cb2eb1..2bf1ae3 100644 --- a/lib/unidig.h +++ b/lib/unidig.h @@ -43,6 +43,6 @@ extern char *dig_getchallenge(char *realm); //Procedure to compute local response to challenge and //check if the remote session is the same -extern _Bool dig_checkresp(RSPTYP *resp,char *secret); +extern char *dig_hashresp(RSPTYP *resp,char *mode,char *secret); #endif