changeset 32343:ff8ab76da6bb

Remove ISO10126 padding when decrypting an incoming transport-encrypted message.
author andrew.victor@mxit.com
date Sat, 13 Aug 2011 17:11:59 +0000
parents 9ad5fcde4af4
children 4bf9b7cf7810
files libpurple/protocols/mxit/cipher.c
diffstat 1 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/mxit/cipher.c	Sat Aug 13 16:29:21 2011 +0000
+++ b/libpurple/protocols/mxit/cipher.c	Sat Aug 13 17:11:59 2011 +0000
@@ -149,7 +149,6 @@
 		Decrypt( (unsigned char*) raw_message + i, (unsigned char*) exkey, (unsigned char*) block );
 		g_string_append_len( decoded, block, 16 );
 	}
-
 	g_free( raw_message );
 
 	purple_debug_info( MXIT_PLUGIN_ID, "decrypted: '%s'\n", decoded->str );
@@ -159,10 +158,16 @@
 		g_string_free( decoded, TRUE );
 		return NULL;			/* message could not be decoded */
 	}
-	g_string_erase( decoded, 0, strlen( SECRET_HEADER ) );		/* remove header */
 
 	/* remove ISO10126 padding */
-// TODO
+	{
+		/* last byte indicates the number of padding bytes */
+		unsigned int padding = decoded->str[decoded->len - 1];
+		g_string_truncate( decoded, decoded->len - padding );
+	}
+
+	/* remove encryption header */
+	g_string_erase( decoded, 0, strlen( SECRET_HEADER ) );
 
 	return g_string_free( decoded, FALSE );
 }