libpurple/protocols/mxit/cipher.c

Sat, 13 Apr 2013 12:24:43 -0400

author
Daniel Atallah <datallah@pidgin.im>
date
Sat, 13 Apr 2013 12:24:43 -0400
changeset 33880
2f2dd47bf56b
parent 33852
368feedc80cf
child 34148
62a874e41930
permissions
-rw-r--r--

Merge with release-2.x.y

28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1 /*
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2 * MXit Protocol libPurple Plugin
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3 *
33679
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
4 * -- encryption --
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5 *
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
6 * Pieter Loubser <libpurple@mxit.com>
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
7 *
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
8 * (C) Copyright 2009 MXit Lifestyle (Pty) Ltd.
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
9 * <http://www.mxitlifestyle.com>
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
10 *
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
11 * This program is free software; you can redistribute it and/or modify
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
12 * it under the terms of the GNU General Public License as published by
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
13 * the Free Software Foundation; either version 2 of the License, or
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
14 * (at your option) any later version.
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
15 *
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
16 * This program is distributed in the hope that it will be useful,
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
19 * GNU General Public License for more details.
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
20 *
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
21 * You should have received a copy of the GNU General Public License
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
22 * along with this program; if not, write to the Free Software
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
24 */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
25
33844
e8edfd4e26ae MXit: Cleanup the #includes (no purple.h) so that it atleast compiles within InstantBird.
Andrew Victor <andrew.victor@mxit.com>
parents: 33713
diff changeset
26 #include "internal.h"
e8edfd4e26ae MXit: Cleanup the #includes (no purple.h) so that it atleast compiles within InstantBird.
Andrew Victor <andrew.victor@mxit.com>
parents: 33713
diff changeset
27 #include "debug.h"
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
28
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
29 #include "mxit.h"
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
30 #include "cipher.h"
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
31 #include "aes.h"
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
32
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
33
33679
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
34 /* encryption */
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
35 #define INITIAL_KEY "6170383452343567"
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
36 #define SECRET_HEADER "<mxit/>"
33679
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
37 #define ENCRYPT_HEADER "<mxitencrypted ver=\"5.2\"/>"
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
38
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
39
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
40 /*------------------------------------------------------------------------
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
41 * Add ISO10126 Padding to the data.
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
42 *
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
43 * @param data The data to pad.
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
44 */
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
45 static void padding_add( GString* data )
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
46 {
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
47 unsigned int blocks = ( data->len / 16 ) + 1;
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
48 unsigned int padding = ( blocks * 16 ) - data->len;
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
49
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
50 g_string_set_size( data, blocks * 16 );
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
51 data->str[data->len - 1] = padding;
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
52 }
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
53
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
54
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
55 /*------------------------------------------------------------------------
33679
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
56 * Remove ISO10126 Padding from the data.
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
57 *
33679
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
58 * @param data The data from which to remove padding.
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
59 */
33679
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
60 static void padding_remove( GString* data )
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
61 {
33679
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
62 unsigned int padding;
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
63
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
64 if ( data->len == 0 )
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
65 return;
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
66
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
67 padding = data->str[data->len - 1];
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
68 g_string_truncate( data, data->len - padding );
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
69 }
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
70
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
71
33679
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
72 /*------------------------------------------------------------------------
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
73 * Generate the Transport-Layer crypto key.
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
74 * (Note: this function is not-thread safe)
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
75 *
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
76 * @param session The MXit Session object
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
77 * @return The transport-layer crypto key.
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
78 */
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
79 static char* transport_layer_key( struct MXitSession* session )
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
80 {
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
81 static char key[16 + 1];
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
82 const char* password = purple_account_get_password( session->acc );
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
83 int passlen = strlen( password );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
84
33679
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
85 /* initialize with initial key */
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
86 g_strlcpy( key, INITIAL_KEY, sizeof( key ) );
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
87
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
88 /* client key (8 bytes) */
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
89 memcpy( key, session->clientkey, strlen( session->clientkey ) );
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
90
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
91 /* add last 8 characters of the PIN (no padding if less characters) */
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
92 if ( passlen <= 8 )
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
93 memcpy( key + 8, password, passlen );
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
94 else
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
95 memcpy( key + 8, password + ( passlen - 8 ), 8 );
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
96
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
97 return key;
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
98 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
99
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
100
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
101 /*------------------------------------------------------------------------
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
102 * Encrypt the user's cleartext password using the AES 128-bit (ECB)
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
103 * encryption algorithm.
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
104 *
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
105 * @param session The MXit session object
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
106 * @return The encrypted & encoded password. Must be g_free'd when no longer needed.
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
107 */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
108 char* mxit_encrypt_password( struct MXitSession* session )
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
109 {
33845
53109a1846ae MXit: Fix compiler warnings related to "comparison between signed and unsigned integer expressions".
Andrew Victor <andrew.victor@mxit.com>
parents: 33844
diff changeset
110 char key[16 + 1];
53109a1846ae MXit: Fix compiler warnings related to "comparison between signed and unsigned integer expressions".
Andrew Victor <andrew.victor@mxit.com>
parents: 33844
diff changeset
111 char exkey[512];
53109a1846ae MXit: Fix compiler warnings related to "comparison between signed and unsigned integer expressions".
Andrew Victor <andrew.victor@mxit.com>
parents: 33844
diff changeset
112 GString* pass = NULL;
53109a1846ae MXit: Fix compiler warnings related to "comparison between signed and unsigned integer expressions".
Andrew Victor <andrew.victor@mxit.com>
parents: 33844
diff changeset
113 GString* encrypted = NULL;
53109a1846ae MXit: Fix compiler warnings related to "comparison between signed and unsigned integer expressions".
Andrew Victor <andrew.victor@mxit.com>
parents: 33844
diff changeset
114 char* base64;
53109a1846ae MXit: Fix compiler warnings related to "comparison between signed and unsigned integer expressions".
Andrew Victor <andrew.victor@mxit.com>
parents: 33844
diff changeset
115 unsigned int i;
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
116
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
117 purple_debug_info( MXIT_PLUGIN_ID, "mxit_encrypt_password\n" );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
118
33679
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
119 /* build the AES encryption key */
31958
e1b3f14fba94 Changed a strcpy in the mxit prpl to a bounds-checked g_strlcpy.
Ethan Blanton <elb@pidgin.im>
parents: 29106
diff changeset
120 g_strlcpy( key, INITIAL_KEY, sizeof( key ) );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
121 memcpy( key, session->clientkey, strlen( session->clientkey ) );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
122 ExpandKey( (unsigned char*) key, (unsigned char*) exkey );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
123
33679
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
124 /* build the secret data to be encrypted: SECRET_HEADER + password */
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
125 pass = g_string_new( SECRET_HEADER );
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
126 g_string_append( pass, purple_account_get_password( session->acc) );
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
127 padding_add( pass ); /* add ISO10126 padding */
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
128
33679
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
129 /* now encrypt the secret. we encrypt each block separately (ECB mode) */
33713
3c21af28962e MXit: Rather use a GString to store the raw encrypted password.
Andrew Victor <andrew.victor@mxit.com>
parents: 33679
diff changeset
130 encrypted = g_string_sized_new( pass->len );
3c21af28962e MXit: Rather use a GString to store the raw encrypted password.
Andrew Victor <andrew.victor@mxit.com>
parents: 33679
diff changeset
131 for ( i = 0; i < pass->len; i += 16 ) {
3c21af28962e MXit: Rather use a GString to store the raw encrypted password.
Andrew Victor <andrew.victor@mxit.com>
parents: 33679
diff changeset
132 char block[16];
3c21af28962e MXit: Rather use a GString to store the raw encrypted password.
Andrew Victor <andrew.victor@mxit.com>
parents: 33679
diff changeset
133
3c21af28962e MXit: Rather use a GString to store the raw encrypted password.
Andrew Victor <andrew.victor@mxit.com>
parents: 33679
diff changeset
134 Encrypt( (unsigned char*) pass->str + i, (unsigned char*) exkey, (unsigned char*) block );
3c21af28962e MXit: Rather use a GString to store the raw encrypted password.
Andrew Victor <andrew.victor@mxit.com>
parents: 33679
diff changeset
135 g_string_append_len( encrypted, block, 16 );
3c21af28962e MXit: Rather use a GString to store the raw encrypted password.
Andrew Victor <andrew.victor@mxit.com>
parents: 33679
diff changeset
136 }
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
137
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
138 /* now base64 encode the encrypted password */
33713
3c21af28962e MXit: Rather use a GString to store the raw encrypted password.
Andrew Victor <andrew.victor@mxit.com>
parents: 33679
diff changeset
139 base64 = purple_base64_encode( (unsigned char*) encrypted->str, encrypted->len );
3c21af28962e MXit: Rather use a GString to store the raw encrypted password.
Andrew Victor <andrew.victor@mxit.com>
parents: 33679
diff changeset
140 g_string_free( encrypted, TRUE );
33679
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
141
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
142 g_string_free( pass, TRUE );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
143
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
144 return base64;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
145 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
146
33679
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
147
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
148 /*------------------------------------------------------------------------
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
149 * Decrypt a message using transport-layer encryption.
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
150 *
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
151 * @param session The MXit session object
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
152 * @param message The encrypted message data (is base64-encoded).
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
153 * @return The decrypted message. Must be g_free'd when no longer needed.
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
154 */
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
155 char* mxit_decrypt_message( struct MXitSession* session, char* message )
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
156 {
33845
53109a1846ae MXit: Fix compiler warnings related to "comparison between signed and unsigned integer expressions".
Andrew Victor <andrew.victor@mxit.com>
parents: 33844
diff changeset
157 guchar* raw_message;
53109a1846ae MXit: Fix compiler warnings related to "comparison between signed and unsigned integer expressions".
Andrew Victor <andrew.victor@mxit.com>
parents: 33844
diff changeset
158 gsize raw_len;
53109a1846ae MXit: Fix compiler warnings related to "comparison between signed and unsigned integer expressions".
Andrew Victor <andrew.victor@mxit.com>
parents: 33844
diff changeset
159 char exkey[512];
53109a1846ae MXit: Fix compiler warnings related to "comparison between signed and unsigned integer expressions".
Andrew Victor <andrew.victor@mxit.com>
parents: 33844
diff changeset
160 GString* decoded = NULL;
53109a1846ae MXit: Fix compiler warnings related to "comparison between signed and unsigned integer expressions".
Andrew Victor <andrew.victor@mxit.com>
parents: 33844
diff changeset
161 unsigned int i;
33679
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
162
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
163 /* remove optional header: <mxitencrypted ver="5.2"/> */
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
164 if ( strncmp( message, ENCRYPT_HEADER, strlen( ENCRYPT_HEADER ) ) == 0 )
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
165 message += strlen( ENCRYPT_HEADER );
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
166
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
167 /* base64 decode the message */
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
168 raw_message = purple_base64_decode( message, &raw_len );
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
169
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
170 /* AES-encrypted data is always blocks of 16 bytes */
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
171 if ( ( raw_len == 0 ) || ( raw_len % 16 != 0 ) )
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
172 return NULL;
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
173
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
174 /* build the AES key */
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
175 ExpandKey( (unsigned char*) transport_layer_key( session ), (unsigned char*) exkey );
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
176
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
177 /* AES decrypt each block */
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
178 decoded = g_string_sized_new( raw_len );
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
179 for ( i = 0; i < raw_len; i += 16 ) {
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
180 char block[16];
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
181
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
182 Decrypt( (unsigned char*) raw_message + i, (unsigned char*) exkey, (unsigned char*) block );
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
183 g_string_append_len( decoded, block, 16 );
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
184 }
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
185 g_free( raw_message );
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
186
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
187 /* check that the decrypted message starts with header: <mxit/> */
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
188 if ( strncmp( decoded->str, SECRET_HEADER, strlen( SECRET_HEADER ) != 0 ) ) {
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
189 g_string_free( decoded, TRUE );
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
190 return NULL; /* message could not be decrypted */
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
191 }
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
192
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
193 /* remove ISO10126 padding */
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
194 padding_remove( decoded );
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
195
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
196 /* remove encryption header */
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
197 g_string_erase( decoded, 0, strlen( SECRET_HEADER ) );
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
198
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
199 return g_string_free( decoded, FALSE );
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
200 }
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
201
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
202
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
203 /*------------------------------------------------------------------------
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
204 * Encrypt a message using transport-layer encryption.
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
205 *
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
206 * @param session The MXit session object
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
207 * @param message The message data.
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
208 * @return The encrypted message. Must be g_free'd when no longer needed.
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
209 */
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
210 char* mxit_encrypt_message( struct MXitSession* session, char* message )
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
211 {
33845
53109a1846ae MXit: Fix compiler warnings related to "comparison between signed and unsigned integer expressions".
Andrew Victor <andrew.victor@mxit.com>
parents: 33844
diff changeset
212 GString* raw_message = NULL;
53109a1846ae MXit: Fix compiler warnings related to "comparison between signed and unsigned integer expressions".
Andrew Victor <andrew.victor@mxit.com>
parents: 33844
diff changeset
213 char exkey[512];
53109a1846ae MXit: Fix compiler warnings related to "comparison between signed and unsigned integer expressions".
Andrew Victor <andrew.victor@mxit.com>
parents: 33844
diff changeset
214 GString* encoded = NULL;
53109a1846ae MXit: Fix compiler warnings related to "comparison between signed and unsigned integer expressions".
Andrew Victor <andrew.victor@mxit.com>
parents: 33844
diff changeset
215 gchar* base64;
53109a1846ae MXit: Fix compiler warnings related to "comparison between signed and unsigned integer expressions".
Andrew Victor <andrew.victor@mxit.com>
parents: 33844
diff changeset
216 unsigned int i;
33679
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
217
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
218 purple_debug_info( MXIT_PLUGIN_ID, "encrypt message: '%s'\n", message );
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
219
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
220 /* append encryption header to message data */
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
221 raw_message = g_string_new( SECRET_HEADER );
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
222 g_string_append( raw_message, message );
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
223 padding_add( raw_message ); /* add ISO10126 padding */
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
224
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
225 /* build the AES key */
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
226 ExpandKey( (unsigned char*) transport_layer_key( session ), (unsigned char*) exkey );
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
227
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
228 /* AES encrypt each block */
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
229 encoded = g_string_sized_new( raw_message->len );
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
230 for ( i = 0; i < raw_message->len; i += 16 ) {
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
231 char block[16];
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
232
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
233 Encrypt( (unsigned char*) raw_message->str + i, (unsigned char*) exkey, (unsigned char*) block );
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
234 g_string_append_len( encoded, block, 16 );
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
235 }
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
236 g_string_free( raw_message, TRUE );
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
237
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
238 /* base64 encode the encrypted message */
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
239 base64 = purple_base64_encode( (unsigned char *) encoded->str, encoded->len );
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
240 g_string_free( encoded, TRUE );
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
241
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
242 purple_debug_info( MXIT_PLUGIN_ID, "encrypted message: '%s'\n", base64 );
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
243
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
244 return base64;
4074275c1007 MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents: 31958
diff changeset
245 }

mercurial