/pidgin/main: 717a428718a6: ciphers: Fix DES sanity checking - ...

Daniel Atallah datallah at pidgin.im
Fri Jun 21 13:48:09 EDT 2013


Changeset: 717a428718a64437d93530c8ef702e6c944e4e3a
Author:	 Daniel Atallah <datallah at pidgin.im>
Date:	 2013-06-21 13:47 -0400
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/717a428718a6

Description:

ciphers: Fix DES sanity checking  - this makes MSN work again

diffstat:

 libpurple/ciphers/des.c |  28 ++++++++++++++--------------
 1 files changed, 14 insertions(+), 14 deletions(-)

diffs (129 lines):

diff --git a/libpurple/ciphers/des.c b/libpurple/ciphers/des.c
--- a/libpurple/ciphers/des.c
+++ b/libpurple/ciphers/des.c
@@ -342,7 +342,7 @@ des_set_key (PurpleCipherContext *contex
 	struct _des_ctx *ctx = purple_cipher_context_get_data(context);
 	int i;
 
-	g_return_if_fail(len != 8);
+	g_return_if_fail(len == 8);
 
 	des_key_schedule (key, ctx->encrypt_subkeys);
 
@@ -399,7 +399,7 @@ des_encrypt(PurpleCipherContext *context
 	guint8 buf[8] = {0,0,0,0,0,0,0,0};
 	ssize_t out_len;
 
-	g_return_val_if_fail(out_size < in_len, -1);
+	g_return_val_if_fail(out_size >= in_len, -1);
 
 	while(offset+8<=in_len) {
 		des_ecb_crypt(purple_cipher_context_get_data(context),
@@ -411,7 +411,7 @@ des_encrypt(PurpleCipherContext *context
 	out_len = in_len;
 	if(offset<in_len) {
 		out_len += in_len - offset;
-		g_return_val_if_fail(out_size < out_len, -1);
+		g_return_val_if_fail(out_size >= out_len, -1);
 		tmp = offset;
 		while(tmp<in_len) {
 			buf[i++] = input[tmp];
@@ -435,7 +435,7 @@ des_decrypt(PurpleCipherContext *context
 	guint8 buf[8] = {0,0,0,0,0,0,0,0};
 	ssize_t out_len;
 
-	g_return_val_if_fail(out_size < in_len, -1);
+	g_return_val_if_fail(out_size >= in_len, -1);
 
 	while(offset+8<=in_len) {
 		des_ecb_crypt(purple_cipher_context_get_data(context),
@@ -447,7 +447,7 @@ des_decrypt(PurpleCipherContext *context
 	out_len = in_len;
 	if(offset<in_len) {
 		out_len += in_len - offset;
-		g_return_val_if_fail(out_size < out_len, -1);
+		g_return_val_if_fail(out_size >= out_len, -1);
 		tmp = offset;
 		while(tmp<in_len) {
 			buf[i++] = input[tmp];
@@ -529,7 +529,7 @@ des3_set_key(PurpleCipherContext *contex
 	struct _des3_ctx *ctx = purple_cipher_context_get_data(context);
 	int i;
 
-	g_return_if_fail(len != 24);
+	g_return_if_fail(len == 24);
 
 	des_key_schedule (key +  0, ctx->key1.encrypt_subkeys);
 	des_key_schedule (key +  8, ctx->key2.encrypt_subkeys);
@@ -562,7 +562,7 @@ des3_ecb_encrypt(struct _des3_ctx *ctx, 
 	guint8 buf[8] = {0,0,0,0,0,0,0,0};
 	ssize_t out_len;
 
-	g_return_val_if_fail(out_size < in_len, -1);
+	g_return_val_if_fail(out_size >= in_len, -1);
 
 	while (offset + 8 <= in_len) {
 		des_ecb_crypt(&ctx->key1,
@@ -582,7 +582,7 @@ des3_ecb_encrypt(struct _des3_ctx *ctx, 
 	out_len = in_len;
 	if (offset < in_len) {
 		out_len += in_len - offset;
-		g_return_val_if_fail(out_size < out_len, -1);
+		g_return_val_if_fail(out_size >= out_len, -1);
 		tmp = offset;
 		memset(buf, 0, 8);
 		while (tmp < in_len) {
@@ -616,7 +616,7 @@ des3_cbc_encrypt(struct _des3_ctx *ctx, 
 	ssize_t out_len;
 	memcpy(buf, ctx->iv, 8);
 
-	g_return_val_if_fail(out_size < in_len, -1);
+	g_return_val_if_fail(out_size >= in_len, -1);
 
 	while (offset + 8 <= in_len) {
 		for (i = 0; i < 8; i++)
@@ -640,7 +640,7 @@ des3_cbc_encrypt(struct _des3_ctx *ctx, 
 	out_len = in_len;
 	if (offset < in_len) {
 		out_len += in_len - offset;
-		g_return_val_if_fail(out_size < out_len, -1);
+		g_return_val_if_fail(out_size >= out_len, -1);
 		tmp = offset;
 		i = 0;
 		while (tmp < in_len) {
@@ -690,7 +690,7 @@ des3_ecb_decrypt(struct _des3_ctx *ctx, 
 	guint8 buf[8] = {0,0,0,0,0,0,0,0};
 	ssize_t out_len;
 
-	g_return_val_if_fail(out_size < in_len, -1);
+	g_return_val_if_fail(out_size >= in_len, -1);
 
 	while (offset + 8 <= in_len) {
 		/* NOTE: Apply key in reverse */
@@ -711,7 +711,7 @@ des3_ecb_decrypt(struct _des3_ctx *ctx, 
 	out_len = in_len;
 	if (offset < in_len) {
 		out_len += in_len - offset;
-		g_return_val_if_fail(out_size < out_len, -1);
+		g_return_val_if_fail(out_size >= out_len, -1);
 		tmp = offset;
 		memset(buf, 0, 8);
 		while (tmp < in_len) {
@@ -745,7 +745,7 @@ des3_cbc_decrypt(struct _des3_ctx *ctx, 
 	guint8 link[8];
 	ssize_t out_len;
 
-	g_return_val_if_fail(out_size < in_len, -1);
+	g_return_val_if_fail(out_size >= in_len, -1);
 
 	memcpy(link, ctx->iv, 8);
 	while (offset + 8 <= in_len) {
@@ -769,7 +769,7 @@ des3_cbc_decrypt(struct _des3_ctx *ctx, 
 	out_len = in_len;
 	if(offset<in_len) {
 		out_len += in_len - offset;
-		g_return_val_if_fail(out_size < out_len, -1);
+		g_return_val_if_fail(out_size >= out_len, -1);
 		tmp = offset;
 		memset(buf, 0, 8);
 		i = 0;



More information about the Commits mailing list