Thu, 03 Apr 2014 04:23:35 +0200
Mxit: fix cipher.h conflict
| libpurple/protocols/mxit/Makefile.am | file | annotate | diff | comparison | revisions | |
| libpurple/protocols/mxit/actions.c | file | annotate | diff | comparison | revisions | |
| libpurple/protocols/mxit/cipher-mxit.c | file | annotate | diff | comparison | revisions | |
| libpurple/protocols/mxit/cipher-mxit.h | file | annotate | diff | comparison | revisions | |
| libpurple/protocols/mxit/cipher.c | file | annotate | diff | comparison | revisions | |
| libpurple/protocols/mxit/cipher.h | file | annotate | diff | comparison | revisions | |
| libpurple/protocols/mxit/login.c | file | annotate | diff | comparison | revisions |
--- a/libpurple/protocols/mxit/Makefile.am Thu Apr 03 04:20:57 2014 +0200 +++ b/libpurple/protocols/mxit/Makefile.am Thu Apr 03 04:23:35 2014 +0200 @@ -8,8 +8,8 @@ actions.h \ chunk.c \ chunk.h \ - cipher.c \ - cipher.h \ + cipher-mxit.c \ + cipher-mxit.h \ filexfer.c \ filexfer.h \ formcmds.c \
--- a/libpurple/protocols/mxit/actions.c Thu Apr 03 04:20:57 2014 +0200 +++ b/libpurple/protocols/mxit/actions.c Thu Apr 03 04:23:35 2014 +0200 @@ -32,7 +32,7 @@ #include "roster.h" #include "actions.h" #include "splashscreen.h" -#include "cipher.h" +#include "cipher-mxit.h" #include "profile.h"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libpurple/protocols/mxit/cipher-mxit.c Thu Apr 03 04:23:35 2014 +0200 @@ -0,0 +1,83 @@ +/* + * purple + * + * Purple is the legal property of its developers, whose names are too numerous + * to list here. Please refer to the COPYRIGHT file distributed with this + * source distribution. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA + */ + +#include "cipher-mxit.h" + +#include "cipher.h" +#include "ciphers/aescipher.h" +#include "debug.h" +#include "internal.h" + +#define INITIAL_KEY "6170383452343567" +#define SECRET_HEADER "<mxit/>" + +/** + * Encrypt the user's cleartext password using the AES 128-bit (ECB) + * encryption algorithm. + * + * @param session The MXit session object + * + * @return The encrypted & encoded password. Must be g_free'd when + * no longer needed. + */ +gchar * +mxit_encrypt_password(struct MXitSession* session) +{ + guchar key[16]; + size_t clientkey_len, header_len, pass_len, plaintext_len; + const gchar *plaintext_passwd; + guchar *plaintext; + guchar encrypted[64]; /* shouldn't be longer than 17 */ + PurpleCipher *cipher; + ssize_t encrypted_size; + + purple_debug_info(MXIT_PLUGIN_ID, "mxit_encrypt_password"); + + /* build the AES encryption key */ + g_assert(strlen(INITIAL_KEY) == sizeof(key)); + memcpy(key, INITIAL_KEY, sizeof(key)); + clientkey_len = strlen(session->clientkey); + if (clientkey_len > sizeof(key)) + clientkey_len = sizeof(key); + memcpy(key, session->clientkey, clientkey_len); + + /* build the secret data to be encrypted: SECRET_HEADER + password */ + plaintext_passwd = purple_connection_get_password(session->con); + g_return_val_if_fail(plaintext_passwd, NULL); + pass_len = strlen(plaintext_passwd); + header_len = strlen(SECRET_HEADER); + /* Trailing NUL, just to be safe. But PKCS#7 seems to be enough. */ + plaintext_len = header_len + pass_len + 1; + plaintext = g_new0(guchar, plaintext_len); + memcpy(plaintext, SECRET_HEADER, header_len); + memcpy(plaintext + header_len, plaintext_passwd, pass_len); + + /* encrypt */ + cipher = purple_aes_cipher_new(); + purple_cipher_set_key(cipher, key, sizeof(key)); + purple_cipher_set_batch_mode(cipher, PURPLE_CIPHER_BATCH_MODE_ECB); + encrypted_size = purple_cipher_encrypt(cipher, + plaintext, plaintext_len, encrypted, sizeof(encrypted)); + g_return_val_if_fail(encrypted_size > 0, NULL); + + return purple_base64_encode(encrypted, encrypted_size); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libpurple/protocols/mxit/cipher-mxit.h Thu Apr 03 04:23:35 2014 +0200 @@ -0,0 +1,31 @@ +/* + * purple + * + * Purple is the legal property of its developers, whose names are too numerous + * to list here. Please refer to the COPYRIGHT file distributed with this + * source distribution. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA + */ + +#ifndef _MXIT_CIPHER_H_ +#define _MXIT_CIPHER_H_ + +#include "mxit.h" + +gchar * +mxit_encrypt_password(struct MXitSession* session); + +#endif /* _MXIT_CIPHER_H_ */
--- a/libpurple/protocols/mxit/cipher.c Thu Apr 03 04:20:57 2014 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,83 +0,0 @@ -/* - * purple - * - * Purple is the legal property of its developers, whose names are too numerous - * to list here. Please refer to the COPYRIGHT file distributed with this - * source distribution. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA - */ - -#include "internal.h" -#include "debug.h" -#include "libpurple/cipher.h" -#include "ciphers/aescipher.h" - -#include "cipher.h" - -#define INITIAL_KEY "6170383452343567" -#define SECRET_HEADER "<mxit/>" - -/** - * Encrypt the user's cleartext password using the AES 128-bit (ECB) - * encryption algorithm. - * - * @param session The MXit session object - * - * @return The encrypted & encoded password. Must be g_free'd when - * no longer needed. - */ -gchar * -mxit_encrypt_password(struct MXitSession* session) -{ - guchar key[16]; - size_t clientkey_len, header_len, pass_len, plaintext_len; - const gchar *plaintext_passwd; - guchar *plaintext; - guchar encrypted[64]; /* shouldn't be longer than 17 */ - PurpleCipher *cipher; - ssize_t encrypted_size; - - purple_debug_info(MXIT_PLUGIN_ID, "mxit_encrypt_password"); - - /* build the AES encryption key */ - g_assert(strlen(INITIAL_KEY) == sizeof(key)); - memcpy(key, INITIAL_KEY, sizeof(key)); - clientkey_len = strlen(session->clientkey); - if (clientkey_len > sizeof(key)) - clientkey_len = sizeof(key); - memcpy(key, session->clientkey, clientkey_len); - - /* build the secret data to be encrypted: SECRET_HEADER + password */ - plaintext_passwd = purple_connection_get_password(session->con); - g_return_val_if_fail(plaintext_passwd, NULL); - pass_len = strlen(plaintext_passwd); - header_len = strlen(SECRET_HEADER); - /* Trailing NUL, just to be safe. But PKCS#7 seems to be enough. */ - plaintext_len = header_len + pass_len + 1; - plaintext = g_new0(guchar, plaintext_len); - memcpy(plaintext, SECRET_HEADER, header_len); - memcpy(plaintext + header_len, plaintext_passwd, pass_len); - - /* encrypt */ - cipher = purple_aes_cipher_new(); - purple_cipher_set_key(cipher, key, sizeof(key)); - purple_cipher_set_batch_mode(cipher, PURPLE_CIPHER_BATCH_MODE_ECB); - encrypted_size = purple_cipher_encrypt(cipher, - plaintext, plaintext_len, encrypted, sizeof(encrypted)); - g_return_val_if_fail(encrypted_size > 0, NULL); - - return purple_base64_encode(encrypted, encrypted_size); -}
--- a/libpurple/protocols/mxit/cipher.h Thu Apr 03 04:20:57 2014 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -/* - * purple - * - * Purple is the legal property of its developers, whose names are too numerous - * to list here. Please refer to the COPYRIGHT file distributed with this - * source distribution. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA - */ - -#ifndef _MXIT_CIPHER_H_ -#define _MXIT_CIPHER_H_ - -#include "mxit.h" - -gchar * -mxit_encrypt_password(struct MXitSession* session); - -#endif /* _MXIT_CIPHER_H_ */