summaryrefslogtreecommitdiff
path: root/protocols/JabberG/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-08-15 20:00:29 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-08-15 20:00:29 +0000
commit623722f7cc4c20d2b7d8df03035801acacda6018 (patch)
treed4c3686f935c12c9e9274cc3706bef12d9a20d86 /protocols/JabberG/src
parent8588345b7b8ff89bf90a216dbed2302fcf3ccdbc (diff)
mir_sha1_byte_t => BYTE;
mir_sha1_long_t => ULONG; mir_hmac_sha1 went to core git-svn-id: http://svn.miranda-ng.org/main/trunk@5707 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/JabberG/src')
-rw-r--r--protocols/JabberG/src/jabber_iqid.cpp4
-rw-r--r--protocols/JabberG/src/jabber_secur.cpp68
-rw-r--r--protocols/JabberG/src/jabber_secur.h2
-rw-r--r--protocols/JabberG/src/jabber_svc.cpp4
-rw-r--r--protocols/JabberG/src/jabber_util.cpp8
-rw-r--r--protocols/JabberG/src/jabber_vcard.cpp4
6 files changed, 25 insertions, 65 deletions
diff --git a/protocols/JabberG/src/jabber_iqid.cpp b/protocols/JabberG/src/jabber_iqid.cpp
index 9c17f9bd8b..db937bee8c 100644
--- a/protocols/JabberG/src/jabber_iqid.cpp
+++ b/protocols/JabberG/src/jabber_iqid.cpp
@@ -1474,10 +1474,10 @@ LBL_ErrFormat:
setByte(hContact, "AvatarType", pictureType);
- mir_sha1_byte_t digest[20];
+ BYTE digest[20];
mir_sha1_ctx sha;
mir_sha1_init(&sha);
- mir_sha1_append(&sha, (mir_sha1_byte_t*)(char*)body, resultLen);
+ mir_sha1_append(&sha, (BYTE*)(char*)body, resultLen);
mir_sha1_finish(&sha, digest);
GetAvatarFileName(hContact, tszFileName, SIZEOF(tszFileName));
diff --git a/protocols/JabberG/src/jabber_secur.cpp b/protocols/JabberG/src/jabber_secur.cpp
index 72068c9d95..67423b03b4 100644
--- a/protocols/JabberG/src/jabber_secur.cpp
+++ b/protocols/JabberG/src/jabber_secur.cpp
@@ -227,49 +227,9 @@ char* TMD5Auth::getChallenge(const TCHAR *challenge)
return mir_base64_encode((PBYTE)buf, cbLen);
}
-
/////////////////////////////////////////////////////////////////////////////////////////
// SCRAM-SHA-1 authorization
-void hmac_sha1(mir_sha1_byte_t *md, mir_sha1_byte_t *key, size_t keylen, mir_sha1_byte_t *text, size_t textlen)
-{
- const unsigned SHA_BLOCKSIZE = 64;
-
- unsigned char mdkey[MIR_SHA1_HASH_SIZE];
- unsigned char k_ipad[SHA_BLOCKSIZE], k_opad[SHA_BLOCKSIZE];
- mir_sha1_ctx ctx;
-
- if (keylen > SHA_BLOCKSIZE)
- {
- mir_sha1_init(&ctx);
- mir_sha1_append(&ctx, key, (int)keylen);
- mir_sha1_finish(&ctx, mdkey);
- keylen = 20;
- key = mdkey;
- }
-
- memcpy(k_ipad, key, keylen);
- memcpy(k_opad, key, keylen);
- memset(k_ipad+keylen, 0x36, SHA_BLOCKSIZE - keylen);
- memset(k_opad+keylen, 0x5c, SHA_BLOCKSIZE - keylen);
-
- for (unsigned i = 0; i < keylen; i++)
- {
- k_ipad[i] ^= 0x36;
- k_opad[i] ^= 0x5c;
- }
-
- mir_sha1_init(&ctx);
- mir_sha1_append(&ctx, k_ipad, SHA_BLOCKSIZE);
- mir_sha1_append(&ctx, text, (int)textlen);
- mir_sha1_finish(&ctx, md);
-
- mir_sha1_init(&ctx);
- mir_sha1_append(&ctx, k_opad, SHA_BLOCKSIZE);
- mir_sha1_append(&ctx, md, MIR_SHA1_HASH_SIZE);
- mir_sha1_finish(&ctx, md);
-}
-
TScramAuth::TScramAuth(ThreadData* info) :
TJabberAuth(info)
{
@@ -284,15 +244,15 @@ TScramAuth::~TScramAuth()
mir_free(serverSignature);
}
-void TScramAuth::Hi(mir_sha1_byte_t* res , char* passw, size_t passwLen, char* salt, size_t saltLen, int ind)
+void TScramAuth::Hi(BYTE* res , char* passw, size_t passwLen, char* salt, size_t saltLen, int ind)
{
- mir_sha1_byte_t u[ MIR_SHA1_HASH_SIZE ];
+ BYTE u[ MIR_SHA1_HASH_SIZE ];
memcpy(u, salt, saltLen); *(unsigned*)(u + saltLen) = htonl(1); saltLen += 4;
memset(res, 0, MIR_SHA1_HASH_SIZE);
for (int i = 0; i < ind; i++)
{
- hmac_sha1(u, (mir_sha1_byte_t*)passw, passwLen, u, saltLen);
+ mir_hmac_sha1(u, (BYTE*)passw, passwLen, u, saltLen);
saltLen = sizeof(u);
for (unsigned j = 0; j < sizeof(u); j++)
@@ -339,13 +299,13 @@ char* TScramAuth::getChallenge(const TCHAR *challenge)
ptrA passw( mir_utf8encodeT(info->password));
size_t passwLen = strlen(passw);
- mir_sha1_byte_t saltedPassw[ MIR_SHA1_HASH_SIZE ];
+ BYTE saltedPassw[ MIR_SHA1_HASH_SIZE ];
Hi(saltedPassw, passw, passwLen, salt, saltLen, ind);
- mir_sha1_byte_t clientKey[ MIR_SHA1_HASH_SIZE ];
- hmac_sha1(clientKey, saltedPassw, sizeof(saltedPassw), (mir_sha1_byte_t*)"Client Key", 10);
+ BYTE clientKey[ MIR_SHA1_HASH_SIZE ];
+ mir_hmac_sha1(clientKey, saltedPassw, sizeof(saltedPassw), (BYTE*)"Client Key", 10);
- mir_sha1_byte_t storedKey[ MIR_SHA1_HASH_SIZE ];
+ BYTE storedKey[ MIR_SHA1_HASH_SIZE ];
mir_sha1_ctx ctx;
mir_sha1_init(&ctx);
@@ -355,19 +315,19 @@ char* TScramAuth::getChallenge(const TCHAR *challenge)
char authmsg[4096];
int authmsgLen = mir_snprintf(authmsg, sizeof(authmsg), "%s,%s,c=biws,r=%s", msg1, chl, snonce);
- mir_sha1_byte_t clientSig[ MIR_SHA1_HASH_SIZE ];
- hmac_sha1(clientSig, storedKey, sizeof(storedKey), (mir_sha1_byte_t*)authmsg, authmsgLen);
+ BYTE clientSig[ MIR_SHA1_HASH_SIZE ];
+ mir_hmac_sha1(clientSig, storedKey, sizeof(storedKey), (BYTE*)authmsg, authmsgLen);
- mir_sha1_byte_t clientProof[ MIR_SHA1_HASH_SIZE ];
+ BYTE clientProof[ MIR_SHA1_HASH_SIZE ];
for (unsigned j = 0; j < sizeof(clientKey); j++)
clientProof[j] = clientKey[j] ^ clientSig[j];
/* Calculate the server signature */
- mir_sha1_byte_t serverKey[ MIR_SHA1_HASH_SIZE ];
- hmac_sha1(serverKey, saltedPassw, sizeof(saltedPassw), (mir_sha1_byte_t*)"Server Key", 10);
+ BYTE serverKey[ MIR_SHA1_HASH_SIZE ];
+ mir_hmac_sha1(serverKey, saltedPassw, sizeof(saltedPassw), (BYTE*)"Server Key", 10);
- mir_sha1_byte_t srvSig[ MIR_SHA1_HASH_SIZE ];
- hmac_sha1(srvSig, serverKey, sizeof(serverKey), (mir_sha1_byte_t*)authmsg, authmsgLen);
+ BYTE srvSig[ MIR_SHA1_HASH_SIZE ];
+ mir_hmac_sha1(srvSig, serverKey, sizeof(serverKey), (BYTE*)authmsg, authmsgLen);
serverSignature = mir_base64_encode((PBYTE)srvSig, sizeof(srvSig));
char buf[4096];
diff --git a/protocols/JabberG/src/jabber_secur.h b/protocols/JabberG/src/jabber_secur.h
index 18afe89dfa..838e11367b 100644
--- a/protocols/JabberG/src/jabber_secur.h
+++ b/protocols/JabberG/src/jabber_secur.h
@@ -92,7 +92,7 @@ public:
virtual char* getChallenge(const TCHAR *challenge);
virtual bool validateLogin(const TCHAR *challenge);
- void Hi(mir_sha1_byte_t* res , char* passw, size_t passwLen, char* salt, size_t saltLen, int ind);
+ void Hi(BYTE* res , char* passw, size_t passwLen, char* salt, size_t saltLen, int ind);
};
// ntlm auth - LanServer based authorization
diff --git a/protocols/JabberG/src/jabber_svc.cpp b/protocols/JabberG/src/jabber_svc.cpp
index 4048dccf74..ae1bf712f7 100644
--- a/protocols/JabberG/src/jabber_svc.cpp
+++ b/protocols/JabberG/src/jabber_svc.cpp
@@ -313,10 +313,10 @@ INT_PTR __cdecl CJabberProto::JabberSetAvatar(WPARAM, LPARAM lParam)
_read(fileIn, pResult, dwPngSize);
_close(fileIn);
- mir_sha1_byte_t digest[MIR_SHA1_HASH_SIZE];
+ BYTE digest[MIR_SHA1_HASH_SIZE];
mir_sha1_ctx sha1ctx;
mir_sha1_init(&sha1ctx);
- mir_sha1_append(&sha1ctx, (mir_sha1_byte_t*)pResult, dwPngSize);
+ mir_sha1_append(&sha1ctx, (BYTE*)pResult, dwPngSize);
mir_sha1_finish(&sha1ctx, digest);
TCHAR tFileName[ MAX_PATH ];
diff --git a/protocols/JabberG/src/jabber_util.cpp b/protocols/JabberG/src/jabber_util.cpp
index a33c8640bd..7b00dfd63d 100644
--- a/protocols/JabberG/src/jabber_util.cpp
+++ b/protocols/JabberG/src/jabber_util.cpp
@@ -341,10 +341,10 @@ char* __stdcall JabberSha1(char* str)
if (str == NULL)
return NULL;
- mir_sha1_byte_t digest[20];
+ BYTE digest[20];
mir_sha1_ctx sha;
mir_sha1_init(&sha);
- mir_sha1_append(&sha, (mir_sha1_byte_t*)str, (int)strlen(str));
+ mir_sha1_append(&sha, (BYTE*)str, (int)strlen(str));
mir_sha1_finish(&sha, digest);
char *result = (char*)mir_alloc(41);
@@ -1625,10 +1625,10 @@ void __cdecl CJabberProto::LoadHttpAvatars(void* param)
setByte(AI.hContact, "AvatarType", pictureType);
char buffer[ 41 ];
- mir_sha1_byte_t digest[20];
+ BYTE digest[20];
mir_sha1_ctx sha;
mir_sha1_init(&sha);
- mir_sha1_append(&sha, (mir_sha1_byte_t*)res->pData, res->dataLength);
+ mir_sha1_append(&sha, (BYTE*)res->pData, res->dataLength);
mir_sha1_finish(&sha, digest);
bin2hex(digest, sizeof(digest), buffer);
diff --git a/protocols/JabberG/src/jabber_vcard.cpp b/protocols/JabberG/src/jabber_vcard.cpp
index 21cf96574c..f0cec19fa1 100644
--- a/protocols/JabberG/src/jabber_vcard.cpp
+++ b/protocols/JabberG/src/jabber_vcard.cpp
@@ -1171,10 +1171,10 @@ void CJabberProto::SetServerVcard(BOOL bPhotoChanged, TCHAR* szPhotoFileName)
// NEED TO UPDATE OUR AVATAR HASH:
- mir_sha1_byte_t digest[MIR_SHA1_HASH_SIZE];
+ BYTE digest[MIR_SHA1_HASH_SIZE];
mir_sha1_ctx sha1ctx;
mir_sha1_init(&sha1ctx);
- mir_sha1_append(&sha1ctx, (mir_sha1_byte_t*)buffer, nRead);
+ mir_sha1_append(&sha1ctx, (BYTE*)buffer, nRead);
mir_sha1_finish(&sha1ctx, digest);
char buf[MIR_SHA1_HASH_SIZE*2+1];