gobjectification: d3172c42: Fix tests to get `make check` to work.
qulogic at pidgin.im
qulogic at pidgin.im
Sun Jul 11 04:05:55 EDT 2010
----------------------------------------------------------------------
Revision: d3172c420e1d28dd47d14c33a719017496368f84
Parent: 1971e9d61f842b4b0294ffb7f1acff7768ee9f6f
Author: qulogic at pidgin.im
Date: 07/11/10 03:54:25
Branch: im.pidgin.gobjectification
URL: http://d.pidgin.im/viewmtn/revision/info/d3172c420e1d28dd47d14c33a719017496368f84
Changelog:
Fix tests to get `make check` to work.
Changes against parent 1971e9d61f842b4b0294ffb7f1acff7768ee9f6f
patched libpurple/tests/test_cipher.c
patched libpurple/tests/test_jabber_scram.c
-------------- next part --------------
============================================================
--- libpurple/tests/test_cipher.c 40bf7024b099e3cac9bf026a994bedf425e68e43
+++ libpurple/tests/test_cipher.c 42528432b2e59087087d388b94cd1a4679d7e276
@@ -10,27 +10,31 @@
#include "../cipher/md4hash.h"
#include "../cipher/md5hash.h"
-#include "../cipher/sha1cipher.h"
+#include "../cipher/sha1hash.h"
+#include "../cipher/sha256hash.h"
+#include "../cipher/descipher.h"
+#include "../cipher/des3cipher.h"
+#include "../cipher/hmaccipher.h"
/******************************************************************************
* MD4 Tests
*****************************************************************************/
#define MD4_TEST(data, digest) { \
- PurpleCipher *cipher = NULL; \
+ PurpleHash *hash = NULL; \
gchar cdigest[33]; \
gboolean ret = FALSE; \
\
- cipher = purple_md4_hash_new(); \
- purple_cipher_append(cipher, (guchar *)(data), strlen((data))); \
+ hash = purple_md4_hash_new(); \
+ purple_hash_append(hash, (guchar *)(data), strlen((data))); \
\
- ret = purple_cipher_digest_to_str(cipher, sizeof(cdigest), cdigest, \
- NULL); \
+ ret = purple_hash_digest_to_str(hash, sizeof(cdigest), cdigest, \
+ NULL); \
\
fail_unless(ret == TRUE, NULL); \
\
fail_unless(strcmp((digest), cdigest) == 0, NULL); \
\
- g_object_unref(G_OBJECT(cipher)); \
+ g_object_unref(G_OBJECT(hash)); \
}
START_TEST(test_md4_empty_string) {
@@ -77,21 +81,21 @@ END_TEST
* MD5 Tests
*****************************************************************************/
#define MD5_TEST(data, digest) { \
- PurpleCipher *cipher = NULL; \
+ PurpleHash *hash = NULL; \
gchar cdigest[33]; \
gboolean ret = FALSE; \
\
- cipher = purple_md5_hash_new(); \
- purple_cipher_append(cipher, (guchar *)(data), strlen((data))); \
+ hash = purple_md5_hash_new(); \
+ purple_hash_append(hash, (guchar *)(data), strlen((data))); \
\
- ret = purple_cipher_digest_to_str(cipher, sizeof(cdigest), cdigest, \
- NULL); \
+ ret = purple_hash_digest_to_str(hash, sizeof(cdigest), cdigest, \
+ NULL); \
\
fail_unless(ret == TRUE, NULL); \
\
fail_unless(strcmp((digest), cdigest) == 0, NULL); \
\
- g_object_unref(G_OBJECT(cipher)); \
+ g_object_unref(G_OBJECT(hash)); \
}
START_TEST(test_md5_empty_string) {
@@ -137,15 +141,15 @@ END_TEST
* SHA-1 Tests
*****************************************************************************/
#define SHA1_TEST(data, digest) { \
- PurpleCipher *cipher = NULL; \
+ PurpleHash *hash = NULL; \
gchar cdigest[41]; \
gboolean ret = FALSE; \
gchar *input = data; \
\
- cipher = purple_sha1_cipher_new(); \
+ hash = purple_sha1_hash_new(); \
\
if (input) { \
- purple_cipher_append(cipher, (guchar *)input, strlen(input)); \
+ purple_hash_append(hash, (guchar *)input, strlen(input)); \
} else { \
gint j; \
guchar buff[1000]; \
@@ -153,17 +157,17 @@ END_TEST
memset(buff, 'a', 1000); \
\
for(j = 0; j < 1000; j++) \
- purple_cipher_append(cipher, buff, 1000); \
+ purple_hash_append(hash, buff, 1000); \
} \
\
- ret = purple_cipher_digest_to_str(cipher, sizeof(cdigest), cdigest, \
- NULL); \
+ ret = purple_hash_digest_to_str(hash, sizeof(cdigest), cdigest, \
+ NULL); \
\
fail_unless(ret == TRUE, NULL); \
\
fail_unless(strcmp((digest), cdigest) == 0, NULL); \
\
- g_object_unref(G_OBJECT(cipher)); \
+ g_object_unref(G_OBJECT(hash)); \
}
START_TEST(test_sha1_empty_string) {
@@ -196,15 +200,15 @@ END_TEST
* SHA-256 Tests
*****************************************************************************/
#define SHA256_TEST(data, digest) { \
- PurpleCipher *cipher = NULL; \
+ PurpleHash *hash = NULL; \
gchar cdigest[65]; \
gboolean ret = FALSE; \
gchar *input = data; \
\
- cipher = purple_sha256_cipher_new(); \
+ hash = purple_sha256_hash_new(); \
\
if (input) { \
- purple_cipher_append(cipher, (guchar *)input, strlen(input)); \
+ purple_hash_append(hash, (guchar *)input, strlen(input)); \
} else { \
gint j; \
guchar buff[1000]; \
@@ -212,17 +216,17 @@ END_TEST
memset(buff, 'a', 1000); \
\
for(j = 0; j < 1000; j++) \
- purple_cipher_append(cipher, buff, 1000); \
+ purple_hash_append(hash, buff, 1000); \
} \
\
- ret = purple_cipher_digest_to_str(cipher, sizeof(cdigest), cdigest, \
- NULL); \
+ ret = purple_hash_digest_to_str(hash, sizeof(cdigest), cdigest, \
+ NULL); \
\
fail_unless(ret == TRUE, NULL); \
\
fail_unless(strcmp((digest), cdigest) == 0, NULL); \
\
- g_object_unref(G_OBJECT(cipher)); \
+ g_object_unref(G_OBJECT(hash)); \
}
START_TEST(test_sha256_empty_string) {
@@ -475,8 +479,7 @@ END_TEST
gchar cdigest[41]; \
gboolean ret = FALSE; \
\
- cipher = purple_hmac_cipher_new(); \
- purple_cipher_set_hash(cipher, (hash)); \
+ cipher = purple_hmac_cipher_new((hash)); \
purple_cipher_set_key_with_len(cipher, (guchar *)(key), (key_len)); \
\
purple_cipher_append(cipher, (guchar *)(data), (data_len)); \
@@ -626,7 +629,7 @@ START_TEST(test_hmac_sha1_Hi) {
"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b",
20,
- purple_sha1_cipher_new(),
+ purple_sha1_hash_new(),
"b617318655057264e28bc0b6fb378c8ef146be00");
}
END_TEST
@@ -636,7 +639,7 @@ START_TEST(test_hmac_sha1_what) {
28,
"Jefe",
4,
- purple_sha1_cipher_new(),
+ purple_sha1_hash_new(),
"effcdf6ae5eb2fa2d27416d5f184df9c259a7c79");
}
END_TEST
@@ -651,7 +654,7 @@ START_TEST(test_hmac_sha1_dd) {
"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa",
20,
- purple_sha1_cipher_new(),
+ purple_sha1_hash_new(),
"125d7342b9ac11cd91a39af48aa17b4f63f175d3");
}
END_TEST
@@ -667,7 +670,7 @@ START_TEST(test_hmac_sha1_cd) {
"\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14"
"\x15\x16\x17\x18\x19",
25,
- purple_sha1_cipher_new(),
+ purple_sha1_hash_new(),
"4c9007f4026250c6bc8414f9bf50c86c2d7235da");
}
END_TEST
@@ -678,7 +681,7 @@ START_TEST(test_hmac_sha1_truncation) {
"\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c"
"\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c",
20,
- purple_sha1_cipher_new(),
+ purple_sha1_hash_new(),
"4c1a03424b55e07fe7f27be1d58bb9324a9a5a04");
}
END_TEST
@@ -695,7 +698,7 @@ START_TEST(test_hmac_sha1_large_key) {
"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa",
80,
- purple_sha1_cipher_new(),
+ purple_sha1_hash_new(),
"aa4ae5e15272d00e95705637ce8a3b55ed402112");
}
END_TEST
@@ -712,7 +715,7 @@ START_TEST(test_hmac_sha1_large_key_and_
"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa",
80,
- purple_sha1_cipher_new(),
+ purple_sha1_hash_new(),
"e8e99d0f45237d786d6bbaa7965c7808bbff1a91");
}
END_TEST
@@ -723,7 +726,7 @@ START_TEST(test_hmac_sha1_null_key) {
"\x0a\x0b\x00\x0d\x0e\x0f\x1a\x2f\x0b\x0b"
"\x0b\x00\x00\x0b\x0b\x49\x5f\x6e\x0b\x0b",
20,
- purple_sha1_cipher_new(),
+ purple_sha1_hash_new(),
"eb62a2e0e33d300be669c52aab3f591bc960aac5");
}
END_TEST
@@ -734,7 +737,7 @@ START_TEST(test_hmac_sha1_null_text) {
"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b",
20,
- purple_sha1_cipher_new(),
+ purple_sha1_hash_new(),
"31ca58d849e971e418e3439de2c6f83144b6abb7");
}
END_TEST
@@ -745,7 +748,7 @@ START_TEST(test_hmac_sha1_null_key_and_t
"\x0c\x0d\x00\x0f\x10\x1a\x3a\x3a\xe6\x34"
"\x0b\x00\x00\x0b\x0b\x49\x5f\x6e\x0b\x0b",
20,
- purple_sha1_cipher_new(),
+ purple_sha1_hash_new(),
"e6b8e2fede87aa09dcb13e554df1435e056eae36");
}
END_TEST
============================================================
--- libpurple/tests/test_jabber_scram.c 706c0804fce2556818a6568708190eae99da1209
+++ libpurple/tests/test_jabber_scram.c b6b61a8a6cc0ba36dc00c3d75eca114f2e729580
@@ -2,10 +2,12 @@
#include "tests.h"
#include "../util.h"
+#include "../cipher/hash.h"
+#include "../cipher/sha1hash.h"
#include "../protocols/jabber/auth_scram.h"
#include "../protocols/jabber/jutil.h"
-static JabberScramHash sha1_mech = { "-SHA-1", "sha1", 20 };
+static JabberScramHash sha1_mech = { "-SHA-1", purple_sha1_hash_new, 20 };
#define assert_pbkdf2_equal(password, salt, count, expected) { \
GString *p = g_string_new(password); \
More information about the Commits
mailing list