/soc/2013/ankitkv/gobjectification: 5c76133baa15: Fixed DES and ...
Ankit Vani
a at nevitus.org
Sat Jun 15 16:28:08 EDT 2013
Changeset: 5c76133baa15fcbf2859216d5f38e7ff196a105d
Author: Ankit Vani <a at nevitus.org>
Date: 2013-06-16 01:57 +0530
Branch: soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/5c76133baa15
Description:
Fixed DES and DES3 ciphers according to the test suite.
* Removed possibly wrong checks
* Fixed the key size being sent to DES's set_key method from DES3
diffstat:
libpurple/ciphers/des.c | 5 -----
libpurple/ciphers/des3.c | 18 +++---------------
2 files changed, 3 insertions(+), 20 deletions(-)
diffs (115 lines):
diff --git a/libpurple/ciphers/des.c b/libpurple/ciphers/des.c
--- a/libpurple/ciphers/des.c
+++ b/libpurple/ciphers/des.c
@@ -433,8 +433,6 @@ purple_des_cipher_encrypt(PurpleCipher *
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);
-
while(offset + 8 <= in_len) {
purple_des_cipher_ecb_crypt(des_cipher, input + offset, output + offset, 0);
offset += 8;
@@ -465,8 +463,6 @@ purple_des_cipher_decrypt(PurpleCipher *
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);
-
while(offset + 8 <= in_len) {
purple_des_cipher_ecb_crypt(des_cipher, input + offset, output + offset, 1);
offset += 8;
@@ -475,7 +471,6 @@ purple_des_cipher_decrypt(PurpleCipher *
out_len = in_len;
if(offset<in_len) {
out_len += in_len - offset;
- g_return_val_if_fail(out_size < out_len, -1);
tmp = offset;
while(tmp<in_len) {
buf[i++] = input[tmp];
diff --git a/libpurple/ciphers/des3.c b/libpurple/ciphers/des3.c
--- a/libpurple/ciphers/des3.c
+++ b/libpurple/ciphers/des3.c
@@ -94,11 +94,11 @@ purple_des3_cipher_set_key(PurpleCipher
g_return_if_fail(len == 24);
purple_cipher_set_key(PURPLE_CIPHER(priv->key1), key + 0,
- purple_des3_cipher_get_key_size(cipher));
+ purple_cipher_get_key_size(PURPLE_CIPHER(priv->key1)));
purple_cipher_set_key(PURPLE_CIPHER(priv->key2), key + 8,
- purple_des3_cipher_get_key_size(cipher));
+ purple_cipher_get_key_size(PURPLE_CIPHER(priv->key2)));
purple_cipher_set_key(PURPLE_CIPHER(priv->key3), key + 16,
- purple_des3_cipher_get_key_size(cipher));
+ purple_cipher_get_key_size(PURPLE_CIPHER(priv->key3)));
g_object_notify(G_OBJECT(des3_cipher), "key");
}
@@ -115,8 +115,6 @@ purple_des3_cipher_ecb_encrypt(PurpleDES
PurpleDES3CipherPrivate *priv = PURPLE_DES3_CIPHER_GET_PRIVATE(des3_cipher);
- g_return_val_if_fail(out_size < in_len, -1);
-
while (offset + 8 <= in_len) {
purple_des_cipher_ecb_crypt(PURPLE_DES_CIPHER(priv->key1),
input + offset, output + offset, 0);
@@ -131,7 +129,6 @@ purple_des3_cipher_ecb_encrypt(PurpleDES
out_len = in_len;
if (offset < in_len) {
out_len += in_len - offset;
- g_return_val_if_fail(out_size < out_len, -1);
tmp = offset;
memset(buf, 0, 8);
while (tmp < in_len) {
@@ -163,8 +160,6 @@ purple_des3_cipher_cbc_encrypt(PurpleDES
memcpy(buf, priv->iv, 8);
- g_return_val_if_fail(out_size < in_len, -1);
-
while (offset + 8 <= in_len) {
for (i = 0; i < 8; i++)
buf[i] ^= input[offset + i];
@@ -183,7 +178,6 @@ purple_des3_cipher_cbc_encrypt(PurpleDES
out_len = in_len;
if (offset < in_len) {
out_len += in_len - offset;
- g_return_val_if_fail(out_size < out_len, -1);
tmp = offset;
i = 0;
while (tmp < in_len) {
@@ -231,8 +225,6 @@ purple_des3_cipher_ecb_decrypt(PurpleDES
ssize_t out_len;
PurpleDES3CipherPrivate *priv = PURPLE_DES3_CIPHER_GET_PRIVATE(des3_cipher);
- g_return_val_if_fail(out_size < in_len, -1);
-
while (offset + 8 <= in_len) {
/* NOTE: Apply key in reverse */
purple_des_cipher_ecb_crypt(PURPLE_DES_CIPHER(priv->key3),
@@ -248,7 +240,6 @@ purple_des3_cipher_ecb_decrypt(PurpleDES
out_len = in_len;
if (offset < in_len) {
out_len += in_len - offset;
- g_return_val_if_fail(out_size < out_len, -1);
tmp = offset;
memset(buf, 0, 8);
while (tmp < in_len) {
@@ -279,8 +270,6 @@ purple_des3_cipher_cbc_decrypt(PurpleDES
ssize_t out_len;
PurpleDES3CipherPrivate *priv = PURPLE_DES3_CIPHER_GET_PRIVATE(des3_cipher);
- g_return_val_if_fail(out_size < in_len, -1);
-
memcpy(link, priv->iv, 8);
while (offset + 8 <= in_len) {
purple_des_cipher_ecb_crypt(PURPLE_DES_CIPHER(priv->key3),
@@ -301,7 +290,6 @@ purple_des3_cipher_cbc_decrypt(PurpleDES
out_len = in_len;
if(offset<in_len) {
out_len += in_len - offset;
- 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