diff --git a/lib/libpics/picsapi.c b/lib/libpics/picsapi.c index 49af6315d110..5eaf0a651fca 100644 --- a/lib/libpics/picsapi.c +++ b/lib/libpics/picsapi.c @@ -263,7 +263,8 @@ pics_hash_password(char *pw) SECStatus status; unsigned char result[SHA1_LENGTH]; - status = SHA1_HashBuf(result, (unsigned char *)pw, XP_STRLEN(pw)); + status = HASH_HashBuf(HASH_AlgSHA1, result, + (unsigned char *)pw, XP_STRLEN(pw)); if (status != SECSuccess) return NULL; diff --git a/modules/security/freenav/navstubs.c b/modules/security/freenav/navstubs.c index fb429375e699..d57bfacea43f 100644 --- a/modules/security/freenav/navstubs.c +++ b/modules/security/freenav/navstubs.c @@ -671,3 +671,60 @@ ATOB_AsciiToData(const char *string, unsigned int *lenp) } +unsigned int +HASH_ResultLen(HASH_HashType type) +{ + return 0; +} + +unsigned int +HASH_ResultLenContext(HASHContext *context) +{ + return 0; +} + +SECStatus +HASH_HashBuf(HASH_HashType type, unsigned char *dest, unsigned char *src, + uint32 src_len) +{ + return SECFailure; +} + +HASHContext * +HASH_Create(HASH_HashType type) +{ + return NULL; +} + +HASHContext * +HASH_Clone(HASHContext *context) +{ + return NULL; +} + +void +HASH_Destroy(HASHContext *context) +{ + return; +} + +void +HASH_Begin(HASHContext *context) +{ + return; +} + +void +HASH_Update(HASHContext *context, const unsigned char *src, unsigned int len) +{ + return; +} + +void +HASH_End(HASHContext *context, unsigned char *result, unsigned int *result_len, + unsigned int max_result_len) +{ + *result_len = 0; + return; +} + diff --git a/modules/security/freenav/secstubs.h b/modules/security/freenav/secstubs.h index 513590e64cdd..51dc143de21c 100644 --- a/modules/security/freenav/secstubs.h +++ b/modules/security/freenav/secstubs.h @@ -114,6 +114,33 @@ void SHA1_End(SHA1Context *cx, unsigned char *digest, unsigned int *digestLen, unsigned int maxDigestLen); +/* + * Generic hash api. In the future this should be the only public + * API. + */ + +extern unsigned int HASH_ResultLen(HASH_HashType type); + +extern unsigned int HASH_ResultLenContext(HASHContext *context); + +extern SECStatus HASH_HashBuf(HASH_HashType type, unsigned char *dest, + unsigned char *src, uint32 src_len); + +extern HASHContext *HASH_Create(HASH_HashType type); + +extern HASHContext *HASH_Clone(HASHContext *context); + +extern void HASH_Destroy(HASHContext *context); + +extern void HASH_Begin(HASHContext *context); + +extern void HASH_Update(HASHContext *context, const unsigned char *src, + unsigned int len); + +extern void HASH_End(HASHContext *context, unsigned char *result, + unsigned int *result_len, unsigned int max_result_len); + + char * BTOA_DataToAscii(const unsigned char *data, unsigned int len); diff --git a/modules/security/freenav/secstubt.h b/modules/security/freenav/secstubt.h index cc13ff540af0..c45ad0bfae62 100644 --- a/modules/security/freenav/secstubt.h +++ b/modules/security/freenav/secstubt.h @@ -30,10 +30,19 @@ typedef struct CERTCertificateStr CERTCertificate; typedef struct _certdb CERTCertDBHandle; typedef struct _md5context MD5Context; typedef struct _sha1context SHA1Context; +typedef struct HASHContextStr HASHContext; #define MD5_LENGTH 16 #define SHA1_LENGTH 20 +typedef enum { + HASH_AlgNULL, + HASH_AlgMD2, + HASH_AlgMD5, + HASH_AlgSHA1, + HASH_AlgTOTAL +} HASH_HashType; + typedef enum _SECStatus { SECWouldBlock = -2, SECFailure = -1, diff --git a/network/protocol/http/mkaccess.c b/network/protocol/http/mkaccess.c index 9ffc6242a136..300485de1922 100644 --- a/network/protocol/http/mkaccess.c +++ b/network/protocol/http/mkaccess.c @@ -55,6 +55,7 @@ #endif #include "secnav.h" +#include "sechash.h" #include "libevent.h" #include "pwcacapi.h" @@ -3438,17 +3439,11 @@ net_parse_authenticate_line(char *auth, net_AuthStruct *ret) PRIVATE void do_md5(unsigned char *stuff, unsigned char digest[16]) { - MD5Context *cx = MD5_NewContext(); - unsigned int len; + SECStatus rv; - if (!cx) - return; + rv = HASH_HashBuf(HASH_AlgMD5, digest, stuff, strlen((char *)stuff)); - MD5_Begin(cx); - MD5_Update(cx, stuff, strlen((char*)stuff)); - MD5_End(cx, digest, &len, 16); /* len had better be 16 when returned! */ - - MD5_DestroyContext(cx, (DSBool)TRUE); + return; }