diff options
author | George Hazan <george.hazan@gmail.com> | 2013-08-15 20:00:29 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-08-15 20:00:29 +0000 |
commit | 623722f7cc4c20d2b7d8df03035801acacda6018 (patch) | |
tree | d4c3686f935c12c9e9274cc3706bef12d9a20d86 /protocols/MRA/src | |
parent | 8588345b7b8ff89bf90a216dbed2302fcf3ccdbc (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/MRA/src')
-rw-r--r-- | protocols/MRA/src/MraUtils.cpp | 60 | ||||
-rw-r--r-- | protocols/MRA/src/Mra_functions.cpp | 4 |
2 files changed, 2 insertions, 62 deletions
diff --git a/protocols/MRA/src/MraUtils.cpp b/protocols/MRA/src/MraUtils.cpp deleted file mode 100644 index d35255d4a9..0000000000 --- a/protocols/MRA/src/MraUtils.cpp +++ /dev/null @@ -1,60 +0,0 @@ -#include "Mra.h"
-#include "MraSendQueue.h"
-
-void hmac_sha1(BYTE *text,size_t text_len,BYTE *key,size_t key_len,BYTE *digest)
-{
- mir_sha1_ctx context;
- BYTE k_ipad[65]; /* inner padding - key XORd with ipad */
- BYTE k_opad[65]; /* outer padding - key XORd with opad */
- BYTE tk[MIR_SHA1_HASH_SIZE];
- /* if key is longer than 64 bytes reset it to key=SHA1(key) */
- if (key_len>64)
- {
- mir_sha1_ctx tctx;
-
- mir_sha1_init(&tctx);
- mir_sha1_append(&tctx,key,key_len);
- mir_sha1_finish(&tctx,(BYTE*)&tk);
-
- key=tk;
- key_len=MIR_SHA1_HASH_SIZE;
- }
-
- /*
- * the HMAC_SHA1 transform looks like:
- *
- * SHA1(K XOR opad, SHA1(K XOR ipad, text))
- *
- * where K is an n byte key
- * ipad is the byte 0x36 repeated 64 times
- * opad is the byte 0x5c repeated 64 times
- * and text is the data being protected
- */
-
- /* start out by storing key in pads */
- memmove(&k_ipad,key,key_len);
- memmove(&k_opad,key,key_len);
- memset(&k_ipad[key_len], 0, (sizeof(k_ipad)-key_len));
- memset(&k_opad[key_len], 0 , (sizeof(k_opad)-key_len));
-
- /* XOR key with ipad and opad values */
- for (size_t i=0;i<(64/sizeof(ULONGLONG));i++)
- {
- ((ULONGLONG*)k_ipad)[i]^=0x3636363636363636;
- ((ULONGLONG*)k_opad)[i]^=0x5C5C5C5C5C5C5C5C;
- }
- /* perform inner SHA1 */
- mir_sha1_init(&context); /* init context for 1st pass */
- mir_sha1_append(&context,k_ipad,64); /* start with inner pad */
- mir_sha1_append(&context,text,text_len); /* then text of datagram */
- mir_sha1_finish(&context,digest); /* finish up 1st pass */
- /* perform outer SHA1 */
- mir_sha1_init(&context); /* init context for 2nd pass */
- mir_sha1_append(&context,k_opad,64); /* start with outer pad */
- mir_sha1_append(&context,(BYTE*)digest,MIR_SHA1_HASH_SIZE); /* then results of 1st hash */
- mir_sha1_finish(&context,digest); /* finish up 2nd pass */
-
- bzero(k_ipad,sizeof(k_ipad));
- bzero(k_opad,sizeof(k_opad));
- bzero(tk,sizeof(tk));
-}
diff --git a/protocols/MRA/src/Mra_functions.cpp b/protocols/MRA/src/Mra_functions.cpp index 114de07da0..23b19814f3 100644 --- a/protocols/MRA/src/Mra_functions.cpp +++ b/protocols/MRA/src/Mra_functions.cpp @@ -1544,7 +1544,7 @@ BOOL CMraProto::SetPassDB(LPSTR lpszBuff, size_t dwBuffSize) btCryptedPass[0] = (BYTE)dwBuffSize;
//memmove(&btCryptedPass[1], lpszBuff, dwBuffSize);
- hmac_sha1(btRandomData, sizeof(btRandomData), (BYTE*)szEMail, dwEMailSize, bthmacSHA1);
+ mir_hmac_sha1(bthmacSHA1, (BYTE*)szEMail, dwEMailSize, btRandomData, sizeof(btRandomData));
RC4(btCryptedPass, sizeof(btCryptedPass), bthmacSHA1, MIR_SHA1_HASH_SIZE);
RC4(btCryptedPass, sizeof(btCryptedPass), btRandomData, sizeof(btRandomData));
@@ -1583,7 +1583,7 @@ BOOL CMraProto::GetPassDB(LPSTR lpszBuff, size_t dwBuffSize, size_t *pdwBuffSize if (mraGetContactSettingBlob(NULL, "pCryptPass", btCryptedPass, sizeof(btCryptedPass), &dwCryptedPass))
if (dwCryptedPass == sizeof(btCryptedPass))
if (mraGetStaticStringA(NULL, "e-mail", szEMail, SIZEOF(szEMail), &dwEMailSize)) {
- hmac_sha1(btRandomData, sizeof(btRandomData), (BYTE*)szEMail, dwEMailSize, bthmacSHA1);
+ mir_hmac_sha1(bthmacSHA1, (BYTE*)szEMail, dwEMailSize, btRandomData, sizeof(btRandomData));
RC4(btCryptedPass, sizeof(btCryptedPass), bthmacSHA1, MIR_SHA1_HASH_SIZE);
CopyMemoryReverseDWORD(btCryptedPass, btCryptedPass, sizeof(btCryptedPass));
|