lvleml.o \
gesspf.o gestcp.o geseml.o \
devlog.o devsoc.o devsql.o \
- unidns.o unieml.o unipar.o \
+ unidig.o unidns.o unieml.o unipar.o \
uniprc.o unisig.o unisql.o unitls.o \
subafn.o subcnv.o subrou.o
lvleml.o: \
subcnv.h subrou.h \
- unieml.h unidns.h \
+ unidig.h unidns.h unieml.h \
lvleml.h lvleml.c
gesspf.o: \
unimar.h \
devsql.h devsql.c
+unidig.o: \
+ subrou.h subcnv.h \
+ unidig.h unidig.c
+
unidns.o: \
subafn.h subrou.h \
unidns.h unidns.c
#include "subrou.h"
#include "subcnv.h"
+#include "unidig.h"
#include "unieml.h"
#include "devlog.h"
#include "gestcp.h"
char *local;
char *hexa;
- local=cnv_cryptmd5(passwd,(unsigned char *)challenge);
+ local=dig_cryptmd5(passwd,(unsigned char *)challenge);
hexa=cnv_tohexa(local);
//(void) rou_alert(0,"%s anwr=<%s>",OPEP,answer);
//(void) rou_alert(0,"%s hexa=<%s>",OPEP,hexa);
res=cnv_getb64(line);
(void) snprintf(answer,sizeof(answer),"%s",res);
(void) rou_alert(0,"JMPDBG Got <%s>",answer);
+ {
+ unsigned char *seq=(unsigned char *)"webmaster@example.com:devel5.safe.ca:xxx";
+ (void) dig_hashmd5(seq);
+ }
res=rou_freestr(res);
line=rou_freestr(line);
}
//local=cnv_cryptmd5(usr->passwd,(unsigned char *)seq);
(void) rou_asprintf(&decoded,"%s%s%s%s",IOBNULL,name,IOBNULL,(char *)0);
- local=cnv_cryptmd5("mailleur",(unsigned char *)seq);
+ local=dig_cryptmd5("mailleur",(unsigned char *)seq);
hexa=cnv_tohexa(local);
(void) rou_alert(0,"%s code=<%s>",OPEP,code);
(void) rou_alert(0,"%s hexa=<%s>",OPEP,hexa);
#include <ctype.h>
#include <stdbool.h>
#include <string.h>
-
-#define OPENSSL_NO_KRB5
#include <openssl/bio.h>
+#include <openssl/buffer.h>
#include <openssl/evp.h>
-#include <openssl/err.h>
-#include <openssl/hmac.h>
-#include <openssl/ssl.h>
#include "subcnv.h"
(void) BIO_free_all(b64);
return coded;
-#undef OPEP
-}
-/*
-\f
-*/
-/********************************************************/
-/* */
-/* Procedure to crypt a string with MD5 hash */
-/* function. */
-/* */
-/********************************************************/
-PUBLIC char *cnv_cryptmd5(const void *key,unsigned char *seq)
-
-{
-#define OPEP "subcnv.c:cnv_hashmd5,"
-
-char *hashmd5; //function result
-unsigned char *d5; //md5 hash result
-u_int reslen;
-int phase;
-int proceed;
-
-hashmd5=(char *)0;
-d5=(unsigned char *)0;
-reslen=-1;
-phase=1;
-proceed=true;
-while (proceed==true) {
- switch (phase) {
- case 0 : //do ve have good parameters
- if ((key==(const void *)0)||(seq==(unsigned char *)0)) {
- (void) fprintf(stderr,"%s key or seq undefined (Bug?)",OPEP);
- phase=999;
- }
- break;
- case 1 : //computing sequence
- d5=HMAC(EVP_md5(),key,strlen(key),seq,strlen((const char *)seq),d5,&reslen);
- if (d5==(unsigned char *)0) {
- (void) fprintf(stderr,"%s No MD5 for key=<%s> and seq=<%s> (Bug?)",
- OPEP,(char *)key,seq);
- phase=999;
- }
- break;
- case 2 : //duplicate md5 result
- if (reslen>0) {
- hashmd5=(char *)calloc(reslen+1,sizeof(char));
- (void) memmove((void *)hashmd5,(void *)d5,reslen);
- }
- break;
- default : //SAFE Guard
- proceed=false;
- break;
- }
- phase++;
- }
-return hashmd5;
-
#undef OPEP
}
/*
//base64 char 0 coding
#define IOBNULL "\\0"
+//MD5 hashing result
+typedef unsigned char MD5TYP[17];
+
//Procedure to convert a plain ASCII B64 sequence
//to a plain ASCII sequence
extern char *cnv_getb64(char *b64);
//to an ASCII B64 sequence
extern char *cnv_setb64(const char *str);
-//procedure to convert a string to a 128 Bit sequence
-//as a string
-extern char *cnv_hashmd5(char *seq);
-
-//Procedure to crypt a string with MD5 hash function
-extern char *cnv_cryptmd5(const void *key,unsigned char *seq);
-
//Procedure to convert a string of character as an HEXA string
extern char *cnv_tohexa(const char *str);
--- /dev/null
+// vim: smarttab tabstop=8 shiftwidth=2 expandtab
+/********************************************************/
+/* */
+/* Implement all procedure to use digest-md5 */
+/* authentication exchange. */
+/* */
+/********************************************************/
+#include <openssl/evp.h>
+#include <openssl/hmac.h>
+#include <string.h>
+
+#include "subrou.h"
+#include "subcnv.h"
+#include "unidig.h"
+
+/*
+ * \f
+*/
+/********************************************************/
+/* */
+/* Procedure to hash a string with MD5 hash */
+/* an return a 16+1 Bytes. */
+/* */
+/********************************************************/
+PUBLIC MD5TYP *dig_hashmd5(unsigned char *seq)
+
+{
+#define OPEP "subdig.c:dig_hashmd5,"
+
+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) {
+ switch (phase) {
+ case 0 : //do we hae a sequence?
+ if ((seq==(unsigned char *)0)&&(strlen((const char *)seq)==0))
+ phase=999; //no need to go further
+ break;
+ case 1 : //getting md5 context
+ if ((mdctx=EVP_MD_CTX_new())==(EVP_MD_CTX *)0) {
+ (void) fprintf(stdout,"%s Unable to open MD5 context (System?)",OPEP);
+ phase=999; //no need to go further
+ }
+ break;
+ case 2 : //doing hashing
+ (void) EVP_DigestInit_ex(mdctx,EVP_md5(),(ENGINE *)0);
+ (void) EVP_DigestUpdate(mdctx,seq,strlen((const char *)seq));
+ break;
+ case 3 : //assign memory
+ md5=calloc(1,sizeof(MD5TYP));
+ (void) EVP_DigestFinal_ex(mdctx,(unsigned char *)md5,&digestlength);
+ EVP_MD_CTX_free(mdctx);
+ break;
+ default : //SAFE Guard
+ proceed=false;
+ break;
+ }
+ phase++;
+ }
+return md5;
+
+#undef OPEP
+}
+/*
+ * \f
+*/
+/********************************************************/
+/* */
+/* Procedure to crypt a string with MD5 hash */
+/* function. */
+/* */
+/********************************************************/
+PUBLIC char *dig_cryptmd5(const void *key,unsigned char *seq)
+
+{
+#define OPEP "subdig.c:dig_hashmd5,"
+
+char *hashmd5; //function result
+unsigned char *d5; //md5 hash result
+u_int reslen;
+int phase;
+int proceed;
+
+hashmd5=(char *)0;
+d5=(unsigned char *)0;
+reslen=-1;
+phase=1;
+proceed=true;
+while (proceed==true) {
+ switch (phase) {
+ case 0 : //do ve have good parameters
+ if ((key==(const void *)0)||(seq==(unsigned char *)0)) {
+ (void) fprintf(stderr,"%s key or seq undefined (Bug?)",OPEP);
+ phase=999;
+ }
+ break;
+ case 1 : //computing sequence
+ d5=HMAC(EVP_md5(),key,strlen(key),seq,strlen((const char *)seq),d5,&reslen);
+ if (d5==(unsigned char *)0) {
+ (void) fprintf(stderr,"%s No MD5 for key=<%s> and seq=<%s> (Bug?)",
+ OPEP,(char *)key,seq);
+ phase=999;
+ }
+ break;
+ case 2 : //duplicate md5 result
+ if (reslen>0) {
+ hashmd5=(char *)calloc(reslen+1,sizeof(char));
+ (void) memmove((void *)hashmd5,(void *)d5,reslen);
+ }
+ break;
+ default : //SAFE Guard
+ proceed=false;
+ break;
+ }
+ phase++;
+ }
+return hashmd5;
+
+#undef OPEP
+}
--- /dev/null
+// vim: smarttab tabstop=8 shiftwidth=2 expandtab
+/********************************************************/
+/* */
+/* Define all procedure to use digest-md5 */
+/* authentication exchanges. */
+/* */
+/********************************************************/
+#ifndef UNIDIG
+#define UNIDIG
+
+//procedure to convert a string to a 128 Bit sequence
+//as a string
+extern MD5TYP *dig_hashmd5(unsigned char *seq);
+
+//Procedure to crypt a string with MD5 hash function
+extern char *dig_cryptmd5(const void *key,unsigned char *seq);
+
+#endif