sha256hash: Remove in favor of GChecksum
--- a/doc/reference/libpurple/libpurple-docs.xml Wed Sep 28 15:49:23 2016 -0500
+++ b/doc/reference/libpurple/libpurple-docs.xml Wed Sep 28 15:49:55 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/sha256hash.xml" />
--- a/libpurple/Makefile.am Wed Sep 28 15:49:23 2016 -0500
+++ b/libpurple/Makefile.am Wed Sep 28 15:49:55 2016 -0500
@@ -47,7 +47,6 @@
@@ -246,8 +245,7 @@
purple_builtheaders = purple.h version.h enums.h marshallers.h
--- a/libpurple/Makefile.mingw Wed Sep 28 15:49:23 2016 -0500
+++ b/libpurple/Makefile.mingw Wed Sep 28 15:49:55 2016 -0500
@@ -74,7 +74,6 @@
--- a/libpurple/ciphers/sha256hash.c Wed Sep 28 15:49:23 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_SHA256_HASH_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE((obj), PURPLE_TYPE_SHA256_HASH, PurpleSHA256HashPrivate))
-} PurpleSHA256HashPrivate;
-/******************************************************************************
- *****************************************************************************/
-static GObjectClass *parent_class = NULL;
-/******************************************************************************
- *****************************************************************************/
-purple_sha256_hash_reset(PurpleHash *hash)
- PurpleSHA256Hash *sha256_hash = PURPLE_SHA256_HASH(hash);
- PurpleSHA256HashPrivate *priv = PURPLE_SHA256_HASH_GET_PRIVATE(sha256_hash);
- g_return_if_fail(priv != NULL);
- g_return_if_fail(priv->checksum != NULL);
- g_checksum_reset(priv->checksum);
-purple_sha256_hash_append(PurpleHash *hash, const guchar *data,
- PurpleSHA256Hash *sha256_hash = PURPLE_SHA256_HASH(hash);
- PurpleSHA256HashPrivate *priv = PURPLE_SHA256_HASH_GET_PRIVATE(sha256_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_sha256_hash_digest(PurpleHash *hash, guchar *digest, size_t buff_len)
- PurpleSHA256Hash *sha256_hash = PURPLE_SHA256_HASH(hash);
- PurpleSHA256HashPrivate *priv = PURPLE_SHA256_HASH_GET_PRIVATE(sha256_hash);
- const gssize required_len = g_checksum_type_get_length(G_CHECKSUM_SHA256);
- 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_sha256_hash_reset(hash);
-purple_sha256_hash_get_block_size(PurpleHash *hash)
-purple_sha256_hash_get_digest_size(PurpleHash *hash)
- return g_checksum_type_get_length(G_CHECKSUM_SHA256);
-/******************************************************************************
- *****************************************************************************/
-purple_sha256_hash_finalize(GObject *obj)
- PurpleSHA256Hash *sha256_hash = PURPLE_SHA256_HASH(obj);
- PurpleSHA256HashPrivate *priv = PURPLE_SHA256_HASH_GET_PRIVATE(sha256_hash);
- g_checksum_free(priv->checksum);
- parent_class->finalize(obj);
-purple_sha256_hash_class_init(PurpleSHA256HashClass *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_sha256_hash_finalize;
- hash_class->reset = purple_sha256_hash_reset;
- hash_class->reset_state = purple_sha256_hash_reset;
- hash_class->append = purple_sha256_hash_append;
- hash_class->digest = purple_sha256_hash_digest;
- hash_class->get_digest_size = purple_sha256_hash_get_digest_size;
- hash_class->get_block_size = purple_sha256_hash_get_block_size;
- g_type_class_add_private(klass, sizeof(PurpleSHA256HashPrivate));
-purple_sha256_hash_init(PurpleHash *hash)
- PurpleSHA256Hash *sha256_hash = PURPLE_SHA256_HASH(hash);
- PurpleSHA256HashPrivate *priv = PURPLE_SHA256_HASH_GET_PRIVATE(sha256_hash);
- priv->checksum = g_checksum_new(G_CHECKSUM_SHA256);
- purple_sha256_hash_reset(hash);
-/******************************************************************************
- *****************************************************************************/
-purple_sha256_hash_get_type(void) {
- static const GTypeInfo info = {
- sizeof(PurpleSHA256HashClass),
- (GClassInitFunc)purple_sha256_hash_class_init,
- sizeof(PurpleSHA256Hash),
- (GInstanceInitFunc)purple_sha256_hash_init,
- type = g_type_register_static(PURPLE_TYPE_HASH,
-purple_sha256_hash_new(void) {
- return g_object_new(PURPLE_TYPE_SHA256_HASH, NULL);
--- a/libpurple/ciphers/sha256hash.h Wed Sep 28 15:49:23 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_SHA256_HASH_H
-#define PURPLE_SHA256_HASH_H
- * @section_id: libpurple-sha256hash
- * @short_description: <filename>ciphers/sha256hash.h</filename>
-#define PURPLE_TYPE_SHA256_HASH (purple_sha256_hash_get_type())
-#define PURPLE_SHA256_HASH(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), PURPLE_TYPE_SHA256_HASH, PurpleSHA256Hash))
-#define PURPLE_SHA256_HASH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PURPLE_TYPE_SHA256_HASH, PurpleSHA256HashClass))
-#define PURPLE_IS_SHA256_HASH(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_SHA256_HASH))
-#define PURPLE_IS_SHA256_HASH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((obj), PURPLE_TYPE_SHA256_HASH))
-#define PURPLE_SHA256_HASH_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), PURPLE_TYPE_SHA256_HASH, PurpleSHA256HashClass))
-typedef struct _PurpleSHA256Hash PurpleSHA256Hash;
-typedef struct _PurpleSHA256HashClass PurpleSHA256HashClass;
-struct _PurpleSHA256Hash {
-struct _PurpleSHA256HashClass {
- PurpleHashClass gparent;
- void (*_purple_reserved1)(void);
- void (*_purple_reserved2)(void);
- void (*_purple_reserved3)(void);
- void (*_purple_reserved4)(void);
-GType purple_sha256_hash_get_type(void);
-PurpleHash *purple_sha256_hash_new(void);
-#endif /* PURPLE_SHA256_HASH_H */
--- a/libpurple/tests/Makefile.am Wed Sep 28 15:49:23 2016 -0500
+++ b/libpurple/tests/Makefile.am Wed Sep 28 15:49:55 2016 -0500
@@ -9,7 +9,6 @@
@@ -24,9 +23,6 @@
test_md4_SOURCES=test_md4.c
test_md4_LDADD=$(COMMON_LIBS)
-test_sha256_SOURCES=test_sha256.c
-test_sha256_LDADD=$(COMMON_LIBS)
test_trie_SOURCES=test_trie.c
test_trie_LDADD=$(COMMON_LIBS)
--- a/libpurple/tests/test_sha256.c Wed Sep 28 15:49:23 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/sha256hash.h"
-test_sha256hash(gchar *data, gchar *digest) {
- PurpleHash *hash = NULL;
- hash = purple_sha256_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_sha256hash_empty_string(void) {
- "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855");
-test_sha256hash_a(void) {
- "ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb");
-test_sha256hash_abc(void) {
- "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad");
-test_sha256hash_abcd_gibberish(void) {
- test_sha256hash("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
- "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1");
-test_sha256hash_1000_as_1000_times(void) {
- "cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0");
-main(gint argc, gchar **argv) {
- g_test_init(&argc, &argv, NULL);
- g_test_add_func("/hash/sha256/empty-string",
- test_sha256hash_empty_string);
- g_test_add_func("/hash/sha256/a",
- g_test_add_func("/hash/sha256/abc",
- g_test_add_func("/hash/sha256/abcd_gibberish",
- test_sha256hash_abcd_gibberish);
- g_test_add_func("/hash/sha256/1000 a's 1000 times",
- test_sha256hash_1000_as_1000_times);