From: Jean-Marc Pigeon (Delson) Date: Sun, 6 Jul 2025 21:52:56 +0000 (-0400) Subject: Problem with dig_hashmd5, seq is NOT always ascii X-Git-Tag: tag-0.12~14 X-Git-Url: https://jmp-git.ovh.safe.ca/?a=commitdiff_plain;h=26f83d1f41d382f68026f8ef8dbcca6c58816ea6;p=jmp%2Fmailleur Problem with dig_hashmd5, seq is NOT always ascii --- diff --git a/lib/lvleml.c b/lib/lvleml.c index a8dabb5..0a2dbac 100644 --- a/lib/lvleml.c +++ b/lib/lvleml.c @@ -490,7 +490,7 @@ resp=(RSPTYP *)0; phase=0; proceed=true; while (proceed==true) { - (void) rou_alert(0,"%s JMPDBG phase='%d'",OPEP,phase); + //(void) rou_alert(0,"%s JMPDBG phase='%d'",OPEP,phase); switch (phase) { case 0 : //Building the challenge sequence if ((challenge=dig_getchallenge())==(char *)0) { diff --git a/lib/unidig.c b/lib/unidig.c index 9cddc36..76c47f3 100644 --- a/lib/unidig.c +++ b/lib/unidig.c @@ -209,13 +209,11 @@ PUBLIC MD5TYP *dig_hashmd5(unsigned char *seq) MD5TYP *md5; EVP_MD_CTX *mdctx; -unsigned int digestlength; int phase; _Bool proceed; md5=(MD5TYP *)0; mdctx=(EVP_MD_CTX *)0; -digestlength=sizeof(MD5TYP)-1; phase=1; proceed=true; while (proceed==true) { @@ -233,11 +231,16 @@ while (proceed==true) { case 2 : //doing hashing (void) EVP_DigestInit_ex(mdctx,EVP_md5(),(ENGINE *)0); (void) EVP_DigestUpdate(mdctx,seq,strlen((const char *)seq)); + (void) rou_alert(0,"%s digestup de of <%s> '%d' long",OPEP,seq,strlen((const char *)seq)); break; - case 3 : //assign memory + case 3 : { //assign memory + unsigned int s; + md5=calloc(1,sizeof(MD5TYP)); - (void) EVP_DigestFinal_ex(mdctx,(unsigned char *)md5,&digestlength); + (void) EVP_DigestFinal_ex(mdctx,(unsigned char *)md5,&s); + (void) rou_alert(0,"%s got digest of '%d' char",OPEP,s); EVP_MD_CTX_free(mdctx); + } break; default : //SAFE Guard proceed=false; @@ -409,14 +412,17 @@ while (proceed==true) { switch (phase) { case 0 : { //computing hash HA1 MD5TYP *A1; - char strA1[sizeof(MD5TYP)+1]; + char second[300]; (void) snprintf(seq,sizeof(seq),"%s:%s:%s",resp->username,resp->realm,secret); + (void) rou_alert(0,"JMDPBG seq1=<%s>",seq); A1=dig_hashmd5((unsigned char *)seq); - (void) memset(strA1,'\000',sizeof(strA1)); - (void) memmove(strA1,(char *)A1,sizeof(MD5TYP)); //algorithm value is "MD5-sess" - (void) snprintf(seq,sizeof(seq),"%s:%s:%s",strA1,resp->nonce,resp->cnonce); + (void) memset(seq,'\000',sizeof(seq)); + (void) memmove(seq,(char *)A1,sizeof(MD5TYP)); + (void) snprintf(second,sizeof(seq),":%s:%s",resp->nonce,resp->cnonce); + (void) strcat(seq+sizeof(MD5TYP),second); + (void) rou_alert(0,"JMDPBG seq2=<%s>",seq); (void) free(A1); A1=dig_hashmd5((unsigned char *)seq); HA1=cnv_tohexa((char *)A1,sizeof(MD5TYP)); diff --git a/lib/unidig.h b/lib/unidig.h index ba1e40e..cecc3c1 100644 --- a/lib/unidig.h +++ b/lib/unidig.h @@ -8,7 +8,7 @@ #ifndef UNIDIG #define UNIDIG -#define REALM APPNAME".email" +#define REALM APPNAME"-email" typedef struct { //DIGEST-MD5 challange response structure char *username; //username requesting authentication