pidgin/pidgin

hmaccipher: Remove in favor of GHmac

2016-09-28, Mike Ruprecht
b1cdbe17f120
Parents 12c5d21febd4
Children ae7cce77183a
hmaccipher: Remove in favor of GHmac
--- a/doc/reference/libpurple/libpurple-docs.xml Wed Sep 28 13:55:30 2016 -0500
+++ b/doc/reference/libpurple/libpurple-docs.xml Wed Sep 28 13:58:54 2016 -0500
@@ -112,7 +112,6 @@
<xi:include href="xml/aescipher.xml" />
<xi:include href="xml/descipher.xml" />
<xi:include href="xml/des3cipher.xml" />
- <xi:include href="xml/hmaccipher.xml" />
<xi:include href="xml/pbkdf2cipher.xml" />
<xi:include href="xml/rc4cipher.xml" />
<xi:include href="xml/md4hash.xml" />
--- a/libpurple/Makefile.am Wed Sep 28 13:55:30 2016 -0500
+++ b/libpurple/Makefile.am Wed Sep 28 13:58:54 2016 -0500
@@ -44,7 +44,6 @@
ciphers/aescipher.c \
ciphers/descipher.c \
ciphers/des3cipher.c \
- ciphers/hmaccipher.c \
ciphers/md4hash.c \
ciphers/md5hash.c \
ciphers/pbkdf2cipher.c \
@@ -247,7 +246,6 @@
aescipher.h \
descipher.h \
des3cipher.h \
- hmaccipher.h \
md4hash.h \
md5hash.h \
pbkdf2cipher.h \
--- a/libpurple/Makefile.mingw Wed Sep 28 13:55:30 2016 -0500
+++ b/libpurple/Makefile.mingw Wed Sep 28 13:58:54 2016 -0500
@@ -71,7 +71,6 @@
ciphers/aescipher.c \
ciphers/descipher.c \
ciphers/des3cipher.c \
- ciphers/hmaccipher.c \
ciphers/md4hash.c \
ciphers/md5hash.c \
ciphers/pbkdf2cipher.c \
--- a/libpurple/ciphers/hmaccipher.c Wed Sep 28 13:55:30 2016 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,341 +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 "glibcompat.h"
-
-#include "hmaccipher.h"
-
-#include <string.h>
-
-/*******************************************************************************
- * Structs
- ******************************************************************************/
-#define PURPLE_HMAC_CIPHER_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE((obj), PURPLE_TYPE_HMAC_CIPHER, PurpleHMACCipherPrivate))
-
-typedef struct {
- PurpleHash *hash;
- guchar *ipad;
- guchar *opad;
-} PurpleHMACCipherPrivate;
-
-/******************************************************************************
- * Enums
- *****************************************************************************/
-enum {
- PROP_NONE,
- PROP_HASH,
- PROP_LAST,
-};
-
-/*******************************************************************************
- * Globals
- ******************************************************************************/
-static GObjectClass *parent_class = NULL;
-static GParamSpec *properties[PROP_LAST];
-
-/*******************************************************************************
- * Helpers
- ******************************************************************************/
-static void
-purple_hmac_cipher_set_hash(PurpleCipher *cipher,
- PurpleHash *hash)
-{
- PurpleHMACCipherPrivate *priv = PURPLE_HMAC_CIPHER_GET_PRIVATE(cipher);
-
- priv->hash = g_object_ref(G_OBJECT(hash));
-
- g_object_notify_by_pspec(G_OBJECT(cipher), properties[PROP_HASH]);
-}
-
-/*******************************************************************************
- * Cipher Stuff
- ******************************************************************************/
-static void
-purple_hmac_cipher_reset(PurpleCipher *cipher) {
- PurpleHMACCipherPrivate *priv = PURPLE_HMAC_CIPHER_GET_PRIVATE(cipher);
-
- if(PURPLE_IS_HASH(priv->hash))
- purple_hash_reset(priv->hash);
-
- g_free(priv->ipad);
- priv->ipad = NULL;
- g_free(priv->opad);
- priv->opad = NULL;
-}
-
-static void
-purple_hmac_cipher_reset_state(PurpleCipher *cipher) {
- PurpleHMACCipherPrivate *priv = PURPLE_HMAC_CIPHER_GET_PRIVATE(cipher);
-
- if(PURPLE_IS_HASH(priv->hash)) {
- purple_hash_reset_state(priv->hash);
- purple_hash_append(priv->hash, priv->ipad,
- purple_hash_get_block_size(priv->hash));
- }
-}
-
-static void
-purple_hmac_cipher_append(PurpleCipher *cipher, const guchar *d, size_t l) {
- PurpleHMACCipherPrivate *priv = PURPLE_HMAC_CIPHER_GET_PRIVATE(cipher);
-
- g_return_if_fail(PURPLE_IS_HASH(priv->hash));
-
- purple_hash_append(priv->hash, d, l);
-}
-
-static gboolean
-purple_hmac_cipher_digest(PurpleCipher *cipher, guchar *out, size_t len)
-{
- PurpleHMACCipherPrivate *priv = PURPLE_HMAC_CIPHER_GET_PRIVATE(cipher);
- guchar *digest = NULL;
- size_t hash_len, block_size;
- gboolean result = FALSE;
-
- g_return_val_if_fail(PURPLE_IS_HASH(priv->hash), FALSE);
-
- hash_len = purple_hash_get_digest_size(priv->hash);
- g_return_val_if_fail(hash_len > 0, FALSE);
-
- block_size = purple_hash_get_block_size(priv->hash);
- digest = g_malloc(hash_len);
-
- /* get the digest of the data */
- result = purple_hash_digest(priv->hash, digest, hash_len);
- purple_hash_reset(priv->hash);
-
- if(!result) {
- g_free(digest);
-
- return FALSE;
- }
-
- /* now append the opad and the digest from above */
- purple_hash_append(priv->hash, priv->opad, block_size);
- purple_hash_append(priv->hash, digest, hash_len);
-
- /* do our last digest */
- result = purple_hash_digest(priv->hash, out, len);
-
- /* cleanup */
- g_free(digest);
-
- return result;
-}
-
-static size_t
-purple_hmac_cipher_get_digest_size(PurpleCipher *cipher)
-{
- PurpleHMACCipherPrivate *priv = PURPLE_HMAC_CIPHER_GET_PRIVATE(cipher);
-
- g_return_val_if_fail(priv->hash != NULL, 0);
-
- return purple_hash_get_digest_size(priv->hash);
-}
-
-static void
-purple_hmac_cipher_set_key(PurpleCipher *cipher, const guchar *key,
- size_t key_len)
-{
- PurpleHMACCipherPrivate *priv = PURPLE_HMAC_CIPHER_GET_PRIVATE(cipher);
- gsize block_size, i;
- guchar *full_key;
-
- g_return_if_fail(priv->hash);
-
- g_free(priv->ipad);
- g_free(priv->opad);
-
- block_size = purple_hash_get_block_size(priv->hash);
- priv->ipad = g_malloc(block_size);
- priv->opad = g_malloc(block_size);
-
- if (key_len > block_size) {
- purple_hash_reset(priv->hash);
- purple_hash_append(priv->hash, key, key_len);
-
- key_len = purple_hash_get_digest_size(priv->hash);
- full_key = g_malloc(key_len);
- purple_hash_digest(priv->hash, full_key, key_len);
- } else {
- full_key = g_memdup(key, key_len);
- }
-
- if (key_len < block_size) {
- full_key = g_realloc(full_key, block_size);
- memset(full_key + key_len, 0, block_size - key_len);
- }
-
- for(i = 0; i < block_size; i++) {
- priv->ipad[i] = 0x36 ^ full_key[i];
- priv->opad[i] = 0x5c ^ full_key[i];
- }
-
- g_free(full_key);
-
- purple_hash_reset(priv->hash);
- purple_hash_append(priv->hash, priv->ipad, block_size);
-}
-
-static size_t
-purple_hmac_cipher_get_block_size(PurpleCipher *cipher)
-{
- PurpleHMACCipherPrivate *priv = NULL;
-
- g_return_val_if_fail(PURPLE_IS_HMAC_CIPHER(cipher), 0);
-
- priv = PURPLE_HMAC_CIPHER_GET_PRIVATE(cipher);
-
- return purple_hash_get_block_size(priv->hash);
-}
-
-/******************************************************************************
- * Object Stuff
- *****************************************************************************/
-static void
-purple_hmac_cipher_set_property(GObject *obj, guint param_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- PurpleCipher *cipher = PURPLE_CIPHER(obj);
-
- switch(param_id) {
- case PROP_HASH:
- purple_hmac_cipher_set_hash(cipher, g_value_get_object(value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
- break;
- }
-}
-
-static void
-purple_hmac_cipher_get_property(GObject *obj, guint param_id, GValue *value,
- GParamSpec *pspec)
-{
- PurpleHMACCipher *cipher = PURPLE_HMAC_CIPHER(obj);
-
- switch(param_id) {
- case PROP_HASH:
- g_value_set_object(value,
- purple_hmac_cipher_get_hash(cipher));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
- break;
- }
-}
-
-static void
-purple_hmac_cipher_finalize(GObject *obj) {
- PurpleCipher *cipher = PURPLE_CIPHER(obj);
- PurpleHMACCipherPrivate *priv = PURPLE_HMAC_CIPHER_GET_PRIVATE(cipher);
-
- purple_hmac_cipher_reset(cipher);
-
- if (priv->hash != NULL)
- g_object_unref(priv->hash);
-
- parent_class->finalize(obj);
-}
-
-static void
-purple_hmac_cipher_class_init(PurpleHMACCipherClass *klass) {
- GObjectClass *obj_class = G_OBJECT_CLASS(klass);
- PurpleCipherClass *cipher_class = PURPLE_CIPHER_CLASS(klass);
-
- parent_class = g_type_class_peek_parent(klass);
-
- g_type_class_add_private(klass, sizeof(PurpleHMACCipherPrivate));
-
- obj_class->finalize = purple_hmac_cipher_finalize;
- obj_class->get_property = purple_hmac_cipher_get_property;
- obj_class->set_property = purple_hmac_cipher_set_property;
-
- cipher_class->reset = purple_hmac_cipher_reset;
- cipher_class->reset_state = purple_hmac_cipher_reset_state;
- cipher_class->append = purple_hmac_cipher_append;
- cipher_class->digest = purple_hmac_cipher_digest;
- cipher_class->get_digest_size = purple_hmac_cipher_get_digest_size;
- cipher_class->set_key = purple_hmac_cipher_set_key;
- cipher_class->get_block_size = purple_hmac_cipher_get_block_size;
-
- properties[PROP_HASH] = g_param_spec_object("hash", "hash", "hash",
- PURPLE_TYPE_HASH,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS);
-
- g_object_class_install_properties(obj_class, PROP_LAST, properties);
-}
-
-/******************************************************************************
- * PurpleHMACCipher API
- *****************************************************************************/
-GType
-purple_hmac_cipher_get_type(void) {
- static GType type = 0;
-
- if(type == 0) {
- static const GTypeInfo info = {
- sizeof(PurpleHMACCipherClass),
- NULL,
- NULL,
- (GClassInitFunc)purple_hmac_cipher_class_init,
- NULL,
- NULL,
- sizeof(PurpleHMACCipher),
- 0,
- (GInstanceInitFunc)purple_cipher_reset,
- NULL,
- };
-
- type = g_type_register_static(PURPLE_TYPE_CIPHER,
- "PurpleHMACCipher",
- &info, 0);
- }
-
- return type;
-}
-
-PurpleCipher *
-purple_hmac_cipher_new(PurpleHash *hash) {
- g_return_val_if_fail(PURPLE_IS_HASH(hash), NULL);
-
- return g_object_new(PURPLE_TYPE_HMAC_CIPHER,
- "hash", hash,
- NULL);
-}
-
-PurpleHash *
-purple_hmac_cipher_get_hash(const PurpleHMACCipher *cipher) {
- PurpleHMACCipherPrivate *priv = NULL;
-
- g_return_val_if_fail(PURPLE_IS_HMAC_CIPHER(cipher), NULL);
-
- priv = PURPLE_HMAC_CIPHER_GET_PRIVATE(cipher);
-
- if(priv && priv->hash)
- return priv->hash;
-
- return NULL;
-}
-
--- a/libpurple/ciphers/hmaccipher.h Wed Sep 28 13:55:30 2016 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,67 +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_HMAC_CIPHER_H
-#define PURPLE_HMAC_CIPHER_H
-/**
- * SECTION:hmaccipher
- * @section_id: libpurple-hmaccipher
- * @short_description: <filename>ciphers/hmaccipher.h</filename>
- * @title: HMAC Cipher
- */
-
-#include "cipher.h"
-
-#define PURPLE_TYPE_HMAC_CIPHER (purple_hmac_cipher_get_type())
-#define PURPLE_HMAC_CIPHER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), PURPLE_TYPE_HMAC_CIPHER, PurpleHMACCipher))
-#define PURPLE_HMAC_CIPHER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PURPLE_TYPE_HMAC_CIPHER, PurpleHMACCipherClass))
-#define PURPLE_IS_HMAC_CIPHER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_HMAC_CIPHER))
-#define PURPLE_IS_HMAC_CIPHER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((obj), PURPLE_TYPE_HMAC_CIPHER))
-#define PURPLE_HMAC_CIPHER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), PURPLE_TYPE_HMAC_CIPHER, PurpleHMACCipherClass))
-
-typedef struct _PurpleHMACCipher PurpleHMACCipher;
-typedef struct _PurpleHMACCipherClass PurpleHMACCipherClass;
-
-struct _PurpleHMACCipher {
- PurpleCipher gparent;
-};
-
-struct _PurpleHMACCipherClass {
- PurpleCipherClass gparent;
-
- /*< private >*/
- void (*_purple_reserved1)(void);
- void (*_purple_reserved2)(void);
- void (*_purple_reserved3)(void);
- void (*_purple_reserved4)(void);
-};
-
-G_BEGIN_DECLS
-
-GType purple_hmac_cipher_get_type(void);
-
-PurpleCipher *purple_hmac_cipher_new(PurpleHash *hash);
-
-PurpleHash *purple_hmac_cipher_get_hash(const PurpleHMACCipher *cipher);
-
-G_END_DECLS
-
-#endif /* PURPLE_HMAC_CIPHER_H */
--- a/libpurple/tests/Makefile.am Wed Sep 28 13:55:30 2016 -0500
+++ b/libpurple/tests/Makefile.am Wed Sep 28 13:58:54 2016 -0500
@@ -8,7 +8,6 @@
test_programs=\
test_des \
test_des3 \
- test_hmac \
test_md4 \
test_md5 \
test_sha1 \
@@ -24,9 +23,6 @@
test_des3_SOURCES=test_des3.c
test_des3_LDADD=$(COMMON_LIBS)
-test_hmac_SOURCES=test_hmac.c
-test_hmac_LDADD=$(COMMON_LIBS)
-
test_md4_SOURCES=test_md4.c
test_md4_LDADD=$(COMMON_LIBS)
--- a/libpurple/tests/test_hmac.c Wed Sep 28 13:55:30 2016 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,401 +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/hmaccipher.h"
-#include "ciphers/md5hash.h"
-#include "ciphers/sha1hash.h"
-
-/******************************************************************************
- * HMAC Tests
- * See RFC2202 and some other NULL tests I made up
- *****************************************************************************/
-static void
-test_hmac(gchar *data, size_t data_len,
- const gchar *key, size_t key_len,
- PurpleHash *hash, const gchar *digest)
-{
- PurpleCipher *cipher = NULL;
- gchar cdigest[41];
- gboolean ret = FALSE;
-
- cipher = purple_hmac_cipher_new(hash);
- purple_cipher_set_key(cipher, (guchar *)key, key_len);
-
- purple_cipher_append(cipher, (guchar *)data, data_len);
- ret = purple_cipher_digest_to_str(cipher, cdigest, sizeof(cdigest));
-
- g_assert(ret);
- g_assert_cmpstr(digest, ==, cdigest);
-
- g_object_unref(G_OBJECT(cipher));
- g_object_unref(G_OBJECT(hash));
-}
-
-static void
-test_hmac_md5_hi(void) {
- test_hmac(
- "Hi There",
- 8,
- "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b",
- 16,
- purple_md5_hash_new(),
- "9294727a3638bb1c13f48ef8158bfc9d"
- );
-}
-
-static void
-test_hmac_md5_what(void) {
- test_hmac(
- "what do ya want for nothing?",
- 28,
- "Jefe",
- 4,
- purple_md5_hash_new(),
- "750c783e6ab0b503eaa86e310a5db738"
- );
-}
-
-static void
-test_hmac_md5_dd(void) {
- test_hmac(
- "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
- "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
- "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
- "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
- "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd",
- 50,
- "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa",
- 16,
- purple_md5_hash_new(),
- "56be34521d144c88dbb8c733f0e8b3f6"
- );
-}
-
-static void
-test_hmac_md5_cd(void) {
- test_hmac(
- "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
- "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
- "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
- "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
- "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd",
- 50,
- "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a"
- "\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14"
- "\x15\x16\x17\x18\x19",
- 25,
- purple_md5_hash_new(),
- "697eaf0aca3a3aea3a75164746ffaa79"
- );
-}
-
-static void
-test_hmac_md5_truncation(void) {
- test_hmac(
- "Test With Truncation",
- 20,
- "\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c",
- 16,
- purple_md5_hash_new(),
- "56461ef2342edc00f9bab995690efd4c"
- );
-}
-
-static void
-test_hmac_md5_large_key(void) {
- test_hmac(
- "Test Using Larger Than Block-Size Key - Hash Key First",
- 54,
- "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
- "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
- "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
- "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
- "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
- "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
- "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
- "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa",
- 80,
- purple_md5_hash_new(),
- "6b1ab7fe4bd7bf8f0b62e6ce61b9d0cd"
- );
-}
-
-static void
-test_hmac_md5_large_key_and_data(void) {
- test_hmac(
- "Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data",
- 73,
- "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
- "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
- "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
- "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
- "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
- "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
- "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
- "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa",
- 80,
- purple_md5_hash_new(),
- "6f630fad67cda0ee1fb1f562db3aa53e"
- );
-}
-
-static void
-test_hmac_md5_null_key(void) {
- test_hmac(
- "Hi There",
- 8,
- "\x0a\x0b\x00\x0d\x0e\x0f\x1a\x2f\x0b\x0b"
- "\x0b\x00\x00\x0b\x0b\x49\x5f\x6e\x0b\x0b",
- 20,
- purple_md5_hash_new(),
- "597bfd644b797a985561eeb03a169e59"
- );
-}
-
-static void
-test_hmac_md5_null_text(void) {
- test_hmac(
- "Hi\x00There",
- 8,
- "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
- "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b",
- 20,
- purple_md5_hash_new(),
- "70be8e1b7b50dfcc335d6cd7992c564f"
- );
-}
-
-static void
-test_hmac_md5_null_key_and_text(void) {
- test_hmac(
- "Hi\x00Th\x00re",
- 8,
- "\x0c\x0d\x00\x0f\x10\x1a\x3a\x3a\xe6\x34"
- "\x0b\x00\x00\x0b\x0b\x49\x5f\x6e\x0b\x0b",
- 20,
- purple_md5_hash_new(),
- "b31bcbba35a33a067cbba9131cba4889"
- );
-}
-
-static void
-test_hmac_sha1_hi(void) {
- test_hmac(
- "Hi There",
- 8,
- "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
- "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b",
- 20,
- purple_sha1_hash_new(),
- "b617318655057264e28bc0b6fb378c8ef146be00"
- );
-}
-
-static void
-test_hmac_sha1_what(void) {
- test_hmac(
- "what do ya want for nothing?",
- 28,
- "Jefe",
- 4,
- purple_sha1_hash_new(),
- "effcdf6ae5eb2fa2d27416d5f184df9c259a7c79"
- );
-}
-
-static void
-test_hmac_sha1_dd(void) {
- test_hmac(
- "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
- "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
- "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
- "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
- "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd",
- 50,
- "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
- "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa",
- 20,
- purple_sha1_hash_new(),
- "125d7342b9ac11cd91a39af48aa17b4f63f175d3"
- );
-}
-
-static void
-test_hmac_sha1_cd(void) {
- test_hmac(
- "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
- "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
- "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
- "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
- "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd",
- 50,
- "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a"
- "\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14"
- "\x15\x16\x17\x18\x19",
- 25,
- purple_sha1_hash_new(),
- "4c9007f4026250c6bc8414f9bf50c86c2d7235da"
- );
-}
-
-static void
-test_hmac_sha1_truncation(void) {
- test_hmac(
- "Test With Truncation",
- 20,
- "\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c"
- "\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c",
- 20,
- purple_sha1_hash_new(),
- "4c1a03424b55e07fe7f27be1d58bb9324a9a5a04"
- );
-}
-
-static void
-test_hmac_sha1_large_key(void) {
- test_hmac(
- "Test Using Larger Than Block-Size Key - Hash Key First",
- 54,
- "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
- "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
- "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
- "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
- "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
- "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
- "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
- "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa",
- 80,
- purple_sha1_hash_new(),
- "aa4ae5e15272d00e95705637ce8a3b55ed402112"
- );
-}
-
-static void
-test_hmac_sha1_large_key_and_data(void) {
- test_hmac(
- "Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data",
- 73,
- "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
- "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
- "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
- "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
- "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
- "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
- "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
- "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa",
- 80,
- purple_sha1_hash_new(),
- "e8e99d0f45237d786d6bbaa7965c7808bbff1a91"
- );
-}
-
-static void
-test_hmac_sha1_null_key(void) {
- test_hmac(
- "Hi There",
- 8,
- "\x0a\x0b\x00\x0d\x0e\x0f\x1a\x2f\x0b\x0b"
- "\x0b\x00\x00\x0b\x0b\x49\x5f\x6e\x0b\x0b",
- 20,
- purple_sha1_hash_new(),
- "eb62a2e0e33d300be669c52aab3f591bc960aac5"
- );
-}
-
-static void
-test_hmac_sha1_null_text(void) {
- test_hmac(
- "Hi\x00There",
- 8,
- "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
- "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b",
- 20,
- purple_sha1_hash_new(),
- "31ca58d849e971e418e3439de2c6f83144b6abb7"
- );
-}
-
-static void
-test_hmac_sha1_null_key_and_text(void) {
- test_hmac(
- "Hi\x00Th\x00re",
- 8,
- "\x0c\x0d\x00\x0f\x10\x1a\x3a\x3a\xe6\x34"
- "\x0b\x00\x00\x0b\x0b\x49\x5f\x6e\x0b\x0b",
- 20,
- purple_sha1_hash_new(),
- "e6b8e2fede87aa09dcb13e554df1435e056eae36"
- );
-}
-
-gint
-main(gint argc, gchar **argv) {
- g_test_init(&argc, &argv, NULL);
-
- g_test_add_func("/hmac/md5/hi",
- test_hmac_md5_hi);
- g_test_add_func("/hmac/md5/what",
- test_hmac_md5_what);
- g_test_add_func("/hmac/md5/dd",
- test_hmac_md5_dd);
- g_test_add_func("/hmac/md5/cd",
- test_hmac_md5_cd);
- g_test_add_func("/hmac/md5/truncation",
- test_hmac_md5_truncation);
- g_test_add_func("/hmac/md5/large key",
- test_hmac_md5_large_key);
- g_test_add_func("/hmac/md5/large key and data",
- test_hmac_md5_large_key_and_data);
- g_test_add_func("/hmac/md5/null key",
- test_hmac_md5_null_key);
- g_test_add_func("/hmac/md5/null text",
- test_hmac_md5_null_text);
- g_test_add_func("/hmac/md5/null key and text",
- test_hmac_md5_null_key_and_text);
-
- g_test_add_func("/hmac/sha1/hi",
- test_hmac_sha1_hi);
- g_test_add_func("/hmac/sha1/what",
- test_hmac_sha1_what);
- g_test_add_func("/hmac/sha1/dd",
- test_hmac_sha1_dd);
- g_test_add_func("/hmac/sha1/cd",
- test_hmac_sha1_cd);
- g_test_add_func("/hmac/sha1/truncation",
- test_hmac_sha1_truncation);
- g_test_add_func("/hmac/sha1/large key",
- test_hmac_sha1_large_key);
- g_test_add_func("/hmac/sha1/large key and data",
- test_hmac_sha1_large_key_and_data);
- g_test_add_func("/hmac/sha1/null key",
- test_hmac_sha1_null_key);
- g_test_add_func("/hmac/sha1/null text",
- test_hmac_sha1_null_text);
- g_test_add_func("/hmac/sha1/null key and text",
- test_hmac_sha1_null_key_and_text);
-
- return g_test_run();
-}