sha1hash: Remove in favor of GChecksum
--- a/doc/reference/libpurple/libpurple-docs.xml Wed Sep 28 15:48:12 2016 -0500
+++ b/doc/reference/libpurple/libpurple-docs.xml Wed Sep 28 15:49:23 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/sha1hash.xml" />
<xi:include href="xml/sha256hash.xml" />
--- a/libpurple/Makefile.am Wed Sep 28 15:48:12 2016 -0500
+++ b/libpurple/Makefile.am Wed Sep 28 15:49:23 2016 -0500
@@ -47,7 +47,6 @@
@@ -248,7 +247,6 @@
purple_builtheaders = purple.h version.h enums.h marshallers.h
--- a/libpurple/Makefile.mingw Wed Sep 28 15:48:12 2016 -0500
+++ b/libpurple/Makefile.mingw Wed Sep 28 15:49:23 2016 -0500
@@ -74,7 +74,6 @@
--- a/libpurple/ciphers/sha1hash.c Wed Sep 28 15:48:12 2016 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,191 +0,0 @@
- * 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
- * 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
-/*******************************************************************************
- ******************************************************************************/
-#define PURPLE_SHA1_HASH_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE((obj), PURPLE_TYPE_SHA1_HASH, PurpleSHA1HashPrivate))
-} PurpleSHA1HashPrivate;
-/******************************************************************************
- *****************************************************************************/
-static GObjectClass *parent_class = NULL;
-/******************************************************************************
- *****************************************************************************/
-purple_sha1_hash_reset(PurpleHash *hash)
- PurpleSHA1Hash *sha1_hash = PURPLE_SHA1_HASH(hash);
- PurpleSHA1HashPrivate *priv = PURPLE_SHA1_HASH_GET_PRIVATE(sha1_hash);
- g_return_if_fail(priv != NULL);
- g_return_if_fail(priv->checksum != NULL);
- g_checksum_reset(priv->checksum);
-purple_sha1_hash_append(PurpleHash *hash, const guchar *data,
- PurpleSHA1Hash *sha1_hash = PURPLE_SHA1_HASH(hash);
- PurpleSHA1HashPrivate *priv = PURPLE_SHA1_HASH_GET_PRIVATE(sha1_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);
- g_checksum_update(priv->checksum, data, len);
-purple_sha1_hash_digest(PurpleHash *hash, guchar *digest, size_t buff_len)
- PurpleSHA1Hash *sha1_hash = PURPLE_SHA1_HASH(hash);
- PurpleSHA1HashPrivate *priv = PURPLE_SHA1_HASH_GET_PRIVATE(sha1_hash);
- const gssize required_len = g_checksum_type_get_length(G_CHECKSUM_SHA1);
- 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)
- purple_sha1_hash_reset(hash);
-purple_sha1_hash_get_block_size(PurpleHash *hash)
-purple_sha1_hash_get_digest_size(PurpleHash *hash)
- return g_checksum_type_get_length(G_CHECKSUM_SHA1);
-/******************************************************************************
- *****************************************************************************/
-purple_sha1_hash_finalize(GObject *obj)
- PurpleSHA1Hash *sha1_hash = PURPLE_SHA1_HASH(obj);
- PurpleSHA1HashPrivate *priv = PURPLE_SHA1_HASH_GET_PRIVATE(sha1_hash);
- g_checksum_free(priv->checksum);
- parent_class->finalize(obj);
-purple_sha1_hash_class_init(PurpleSHA1HashClass *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_sha1_hash_finalize;
- hash_class->reset = purple_sha1_hash_reset;
- hash_class->reset_state = purple_sha1_hash_reset;
- hash_class->append = purple_sha1_hash_append;
- hash_class->digest = purple_sha1_hash_digest;
- hash_class->get_digest_size = purple_sha1_hash_get_digest_size;
- hash_class->get_block_size = purple_sha1_hash_get_block_size;
- g_type_class_add_private(klass, sizeof(PurpleSHA1HashPrivate));
-purple_sha1_hash_init(PurpleHash *hash)
- PurpleSHA1Hash *sha1_hash = PURPLE_SHA1_HASH(hash);
- PurpleSHA1HashPrivate *priv = PURPLE_SHA1_HASH_GET_PRIVATE(sha1_hash);
- priv->checksum = g_checksum_new(G_CHECKSUM_SHA1);
- purple_sha1_hash_reset(hash);
-/******************************************************************************
- *****************************************************************************/
-purple_sha1_hash_get_type(void) {
- static const GTypeInfo info = {
- sizeof(PurpleSHA1HashClass),
- (GClassInitFunc)purple_sha1_hash_class_init,
- sizeof(PurpleSHA1Hash),
- (GInstanceInitFunc)purple_sha1_hash_init,
- type = g_type_register_static(PURPLE_TYPE_HASH,
-purple_sha1_hash_new(void) {
- return g_object_new(PURPLE_TYPE_SHA1_HASH, NULL);
--- a/libpurple/ciphers/sha1hash.h Wed Sep 28 15:48:12 2016 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
- * 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
- * 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_SHA1_HASH_H
-#define PURPLE_SHA1_HASH_H
- * @section_id: libpurple-sha1hash
- * @short_description: <filename>ciphers/sha1hash.h</filename>
-#define PURPLE_TYPE_SHA1_HASH (purple_sha1_hash_get_type())
-#define PURPLE_SHA1_HASH(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), PURPLE_TYPE_SHA1_HASH, PurpleSHA1Hash))
-#define PURPLE_SHA1_HASH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PURPLE_TYPE_SHA1_HASH, PurpleSHA1HashClass))
-#define PURPLE_IS_SHA1_HASH(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_SHA1_HASH))
-#define PURPLE_IS_SHA1_HASH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((obj), PURPLE_TYPE_SHA1_HASH))
-#define PURPLE_SHA1_HASH_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), PURPLE_TYPE_SHA1_HASH, PurpleSHA1HashClass))
-typedef struct _PurpleSHA1Hash PurpleSHA1Hash;
-typedef struct _PurpleSHA1HashClass PurpleSHA1HashClass;
-struct _PurpleSHA1Hash {
-struct _PurpleSHA1HashClass {
- PurpleHashClass gparent;
- void (*_purple_reserved1)(void);
- void (*_purple_reserved2)(void);
- void (*_purple_reserved3)(void);
- void (*_purple_reserved4)(void);
-GType purple_sha1_hash_get_type(void);
-PurpleHash *purple_sha1_hash_new(void);
-#endif /* PURPLE_SHA1_HASH_H */
--- a/libpurple/tests/Makefile.am Wed Sep 28 15:48:12 2016 -0500
+++ b/libpurple/tests/Makefile.am Wed Sep 28 15:49:23 2016 -0500
@@ -9,7 +9,6 @@
@@ -25,9 +24,6 @@
test_md4_SOURCES=test_md4.c
test_md4_LDADD=$(COMMON_LIBS)
-test_sha1_SOURCES=test_sha1.c
-test_sha1_LDADD=$(COMMON_LIBS)
test_sha256_SOURCES=test_sha256.c
test_sha256_LDADD=$(COMMON_LIBS)
--- a/libpurple/tests/test_sha1.c Wed Sep 28 15:48:12 2016 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,101 +0,0 @@
- * 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
- * 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 "ciphers/sha1hash.h"
-test_sha1hash(gchar *data, gchar *digest) {
- PurpleHash *hash = NULL;
- hash = purple_sha1_hash_new();
- purple_hash_append(hash, (guchar *)data, strlen(data));
- memset(buff, 'a', 1000);
- for(j = 0; j < 1000; j++)
- purple_hash_append(hash, buff, 1000);
- ret = purple_hash_digest_to_str(hash, cdigest, sizeof(cdigest));
- g_assert_cmpstr(digest, ==, cdigest);
-test_sha1hash_empty_string(void) {
- "da39a3ee5e6b4b0d3255bfef95601890afd80709");
- "86f7e437faa5a7fce15d1ddcb9eaeaea377667b8");
-test_sha1hash_abc(void) {
- "a9993e364706816aba3e25717850c26c9cd0d89d");
-test_sha1hash_abcd_gibberish(void) {
- test_sha1hash("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
- "84983e441c3bd26ebaae4aa1f95129e5e54670f1");
-test_sha1hash_1000_as_1000_times(void) {
- "34aa973cd4c4daa4f61eeb2bdbad27316534016f");
-main(gint argc, gchar **argv) {
- g_test_init(&argc, &argv, NULL);
- g_test_add_func("/hash/sha1/empty-string",
- test_sha1hash_empty_string);
- g_test_add_func("/hash/sha1/a",
- g_test_add_func("/hash/sha1/abc",
- g_test_add_func("/hash/sha1/abcd_gibberish",
- test_sha1hash_abcd_gibberish);
- g_test_add_func("/hash/sha1/1000 a's 1000 times",
- test_sha1hash_1000_as_1000_times);