pidgin/pidgin

md5hash: Remove in favor of GChecksum

2016-09-28, Mike Ruprecht
2bf57fef601e
Parents 7a7637a9aaf7
Children 09e43b6fe996
md5hash: Remove in favor of GChecksum
--- a/doc/reference/libpurple/libpurple-docs.xml Wed Sep 28 17:00:18 2016 -0500
+++ b/doc/reference/libpurple/libpurple-docs.xml Wed Sep 28 15:48:12 2016 -0500
@@ -115,7 +115,6 @@
<xi:include href="xml/pbkdf2cipher.xml" />
<xi:include href="xml/rc4cipher.xml" />
<xi:include href="xml/md4hash.xml" />
- <xi:include href="xml/md5hash.xml" />
<xi:include href="xml/sha1hash.xml" />
<xi:include href="xml/sha256hash.xml" />
</chapter>
--- a/libpurple/Makefile.am Wed Sep 28 17:00:18 2016 -0500
+++ b/libpurple/Makefile.am Wed Sep 28 15:48:12 2016 -0500
@@ -45,7 +45,6 @@
ciphers/descipher.c \
ciphers/des3cipher.c \
ciphers/md4hash.c \
- ciphers/md5hash.c \
ciphers/pbkdf2cipher.c \
ciphers/rc4cipher.c \
ciphers/sha1hash.c \
@@ -247,7 +246,6 @@
descipher.h \
des3cipher.h \
md4hash.h \
- md5hash.h \
pbkdf2cipher.h \
rc4cipher.h \
sha1hash.h \
--- a/libpurple/Makefile.mingw Wed Sep 28 17:00:18 2016 -0500
+++ b/libpurple/Makefile.mingw Wed Sep 28 15:48:12 2016 -0500
@@ -72,7 +72,6 @@
ciphers/descipher.c \
ciphers/des3cipher.c \
ciphers/md4hash.c \
- ciphers/md5hash.c \
ciphers/pbkdf2cipher.c \
ciphers/rc4cipher.c \
ciphers/sha1hash.c \
--- a/libpurple/ciphers/md5hash.c Wed Sep 28 17:00:18 2016 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,191 +0,0 @@
-/*
- * purple
- *
- * Purple is the legal property of its developers, whose names are too numerous
- * to list here. Please refer to the COPYRIGHT file distributed with this
- * source distribution.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
- */
-#include "internal.h"
-#include "md5hash.h"
-
-/*******************************************************************************
- * Structs
- ******************************************************************************/
-#define PURPLE_MD5_HASH_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE((obj), PURPLE_TYPE_MD5_HASH, PurpleMD5HashPrivate))
-
-typedef struct {
- GChecksum *checksum;
-} PurpleMD5HashPrivate;
-
-/******************************************************************************
- * Globals
- *****************************************************************************/
-static GObjectClass *parent_class = NULL;
-
-/******************************************************************************
- * Hash Stuff
- *****************************************************************************/
-
-static void
-purple_md5_hash_reset(PurpleHash *hash)
-{
- PurpleMD5Hash *md5_hash = PURPLE_MD5_HASH(hash);
- PurpleMD5HashPrivate *priv = PURPLE_MD5_HASH_GET_PRIVATE(md5_hash);
-
- g_return_if_fail(priv != NULL);
- g_return_if_fail(priv->checksum != NULL);
-
- g_checksum_reset(priv->checksum);
-}
-
-static void
-purple_md5_hash_append(PurpleHash *hash, const guchar *data,
- gsize len)
-{
- PurpleMD5Hash *md5_hash = PURPLE_MD5_HASH(hash);
- PurpleMD5HashPrivate *priv = PURPLE_MD5_HASH_GET_PRIVATE(md5_hash);
-
- g_return_if_fail(priv != NULL);
- g_return_if_fail(priv->checksum != NULL);
-
- while (len >= G_MAXSSIZE) {
- g_checksum_update(priv->checksum, data, G_MAXSSIZE);
- len -= G_MAXSSIZE;
- data += G_MAXSSIZE;
- }
-
- if (len)
- g_checksum_update(priv->checksum, data, len);
-}
-
-static gboolean
-purple_md5_hash_digest(PurpleHash *hash, guchar *digest, size_t buff_len)
-{
- PurpleMD5Hash *md5_hash = PURPLE_MD5_HASH(hash);
- PurpleMD5HashPrivate *priv = PURPLE_MD5_HASH_GET_PRIVATE(md5_hash);
-
- const gssize required_len = g_checksum_type_get_length(G_CHECKSUM_MD5);
- gsize digest_len = buff_len;
-
- g_return_val_if_fail(priv != NULL, FALSE);
- g_return_val_if_fail(priv->checksum != NULL, FALSE);
-
- g_return_val_if_fail(required_len >= 0, FALSE);
- g_return_val_if_fail(buff_len >= (gsize)required_len, FALSE);
-
- g_checksum_get_digest(priv->checksum, digest, &digest_len);
-
- if (digest_len != (gsize)required_len)
- return FALSE;
-
- purple_md5_hash_reset(hash);
-
- return TRUE;
-}
-
-static size_t
-purple_md5_hash_get_block_size(PurpleHash *hash)
-{
- return 64;
-}
-
-static size_t
-purple_md5_hash_get_digest_size(PurpleHash *hash)
-{
- return g_checksum_type_get_length(G_CHECKSUM_MD5);
-}
-
-/******************************************************************************
- * Object Stuff
- *****************************************************************************/
-
-static void
-purple_md5_hash_finalize(GObject *obj)
-{
- PurpleMD5Hash *md5_hash = PURPLE_MD5_HASH(obj);
- PurpleMD5HashPrivate *priv = PURPLE_MD5_HASH_GET_PRIVATE(md5_hash);
-
- if (priv->checksum)
- g_checksum_free(priv->checksum);
-
- parent_class->finalize(obj);
-}
-
-static void
-purple_md5_hash_class_init(PurpleMD5HashClass *klass) {
- GObjectClass *obj_class = G_OBJECT_CLASS(klass);
- PurpleHashClass *hash_class = PURPLE_HASH_CLASS(klass);
-
- parent_class = g_type_class_peek_parent(klass);
-
- obj_class->finalize = purple_md5_hash_finalize;
-
- hash_class->reset = purple_md5_hash_reset;
- hash_class->reset_state = purple_md5_hash_reset;
- hash_class->append = purple_md5_hash_append;
- hash_class->digest = purple_md5_hash_digest;
- hash_class->get_digest_size = purple_md5_hash_get_digest_size;
- hash_class->get_block_size = purple_md5_hash_get_block_size;
-
- g_type_class_add_private(klass, sizeof(PurpleMD5HashPrivate));
-}
-
-static void
-purple_md5_hash_init(PurpleHash *hash)
-{
- PurpleMD5Hash *md5_hash = PURPLE_MD5_HASH(hash);
- PurpleMD5HashPrivate *priv = PURPLE_MD5_HASH_GET_PRIVATE(md5_hash);
-
- priv->checksum = g_checksum_new(G_CHECKSUM_MD5);
-
- purple_md5_hash_reset(hash);
-}
-
-/******************************************************************************
- * API
- *****************************************************************************/
-GType
-purple_md5_hash_get_type(void) {
- static GType type = 0;
-
- if(type == 0) {
- static const GTypeInfo info = {
- sizeof(PurpleMD5HashClass),
- NULL,
- NULL,
- (GClassInitFunc)purple_md5_hash_class_init,
- NULL,
- NULL,
- sizeof(PurpleMD5Hash),
- 0,
- (GInstanceInitFunc)purple_md5_hash_init,
- NULL,
- };
-
- type = g_type_register_static(PURPLE_TYPE_HASH,
- "PurpleMD5Hash",
- &info, 0);
- }
-
- return type;
-}
-
-PurpleHash *
-purple_md5_hash_new(void) {
- return g_object_new(PURPLE_TYPE_MD5_HASH, NULL);
-}
--- a/libpurple/ciphers/md5hash.h Wed Sep 28 17:00:18 2016 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-/* purple
- *
- * Purple is the legal property of its developers, whose names are too numerous
- * to list here. Please refer to the COPYRIGHT file distributed with this
- * source distribution.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
- */
-
-#ifndef PURPLE_MD5_HASH_H
-#define PURPLE_MD5_HASH_H
-/**
- * SECTION:md5hash
- * @section_id: libpurple-md5hash
- * @short_description: <filename>ciphers/md5hash.h</filename>
- * @title: MD5 Hash
- */
-
-#include "cipher.h"
-
-#define PURPLE_TYPE_MD5_HASH (purple_md5_hash_get_type())
-#define PURPLE_MD5_HASH(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), PURPLE_TYPE_MD5_HASH, PurpleMD5Hash))
-#define PURPLE_MD5_HASH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PURPLE_TYPE_MD5_HASH, PurpleMD5HashClass))
-#define PURPLE_IS_MD5_HASH(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_MD5_HASH))
-#define PURPLE_IS_MD5_HASH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((obj), PURPLE_TYPE_MD5_HASH))
-#define PURPLE_MD5_HASH_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), PURPLE_TYPE_MD5_HASH, PurpleMD5HashClass))
-
-typedef struct _PurpleMD5Hash PurpleMD5Hash;
-typedef struct _PurpleMD5HashClass PurpleMD5HashClass;
-
-struct _PurpleMD5Hash {
- PurpleHash gparent;
-};
-
-struct _PurpleMD5HashClass {
- PurpleHashClass gparent;
-
- /*< private >*/
- void (*_purple_reserved1)(void);
- void (*_purple_reserved2)(void);
- void (*_purple_reserved3)(void);
- void (*_purple_reserved4)(void);
-};
-
-G_BEGIN_DECLS
-
-GType purple_md5_hash_get_type(void);
-
-PurpleHash *purple_md5_hash_new(void);
-
-G_END_DECLS
-
-#endif /* PURPLE_MD5_HASH_H */
--- a/libpurple/tests/Makefile.am Wed Sep 28 17:00:18 2016 -0500
+++ b/libpurple/tests/Makefile.am Wed Sep 28 15:48:12 2016 -0500
@@ -9,7 +9,6 @@
test_des \
test_des3 \
test_md4 \
- test_md5 \
test_sha1 \
test_sha256 \
test_trie \
@@ -26,9 +25,6 @@
test_md4_SOURCES=test_md4.c
test_md4_LDADD=$(COMMON_LIBS)
-test_md5_SOURCES=test_md5.c
-test_md5_LDADD=$(COMMON_LIBS)
-
test_sha1_SOURCES=test_sha1.c
test_sha1_LDADD=$(COMMON_LIBS)
--- a/libpurple/tests/test_md5.c Wed Sep 28 17:00:18 2016 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,107 +0,0 @@
-/*
- * purple
- *
- * Purple is the legal property of its developers, whose names are too numerous
- * to list here. Please refer to the COPYRIGHT file distributed with this
- * source distribution.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
- *
- */
-#include <glib.h>
-
-#include <purple.h>
-
-#include "ciphers/md5hash.h"
-
-static void
-test_md5hash(gchar *data, gchar *digest) {
- PurpleHash *hash = NULL;
- gchar cdigest[33];
- gboolean ret = FALSE;
-
- hash = purple_md5_hash_new();
-
- purple_hash_append(hash, (guchar *)data, strlen(data));
-
- ret = purple_hash_digest_to_str(hash, cdigest, sizeof(cdigest));
-
- g_assert(ret);
- g_assert_cmpstr(digest, ==, cdigest);
-}
-
-static void
-test_md5hash_empty_string(void) {
- test_md5hash("",
- "d41d8cd98f00b204e9800998ecf8427e");
-}
-
-static void
-test_md5hash_a(void) {
- test_md5hash("a",
- "0cc175b9c0f1b6a831c399e269772661");
-}
-
-static void
-test_md5hash_abc(void) {
- test_md5hash("abc",
- "900150983cd24fb0d6963f7d28e17f72");
-}
-
-static void
-test_md5hash_message_digest(void) {
- test_md5hash("message digest",
- "f96b697d7cb7938d525a2f31aaf161d0");
-}
-
-static void
-test_md5hash_a_to_z(void) {
- test_md5hash("abcdefghijklmnopqrstuvwxyz",
- "c3fcd3d76192e4007dfb496cca67e13b");
-}
-
-static void
-test_md5hash_A_to_Z_a_to_z_0_to_9(void) {
- test_md5hash("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
- "d174ab98d277d9f5a5611c2c9f419d9f");
-}
-
-static void
-test_md5hash_1_to_0_eight_times(void) {
- test_md5hash("12345678901234567890123456789012345678901234567890123456789012345678901234567890",
- "57edf4a22be3c955ac49da2e2107b67a");
-}
-
-gint
-main(gint argc, gchar **argv) {
- g_test_init(&argc, &argv, NULL);
-
- g_test_add_func("/hash/md5/empty-string",
- test_md5hash_empty_string);
- g_test_add_func("/hash/md5/a",
- test_md5hash_a);
- g_test_add_func("/hash/md5/abc",
- test_md5hash_abc);
- g_test_add_func("/hash/md5/message digest",
- test_md5hash_message_digest);
- g_test_add_func("/hash/md5/a to z",
- test_md5hash_a_to_z);
- g_test_add_func("/hash/md5/A to Z, a to z, 0 to 9" ,
- test_md5hash_A_to_Z_a_to_z_0_to_9);
- g_test_add_func("/hash/md5/1 to 0 eight times",
- test_md5hash_1_to_0_eight_times);
-
- return g_test_run();
-}