pidgin.mxit: cb4ebf69: Remove ISO10126 padding when decrypting ...

andrew.victor at mxit.com andrew.victor at mxit.com
Sat Aug 13 18:05:49 EDT 2011


----------------------------------------------------------------------
Revision: cb4ebf69baee194624a1e5c05c5f2372fd13a0b4
Parent:   aaee2d99cc08c2b99d8829ed7b6875ac85324d87
Author:   andrew.victor at mxit.com
Date:     08/13/11 13:11:59
Branch:   im.pidgin.pidgin.mxit
URL: http://d.pidgin.im/viewmtn/revision/info/cb4ebf69baee194624a1e5c05c5f2372fd13a0b4

Changelog: 

Remove ISO10126 padding when decrypting an incoming transport-encrypted message.


Changes against parent aaee2d99cc08c2b99d8829ed7b6875ac85324d87

  patched  libpurple/protocols/mxit/cipher.c

-------------- next part --------------
============================================================
--- libpurple/protocols/mxit/cipher.c	d193a87cb8968377d2ce07254c5cc2d78a501b01
+++ libpurple/protocols/mxit/cipher.c	e99a14de17a556650a28dfdc78bfe554221cde3d
@@ -149,7 +149,6 @@ char* mxit_decrypt_message( struct MXitS
 		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 @@ char* mxit_decrypt_message( struct MXitS
 		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 );
 }


More information about the Commits mailing list