diff options
author | Alexander Gluzsky <sss123next@list.ru> | 2016-04-07 18:53:06 +0000 |
---|---|---|
committer | Alexander Gluzsky <sss123next@list.ru> | 2016-04-07 18:53:06 +0000 |
commit | 45795f0e01be0f51ac647cac4e7c35463f39636a (patch) | |
tree | a2e8dbd515f4006b09ff913e70a05214cf90b6a2 | |
parent | 6d823d15030bc2ccb7237a15492d20a204244ce0 (diff) |
aim:
"clientlogin":
implemented hmac_sha256
"clientlogin" is fully implemented now
//TODO: make some testing
//TODO: turn it on
git-svn-id: http://svn.miranda-ng.org/main/trunk@16607 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rwxr-xr-x | protocols/AimOscar/src/connection.cpp | 26 | ||||
-rwxr-xr-x | protocols/AimOscar/src/stdafx.h | 3 | ||||
-rwxr-xr-x | protocols/AimOscar/src/utility.cpp | 16 | ||||
-rwxr-xr-x[-rw-r--r--] | protocols/AimOscar/src/utility.h | 2 |
4 files changed, 36 insertions, 11 deletions
diff --git a/protocols/AimOscar/src/connection.cpp b/protocols/AimOscar/src/connection.cpp index 0be3ef6dfc..600f4cbcc9 100755 --- a/protocols/AimOscar/src/connection.cpp +++ b/protocols/AimOscar/src/connection.cpp @@ -258,7 +258,8 @@ void generate_signature(char *signature, const char *method, const char *url, co mir_snprintf(signature_base, 1023, "%s%s%s", method, encoded_url, encoded_parameters);
mir_free(encoded_url);
mir_free(encoded_parameters);
- //signature = hmac_sha256(session_key, signature_base);//TODO: need this to be implemented
+ hmac_sha256(session_key, signature_base, signature);
+
}
void fill_session_url(char *buf, char *token, char *secret, time_t &hosttime, const char *password, bool encryption = true)
@@ -269,12 +270,12 @@ void fill_session_url(char *buf, char *token, char *secret, time_t &hosttime, co */
char query_string[1024];
query_string[0] = 0;
- construct_query_string(query_string, token, hosttime);
+ construct_query_string(query_string, token, hosttime, encryption);
char signature[512];
char session_key[1024];
- //session_key = hmac_sha256(password, secret); //TODO: need this to be implemented
+ hmac_sha256(password, secret, session_key);
generate_signature(signature, "GET", AIM_SESSION_URL, query_string, session_key);
@@ -353,17 +354,20 @@ bool parse_start_socar_session_response(char *response, char *bos_host, unsigned bos_port = atoi(tmp_port);
mir_strcpy(cookie, tmp_cookie);
mir_free(tmp_host); mir_free(tmp_port); mir_free(tmp_cookie);
- HXML tls_node = xmlGetNthChild(data, _T("tlsCertName"), 0); //tls is optional, so this is not fatal error
- if(tls_node)
+ if (encryption)
{
- LPCTSTR certname_w = xmlGetText(tls_node);
- if(certname_w)
+ HXML tls_node = xmlGetNthChild(data, _T("tlsCertName"), 0); //tls is optional, so this is not fatal error
+ if (tls_node)
{
- char *tmp_certname = mir_t2a(certname_w);
- if(tmp_certname)
+ LPCTSTR certname_w = xmlGetText(tls_node);
+ if (certname_w)
{
- mir_strcpy(tls_cert_name, tmp_certname);
- mir_free(tmp_certname);
+ char *tmp_certname = mir_t2a(certname_w);
+ if (tmp_certname)
+ {
+ mir_strcpy(tls_cert_name, tmp_certname);
+ mir_free(tmp_certname);
+ }
}
}
}
diff --git a/protocols/AimOscar/src/stdafx.h b/protocols/AimOscar/src/stdafx.h index 56246fc344..e76898dcbf 100755 --- a/protocols/AimOscar/src/stdafx.h +++ b/protocols/AimOscar/src/stdafx.h @@ -74,6 +74,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "ui.h"
#include "version.h"
+//openssl
+#include <openssl/hmac.h>
+
// Protocol limits
#define MAX_SCREEN_NAME_LENGTH 97
#define MAX_GROUP_NAME_LENGTH 48
diff --git a/protocols/AimOscar/src/utility.cpp b/protocols/AimOscar/src/utility.cpp index 06849fb8b9..4ba0cc56c5 100755 --- a/protocols/AimOscar/src/utility.cpp +++ b/protocols/AimOscar/src/utility.cpp @@ -651,3 +651,19 @@ unsigned short get_random(void) id &= 0x7fff;
return id;
}
+
+void hmac_sha256(const char *key, const char *msg, char *buf)
+{
+ unsigned char hash[32];
+
+ HMAC_CTX hmac;
+ HMAC_CTX_init(&hmac);
+ HMAC_Init_ex(&hmac, &key[0], strlen(key), EVP_sha256(), NULL);
+ HMAC_Update(&hmac, (unsigned char*)&msg[0], strlen(msg));
+ unsigned int len = 32;
+ HMAC_Final(&hmac, hash, &len);
+ HMAC_CTX_cleanup(&hmac);
+
+ mir_strncpy(buf, key, len);
+
+}
\ No newline at end of file diff --git a/protocols/AimOscar/src/utility.h b/protocols/AimOscar/src/utility.h index 447d78538e..f5f6e0ef53 100644..100755 --- a/protocols/AimOscar/src/utility.h +++ b/protocols/AimOscar/src/utility.h @@ -31,6 +31,8 @@ inline int cap_cmp(const char* cap, const char* cap2) { return memcmp(cap, cap2, inline const char* alpha_cap_str(char ver) { return (ver & 0x80) ? " Alpha" : ""; }
inline const char* secure_cap_str(char* ver) { return (*(int*)ver == 0xDEC0FE5A) ? " + SecureIM" : ""; }
+void hmac_sha256(const char *key, const char *msg, char *buf);
+
struct BdListItem
{
|