diff options
author | Fishbone <fishbone@miranda-ng.org> | 2013-06-02 16:19:21 +0000 |
---|---|---|
committer | Fishbone <fishbone@miranda-ng.org> | 2013-06-02 16:19:21 +0000 |
commit | ab7e0b08fa8c31cf1d468ab4b3c660e2b1836811 (patch) | |
tree | 52977603ea0f431adff16573d3d5b46a95843c7f /protocols/WhatsApp/src/WhatsAPI++/WALogin.h | |
parent | 8320783f99419db1e40346fdb292c19ee008948b (diff) |
Added WhatsApp-protocol
git-svn-id: http://svn.miranda-ng.org/main/trunk@4861 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/WhatsApp/src/WhatsAPI++/WALogin.h')
-rw-r--r-- | protocols/WhatsApp/src/WhatsAPI++/WALogin.h | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/protocols/WhatsApp/src/WhatsAPI++/WALogin.h b/protocols/WhatsApp/src/WhatsAPI++/WALogin.h new file mode 100644 index 0000000000..92054abf54 --- /dev/null +++ b/protocols/WhatsApp/src/WhatsAPI++/WALogin.h @@ -0,0 +1,75 @@ +/*
+ * WALogin.h
+ *
+ * Created on: 26/06/2012
+ * Author: Antonio
+ */
+
+#ifndef WALOGIN_H_
+#define WALOGIN_H_
+
+#include "BinTreeNodeReader.h"
+#include "BinTreeNodeWriter.h"
+#include "WAConnection.h"
+#include <openssl/rc4.h>
+#include <openssl/hmac.h>
+#include <string>
+
+class WAConnection;
+class BinTreeNodeReader;
+class BinTreeNodeWriter;
+
+class KeyStream {
+private:
+ RC4_KEY rc4;
+ HMAC_CTX hmac;
+ unsigned char* key;
+ int keyLength;
+
+ void hmacsha1(unsigned char* text, int textLength, unsigned char *out);
+
+public:
+ KeyStream(unsigned char* key, size_t keyLegnth);
+ virtual ~KeyStream();
+
+ static void keyFromPasswordAndNonce(const std::string& pass, const std::vector<unsigned char>& nonce, unsigned char *out);
+ void decodeMessage(unsigned char* buffer, int macOffset, int offset, const int length);
+ void encodeMessage(unsigned char* buffer, int macOffset, int offset, const int length);
+};
+
+
+class WALogin {
+private:
+ static const std::string NONCE_KEY;
+ KeyStream* outputKey;
+ WAConnection* connection;
+
+ std::vector<unsigned char>* getAuthBlob(const std::vector<unsigned char>& nonce);
+ void sendResponse(const std::vector<unsigned char>& challengeData);
+ void sendFeatures();
+ void sendAuth(const std::vector<unsigned char>& nonce);
+ std::vector<unsigned char>* readFeaturesUntilChallengeOrSuccess();
+ void parseSuccessNode(ProtocolTreeNode* node);
+ std::vector<unsigned char> readSuccess();
+ std::string getResponse(const std::string& challenge);
+
+public:
+ std::string user;
+ std::string domain;
+ std::string password;
+ std::string resource;
+ std::string push_name;
+ bool supports_receipt_acks;
+ time_t expire_date;
+ int account_kind;
+ BinTreeNodeReader* inn;
+ BinTreeNodeWriter* out;
+
+ WALogin(WAConnection* connection, BinTreeNodeReader *reader, BinTreeNodeWriter *writer, const std::string& domain, const std::string& user, const std::string& resource, const std::string& password, const std::string& push_name);
+ std::vector<unsigned char>* login(const std::vector<unsigned char>& blobLength);
+ BinTreeNodeReader *getTreeNodeReader();
+ BinTreeNodeWriter *getTreeNodeWriter();
+ virtual ~WALogin();
+};
+
+#endif /* WALOGIN_H_ */
|