зеркало из https://github.com/mozilla/gecko-dev.git
part of work to add support for APOP, patch by ch.ey@gmx.net, r/sr=bienvenu 43923
This commit is contained in:
Родитель
d02d3e1612
Коммит
7b75b2e7d9
|
@ -811,3 +811,29 @@ nsresult MSGCramMD5(const char *text, PRInt32 text_len, const char *key, PRInt32
|
|||
|
||||
}
|
||||
|
||||
|
||||
// digest needs to be a pointer to a DIGEST_LENGTH (16) byte buffer
|
||||
nsresult MSGApopMD5(const char *text, PRInt32 text_len, const char *password, PRInt32 password_len, unsigned char *digest)
|
||||
{
|
||||
nsresult rv;
|
||||
unsigned char result[DIGEST_LENGTH];
|
||||
unsigned char *presult = result;
|
||||
|
||||
nsCOMPtr<nsISignatureVerifier> verifier = do_GetService(SIGNATURE_VERIFIER_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
||||
HASHContextStr *context;
|
||||
PRUint32 resultLen;
|
||||
|
||||
rv = verifier->HashBegin(nsISignatureVerifier::MD5, &context);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = verifier->HashUpdate(context, text, text_len);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = verifier->HashUpdate(context, password, password_len);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = verifier->HashEnd(context, &presult, &resultLen, DIGEST_LENGTH);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
memcpy(digest, result, DIGEST_LENGTH);
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -97,5 +97,6 @@ NS_MSG_BASE nsresult GetOrCreateFolder(const nsACString & aURI, nsIUrlListener *
|
|||
#define DIGEST_LENGTH 16
|
||||
|
||||
NS_MSG_BASE nsresult MSGCramMD5(const char *text, PRInt32 text_len, const char *key, PRInt32 key_len, unsigned char *digest);
|
||||
NS_MSG_BASE nsresult MSGApopMD5(const char *text, PRInt32 text_len, const char *password, PRInt32 password_len, unsigned char *digest);
|
||||
#endif
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче