annotate plugins/ciphertest.c @ 10686:212946f774c0

[gaim-migrate @ 12233] Fix win32 compilation for cipher changes. committer: Tailor Script <tailor@pidgin.im>
author Daniel Atallah <daniel.atallah@gmail.com>
date Fri, 11 Mar 2005 22:45:41 +0000
parents 72a5babfa8b4
children b256ce6b85b8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10684
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1 /*
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
2 * A plugin to test the ciphers that ship with gaim
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
3 *
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
4 * Copyright (C) 2004, Gary Kramlich <amc_grim@users.sf.net>
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
5 *
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
7 * modify it under the terms of the GNU General Public License as
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
8 * published by the Free Software Foundation; either version 2 of the
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
9 * License, or (at your option) any later version.
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
10 *
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful, but
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
14 * General Public License for more details.
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
15 *
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
19 * 02111-1307, USA.
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
20 */
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
21
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
22 #ifdef HAVE_CONFIG_H
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
23 #include <config.h>
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
24 #endif
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
25
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
26 #ifndef GAIM_PLUGINS
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
27 #define GAIM_PLUGINS
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
28 #endif
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
29
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
30 #include "internal.h"
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
31
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
32 #include <glib.h>
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
33 #include <string.h>
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
34
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
35 #include "cipher.h"
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
36 #include "debug.h"
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
37 #include "plugin.h"
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
38 #include "version.h"
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
39
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
40 struct test {
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
41 const guint8 *question;
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
42 const guint8 *answer;
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
43 };
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
44
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
45 /**************************************************************************
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
46 * MD5 Stuff
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
47 **************************************************************************/
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
48 struct test md5_tests[8] = {
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
49 { "", "d41d8cd98f00b204e9800998ecf8427e"},
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
50 { "a", "0cc175b9c0f1b6a831c399e269772661"},
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
51 { "abc", "900150983cd24fb0d6963f7d28e17f72"},
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
52 { "message digest", "f96b697d7cb7938d525a2f31aaf161d0"},
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
53 { "abcdefghijklmnopqrstuvwxyz", "c3fcd3d76192e4007dfb496cca67e13b"},
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
54 { "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
55 "abcdefghijklmnopqrstuvwxyz"
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
56 "0123456789", "d174ab98d277d9f5a5611c2c9f419d9f"},
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
57 {"123456789012345678901234567"
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
58 "890123456789012345678901234"
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
59 "56789012345678901234567890", "57edf4a22be3c955ac49da2e2107b67a"},
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
60 { NULL, NULL }
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
61 };
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
62
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
63 static void
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
64 cipher_test_md5() {
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
65 GaimCipher *cipher;
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
66 GaimCipherContext *context;
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
67 gchar digest[32];
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
68 gint i = 0;
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
69
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
70 cipher = gaim_ciphers_find_cipher("md5");
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
71 if(!cipher) {
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
72 gaim_debug_info("cipher-test",
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
73 "could not find md5 cipher, not testing\n");
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
74 return;
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
75 }
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
76
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
77 gaim_debug_info("cipher-test", "Running md5 tests\n");
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
78
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
79 context = gaim_cipher_context_new(cipher, NULL);
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
80
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
81 while(md5_tests[i].answer) {
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
82 gaim_debug_info("cipher-test", "Test %02d:\n", i);
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
83 gaim_debug_info("cipher-test", "Testing '%s'\n", md5_tests[i].question);
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
84
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
85 gaim_cipher_context_append(context, md5_tests[i].question,
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
86 strlen(md5_tests[i].question));
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
87
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
88 gaim_cipher_context_digest_to_str(context, NULL, digest);
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
89
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
90 gaim_debug_info("cipher-test", "\tGot: %s\n", digest);
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
91 gaim_debug_info("cipher-test", "\tWanted: %s\n", md5_tests[i].answer);
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
92
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
93 gaim_cipher_context_reset(context, NULL);
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
94 i++;
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
95 }
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
96
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
97 gaim_cipher_context_destroy(context);
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
98
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
99 gaim_debug_info("cipher-test", "md5 tests completed\n\n");
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
100 }
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
101
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
102 /**************************************************************************
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
103 * SHA-1 stuff
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
104 **************************************************************************/
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
105 struct test sha1_tests[5] = {
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
106 {"a", "86f7e437faa5a7fce15d1ddcb9eaeaea377667b8"},
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
107 {"abc", "a9993e364706816aba3e25717850c26c9cd0d89d"} ,
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
108 {"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", "84983e441c3bd26ebaae4aa1f95129e5e54670f1"} ,
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
109 {NULL, "34aa973cd4c4daa4f61eeb2bdbad27316534016f"},
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
110 {NULL, NULL}
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
111 };
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
112
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
113 static void
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
114 cipher_test_sha1() {
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
115 GaimCipher *cipher;
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
116 GaimCipherContext *context;
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
117 gchar digest[40];
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
118 gint i = 0;
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
119
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
120 cipher = gaim_ciphers_find_cipher("sha1");
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
121 if(!cipher) {
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
122 gaim_debug_info("cipher-test",
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
123 "could not find sha1 cipher, not testing\n");
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
124 return;
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
125 }
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
126
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
127 gaim_debug_info("cipher-test", "Running sha1 tests\n");
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
128
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
129 context = gaim_cipher_context_new(cipher, NULL);
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
130
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
131 while(sha1_tests[i].answer) {
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
132 gaim_debug_info("cipher-test", "Test %02d:\n", i);
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
133 gaim_debug_info("cipher-test", "Testing '%s'\n",
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
134 (sha1_tests[i].question != NULL) ?
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
135 sha1_tests[i].question : "'a'x1000, 1000 times");
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
136
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
137 if(sha1_tests[i].question) {
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
138 gaim_cipher_context_append(context, sha1_tests[i].question,
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
139 strlen(sha1_tests[i].question));
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
140 } else {
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
141 gint j;
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
142 guint8 buff[1000];
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
143
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
144 memset(buff, 'a', 1000);
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
145
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
146 for(j = 0; j < 1000; j++)
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
147 gaim_cipher_context_append(context, buff, 1000);
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
148 }
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
149
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
150 gaim_cipher_context_digest_to_str(context, NULL, digest);
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
151
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
152 gaim_debug_info("cipher-test", "\tGot: %s\n", digest);
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
153 gaim_debug_info("cipher-test", "\tWanted: %s\n", sha1_tests[i].answer);
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
154
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
155 gaim_cipher_context_reset(context, NULL);
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
156 i++;
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
157 }
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
158
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
159 gaim_cipher_context_destroy(context);
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
160
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
161 gaim_debug_info("cipher-test", "sha1 tests completed\n\n");
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
162 }
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
163 /**************************************************************************
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
164 * Plugin stuff
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
165 **************************************************************************/
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
166 static gboolean
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
167 plugin_load(GaimPlugin *plugin) {
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
168 cipher_test_md5();
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
169 cipher_test_sha1();
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
170
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
171 return TRUE;
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
172 }
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
173
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
174 static GaimPluginInfo info =
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
175 {
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
176 GAIM_PLUGIN_MAGIC,
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
177 GAIM_MAJOR_VERSION,
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
178 GAIM_MINOR_VERSION,
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
179 GAIM_PLUGIN_STANDARD, /**< type */
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
180 NULL, /**< ui_requirement */
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
181 0, /**< flags */
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
182 NULL, /**< dependencies */
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
183 GAIM_PRIORITY_DEFAULT, /**< priority */
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
184
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
185 "core-cipher-test", /**< id */
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
186 N_("Cipher Test"), /**< name */
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
187 VERSION, /**< version */
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
188 /** summary */
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
189 N_("Tests the ciphers that ship with gaim."),
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
190 /** description */
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
191 N_("Tests the ciphers that ship with gaim."),
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
192 "Gary Kramlich <amc_grim@users.sf.net>", /**< author */
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
193 GAIM_WEBSITE, /**< homepage */
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
194
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
195 plugin_load, /**< load */
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
196 NULL, /**< unload */
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
197 NULL, /**< destroy */
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
198
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
199 NULL, /**< ui_info */
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
200 NULL, /**< extra_info */
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
201 NULL,
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
202 NULL
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
203 };
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
204
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
205 static void
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
206 init_plugin(GaimPlugin *plugin) {
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
207 }
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
208
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
209 GAIM_INIT_PLUGIN(ciper_test, init_plugin, info)