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/Gadu-Gadu/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/Gadu-Gadu/src')
-rw-r--r-- | protocols/Gadu-Gadu/src/avatar.cpp | 2 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/oauth.cpp | 46 |
2 files changed, 3 insertions, 45 deletions
diff --git a/protocols/Gadu-Gadu/src/avatar.cpp b/protocols/Gadu-Gadu/src/avatar.cpp index 400182613c..05d4f8781a 100644 --- a/protocols/Gadu-Gadu/src/avatar.cpp +++ b/protocols/Gadu-Gadu/src/avatar.cpp @@ -114,7 +114,7 @@ char *gg_avatarhash(char *param) if (param == NULL || (result = (char *)mir_alloc(MIR_SHA1_HASH_SIZE * 2 + 1)) == NULL)
return NULL;
- mir_sha1_byte_t digest[MIR_SHA1_HASH_SIZE];
+ BYTE digest[MIR_SHA1_HASH_SIZE];
mir_sha1_hash((BYTE*)param, (int)strlen(param), digest);
return bin2hex(digest, sizeof(digest), result);
}
diff --git a/protocols/Gadu-Gadu/src/oauth.cpp b/protocols/Gadu-Gadu/src/oauth.cpp index e2484a3838..7f428319e7 100644 --- a/protocols/Gadu-Gadu/src/oauth.cpp +++ b/protocols/Gadu-Gadu/src/oauth.cpp @@ -50,46 +50,6 @@ static int paramsortFunc(const OAUTHPARAMETER *p1, const OAUTHPARAMETER *p2) return res != 0 ? res : strcmp(p1->value, p2->value);
}
-// HMAC-SHA1 (see RFC 2104 for details)
-void hmacsha1_hash(mir_sha1_byte_t *text, int text_len, mir_sha1_byte_t *key, int key_len,
- mir_sha1_byte_t digest[MIR_SHA1_HASH_SIZE])
-{
- mir_sha1_ctx context;
- mir_sha1_byte_t k_ipad[64];
- mir_sha1_byte_t k_opad[64];
- int i;
-
- if (key_len > 64) {
- mir_sha1_ctx tctx;
- mir_sha1_byte_t tk[MIR_SHA1_HASH_SIZE];
-
- mir_sha1_init(&tctx);
- mir_sha1_append(&tctx, key, key_len);
- mir_sha1_finish(&tctx, tk);
-
- key = tk;
- key_len = MIR_SHA1_HASH_SIZE;
- }
-
- memset(k_ipad, 0x36, 64);
- memset(k_opad, 0x5c, 64);
-
- for (i = 0; i < key_len; i++) {
- k_ipad[i] ^= key[i];
- k_opad[i] ^= key[i];
- }
-
- mir_sha1_init(&context);
- mir_sha1_append(&context, k_ipad, 64);
- mir_sha1_append(&context, text, text_len);
- mir_sha1_finish(&context, digest);
-
- mir_sha1_init(&context);
- mir_sha1_append(&context, k_opad, 64);
- mir_sha1_append(&context, digest, MIR_SHA1_HASH_SIZE);
- mir_sha1_finish(&context, digest);
-}
-
// see RFC 3986 for details
#define isunreserved(c) ( isalnum((unsigned char)c) || c == '-' || c == '.' || c == '_' || c == '~')
char *oauth_uri_escape(const char *str)
@@ -239,12 +199,10 @@ int oauth_sign_request(LIST<OAUTHPARAMETER> ¶ms, const char *httpmethod, con strcat(key, "&");
strcat(key, tsenc);
- mir_sha1_byte_t digest[MIR_SHA1_HASH_SIZE];
- hmacsha1_hash((BYTE*)(char*)text, (int)strlen(text), (BYTE*)(char*)key, (int)strlen(key), digest);
+ BYTE digest[MIR_SHA1_HASH_SIZE];
+ mir_hmac_sha1(digest, (BYTE*)(char*)text, strlen(text), (BYTE*)(char*)key, strlen(key));
sign = mir_base64_encode(digest, MIR_SHA1_HASH_SIZE);
}
-// else if (!strcmp(signmethod, "RSA-SHA1")) { // unimplemented
-// }
else { // PLAINTEXT
ptrA csenc( oauth_uri_escape(consumer_secret));
ptrA tsenc( oauth_uri_escape(token_secret));
|