зеркало из https://github.com/mozilla/gecko-dev.git
Pull changes forward from Nova.
New generalized hashing API.
This commit is contained in:
Родитель
a0de371b82
Коммит
9773eecb93
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче