aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/libgcrypt/libgcrypt-1.2.2/tests
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/libgcrypt/libgcrypt-1.2.2/tests')
-rw-r--r--[-rwxr-xr-x]linden/indra/libgcrypt/libgcrypt-1.2.2/tests/ChangeLog626
-rw-r--r--[-rwxr-xr-x]linden/indra/libgcrypt/libgcrypt-1.2.2/tests/Makefile.am58
-rw-r--r--[-rwxr-xr-x]linden/indra/libgcrypt/libgcrypt-1.2.2/tests/Makefile.in1258
-rw-r--r--[-rwxr-xr-x]linden/indra/libgcrypt/libgcrypt-1.2.2/tests/ac.c314
-rw-r--r--[-rwxr-xr-x]linden/indra/libgcrypt/libgcrypt-1.2.2/tests/basic.c2184
-rw-r--r--[-rwxr-xr-x]linden/indra/libgcrypt/libgcrypt-1.2.2/tests/benchmark.c880
-rw-r--r--[-rwxr-xr-x]linden/indra/libgcrypt/libgcrypt-1.2.2/tests/keygen.c482
-rw-r--r--[-rwxr-xr-x]linden/indra/libgcrypt/libgcrypt-1.2.2/tests/prime.c238
-rw-r--r--[-rwxr-xr-x]linden/indra/libgcrypt/libgcrypt-1.2.2/tests/pubkey.c504
-rw-r--r--[-rwxr-xr-x]linden/indra/libgcrypt/libgcrypt-1.2.2/tests/random.c504
-rw-r--r--[-rwxr-xr-x]linden/indra/libgcrypt/libgcrypt-1.2.2/tests/register.c318
-rw-r--r--[-rwxr-xr-x]linden/indra/libgcrypt/libgcrypt-1.2.2/tests/testapi.c224
-rw-r--r--[-rwxr-xr-x]linden/indra/libgcrypt/libgcrypt-1.2.2/tests/tsexp.c792
13 files changed, 4191 insertions, 4191 deletions
diff --git a/linden/indra/libgcrypt/libgcrypt-1.2.2/tests/ChangeLog b/linden/indra/libgcrypt/libgcrypt-1.2.2/tests/ChangeLog
index 14116c6..c3b8b1a 100755..100644
--- a/linden/indra/libgcrypt/libgcrypt-1.2.2/tests/ChangeLog
+++ b/linden/indra/libgcrypt/libgcrypt-1.2.2/tests/ChangeLog
@@ -1,313 +1,313 @@
12005-09-13 Werner Koch <wk@g10code.com> 12005-09-13 Werner Koch <wk@g10code.com>
2 2
3 * random.c: New. 3 * random.c: New.
4 4
52005-06-16 Werner Koch <wk@g10code.com> 52005-06-16 Werner Koch <wk@g10code.com>
6 6
7 * basic.c (check_one_md): Made P unsigned. 7 * basic.c (check_one_md): Made P unsigned.
8 8
92004-02-25 Werner Koch <wk@gnupg.org> 92004-02-25 Werner Koch <wk@gnupg.org>
10 10
11 * Makefile.am (TEST): Add benchmark. 11 * Makefile.am (TEST): Add benchmark.
12 12
13 * benchmark.c (md_bench, cipher_bench): Allow NULL arg to to run 13 * benchmark.c (md_bench, cipher_bench): Allow NULL arg to to run
14 tests for all algorithms. 14 tests for all algorithms.
15 (main): Run all tests by default. 15 (main): Run all tests by default.
16 16
172004-02-03 Werner Koch <wk@gnupg.org> 172004-02-03 Werner Koch <wk@gnupg.org>
18 18
19 * tsexp.c (basic): New pass to check secure memory switching. 19 * tsexp.c (basic): New pass to check secure memory switching.
20 20
212004-01-12 Moritz Schulte <mo@g10code.com> 212004-01-12 Moritz Schulte <mo@g10code.com>
22 22
23 * ac.c (check_one): Adjust to new ac API. 23 * ac.c (check_one): Adjust to new ac API.
24 24
252003-11-22 Werner Koch <wk@gnupg.org> 252003-11-22 Werner Koch <wk@gnupg.org>
26 26
27 * pubkey.c (check_keys_crypt): Fixed my last patch. 27 * pubkey.c (check_keys_crypt): Fixed my last patch.
28 28
292003-11-11 Werner Koch <wk@gnupg.org> 292003-11-11 Werner Koch <wk@gnupg.org>
30 30
31 * tsexp.c (basic): Add pass structure and a test for the %b 31 * tsexp.c (basic): Add pass structure and a test for the %b
32 format. 32 format.
33 33
342003-11-04 Werner Koch <wk@gnupg.org> 342003-11-04 Werner Koch <wk@gnupg.org>
35 35
36 * Makefile.am (noinst_PROGRAMS): Use this so that test programs 36 * Makefile.am (noinst_PROGRAMS): Use this so that test programs
37 get always build. 37 get always build.
38 38
39 * keygen.c (check_nonce): New. 39 * keygen.c (check_nonce): New.
40 (main): Add a basic check for the nocen function. 40 (main): Add a basic check for the nocen function.
41 41
422003-10-31 Werner Koch <wk@gnupg.org> 422003-10-31 Werner Koch <wk@gnupg.org>
43 43
44 * basic.c (check_aes128_cbc_cts_cipher): Make it a prototype 44 * basic.c (check_aes128_cbc_cts_cipher): Make it a prototype
45 45
46 * ac.c (check_run): Comment unused variable. 46 * ac.c (check_run): Comment unused variable.
47 47
482003-10-10 Werner Koch <wk@gnupg.org> 482003-10-10 Werner Koch <wk@gnupg.org>
49 49
50 * prime.c (check_primes): Generate a generator and avoid printing 50 * prime.c (check_primes): Generate a generator and avoid printing
51 unless in verbose mode. 51 unless in verbose mode.
52 52
532003-10-07 Werner Koch <wk@gnupg.org> 532003-10-07 Werner Koch <wk@gnupg.org>
54 54
55 * tsexp.c (check_sscan): New. 55 * tsexp.c (check_sscan): New.
56 56
572003-09-04 Werner Koch <wk@gnupg.org> 572003-09-04 Werner Koch <wk@gnupg.org>
58 58
59 * pubkey.c (check_keys_crypt): Fix for compatibility mode. 59 * pubkey.c (check_keys_crypt): Fix for compatibility mode.
60 60
612003-09-02 Moritz Schulte <mo@g10code.com> 612003-09-02 Moritz Schulte <mo@g10code.com>
62 62
63 * Makefile.am (TESTS): Added: prime. 63 * Makefile.am (TESTS): Added: prime.
64 64
65 * prime.c: New file. 65 * prime.c: New file.
66 66
672003-08-27 Moritz Schulte <mo@g10code.com> 672003-08-27 Moritz Schulte <mo@g10code.com>
68 68
69 * basic.c (check_ciphers): Added: Serpent. 69 * basic.c (check_ciphers): Added: Serpent.
70 Write braces around flags. 70 Write braces around flags.
71 71
722003-08-04 Moritz Schulte <moritz@g10code.com> 722003-08-04 Moritz Schulte <moritz@g10code.com>
73 73
74 * benchmark.c (do_powm): Adjust for new gcry_mpi_scan interface. 74 * benchmark.c (do_powm): Adjust for new gcry_mpi_scan interface.
75 75
762003-07-23 Moritz Schulte <moritz@g10code.com> 762003-07-23 Moritz Schulte <moritz@g10code.com>
77 77
78 * ac.c (key_copy): New function... 78 * ac.c (key_copy): New function...
79 (check_one): ... use it. 79 (check_one): ... use it.
80 80
812003-07-22 Moritz Schulte <moritz@g10code.com> 812003-07-22 Moritz Schulte <moritz@g10code.com>
82 82
83 * basic.c (check_ciphers): Use gcry_cipher_map_name. 83 * basic.c (check_ciphers): Use gcry_cipher_map_name.
84 84
852003-07-18 Moritz Schulte <moritz@g10code.com> 852003-07-18 Moritz Schulte <moritz@g10code.com>
86 86
87 * ac.c (check_run): Renamed to ... 87 * ac.c (check_run): Renamed to ...
88 (check_one): ... this, changed calling interface. 88 (check_one): ... this, changed calling interface.
89 (check_run): New function. 89 (check_run): New function.
90 90
91 * register.c: Adjust gcry_cipher_spec_t structure. 91 * register.c: Adjust gcry_cipher_spec_t structure.
92 92
932003-07-14 Moritz Schulte <moritz@g10code.com> 932003-07-14 Moritz Schulte <moritz@g10code.com>
94 94
95 * register.c: Adjust cipher specification structure. 95 * register.c: Adjust cipher specification structure.
96 96
97 * benchmark.c: New file. 97 * benchmark.c: New file.
98 * testapi.c: New file. 98 * testapi.c: New file.
99 99
100 * Makefile.am (EXTRA_PROGRAMS): Set to: benchmark testapi. 100 * Makefile.am (EXTRA_PROGRAMS): Set to: benchmark testapi.
101 (check_PROGRAMS): Set to: $(TESTS). 101 (check_PROGRAMS): Set to: $(TESTS).
102 102
1032003-07-12 Moritz Schulte <moritz@g10code.com> 1032003-07-12 Moritz Schulte <moritz@g10code.com>
104 104
105 * ac.c, basic.c, keygen.c, register.c, sexp.c, tsexp.c: Used 105 * ac.c, basic.c, keygen.c, register.c, sexp.c, tsexp.c: Used
106 gcry_err* wrappers for libgpg symbols. 106 gcry_err* wrappers for libgpg symbols.
107 107
108 * basic.c (check_ciphers): Added: GCRY_CIPHER_TWOFISH128. 108 * basic.c (check_ciphers): Added: GCRY_CIPHER_TWOFISH128.
109 109
1102003-07-08 Moritz Schulte <moritz@g10code.com> 1102003-07-08 Moritz Schulte <moritz@g10code.com>
111 111
112 * Makefile.am (LIBS): Remove: -lpthread. 112 * Makefile.am (LIBS): Remove: -lpthread.
113 113
114 * basic.c (check_one_cipher): Fix variable initialization. Thanks 114 * basic.c (check_one_cipher): Fix variable initialization. Thanks
115 to Simon Joseffson <jas@extundo.com>. 115 to Simon Joseffson <jas@extundo.com>.
116 116
1172003-07-07 Moritz Schulte <moritz@g10code.com> 1172003-07-07 Moritz Schulte <moritz@g10code.com>
118 118
119 * Makefile.am (TESTS): Added: register. 119 * Makefile.am (TESTS): Added: register.
120 120
1212003-07-05 Moritz Schulte <moritz@g10code.com> 1212003-07-05 Moritz Schulte <moritz@g10code.com>
122 122
123 * register.c (check_run): Adjusted for new gcry_cipher_register API. 123 * register.c (check_run): Adjusted for new gcry_cipher_register API.
124 124
1252003-07-02 Moritz Schulte <moritz@g10code.com> 1252003-07-02 Moritz Schulte <moritz@g10code.com>
126 126
127 * Makefile.am (TESTS): Added: ac. 127 * Makefile.am (TESTS): Added: ac.
128 * ac.c: New file. 128 * ac.c: New file.
129 129
1302003-06-18 Werner Koch <wk@gnupg.org> 1302003-06-18 Werner Koch <wk@gnupg.org>
131 131
132 * basic.c (check_cbc_mac_cipher): Adjusted for new API of get_blklen 132 * basic.c (check_cbc_mac_cipher): Adjusted for new API of get_blklen
133 and get_keylen. 133 and get_keylen.
134 (check_ctr_cipher): Ditto. 134 (check_ctr_cipher): Ditto.
135 (check_one_cipher): Ditto. 135 (check_one_cipher): Ditto.
136 (check_one_md): Adjusted for new API of gcry_md_copy. 136 (check_one_md): Adjusted for new API of gcry_md_copy.
137 137
1382003-06-18 Moritz Schulte <moritz@g10code.com> 1382003-06-18 Moritz Schulte <moritz@g10code.com>
139 139
140 * register.c: Replace old type GcryModule with newer one: 140 * register.c: Replace old type GcryModule with newer one:
141 gcry_module_t. 141 gcry_module_t.
142 Adjusted for new API. 142 Adjusted for new API.
143 143
144 * Makefile.am (AM_CFLAGS): Added: @GPG_ERROR_CFLAGS@. 144 * Makefile.am (AM_CFLAGS): Added: @GPG_ERROR_CFLAGS@.
145 145
1462003-06-15 Moritz Schulte <moritz@g10code.com> 1462003-06-15 Moritz Schulte <moritz@g10code.com>
147 147
148 * basic.c (get_keys_new): New function. 148 * basic.c (get_keys_new): New function.
149 (do_check_one_pubkey): New function ... 149 (do_check_one_pubkey): New function ...
150 (check_one_pubkey): ... use it. 150 (check_one_pubkey): ... use it.
151 (progress_handler): New function. 151 (progress_handler): New function.
152 (main): Use gcry_set_progress_handler. 152 (main): Use gcry_set_progress_handler.
153 153
1542003-06-14 Moritz Schulte <moritz@g10code.com> 1542003-06-14 Moritz Schulte <moritz@g10code.com>
155 155
156 * basic.c: Replaced calls to gcry_strerror with calls to 156 * basic.c: Replaced calls to gcry_strerror with calls to
157 gpg_strerror. 157 gpg_strerror.
158 (check_one_md): Adjust for new gcry_md_copy API. 158 (check_one_md): Adjust for new gcry_md_copy API.
159 159
160 * tsexp.c: Likewise. 160 * tsexp.c: Likewise.
161 * keygen.c: Likewise. 161 * keygen.c: Likewise.
162 162
1632003-06-12 Moritz Schulte <moritz@g10code.com> 1632003-06-12 Moritz Schulte <moritz@g10code.com>
164 164
165 * basic.c: Changed here and there, reorganized pubkey checks, 165 * basic.c: Changed here and there, reorganized pubkey checks,
166 added DSA and ELG keys. 166 added DSA and ELG keys.
167 167
1682003-06-09 Moritz Schulte <moritz@g10code.com> 1682003-06-09 Moritz Schulte <moritz@g10code.com>
169 169
170 * basic.c, keygen.c, pubkey.c, register.c, tsexp.c: Changed to use 170 * basic.c, keygen.c, pubkey.c, register.c, tsexp.c: Changed to use
171 new API. 171 new API.
172 172
1732003-06-01 Moritz Schulte <moritz@g10code.com> 1732003-06-01 Moritz Schulte <moritz@g10code.com>
174 174
175 * tsexp.c (canon_len): Adjust for new gcry_sexp_canon_len API. 175 * tsexp.c (canon_len): Adjust for new gcry_sexp_canon_len API.
176 176
1772003-05-26 Moritz Schulte <moritz@g10code.com> 1772003-05-26 Moritz Schulte <moritz@g10code.com>
178 178
179 * basic.c (verify_one_signature): Adjust for libgpg-error. 179 * basic.c (verify_one_signature): Adjust for libgpg-error.
180 (check_pubkey_sign): Likewise. 180 (check_pubkey_sign): Likewise.
181 (check_pubkey): Likewise. 181 (check_pubkey): Likewise.
182 * basic.c (check_pubkey_sign): Likewise. 182 * basic.c (check_pubkey_sign): Likewise.
183 * tsexp.c (canon_len): Likewise. 183 * tsexp.c (canon_len): Likewise.
184 (back_and_forth_one): Likewise. 184 (back_and_forth_one): Likewise.
185 185
1862003-04-27 Moritz Schulte <moritz@g10code.com> 1862003-04-27 Moritz Schulte <moritz@g10code.com>
187 187
188 * pubkey.c: Changed the sample private key to contain the 188 * pubkey.c: Changed the sample private key to contain the
189 identifier `openpgp-rsa' instead of `rsa'. 189 identifier `openpgp-rsa' instead of `rsa'.
190 190
191 * basic.c (check_digests): Enabled/fixed some tests for TIGER. 191 * basic.c (check_digests): Enabled/fixed some tests for TIGER.
192 192
1932003-04-17 Moritz Schulte <moritz@g10code.com> 1932003-04-17 Moritz Schulte <moritz@g10code.com>
194 194
195 * Makefile.am (TESTS): Removed `register' for now. 195 * Makefile.am (TESTS): Removed `register' for now.
196 196
1972003-04-17 Moritz Schulte <moritz@g10code.com> 1972003-04-17 Moritz Schulte <moritz@g10code.com>
198 198
199 * basic.c (check_digests): Include checks for SHA512 and SHA384. 199 * basic.c (check_digests): Include checks for SHA512 and SHA384.
200 200
2012003-04-16 Moritz Schulte <moritz@g10code.com> 2012003-04-16 Moritz Schulte <moritz@g10code.com>
202 202
203 * basic.c (check_one_md): Also test md_copy. 203 * basic.c (check_one_md): Also test md_copy.
204 204
2052003-04-07 Moritz Schulte <moritz@g10code.com> 2052003-04-07 Moritz Schulte <moritz@g10code.com>
206 206
207 * Makefile.am (TESTS): Added register. 207 * Makefile.am (TESTS): Added register.
208 208
209 * register.c: New file. 209 * register.c: New file.
210 210
2112003-03-30 Simon Josefsson <jas@extundo.com> 2112003-03-30 Simon Josefsson <jas@extundo.com>
212 212
213 * basic.c (check_one_cipher): New. Test CTR. 213 * basic.c (check_one_cipher): New. Test CTR.
214 (main): Call it. 214 (main): Call it.
215 (check_ciphers): Check CTR mode. 215 (check_ciphers): Check CTR mode.
216 216
2172003-03-26 Moritz Schulte <moritz@g10code.com> 2172003-03-26 Moritz Schulte <moritz@g10code.com>
218 218
219 * Makefile.am (TESTS): Added pubkey. 219 * Makefile.am (TESTS): Added pubkey.
220 220
221 * pubkey.c: New file. 221 * pubkey.c: New file.
222 222
2232003-03-22 Simon Josefsson <jas@extundo.com> 2232003-03-22 Simon Josefsson <jas@extundo.com>
224 224
225 * basic.c (check_cbc_mac_cipher): New. 225 * basic.c (check_cbc_mac_cipher): New.
226 (main): Use it. 226 (main): Use it.
227 227
2282003-03-19 Werner Koch <wk@gnupg.org> 2282003-03-19 Werner Koch <wk@gnupg.org>
229 229
230 * keygen.c (check_rsa_keys): Don't expect an exponent when asking 230 * keygen.c (check_rsa_keys): Don't expect an exponent when asking
231 for e=0. 231 for e=0.
232 (check_generated_rsa_key): Just print exponent if EXPECTED_E is 0. 232 (check_generated_rsa_key): Just print exponent if EXPECTED_E is 0.
233 233
2342003-03-02 Moritz Schulte <moritz@g10code.com> 2342003-03-02 Moritz Schulte <moritz@g10code.com>
235 235
236 * basic.c (check_one_cipher): Use gcry_cipher_reset() instead of 236 * basic.c (check_one_cipher): Use gcry_cipher_reset() instead of
237 gcry_cipher_close(), gcry_cipher_open and gcry_cipher_setkey(). 237 gcry_cipher_close(), gcry_cipher_open and gcry_cipher_setkey().
238 238
2392003-01-23 Werner Koch <wk@gnupg.org> 2392003-01-23 Werner Koch <wk@gnupg.org>
240 240
241 * keygen.c: New. 241 * keygen.c: New.
242 242
2432003-01-20 Simon Josefsson <jas@extundo.com> 2432003-01-20 Simon Josefsson <jas@extundo.com>
244 244
245 * basic.c (check_digests): Add CRC. 245 * basic.c (check_digests): Add CRC.
246 (check_one_md): Print computed and expected values on error. 246 (check_one_md): Print computed and expected values on error.
247 247
2482003-01-20 Werner Koch <wk@gnupg.org> 2482003-01-20 Werner Koch <wk@gnupg.org>
249 249
250 * basic.c (check_one_md): Kludge to check a one million "a". 250 * basic.c (check_one_md): Kludge to check a one million "a".
251 (check_digests): Add checks for SHA-256. 251 (check_digests): Add checks for SHA-256.
252 252
2532003-01-20 Werner Koch <wk@gnupg.org> 2532003-01-20 Werner Koch <wk@gnupg.org>
254 254
255 * basic.c (check_pubkey): Check the keygrip for the sample key. 255 * basic.c (check_pubkey): Check the keygrip for the sample key.
256 256
2572003-01-15 Werner Koch <wk@gnupg.org> 2572003-01-15 Werner Koch <wk@gnupg.org>
258 258
259 * basic.c (verify_one_signature,check_pubkey_sign) 259 * basic.c (verify_one_signature,check_pubkey_sign)
260 (check_pubkey): New. 260 (check_pubkey): New.
261 (main): Check public key functions. Add a --debug option. 261 (main): Check public key functions. Add a --debug option.
262 262
2632002-11-23 Werner Koch <wk@gnupg.org> 2632002-11-23 Werner Koch <wk@gnupg.org>
264 264
265 * basic.c (check_digests): Add another test for MD4. By Simon 265 * basic.c (check_digests): Add another test for MD4. By Simon
266 Josefsson. 266 Josefsson.
267 267
2682002-11-10 Simon Josefsson <jas@extundo.com> 2682002-11-10 Simon Josefsson <jas@extundo.com>
269 269
270 * basic.c (check_aes128_cbc_cts_cipher): New function. 270 * basic.c (check_aes128_cbc_cts_cipher): New function.
271 (check_one_cipher): Add flags parameter. 271 (check_one_cipher): Add flags parameter.
272 (check_ciphers): Support flags parameter. 272 (check_ciphers): Support flags parameter.
273 (main): Check CTS. 273 (main): Check CTS.
274 274
2752002-11-10 Werner Koch <wk@gnupg.org> 2752002-11-10 Werner Koch <wk@gnupg.org>
276 276
277 * basic.c (check_one_md): New. By Simon Josefsson. 277 * basic.c (check_one_md): New. By Simon Josefsson.
278 (check_digests): New tests for MD4. By Simon. 278 (check_digests): New tests for MD4. By Simon.
279 279
2802002-08-26 Werner Koch <wk@gnupg.org> 2802002-08-26 Werner Koch <wk@gnupg.org>
281 281
282 * basic.c (check_ciphers): Check simple DES. 282 * basic.c (check_ciphers): Check simple DES.
283 283
2842002-05-16 Werner Koch <wk@gnupg.org> 2842002-05-16 Werner Koch <wk@gnupg.org>
285 285
286 * tsexp.c (back_and_forth): Very minimal test of the new functions. 286 * tsexp.c (back_and_forth): Very minimal test of the new functions.
287 287
2882002-05-14 Werner Koch <wk@gnupg.org> 2882002-05-14 Werner Koch <wk@gnupg.org>
289 289
290 Changed license of all files to the LGPL. 290 Changed license of all files to the LGPL.
291 291
2922002-05-02 Werner Koch <wk@gnupg.org> 2922002-05-02 Werner Koch <wk@gnupg.org>
293 293
294 * basic.c: Add option --verbose. 294 * basic.c: Add option --verbose.
295 295
2962002-01-11 Werner Koch <wk@gnupg.org> 2962002-01-11 Werner Koch <wk@gnupg.org>
297 297
298 * tsexp.c (canon_len): Fixed tests. 298 * tsexp.c (canon_len): Fixed tests.
299 299
3002001-12-18 Werner Koch <wk@gnupg.org> 3002001-12-18 Werner Koch <wk@gnupg.org>
301 301
302 * tsexp.c: New. 302 * tsexp.c: New.
303 303
304 304
305 Copyright 2001, 2002, 2003 Free Software Foundation, Inc. 305 Copyright 2001, 2002, 2003 Free Software Foundation, Inc.
306 306
307 This file is free software; as a special exception the author gives 307 This file is free software; as a special exception the author gives
308 unlimited permission to copy and/or distribute it, with or without 308 unlimited permission to copy and/or distribute it, with or without
309 modifications, as long as this notice is preserved. 309 modifications, as long as this notice is preserved.
310 310
311 This file is distributed in the hope that it will be useful, but 311 This file is distributed in the hope that it will be useful, but
312 WITHOUT ANY WARRANTY, to the extent permitted by law; without even the 312 WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
313 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 313 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
diff --git a/linden/indra/libgcrypt/libgcrypt-1.2.2/tests/Makefile.am b/linden/indra/libgcrypt/libgcrypt-1.2.2/tests/Makefile.am
index 13b7fa8..36aede8 100755..100644
--- a/linden/indra/libgcrypt/libgcrypt-1.2.2/tests/Makefile.am
+++ b/linden/indra/libgcrypt/libgcrypt-1.2.2/tests/Makefile.am
@@ -1,29 +1,29 @@
1# Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. 1# Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
2# 2#
3# This file is part of Libgcrypt. 3# This file is part of Libgcrypt.
4# 4#
5# Libgcrypt is free software; you can redistribute it and/or modify 5# Libgcrypt is free software; you can redistribute it and/or modify
6# it under the terms of the GNU Lesser General Public License as 6# it under the terms of the GNU Lesser General Public License as
7# published by the Free Software Foundation; either version 2.1 of 7# published by the Free Software Foundation; either version 2.1 of
8# the License, or (at your option) any later version. 8# the License, or (at your option) any later version.
9# 9#
10# Libgcrypt is distributed in the hope that it will be useful, 10# Libgcrypt is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of 11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU Lesser General Public License for more details. 13# GNU Lesser General Public License for more details.
14# 14#
15# You should have received a copy of the GNU Lesser General Public 15# You should have received a copy of the GNU Lesser General Public
16# License along with this program; if not, write to the Free Software 16# License along with this program; if not, write to the Free Software
17# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 17# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
18 18
19## Process this file with automake to produce Makefile.in 19## Process this file with automake to produce Makefile.in
20 20
21TESTS = prime register ac basic tsexp keygen pubkey benchmark random 21TESTS = prime register ac basic tsexp keygen pubkey benchmark random
22 22
23INCLUDES = -I$(top_srcdir)/src 23INCLUDES = -I$(top_srcdir)/src
24LDADD = ../src/libgcrypt.la 24LDADD = ../src/libgcrypt.la
25 25
26EXTRA_PROGRAMS = testapi 26EXTRA_PROGRAMS = testapi
27noinst_PROGRAMS = $(TESTS) 27noinst_PROGRAMS = $(TESTS)
28 28
29AM_CFLAGS = @GPG_ERROR_CFLAGS@ 29AM_CFLAGS = @GPG_ERROR_CFLAGS@
diff --git a/linden/indra/libgcrypt/libgcrypt-1.2.2/tests/Makefile.in b/linden/indra/libgcrypt/libgcrypt-1.2.2/tests/Makefile.in
index a4c5b55..4cb4ea2 100755..100644
--- a/linden/indra/libgcrypt/libgcrypt-1.2.2/tests/Makefile.in
+++ b/linden/indra/libgcrypt/libgcrypt-1.2.2/tests/Makefile.in
@@ -1,629 +1,629 @@
1# Makefile.in generated by automake 1.9.4 from Makefile.am. 1# Makefile.in generated by automake 1.9.4 from Makefile.am.
2# @configure_input@ 2# @configure_input@
3 3
4# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 4# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
5# 2003, 2004 Free Software Foundation, Inc. 5# 2003, 2004 Free Software Foundation, Inc.
6# This Makefile.in is free software; the Free Software Foundation 6# This Makefile.in is free software; the Free Software Foundation
7# gives unlimited permission to copy and/or distribute it, 7# gives unlimited permission to copy and/or distribute it,
8# with or without modifications, as long as this notice is preserved. 8# with or without modifications, as long as this notice is preserved.
9 9
10# This program is distributed in the hope that it will be useful, 10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY, to the extent permitted by law; without 11# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
12# even the implied warranty of MERCHANTABILITY or FITNESS FOR A 12# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13# PARTICULAR PURPOSE. 13# PARTICULAR PURPOSE.
14 14
15@SET_MAKE@ 15@SET_MAKE@
16 16
17# Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. 17# Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
18# 18#
19# This file is part of Libgcrypt. 19# This file is part of Libgcrypt.
20# 20#
21# Libgcrypt is free software; you can redistribute it and/or modify 21# Libgcrypt is free software; you can redistribute it and/or modify
22# it under the terms of the GNU Lesser General Public License as 22# it under the terms of the GNU Lesser General Public License as
23# published by the Free Software Foundation; either version 2.1 of 23# published by the Free Software Foundation; either version 2.1 of
24# the License, or (at your option) any later version. 24# the License, or (at your option) any later version.
25# 25#
26# Libgcrypt is distributed in the hope that it will be useful, 26# Libgcrypt is distributed in the hope that it will be useful,
27# but WITHOUT ANY WARRANTY; without even the implied warranty of 27# but WITHOUT ANY WARRANTY; without even the implied warranty of
28# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 28# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29# GNU Lesser General Public License for more details. 29# GNU Lesser General Public License for more details.
30# 30#
31# You should have received a copy of the GNU Lesser General Public 31# You should have received a copy of the GNU Lesser General Public
32# License along with this program; if not, write to the Free Software 32# License along with this program; if not, write to the Free Software
33# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 33# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
34 34
35SOURCES = ac.c basic.c benchmark.c keygen.c prime.c pubkey.c random.c register.c testapi.c tsexp.c 35SOURCES = ac.c basic.c benchmark.c keygen.c prime.c pubkey.c random.c register.c testapi.c tsexp.c
36 36
37srcdir = @srcdir@ 37srcdir = @srcdir@
38top_srcdir = @top_srcdir@ 38top_srcdir = @top_srcdir@
39VPATH = @srcdir@ 39VPATH = @srcdir@
40pkgdatadir = $(datadir)/@PACKAGE@ 40pkgdatadir = $(datadir)/@PACKAGE@
41pkglibdir = $(libdir)/@PACKAGE@ 41pkglibdir = $(libdir)/@PACKAGE@
42pkgincludedir = $(includedir)/@PACKAGE@ 42pkgincludedir = $(includedir)/@PACKAGE@
43top_builddir = .. 43top_builddir = ..
44am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd 44am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
45INSTALL = @INSTALL@ 45INSTALL = @INSTALL@
46install_sh_DATA = $(install_sh) -c -m 644 46install_sh_DATA = $(install_sh) -c -m 644
47install_sh_PROGRAM = $(install_sh) -c 47install_sh_PROGRAM = $(install_sh) -c
48install_sh_SCRIPT = $(install_sh) -c 48install_sh_SCRIPT = $(install_sh) -c
49INSTALL_HEADER = $(INSTALL_DATA) 49INSTALL_HEADER = $(INSTALL_DATA)
50transform = $(program_transform_name) 50transform = $(program_transform_name)
51NORMAL_INSTALL = : 51NORMAL_INSTALL = :
52PRE_INSTALL = : 52PRE_INSTALL = :
53POST_INSTALL = : 53POST_INSTALL = :
54NORMAL_UNINSTALL = : 54NORMAL_UNINSTALL = :
55PRE_UNINSTALL = : 55PRE_UNINSTALL = :
56POST_UNINSTALL = : 56POST_UNINSTALL = :
57build_triplet = @build@ 57build_triplet = @build@
58host_triplet = @host@ 58host_triplet = @host@
59target_triplet = @target@ 59target_triplet = @target@
60EXTRA_PROGRAMS = testapi$(EXEEXT) 60EXTRA_PROGRAMS = testapi$(EXEEXT)
61noinst_PROGRAMS = $(am__EXEEXT_1) 61noinst_PROGRAMS = $(am__EXEEXT_1)
62subdir = tests 62subdir = tests
63DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ChangeLog 63DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ChangeLog
64ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 64ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
65am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ 65am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
66 $(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac 66 $(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
67am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ 67am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
68 $(ACLOCAL_M4) 68 $(ACLOCAL_M4)
69mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs 69mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
70CONFIG_HEADER = $(top_builddir)/config.h 70CONFIG_HEADER = $(top_builddir)/config.h
71CONFIG_CLEAN_FILES = 71CONFIG_CLEAN_FILES =
72am__EXEEXT_1 = prime$(EXEEXT) register$(EXEEXT) ac$(EXEEXT) \ 72am__EXEEXT_1 = prime$(EXEEXT) register$(EXEEXT) ac$(EXEEXT) \
73 basic$(EXEEXT) tsexp$(EXEEXT) keygen$(EXEEXT) pubkey$(EXEEXT) \ 73 basic$(EXEEXT) tsexp$(EXEEXT) keygen$(EXEEXT) pubkey$(EXEEXT) \
74 benchmark$(EXEEXT) random$(EXEEXT) 74 benchmark$(EXEEXT) random$(EXEEXT)
75PROGRAMS = $(noinst_PROGRAMS) 75PROGRAMS = $(noinst_PROGRAMS)
76ac_SOURCES = ac.c 76ac_SOURCES = ac.c
77ac_OBJECTS = ac.$(OBJEXT) 77ac_OBJECTS = ac.$(OBJEXT)
78ac_LDADD = $(LDADD) 78ac_LDADD = $(LDADD)
79ac_DEPENDENCIES = ../src/libgcrypt.la 79ac_DEPENDENCIES = ../src/libgcrypt.la
80basic_SOURCES = basic.c 80basic_SOURCES = basic.c
81basic_OBJECTS = basic.$(OBJEXT) 81basic_OBJECTS = basic.$(OBJEXT)
82basic_LDADD = $(LDADD) 82basic_LDADD = $(LDADD)
83basic_DEPENDENCIES = ../src/libgcrypt.la 83basic_DEPENDENCIES = ../src/libgcrypt.la
84benchmark_SOURCES = benchmark.c 84benchmark_SOURCES = benchmark.c
85benchmark_OBJECTS = benchmark.$(OBJEXT) 85benchmark_OBJECTS = benchmark.$(OBJEXT)
86benchmark_LDADD = $(LDADD) 86benchmark_LDADD = $(LDADD)
87benchmark_DEPENDENCIES = ../src/libgcrypt.la 87benchmark_DEPENDENCIES = ../src/libgcrypt.la
88keygen_SOURCES = keygen.c 88keygen_SOURCES = keygen.c
89keygen_OBJECTS = keygen.$(OBJEXT) 89keygen_OBJECTS = keygen.$(OBJEXT)
90keygen_LDADD = $(LDADD) 90keygen_LDADD = $(LDADD)
91keygen_DEPENDENCIES = ../src/libgcrypt.la 91keygen_DEPENDENCIES = ../src/libgcrypt.la
92prime_SOURCES = prime.c 92prime_SOURCES = prime.c
93prime_OBJECTS = prime.$(OBJEXT) 93prime_OBJECTS = prime.$(OBJEXT)
94prime_LDADD = $(LDADD) 94prime_LDADD = $(LDADD)
95prime_DEPENDENCIES = ../src/libgcrypt.la 95prime_DEPENDENCIES = ../src/libgcrypt.la
96pubkey_SOURCES = pubkey.c 96pubkey_SOURCES = pubkey.c
97pubkey_OBJECTS = pubkey.$(OBJEXT) 97pubkey_OBJECTS = pubkey.$(OBJEXT)
98pubkey_LDADD = $(LDADD) 98pubkey_LDADD = $(LDADD)
99pubkey_DEPENDENCIES = ../src/libgcrypt.la 99pubkey_DEPENDENCIES = ../src/libgcrypt.la
100random_SOURCES = random.c 100random_SOURCES = random.c
101random_OBJECTS = random.$(OBJEXT) 101random_OBJECTS = random.$(OBJEXT)
102random_LDADD = $(LDADD) 102random_LDADD = $(LDADD)
103random_DEPENDENCIES = ../src/libgcrypt.la 103random_DEPENDENCIES = ../src/libgcrypt.la
104register_SOURCES = register.c 104register_SOURCES = register.c
105register_OBJECTS = register.$(OBJEXT) 105register_OBJECTS = register.$(OBJEXT)
106register_LDADD = $(LDADD) 106register_LDADD = $(LDADD)
107register_DEPENDENCIES = ../src/libgcrypt.la 107register_DEPENDENCIES = ../src/libgcrypt.la
108testapi_SOURCES = testapi.c 108testapi_SOURCES = testapi.c
109testapi_OBJECTS = testapi.$(OBJEXT) 109testapi_OBJECTS = testapi.$(OBJEXT)
110testapi_LDADD = $(LDADD) 110testapi_LDADD = $(LDADD)
111testapi_DEPENDENCIES = ../src/libgcrypt.la 111testapi_DEPENDENCIES = ../src/libgcrypt.la
112tsexp_SOURCES = tsexp.c 112tsexp_SOURCES = tsexp.c
113tsexp_OBJECTS = tsexp.$(OBJEXT) 113tsexp_OBJECTS = tsexp.$(OBJEXT)
114tsexp_LDADD = $(LDADD) 114tsexp_LDADD = $(LDADD)
115tsexp_DEPENDENCIES = ../src/libgcrypt.la 115tsexp_DEPENDENCIES = ../src/libgcrypt.la
116DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) 116DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
117depcomp = $(SHELL) $(top_srcdir)/depcomp 117depcomp = $(SHELL) $(top_srcdir)/depcomp
118am__depfiles_maybe = depfiles 118am__depfiles_maybe = depfiles
119COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ 119COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
120 $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) 120 $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
121LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \ 121LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \
122 $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ 122 $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
123 $(AM_CFLAGS) $(CFLAGS) 123 $(AM_CFLAGS) $(CFLAGS)
124CCLD = $(CC) 124CCLD = $(CC)
125LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ 125LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
126 $(AM_LDFLAGS) $(LDFLAGS) -o $@ 126 $(AM_LDFLAGS) $(LDFLAGS) -o $@
127SOURCES = ac.c basic.c benchmark.c keygen.c prime.c pubkey.c random.c \ 127SOURCES = ac.c basic.c benchmark.c keygen.c prime.c pubkey.c random.c \
128 register.c testapi.c tsexp.c 128 register.c testapi.c tsexp.c
129DIST_SOURCES = ac.c basic.c benchmark.c keygen.c prime.c pubkey.c \ 129DIST_SOURCES = ac.c basic.c benchmark.c keygen.c prime.c pubkey.c \
130 random.c register.c testapi.c tsexp.c 130 random.c register.c testapi.c tsexp.c
131ETAGS = etags 131ETAGS = etags
132CTAGS = ctags 132CTAGS = ctags
133DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) 133DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
134ACLOCAL = @ACLOCAL@ 134ACLOCAL = @ACLOCAL@
135AMDEP_FALSE = @AMDEP_FALSE@ 135AMDEP_FALSE = @AMDEP_FALSE@
136AMDEP_TRUE = @AMDEP_TRUE@ 136AMDEP_TRUE = @AMDEP_TRUE@
137AMTAR = @AMTAR@ 137AMTAR = @AMTAR@
138AR = @AR@ 138AR = @AR@
139AUTOCONF = @AUTOCONF@ 139AUTOCONF = @AUTOCONF@
140AUTOHEADER = @AUTOHEADER@ 140AUTOHEADER = @AUTOHEADER@
141AUTOMAKE = @AUTOMAKE@ 141AUTOMAKE = @AUTOMAKE@
142AWK = @AWK@ 142AWK = @AWK@
143CC = @CC@ 143CC = @CC@
144CCAS = @CCAS@ 144CCAS = @CCAS@
145CCASFLAGS = @CCASFLAGS@ 145CCASFLAGS = @CCASFLAGS@
146CCDEPMODE = @CCDEPMODE@ 146CCDEPMODE = @CCDEPMODE@
147CFLAGS = @CFLAGS@ 147CFLAGS = @CFLAGS@
148CPP = @CPP@ 148CPP = @CPP@
149CPPFLAGS = @CPPFLAGS@ 149CPPFLAGS = @CPPFLAGS@
150CROSS_COMPILING_FALSE = @CROSS_COMPILING_FALSE@ 150CROSS_COMPILING_FALSE = @CROSS_COMPILING_FALSE@
151CROSS_COMPILING_TRUE = @CROSS_COMPILING_TRUE@ 151CROSS_COMPILING_TRUE = @CROSS_COMPILING_TRUE@
152CXX = @CXX@ 152CXX = @CXX@
153CXXCPP = @CXXCPP@ 153CXXCPP = @CXXCPP@
154CXXDEPMODE = @CXXDEPMODE@ 154CXXDEPMODE = @CXXDEPMODE@
155CXXFLAGS = @CXXFLAGS@ 155CXXFLAGS = @CXXFLAGS@
156CYGPATH_W = @CYGPATH_W@ 156CYGPATH_W = @CYGPATH_W@
157DEFS = @DEFS@ 157DEFS = @DEFS@
158DEPDIR = @DEPDIR@ 158DEPDIR = @DEPDIR@
159ECHO = @ECHO@ 159ECHO = @ECHO@
160ECHO_C = @ECHO_C@ 160ECHO_C = @ECHO_C@
161ECHO_N = @ECHO_N@ 161ECHO_N = @ECHO_N@
162ECHO_T = @ECHO_T@ 162ECHO_T = @ECHO_T@
163EGREP = @EGREP@ 163EGREP = @EGREP@
164EXEEXT = @EXEEXT@ 164EXEEXT = @EXEEXT@
165F77 = @F77@ 165F77 = @F77@
166FFLAGS = @FFLAGS@ 166FFLAGS = @FFLAGS@
167GCRYPT_CIPHERS = @GCRYPT_CIPHERS@ 167GCRYPT_CIPHERS = @GCRYPT_CIPHERS@
168GCRYPT_DIGESTS = @GCRYPT_DIGESTS@ 168GCRYPT_DIGESTS = @GCRYPT_DIGESTS@
169GCRYPT_PUBKEY_CIPHERS = @GCRYPT_PUBKEY_CIPHERS@ 169GCRYPT_PUBKEY_CIPHERS = @GCRYPT_PUBKEY_CIPHERS@
170GCRYPT_RANDOM = @GCRYPT_RANDOM@ 170GCRYPT_RANDOM = @GCRYPT_RANDOM@
171GPG_ERROR_CFLAGS = @GPG_ERROR_CFLAGS@ 171GPG_ERROR_CFLAGS = @GPG_ERROR_CFLAGS@
172GPG_ERROR_CONFIG = @GPG_ERROR_CONFIG@ 172GPG_ERROR_CONFIG = @GPG_ERROR_CONFIG@
173GPG_ERROR_LIBS = @GPG_ERROR_LIBS@ 173GPG_ERROR_LIBS = @GPG_ERROR_LIBS@
174HAVE_LD_VERSION_SCRIPT_FALSE = @HAVE_LD_VERSION_SCRIPT_FALSE@ 174HAVE_LD_VERSION_SCRIPT_FALSE = @HAVE_LD_VERSION_SCRIPT_FALSE@
175HAVE_LD_VERSION_SCRIPT_TRUE = @HAVE_LD_VERSION_SCRIPT_TRUE@ 175HAVE_LD_VERSION_SCRIPT_TRUE = @HAVE_LD_VERSION_SCRIPT_TRUE@
176INSTALL_DATA = @INSTALL_DATA@ 176INSTALL_DATA = @INSTALL_DATA@
177INSTALL_PROGRAM = @INSTALL_PROGRAM@ 177INSTALL_PROGRAM = @INSTALL_PROGRAM@
178INSTALL_SCRIPT = @INSTALL_SCRIPT@ 178INSTALL_SCRIPT = @INSTALL_SCRIPT@
179INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ 179INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
180LDFLAGS = @LDFLAGS@ 180LDFLAGS = @LDFLAGS@
181LIBGCRYPT_CIPHERS = @LIBGCRYPT_CIPHERS@ 181LIBGCRYPT_CIPHERS = @LIBGCRYPT_CIPHERS@
182LIBGCRYPT_CONFIG_API_VERSION = @LIBGCRYPT_CONFIG_API_VERSION@ 182LIBGCRYPT_CONFIG_API_VERSION = @LIBGCRYPT_CONFIG_API_VERSION@
183LIBGCRYPT_CONFIG_CFLAGS = @LIBGCRYPT_CONFIG_CFLAGS@ 183LIBGCRYPT_CONFIG_CFLAGS = @LIBGCRYPT_CONFIG_CFLAGS@
184LIBGCRYPT_CONFIG_LIBS = @LIBGCRYPT_CONFIG_LIBS@ 184LIBGCRYPT_CONFIG_LIBS = @LIBGCRYPT_CONFIG_LIBS@
185LIBGCRYPT_DIGESTS = @LIBGCRYPT_DIGESTS@ 185LIBGCRYPT_DIGESTS = @LIBGCRYPT_DIGESTS@
186LIBGCRYPT_LT_AGE = @LIBGCRYPT_LT_AGE@ 186LIBGCRYPT_LT_AGE = @LIBGCRYPT_LT_AGE@
187LIBGCRYPT_LT_CURRENT = @LIBGCRYPT_LT_CURRENT@ 187LIBGCRYPT_LT_CURRENT = @LIBGCRYPT_LT_CURRENT@
188LIBGCRYPT_LT_REVISION = @LIBGCRYPT_LT_REVISION@ 188LIBGCRYPT_LT_REVISION = @LIBGCRYPT_LT_REVISION@
189LIBGCRYPT_PUBKEY_CIPHERS = @LIBGCRYPT_PUBKEY_CIPHERS@ 189LIBGCRYPT_PUBKEY_CIPHERS = @LIBGCRYPT_PUBKEY_CIPHERS@
190LIBGCRYPT_THREAD_MODULES = @LIBGCRYPT_THREAD_MODULES@ 190LIBGCRYPT_THREAD_MODULES = @LIBGCRYPT_THREAD_MODULES@
191LIBOBJS = @LIBOBJS@ 191LIBOBJS = @LIBOBJS@
192LIBS = @LIBS@ 192LIBS = @LIBS@
193LIBTOOL = @LIBTOOL@ 193LIBTOOL = @LIBTOOL@
194LN_S = @LN_S@ 194LN_S = @LN_S@
195LTLIBOBJS = @LTLIBOBJS@ 195LTLIBOBJS = @LTLIBOBJS@
196MAINT = @MAINT@ 196MAINT = @MAINT@
197MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@ 197MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
198MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@ 198MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
199MAKEINFO = @MAKEINFO@ 199MAKEINFO = @MAKEINFO@
200MPI_MOD_LIST_LO = @MPI_MOD_LIST_LO@ 200MPI_MOD_LIST_LO = @MPI_MOD_LIST_LO@
201MPI_MOD_LIST_O = @MPI_MOD_LIST_O@ 201MPI_MOD_LIST_O = @MPI_MOD_LIST_O@
202MPI_SFLAGS = @MPI_SFLAGS@ 202MPI_SFLAGS = @MPI_SFLAGS@
203NOEXECSTACK_FLAGS = @NOEXECSTACK_FLAGS@ 203NOEXECSTACK_FLAGS = @NOEXECSTACK_FLAGS@
204OBJEXT = @OBJEXT@ 204OBJEXT = @OBJEXT@
205PACKAGE = @PACKAGE@ 205PACKAGE = @PACKAGE@
206PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ 206PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
207PACKAGE_NAME = @PACKAGE_NAME@ 207PACKAGE_NAME = @PACKAGE_NAME@
208PACKAGE_STRING = @PACKAGE_STRING@ 208PACKAGE_STRING = @PACKAGE_STRING@
209PACKAGE_TARNAME = @PACKAGE_TARNAME@ 209PACKAGE_TARNAME = @PACKAGE_TARNAME@
210PACKAGE_VERSION = @PACKAGE_VERSION@ 210PACKAGE_VERSION = @PACKAGE_VERSION@
211PATH_SEPARATOR = @PATH_SEPARATOR@ 211PATH_SEPARATOR = @PATH_SEPARATOR@
212RANLIB = @RANLIB@ 212RANLIB = @RANLIB@
213SET_MAKE = @SET_MAKE@ 213SET_MAKE = @SET_MAKE@
214SHELL = @SHELL@ 214SHELL = @SHELL@
215STRIP = @STRIP@ 215STRIP = @STRIP@
216VERSION = @VERSION@ 216VERSION = @VERSION@
217ac_ct_AR = @ac_ct_AR@ 217ac_ct_AR = @ac_ct_AR@
218ac_ct_CC = @ac_ct_CC@ 218ac_ct_CC = @ac_ct_CC@
219ac_ct_CXX = @ac_ct_CXX@ 219ac_ct_CXX = @ac_ct_CXX@
220ac_ct_F77 = @ac_ct_F77@ 220ac_ct_F77 = @ac_ct_F77@
221ac_ct_RANLIB = @ac_ct_RANLIB@ 221ac_ct_RANLIB = @ac_ct_RANLIB@
222ac_ct_STRIP = @ac_ct_STRIP@ 222ac_ct_STRIP = @ac_ct_STRIP@
223am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ 223am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
224am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ 224am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
225am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ 225am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
226am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ 226am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
227am__include = @am__include@ 227am__include = @am__include@
228am__leading_dot = @am__leading_dot@ 228am__leading_dot = @am__leading_dot@
229am__quote = @am__quote@ 229am__quote = @am__quote@
230am__tar = @am__tar@ 230am__tar = @am__tar@
231am__untar = @am__untar@ 231am__untar = @am__untar@
232bindir = @bindir@ 232bindir = @bindir@
233build = @build@ 233build = @build@
234build_alias = @build_alias@ 234build_alias = @build_alias@
235build_cpu = @build_cpu@ 235build_cpu = @build_cpu@
236build_os = @build_os@ 236build_os = @build_os@
237build_vendor = @build_vendor@ 237build_vendor = @build_vendor@
238datadir = @datadir@ 238datadir = @datadir@
239exec_prefix = @exec_prefix@ 239exec_prefix = @exec_prefix@
240host = @host@ 240host = @host@
241host_alias = @host_alias@ 241host_alias = @host_alias@
242host_cpu = @host_cpu@ 242host_cpu = @host_cpu@
243host_os = @host_os@ 243host_os = @host_os@
244host_vendor = @host_vendor@ 244host_vendor = @host_vendor@
245includedir = @includedir@ 245includedir = @includedir@
246infodir = @infodir@ 246infodir = @infodir@
247install_sh = @install_sh@ 247install_sh = @install_sh@
248libdir = @libdir@ 248libdir = @libdir@
249libexecdir = @libexecdir@ 249libexecdir = @libexecdir@
250localstatedir = @localstatedir@ 250localstatedir = @localstatedir@
251mandir = @mandir@ 251mandir = @mandir@
252mkdir_p = @mkdir_p@ 252mkdir_p = @mkdir_p@
253oldincludedir = @oldincludedir@ 253oldincludedir = @oldincludedir@
254prefix = @prefix@ 254prefix = @prefix@
255program_transform_name = @program_transform_name@ 255program_transform_name = @program_transform_name@
256sbindir = @sbindir@ 256sbindir = @sbindir@
257sharedstatedir = @sharedstatedir@ 257sharedstatedir = @sharedstatedir@
258sysconfdir = @sysconfdir@ 258sysconfdir = @sysconfdir@
259target = @target@ 259target = @target@
260target_alias = @target_alias@ 260target_alias = @target_alias@
261target_cpu = @target_cpu@ 261target_cpu = @target_cpu@
262target_os = @target_os@ 262target_os = @target_os@
263target_vendor = @target_vendor@ 263target_vendor = @target_vendor@
264TESTS = prime register ac basic tsexp keygen pubkey benchmark random 264TESTS = prime register ac basic tsexp keygen pubkey benchmark random
265INCLUDES = -I$(top_srcdir)/src 265INCLUDES = -I$(top_srcdir)/src
266LDADD = ../src/libgcrypt.la 266LDADD = ../src/libgcrypt.la
267AM_CFLAGS = @GPG_ERROR_CFLAGS@ 267AM_CFLAGS = @GPG_ERROR_CFLAGS@
268all: all-am 268all: all-am
269 269
270.SUFFIXES: 270.SUFFIXES:
271.SUFFIXES: .c .lo .o .obj 271.SUFFIXES: .c .lo .o .obj
272$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) 272$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
273 @for dep in $?; do \ 273 @for dep in $?; do \
274 case '$(am__configure_deps)' in \ 274 case '$(am__configure_deps)' in \
275 *$$dep*) \ 275 *$$dep*) \
276 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ 276 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
277 && exit 0; \ 277 && exit 0; \
278 exit 1;; \ 278 exit 1;; \
279 esac; \ 279 esac; \
280 done; \ 280 done; \
281 echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu tests/Makefile'; \ 281 echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu tests/Makefile'; \
282 cd $(top_srcdir) && \ 282 cd $(top_srcdir) && \
283 $(AUTOMAKE) --gnu tests/Makefile 283 $(AUTOMAKE) --gnu tests/Makefile
284.PRECIOUS: Makefile 284.PRECIOUS: Makefile
285Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status 285Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
286 @case '$?' in \ 286 @case '$?' in \
287 *config.status*) \ 287 *config.status*) \
288 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ 288 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
289 *) \ 289 *) \
290 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ 290 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
291 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ 291 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
292 esac; 292 esac;
293 293
294$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) 294$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
295 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 295 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
296 296
297$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) 297$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
298 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 298 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
299$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) 299$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
300 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 300 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
301 301
302clean-noinstPROGRAMS: 302clean-noinstPROGRAMS:
303 @list='$(noinst_PROGRAMS)'; for p in $$list; do \ 303 @list='$(noinst_PROGRAMS)'; for p in $$list; do \
304 f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ 304 f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
305 echo " rm -f $$p $$f"; \ 305 echo " rm -f $$p $$f"; \
306 rm -f $$p $$f ; \ 306 rm -f $$p $$f ; \
307 done 307 done
308ac$(EXEEXT): $(ac_OBJECTS) $(ac_DEPENDENCIES) 308ac$(EXEEXT): $(ac_OBJECTS) $(ac_DEPENDENCIES)
309 @rm -f ac$(EXEEXT) 309 @rm -f ac$(EXEEXT)
310 $(LINK) $(ac_LDFLAGS) $(ac_OBJECTS) $(ac_LDADD) $(LIBS) 310 $(LINK) $(ac_LDFLAGS) $(ac_OBJECTS) $(ac_LDADD) $(LIBS)
311basic$(EXEEXT): $(basic_OBJECTS) $(basic_DEPENDENCIES) 311basic$(EXEEXT): $(basic_OBJECTS) $(basic_DEPENDENCIES)
312 @rm -f basic$(EXEEXT) 312 @rm -f basic$(EXEEXT)
313 $(LINK) $(basic_LDFLAGS) $(basic_OBJECTS) $(basic_LDADD) $(LIBS) 313 $(LINK) $(basic_LDFLAGS) $(basic_OBJECTS) $(basic_LDADD) $(LIBS)
314benchmark$(EXEEXT): $(benchmark_OBJECTS) $(benchmark_DEPENDENCIES) 314benchmark$(EXEEXT): $(benchmark_OBJECTS) $(benchmark_DEPENDENCIES)
315 @rm -f benchmark$(EXEEXT) 315 @rm -f benchmark$(EXEEXT)
316 $(LINK) $(benchmark_LDFLAGS) $(benchmark_OBJECTS) $(benchmark_LDADD) $(LIBS) 316 $(LINK) $(benchmark_LDFLAGS) $(benchmark_OBJECTS) $(benchmark_LDADD) $(LIBS)
317keygen$(EXEEXT): $(keygen_OBJECTS) $(keygen_DEPENDENCIES) 317keygen$(EXEEXT): $(keygen_OBJECTS) $(keygen_DEPENDENCIES)
318 @rm -f keygen$(EXEEXT) 318 @rm -f keygen$(EXEEXT)
319 $(LINK) $(keygen_LDFLAGS) $(keygen_OBJECTS) $(keygen_LDADD) $(LIBS) 319 $(LINK) $(keygen_LDFLAGS) $(keygen_OBJECTS) $(keygen_LDADD) $(LIBS)
320prime$(EXEEXT): $(prime_OBJECTS) $(prime_DEPENDENCIES) 320prime$(EXEEXT): $(prime_OBJECTS) $(prime_DEPENDENCIES)
321 @rm -f prime$(EXEEXT) 321 @rm -f prime$(EXEEXT)
322 $(LINK) $(prime_LDFLAGS) $(prime_OBJECTS) $(prime_LDADD) $(LIBS) 322 $(LINK) $(prime_LDFLAGS) $(prime_OBJECTS) $(prime_LDADD) $(LIBS)
323pubkey$(EXEEXT): $(pubkey_OBJECTS) $(pubkey_DEPENDENCIES) 323pubkey$(EXEEXT): $(pubkey_OBJECTS) $(pubkey_DEPENDENCIES)
324 @rm -f pubkey$(EXEEXT) 324 @rm -f pubkey$(EXEEXT)
325 $(LINK) $(pubkey_LDFLAGS) $(pubkey_OBJECTS) $(pubkey_LDADD) $(LIBS) 325 $(LINK) $(pubkey_LDFLAGS) $(pubkey_OBJECTS) $(pubkey_LDADD) $(LIBS)
326random$(EXEEXT): $(random_OBJECTS) $(random_DEPENDENCIES) 326random$(EXEEXT): $(random_OBJECTS) $(random_DEPENDENCIES)
327 @rm -f random$(EXEEXT) 327 @rm -f random$(EXEEXT)
328 $(LINK) $(random_LDFLAGS) $(random_OBJECTS) $(random_LDADD) $(LIBS) 328 $(LINK) $(random_LDFLAGS) $(random_OBJECTS) $(random_LDADD) $(LIBS)
329register$(EXEEXT): $(register_OBJECTS) $(register_DEPENDENCIES) 329register$(EXEEXT): $(register_OBJECTS) $(register_DEPENDENCIES)
330 @rm -f register$(EXEEXT) 330 @rm -f register$(EXEEXT)
331 $(LINK) $(register_LDFLAGS) $(register_OBJECTS) $(register_LDADD) $(LIBS) 331 $(LINK) $(register_LDFLAGS) $(register_OBJECTS) $(register_LDADD) $(LIBS)
332testapi$(EXEEXT): $(testapi_OBJECTS) $(testapi_DEPENDENCIES) 332testapi$(EXEEXT): $(testapi_OBJECTS) $(testapi_DEPENDENCIES)
333 @rm -f testapi$(EXEEXT) 333 @rm -f testapi$(EXEEXT)
334 $(LINK) $(testapi_LDFLAGS) $(testapi_OBJECTS) $(testapi_LDADD) $(LIBS) 334 $(LINK) $(testapi_LDFLAGS) $(testapi_OBJECTS) $(testapi_LDADD) $(LIBS)
335tsexp$(EXEEXT): $(tsexp_OBJECTS) $(tsexp_DEPENDENCIES) 335tsexp$(EXEEXT): $(tsexp_OBJECTS) $(tsexp_DEPENDENCIES)
336 @rm -f tsexp$(EXEEXT) 336 @rm -f tsexp$(EXEEXT)
337 $(LINK) $(tsexp_LDFLAGS) $(tsexp_OBJECTS) $(tsexp_LDADD) $(LIBS) 337 $(LINK) $(tsexp_LDFLAGS) $(tsexp_OBJECTS) $(tsexp_LDADD) $(LIBS)
338 338
339mostlyclean-compile: 339mostlyclean-compile:
340 -rm -f *.$(OBJEXT) 340 -rm -f *.$(OBJEXT)
341 341
342distclean-compile: 342distclean-compile:
343 -rm -f *.tab.c 343 -rm -f *.tab.c
344 344
345@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ac.Po@am__quote@ 345@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ac.Po@am__quote@
346@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/basic.Po@am__quote@ 346@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/basic.Po@am__quote@
347@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/benchmark.Po@am__quote@ 347@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/benchmark.Po@am__quote@
348@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/keygen.Po@am__quote@ 348@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/keygen.Po@am__quote@
349@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/prime.Po@am__quote@ 349@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/prime.Po@am__quote@
350@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pubkey.Po@am__quote@ 350@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pubkey.Po@am__quote@
351@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/random.Po@am__quote@ 351@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/random.Po@am__quote@
352@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/register.Po@am__quote@ 352@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/register.Po@am__quote@
353@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testapi.Po@am__quote@ 353@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testapi.Po@am__quote@
354@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tsexp.Po@am__quote@ 354@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tsexp.Po@am__quote@
355 355
356.c.o: 356.c.o:
357@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ 357@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
358@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi 358@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
359@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ 359@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
360@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 360@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
361@am__fastdepCC_FALSE@ $(COMPILE) -c $< 361@am__fastdepCC_FALSE@ $(COMPILE) -c $<
362 362
363.c.obj: 363.c.obj:
364@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ 364@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
365@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi 365@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
366@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ 366@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
367@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 367@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
368@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` 368@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
369 369
370.c.lo: 370.c.lo:
371@am__fastdepCC_TRUE@ if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ 371@am__fastdepCC_TRUE@ if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
372@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi 372@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
373@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ 373@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
374@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 374@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
375@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< 375@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
376 376
377mostlyclean-libtool: 377mostlyclean-libtool:
378 -rm -f *.lo 378 -rm -f *.lo
379 379
380clean-libtool: 380clean-libtool:
381 -rm -rf .libs _libs 381 -rm -rf .libs _libs
382 382
383distclean-libtool: 383distclean-libtool:
384 -rm -f libtool 384 -rm -f libtool
385uninstall-info-am: 385uninstall-info-am:
386 386
387ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) 387ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
388 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ 388 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
389 unique=`for i in $$list; do \ 389 unique=`for i in $$list; do \
390 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ 390 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
391 done | \ 391 done | \
392 $(AWK) ' { files[$$0] = 1; } \ 392 $(AWK) ' { files[$$0] = 1; } \
393 END { for (i in files) print i; }'`; \ 393 END { for (i in files) print i; }'`; \
394 mkid -fID $$unique 394 mkid -fID $$unique
395tags: TAGS 395tags: TAGS
396 396
397TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ 397TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
398 $(TAGS_FILES) $(LISP) 398 $(TAGS_FILES) $(LISP)
399 tags=; \ 399 tags=; \
400 here=`pwd`; \ 400 here=`pwd`; \
401 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ 401 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
402 unique=`for i in $$list; do \ 402 unique=`for i in $$list; do \
403 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ 403 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
404 done | \ 404 done | \
405 $(AWK) ' { files[$$0] = 1; } \ 405 $(AWK) ' { files[$$0] = 1; } \
406 END { for (i in files) print i; }'`; \ 406 END { for (i in files) print i; }'`; \
407 if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ 407 if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
408 test -n "$$unique" || unique=$$empty_fix; \ 408 test -n "$$unique" || unique=$$empty_fix; \
409 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ 409 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
410 $$tags $$unique; \ 410 $$tags $$unique; \
411 fi 411 fi
412ctags: CTAGS 412ctags: CTAGS
413CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ 413CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
414 $(TAGS_FILES) $(LISP) 414 $(TAGS_FILES) $(LISP)
415 tags=; \ 415 tags=; \
416 here=`pwd`; \ 416 here=`pwd`; \
417 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ 417 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
418 unique=`for i in $$list; do \ 418 unique=`for i in $$list; do \
419 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ 419 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
420 done | \ 420 done | \
421 $(AWK) ' { files[$$0] = 1; } \ 421 $(AWK) ' { files[$$0] = 1; } \
422 END { for (i in files) print i; }'`; \ 422 END { for (i in files) print i; }'`; \
423 test -z "$(CTAGS_ARGS)$$tags$$unique" \ 423 test -z "$(CTAGS_ARGS)$$tags$$unique" \
424 || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ 424 || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
425 $$tags $$unique 425 $$tags $$unique
426 426
427GTAGS: 427GTAGS:
428 here=`$(am__cd) $(top_builddir) && pwd` \ 428 here=`$(am__cd) $(top_builddir) && pwd` \
429 && cd $(top_srcdir) \ 429 && cd $(top_srcdir) \
430 && gtags -i $(GTAGS_ARGS) $$here 430 && gtags -i $(GTAGS_ARGS) $$here
431 431
432distclean-tags: 432distclean-tags:
433 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags 433 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
434 434
435check-TESTS: $(TESTS) 435check-TESTS: $(TESTS)
436 @failed=0; all=0; xfail=0; xpass=0; skip=0; \ 436 @failed=0; all=0; xfail=0; xpass=0; skip=0; \
437 srcdir=$(srcdir); export srcdir; \ 437 srcdir=$(srcdir); export srcdir; \
438 list='$(TESTS)'; \ 438 list='$(TESTS)'; \
439 if test -n "$$list"; then \ 439 if test -n "$$list"; then \
440 for tst in $$list; do \ 440 for tst in $$list; do \
441 if test -f ./$$tst; then dir=./; \ 441 if test -f ./$$tst; then dir=./; \
442 elif test -f $$tst; then dir=; \ 442 elif test -f $$tst; then dir=; \
443 else dir="$(srcdir)/"; fi; \ 443 else dir="$(srcdir)/"; fi; \
444 if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ 444 if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \
445 all=`expr $$all + 1`; \ 445 all=`expr $$all + 1`; \
446 case " $(XFAIL_TESTS) " in \ 446 case " $(XFAIL_TESTS) " in \
447 *" $$tst "*) \ 447 *" $$tst "*) \
448 xpass=`expr $$xpass + 1`; \ 448 xpass=`expr $$xpass + 1`; \
449 failed=`expr $$failed + 1`; \ 449 failed=`expr $$failed + 1`; \
450 echo "XPASS: $$tst"; \ 450 echo "XPASS: $$tst"; \
451 ;; \ 451 ;; \
452 *) \ 452 *) \
453 echo "PASS: $$tst"; \ 453 echo "PASS: $$tst"; \
454 ;; \ 454 ;; \
455 esac; \ 455 esac; \
456 elif test $$? -ne 77; then \ 456 elif test $$? -ne 77; then \
457 all=`expr $$all + 1`; \ 457 all=`expr $$all + 1`; \
458 case " $(XFAIL_TESTS) " in \ 458 case " $(XFAIL_TESTS) " in \
459 *" $$tst "*) \ 459 *" $$tst "*) \
460 xfail=`expr $$xfail + 1`; \ 460 xfail=`expr $$xfail + 1`; \
461 echo "XFAIL: $$tst"; \ 461 echo "XFAIL: $$tst"; \
462 ;; \ 462 ;; \
463 *) \ 463 *) \
464 failed=`expr $$failed + 1`; \ 464 failed=`expr $$failed + 1`; \
465 echo "FAIL: $$tst"; \ 465 echo "FAIL: $$tst"; \
466 ;; \ 466 ;; \
467 esac; \ 467 esac; \
468 else \ 468 else \
469 skip=`expr $$skip + 1`; \ 469 skip=`expr $$skip + 1`; \
470 echo "SKIP: $$tst"; \ 470 echo "SKIP: $$tst"; \
471 fi; \ 471 fi; \
472 done; \ 472 done; \
473 if test "$$failed" -eq 0; then \ 473 if test "$$failed" -eq 0; then \
474 if test "$$xfail" -eq 0; then \ 474 if test "$$xfail" -eq 0; then \
475 banner="All $$all tests passed"; \ 475 banner="All $$all tests passed"; \
476 else \ 476 else \
477 banner="All $$all tests behaved as expected ($$xfail expected failures)"; \ 477 banner="All $$all tests behaved as expected ($$xfail expected failures)"; \
478 fi; \ 478 fi; \
479 else \ 479 else \
480 if test "$$xpass" -eq 0; then \ 480 if test "$$xpass" -eq 0; then \
481 banner="$$failed of $$all tests failed"; \ 481 banner="$$failed of $$all tests failed"; \
482 else \ 482 else \
483 banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \ 483 banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \
484 fi; \ 484 fi; \
485 fi; \ 485 fi; \
486 dashes="$$banner"; \ 486 dashes="$$banner"; \
487 skipped=""; \ 487 skipped=""; \
488 if test "$$skip" -ne 0; then \ 488 if test "$$skip" -ne 0; then \
489 skipped="($$skip tests were not run)"; \ 489 skipped="($$skip tests were not run)"; \
490 test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \ 490 test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
491 dashes="$$skipped"; \ 491 dashes="$$skipped"; \
492 fi; \ 492 fi; \
493 report=""; \ 493 report=""; \
494 if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \ 494 if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
495 report="Please report to $(PACKAGE_BUGREPORT)"; \ 495 report="Please report to $(PACKAGE_BUGREPORT)"; \
496 test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \ 496 test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
497 dashes="$$report"; \ 497 dashes="$$report"; \
498 fi; \ 498 fi; \
499 dashes=`echo "$$dashes" | sed s/./=/g`; \ 499 dashes=`echo "$$dashes" | sed s/./=/g`; \
500 echo "$$dashes"; \ 500 echo "$$dashes"; \
501 echo "$$banner"; \ 501 echo "$$banner"; \
502 test -z "$$skipped" || echo "$$skipped"; \ 502 test -z "$$skipped" || echo "$$skipped"; \
503 test -z "$$report" || echo "$$report"; \ 503 test -z "$$report" || echo "$$report"; \
504 echo "$$dashes"; \ 504 echo "$$dashes"; \
505 test "$$failed" -eq 0; \ 505 test "$$failed" -eq 0; \
506 else :; fi 506 else :; fi
507 507
508distdir: $(DISTFILES) 508distdir: $(DISTFILES)
509 @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ 509 @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
510 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ 510 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
511 list='$(DISTFILES)'; for file in $$list; do \ 511 list='$(DISTFILES)'; for file in $$list; do \
512 case $$file in \ 512 case $$file in \
513 $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ 513 $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
514 $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ 514 $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
515 esac; \ 515 esac; \
516 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ 516 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
517 dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ 517 dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
518 if test "$$dir" != "$$file" && test "$$dir" != "."; then \ 518 if test "$$dir" != "$$file" && test "$$dir" != "."; then \
519 dir="/$$dir"; \ 519 dir="/$$dir"; \
520 $(mkdir_p) "$(distdir)$$dir"; \ 520 $(mkdir_p) "$(distdir)$$dir"; \
521 else \ 521 else \
522 dir=''; \ 522 dir=''; \
523 fi; \ 523 fi; \
524 if test -d $$d/$$file; then \ 524 if test -d $$d/$$file; then \
525 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ 525 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
526 cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ 526 cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
527 fi; \ 527 fi; \
528 cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ 528 cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
529 else \ 529 else \
530 test -f $(distdir)/$$file \ 530 test -f $(distdir)/$$file \
531 || cp -p $$d/$$file $(distdir)/$$file \ 531 || cp -p $$d/$$file $(distdir)/$$file \
532 || exit 1; \ 532 || exit 1; \
533 fi; \ 533 fi; \
534 done 534 done
535check-am: all-am 535check-am: all-am
536 $(MAKE) $(AM_MAKEFLAGS) check-TESTS 536 $(MAKE) $(AM_MAKEFLAGS) check-TESTS
537check: check-am 537check: check-am
538all-am: Makefile $(PROGRAMS) 538all-am: Makefile $(PROGRAMS)
539installdirs: 539installdirs:
540install: install-am 540install: install-am
541install-exec: install-exec-am 541install-exec: install-exec-am
542install-data: install-data-am 542install-data: install-data-am
543uninstall: uninstall-am 543uninstall: uninstall-am
544 544
545install-am: all-am 545install-am: all-am
546 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am 546 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
547 547
548installcheck: installcheck-am 548installcheck: installcheck-am
549install-strip: 549install-strip:
550 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ 550 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
551 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ 551 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
552 `test -z '$(STRIP)' || \ 552 `test -z '$(STRIP)' || \
553 echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install 553 echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
554mostlyclean-generic: 554mostlyclean-generic:
555 555
556clean-generic: 556clean-generic:
557 557
558distclean-generic: 558distclean-generic:
559 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) 559 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
560 560
561maintainer-clean-generic: 561maintainer-clean-generic:
562 @echo "This command is intended for maintainers to use" 562 @echo "This command is intended for maintainers to use"
563 @echo "it deletes files that may require special tools to rebuild." 563 @echo "it deletes files that may require special tools to rebuild."
564clean: clean-am 564clean: clean-am
565 565
566clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \ 566clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \
567 mostlyclean-am 567 mostlyclean-am
568 568
569distclean: distclean-am 569distclean: distclean-am
570 -rm -rf ./$(DEPDIR) 570 -rm -rf ./$(DEPDIR)
571 -rm -f Makefile 571 -rm -f Makefile
572distclean-am: clean-am distclean-compile distclean-generic \ 572distclean-am: clean-am distclean-compile distclean-generic \
573 distclean-libtool distclean-tags 573 distclean-libtool distclean-tags
574 574
575dvi: dvi-am 575dvi: dvi-am
576 576
577dvi-am: 577dvi-am:
578 578
579html: html-am 579html: html-am
580 580
581info: info-am 581info: info-am
582 582
583info-am: 583info-am:
584 584
585install-data-am: 585install-data-am:
586 586
587install-exec-am: 587install-exec-am:
588 588
589install-info: install-info-am 589install-info: install-info-am
590 590
591install-man: 591install-man:
592 592
593installcheck-am: 593installcheck-am:
594 594
595maintainer-clean: maintainer-clean-am 595maintainer-clean: maintainer-clean-am
596 -rm -rf ./$(DEPDIR) 596 -rm -rf ./$(DEPDIR)
597 -rm -f Makefile 597 -rm -f Makefile
598maintainer-clean-am: distclean-am maintainer-clean-generic 598maintainer-clean-am: distclean-am maintainer-clean-generic
599 599
600mostlyclean: mostlyclean-am 600mostlyclean: mostlyclean-am
601 601
602mostlyclean-am: mostlyclean-compile mostlyclean-generic \ 602mostlyclean-am: mostlyclean-compile mostlyclean-generic \
603 mostlyclean-libtool 603 mostlyclean-libtool
604 604
605pdf: pdf-am 605pdf: pdf-am
606 606
607pdf-am: 607pdf-am:
608 608
609ps: ps-am 609ps: ps-am
610 610
611ps-am: 611ps-am:
612 612
613uninstall-am: uninstall-info-am 613uninstall-am: uninstall-info-am
614 614
615.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \ 615.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \
616 clean-generic clean-libtool clean-noinstPROGRAMS ctags \ 616 clean-generic clean-libtool clean-noinstPROGRAMS ctags \
617 distclean distclean-compile distclean-generic \ 617 distclean distclean-compile distclean-generic \
618 distclean-libtool distclean-tags distdir dvi dvi-am html \ 618 distclean-libtool distclean-tags distdir dvi dvi-am html \
619 html-am info info-am install install-am install-data \ 619 html-am info info-am install install-am install-data \
620 install-data-am install-exec install-exec-am install-info \ 620 install-data-am install-exec install-exec-am install-info \
621 install-info-am install-man install-strip installcheck \ 621 install-info-am install-man install-strip installcheck \
622 installcheck-am installdirs maintainer-clean \ 622 installcheck-am installdirs maintainer-clean \
623 maintainer-clean-generic mostlyclean mostlyclean-compile \ 623 maintainer-clean-generic mostlyclean mostlyclean-compile \
624 mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ 624 mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
625 tags uninstall uninstall-am uninstall-info-am 625 tags uninstall uninstall-am uninstall-info-am
626 626
627# Tell versions [3.59,3.63) of GNU make to not export all variables. 627# Tell versions [3.59,3.63) of GNU make to not export all variables.
628# Otherwise a system limit (for SysV at least) may be exceeded. 628# Otherwise a system limit (for SysV at least) may be exceeded.
629.NOEXPORT: 629.NOEXPORT:
diff --git a/linden/indra/libgcrypt/libgcrypt-1.2.2/tests/ac.c b/linden/indra/libgcrypt/libgcrypt-1.2.2/tests/ac.c
index 31d393b..de37a2c 100755..100644
--- a/linden/indra/libgcrypt/libgcrypt-1.2.2/tests/ac.c
+++ b/linden/indra/libgcrypt/libgcrypt-1.2.2/tests/ac.c
@@ -1,157 +1,157 @@
1/* pubkey.c - Public key encryption/decryption tests 1/* pubkey.c - Public key encryption/decryption tests
2 * Copyright (C) 2003 Free Software Foundation, Inc. 2 * Copyright (C) 2003 Free Software Foundation, Inc.
3 * 3 *
4 * This file is part of Libgcrypt. 4 * This file is part of Libgcrypt.
5 * 5 *
6 * Libgcrypt is free software; you can redistribute it and/or modify 6 * Libgcrypt is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as 7 * it under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation; either version 2.1 of 8 * published by the Free Software Foundation; either version 2.1 of
9 * the License, or (at your option) any later version. 9 * the License, or (at your option) any later version.
10 * 10 *
11 * Libgcrypt is distributed in the hope that it will be useful, 11 * Libgcrypt is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details. 14 * GNU Lesser General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU Lesser General Public 16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this program; if not, write to the Free Software 17 * License along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
19 */ 19 */
20 20
21#include <stdarg.h> 21#include <stdarg.h>
22#include <stdio.h> 22#include <stdio.h>
23#include <stdlib.h> 23#include <stdlib.h>
24#include <string.h> 24#include <string.h>
25#include <assert.h> 25#include <assert.h>
26 26
27#include "../src/gcrypt.h" 27#include "../src/gcrypt.h"
28 28
29static int verbose; 29static int verbose;
30 30
31static void 31static void
32die (const char *format, ...) 32die (const char *format, ...)
33{ 33{
34 va_list arg_ptr ; 34 va_list arg_ptr ;
35 35
36 va_start( arg_ptr, format ) ; 36 va_start( arg_ptr, format ) ;
37 vfprintf (stderr, format, arg_ptr ); 37 vfprintf (stderr, format, arg_ptr );
38 va_end(arg_ptr); 38 va_end(arg_ptr);
39 exit (1); 39 exit (1);
40} 40}
41 41
42void 42void
43key_copy (gcry_ac_handle_t handle, 43key_copy (gcry_ac_handle_t handle,
44 gcry_ac_key_type_t type, 44 gcry_ac_key_type_t type,
45 gcry_ac_key_t *key_cp, gcry_ac_key_t key) 45 gcry_ac_key_t *key_cp, gcry_ac_key_t key)
46{ 46{
47 gcry_error_t err = 0; 47 gcry_error_t err = 0;
48 48
49 err = gcry_ac_key_init (key_cp, handle, type, 49 err = gcry_ac_key_init (key_cp, handle, type,
50 gcry_ac_key_data_get (key)); 50 gcry_ac_key_data_get (key));
51 51
52 assert (! err); 52 assert (! err);
53} 53}
54 54
55void 55void
56check_one (gcry_mpi_t x) 56check_one (gcry_mpi_t x)
57{ 57{
58 gcry_ac_handle_t handle; 58 gcry_ac_handle_t handle;
59 gcry_ac_key_pair_t key_pair; 59 gcry_ac_key_pair_t key_pair;
60 gcry_ac_key_t key_sec, key_sec_cp, key_pub, key_pub_cp; 60 gcry_ac_key_t key_sec, key_sec_cp, key_pub, key_pub_cp;
61 gcry_error_t err = 0; 61 gcry_error_t err = 0;
62 gcry_mpi_t x2; 62 gcry_mpi_t x2;
63 gcry_ac_data_t data, data2; 63 gcry_ac_data_t data, data2;
64 gcry_ac_key_spec_rsa_t rsa_spec; 64 gcry_ac_key_spec_rsa_t rsa_spec;
65 65
66 rsa_spec.e = gcry_mpi_new (0); 66 rsa_spec.e = gcry_mpi_new (0);
67 gcry_mpi_set_ui (rsa_spec.e, 1); 67 gcry_mpi_set_ui (rsa_spec.e, 1);
68 68
69 err = gcry_ac_open (&handle, GCRY_AC_RSA, 0); 69 err = gcry_ac_open (&handle, GCRY_AC_RSA, 0);
70 assert (! err); 70 assert (! err);
71 71
72 err = gcry_ac_key_pair_generate (handle, 1024, &rsa_spec, &key_pair, NULL); 72 err = gcry_ac_key_pair_generate (handle, 1024, &rsa_spec, &key_pair, NULL);
73 assert (! err); 73 assert (! err);
74 74
75 key_sec = gcry_ac_key_pair_extract (key_pair, GCRY_AC_KEY_SECRET); 75 key_sec = gcry_ac_key_pair_extract (key_pair, GCRY_AC_KEY_SECRET);
76 key_copy (handle, GCRY_AC_KEY_SECRET, &key_sec_cp, key_sec); 76 key_copy (handle, GCRY_AC_KEY_SECRET, &key_sec_cp, key_sec);
77 77
78 key_pub = gcry_ac_key_pair_extract (key_pair, GCRY_AC_KEY_PUBLIC); 78 key_pub = gcry_ac_key_pair_extract (key_pair, GCRY_AC_KEY_PUBLIC);
79 key_copy (handle, GCRY_AC_KEY_PUBLIC, &key_pub_cp, key_pub); 79 key_copy (handle, GCRY_AC_KEY_PUBLIC, &key_pub_cp, key_pub);
80 80
81 err = gcry_ac_data_encrypt (handle, GCRY_AC_FLAG_NO_BLINDING, key_pub_cp, x, &data); 81 err = gcry_ac_data_encrypt (handle, GCRY_AC_FLAG_NO_BLINDING, key_pub_cp, x, &data);
82 assert (! err); 82 assert (! err);
83 83
84 err = gcry_ac_data_decrypt (handle, GCRY_AC_FLAG_NO_BLINDING, key_sec_cp, &x2, data); 84 err = gcry_ac_data_decrypt (handle, GCRY_AC_FLAG_NO_BLINDING, key_sec_cp, &x2, data);
85 assert (! err); 85 assert (! err);
86 86
87 assert (! gcry_mpi_cmp (x, x2)); 87 assert (! gcry_mpi_cmp (x, x2));
88 88
89 gcry_ac_data_destroy (data); 89 gcry_ac_data_destroy (data);
90 90
91 err = gcry_ac_data_sign (handle, key_sec, x, &data); 91 err = gcry_ac_data_sign (handle, key_sec, x, &data);
92 assert (! err); 92 assert (! err);
93 err = gcry_ac_data_copy (&data2, data); 93 err = gcry_ac_data_copy (&data2, data);
94 assert (! err); 94 assert (! err);
95 gcry_ac_data_destroy (data); 95 gcry_ac_data_destroy (data);
96 err = gcry_ac_data_copy (&data, data2); 96 err = gcry_ac_data_copy (&data, data2);
97 assert (! err); 97 assert (! err);
98 gcry_ac_data_destroy (data2); 98 gcry_ac_data_destroy (data2);
99 99
100 err = gcry_ac_data_verify (handle, key_pub, x, data); 100 err = gcry_ac_data_verify (handle, key_pub, x, data);
101 assert (! err); 101 assert (! err);
102 102
103 gcry_ac_data_destroy (data); 103 gcry_ac_data_destroy (data);
104 104
105 err = gcry_ac_data_sign (handle, key_sec, x, &data); 105 err = gcry_ac_data_sign (handle, key_sec, x, &data);
106 assert (! err); 106 assert (! err);
107 { 107 {
108 const char *label; 108 const char *label;
109 gcry_mpi_t y; 109 gcry_mpi_t y;
110 110
111 err = gcry_ac_data_get_index (data, 0, 0, &label, &y); 111 err = gcry_ac_data_get_index (data, 0, 0, &label, &y);
112 assert (! err); 112 assert (! err);
113 gcry_mpi_add_ui (y, y, 1); 113 gcry_mpi_add_ui (y, y, 1);
114 114
115 err = gcry_ac_data_verify (handle, key_pub, x, data); 115 err = gcry_ac_data_verify (handle, key_pub, x, data);
116 assert (gcry_err_code (err) == GPG_ERR_BAD_SIGNATURE); 116 assert (gcry_err_code (err) == GPG_ERR_BAD_SIGNATURE);
117 } 117 }
118 118
119 gcry_ac_close (handle); 119 gcry_ac_close (handle);
120} 120}
121 121
122void 122void
123check_run (void) 123check_run (void)
124{ 124{
125 /*const char *s = "All Hail Discordia."; -- not used */ 125 /*const char *s = "All Hail Discordia."; -- not used */
126 unsigned int a = 0x4223; 126 unsigned int a = 0x4223;
127 gcry_mpi_t x; 127 gcry_mpi_t x;
128 128
129 x = gcry_mpi_new (0); 129 x = gcry_mpi_new (0);
130 gcry_mpi_set_ui (x, a); 130 gcry_mpi_set_ui (x, a);
131 check_one (x); 131 check_one (x);
132 gcry_mpi_release (x); 132 gcry_mpi_release (x);
133} 133}
134 134
135int 135int
136main (int argc, char **argv) 136main (int argc, char **argv)
137{ 137{
138 int debug = 0; 138 int debug = 0;
139 int i = 1; 139 int i = 1;
140 140
141 if (argc > 1 && !strcmp (argv[1], "--verbose")) 141 if (argc > 1 && !strcmp (argv[1], "--verbose"))
142 verbose = 1; 142 verbose = 1;
143 else if (argc > 1 && !strcmp (argv[1], "--debug")) 143 else if (argc > 1 && !strcmp (argv[1], "--debug"))
144 verbose = debug = 1; 144 verbose = debug = 1;
145 145
146 gcry_control (GCRYCTL_DISABLE_SECMEM, 0); 146 gcry_control (GCRYCTL_DISABLE_SECMEM, 0);
147 if (!gcry_check_version (GCRYPT_VERSION)) 147 if (!gcry_check_version (GCRYPT_VERSION))
148 die ("version mismatch\n"); 148 die ("version mismatch\n");
149 gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); 149 gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
150 if (debug) 150 if (debug)
151 gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1u , 0); 151 gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1u , 0);
152 152
153 for (; i > 0; i--) 153 for (; i > 0; i--)
154 check_run (); 154 check_run ();
155 155
156 return 0; 156 return 0;
157} 157}
diff --git a/linden/indra/libgcrypt/libgcrypt-1.2.2/tests/basic.c b/linden/indra/libgcrypt/libgcrypt-1.2.2/tests/basic.c
index 1b8a314..9c4e5fa 100755..100644
--- a/linden/indra/libgcrypt/libgcrypt-1.2.2/tests/basic.c
+++ b/linden/indra/libgcrypt/libgcrypt-1.2.2/tests/basic.c
@@ -1,1092 +1,1092 @@
1/* basic.c - basic regression tests 1/* basic.c - basic regression tests
2 * Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. 2 * Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
3 * 3 *
4 * This file is part of Libgcrypt. 4 * This file is part of Libgcrypt.
5 * 5 *
6 * Libgcrypt is free software; you can redistribute it and/or modify 6 * Libgcrypt is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as 7 * it under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation; either version 2.1 of 8 * published by the Free Software Foundation; either version 2.1 of
9 * the License, or (at your option) any later version. 9 * the License, or (at your option) any later version.
10 * 10 *
11 * Libgcrypt is distributed in the hope that it will be useful, 11 * Libgcrypt is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details. 14 * GNU Lesser General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU Lesser General Public 16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this program; if not, write to the Free Software 17 * License along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
19 */ 19 */
20 20
21#include <stdio.h> 21#include <stdio.h>
22#include <stdlib.h> 22#include <stdlib.h>
23#include <string.h> 23#include <string.h>
24#include <stdarg.h> 24#include <stdarg.h>
25 25
26#include "../src/gcrypt.h" 26#include "../src/gcrypt.h"
27 27
28typedef struct test_spec_pubkey_key 28typedef struct test_spec_pubkey_key
29{ 29{
30 const char *secret; 30 const char *secret;
31 const char *public; 31 const char *public;
32 const unsigned char *grip; 32 const unsigned char *grip;
33} 33}
34test_spec_pubkey_key_t; 34test_spec_pubkey_key_t;
35 35
36typedef struct test_spec_pubkey 36typedef struct test_spec_pubkey
37{ 37{
38 int id; 38 int id;
39 int flags; 39 int flags;
40 test_spec_pubkey_key_t key; 40 test_spec_pubkey_key_t key;
41} 41}
42test_spec_pubkey_t; 42test_spec_pubkey_t;
43 43
44#define FLAG_CRYPT (1 << 0) 44#define FLAG_CRYPT (1 << 0)
45#define FLAG_SIGN (1 << 1) 45#define FLAG_SIGN (1 << 1)
46#define FLAG_GRIP (1 << 2) 46#define FLAG_GRIP (1 << 2)
47 47
48static int verbose; 48static int verbose;
49static int error_count; 49static int error_count;
50 50
51static void 51static void
52fail (const char *format, ...) 52fail (const char *format, ...)
53{ 53{
54 va_list arg_ptr; 54 va_list arg_ptr;
55 55
56 va_start (arg_ptr, format); 56 va_start (arg_ptr, format);
57 vfprintf (stderr, format, arg_ptr); 57 vfprintf (stderr, format, arg_ptr);
58 va_end (arg_ptr); 58 va_end (arg_ptr);
59 error_count++; 59 error_count++;
60} 60}
61 61
62static void 62static void
63die (const char *format, ...) 63die (const char *format, ...)
64{ 64{
65 va_list arg_ptr; 65 va_list arg_ptr;
66 66
67 va_start (arg_ptr, format); 67 va_start (arg_ptr, format);
68 vfprintf (stderr, format, arg_ptr); 68 vfprintf (stderr, format, arg_ptr);
69 va_end (arg_ptr); 69 va_end (arg_ptr);
70 exit (1); 70 exit (1);
71} 71}
72 72
73#define MAX_DATA_LEN 100 73#define MAX_DATA_LEN 100
74 74
75void 75void
76progress_handler (void *cb_data, const char *what, int printchar, 76progress_handler (void *cb_data, const char *what, int printchar,
77 int current, int total) 77 int current, int total)
78{ 78{
79 putchar (printchar); 79 putchar (printchar);
80} 80}
81 81
82static void 82static void
83check_cbc_mac_cipher (void) 83check_cbc_mac_cipher (void)
84{ 84{
85 struct tv 85 struct tv
86 { 86 {
87 int algo; 87 int algo;
88 char key[MAX_DATA_LEN]; 88 char key[MAX_DATA_LEN];
89 char plaintext[MAX_DATA_LEN]; 89 char plaintext[MAX_DATA_LEN];
90 size_t plaintextlen; 90 size_t plaintextlen;
91 char mac[MAX_DATA_LEN]; 91 char mac[MAX_DATA_LEN];
92 } 92 }
93 tv[] = 93 tv[] =
94 { 94 {
95 { GCRY_CIPHER_AES, 95 { GCRY_CIPHER_AES,
96 "chicken teriyaki", 96 "chicken teriyaki",
97 "This is a sample plaintext for CBC MAC of sixtyfour bytes.......", 97 "This is a sample plaintext for CBC MAC of sixtyfour bytes.......",
98 0, "\x23\x8f\x6d\xc7\x53\x6a\x62\x97\x11\xc4\xa5\x16\x43\xea\xb0\xb6" }, 98 0, "\x23\x8f\x6d\xc7\x53\x6a\x62\x97\x11\xc4\xa5\x16\x43\xea\xb0\xb6" },
99 { GCRY_CIPHER_3DES, 99 { GCRY_CIPHER_3DES,
100 "abcdefghABCDEFGH01234567", 100 "abcdefghABCDEFGH01234567",
101 "This is a sample plaintext for CBC MAC of sixtyfour bytes.......", 101 "This is a sample plaintext for CBC MAC of sixtyfour bytes.......",
102 0, "\x5c\x11\xf0\x01\x47\xbd\x3d\x3a" }, 102 0, "\x5c\x11\xf0\x01\x47\xbd\x3d\x3a" },
103 { GCRY_CIPHER_DES, 103 { GCRY_CIPHER_DES,
104 "abcdefgh", 104 "abcdefgh",
105 "This is a sample plaintext for CBC MAC of sixtyfour bytes.......", 105 "This is a sample plaintext for CBC MAC of sixtyfour bytes.......",
106 0, "\xfa\x4b\xdf\x9d\xfa\xab\x01\x70" } 106 0, "\xfa\x4b\xdf\x9d\xfa\xab\x01\x70" }
107 }; 107 };
108 gcry_cipher_hd_t hd; 108 gcry_cipher_hd_t hd;
109 char out[MAX_DATA_LEN]; 109 char out[MAX_DATA_LEN];
110 int i, blklen, keylen; 110 int i, blklen, keylen;
111 gcry_error_t err = 0; 111 gcry_error_t err = 0;
112 112
113 for (i = 0; i < sizeof (tv) / sizeof (tv[0]); i++) 113 for (i = 0; i < sizeof (tv) / sizeof (tv[0]); i++)
114 { 114 {
115 err = gcry_cipher_open (&hd, 115 err = gcry_cipher_open (&hd,
116 tv[i].algo, 116 tv[i].algo,
117 GCRY_CIPHER_MODE_CBC, GCRY_CIPHER_CBC_MAC); 117 GCRY_CIPHER_MODE_CBC, GCRY_CIPHER_CBC_MAC);
118 if (!hd) 118 if (!hd)
119 { 119 {
120 fail ("cbc-mac algo %d, grcy_open_cipher failed: %s\n", 120 fail ("cbc-mac algo %d, grcy_open_cipher failed: %s\n",
121 tv[i].algo, gpg_strerror (err)); 121 tv[i].algo, gpg_strerror (err));
122 return; 122 return;
123 } 123 }
124 124
125 blklen = gcry_cipher_get_algo_blklen(tv[i].algo); 125 blklen = gcry_cipher_get_algo_blklen(tv[i].algo);
126 if (!blklen) 126 if (!blklen)
127 { 127 {
128 fail ("cbc-mac algo %d, gcry_cipher_get_algo_blklen failed\n", 128 fail ("cbc-mac algo %d, gcry_cipher_get_algo_blklen failed\n",
129 tv[i].algo); 129 tv[i].algo);
130 gcry_cipher_close (hd); 130 gcry_cipher_close (hd);
131 return; 131 return;
132 } 132 }
133 133
134 keylen = gcry_cipher_get_algo_keylen (tv[i].algo); 134 keylen = gcry_cipher_get_algo_keylen (tv[i].algo);
135 if (!keylen) 135 if (!keylen)
136 { 136 {
137 fail ("cbc-mac algo %d, gcry_cipher_get_algo_keylen failed\n", 137 fail ("cbc-mac algo %d, gcry_cipher_get_algo_keylen failed\n",
138 tv[i].algo); 138 tv[i].algo);
139 return; 139 return;
140 } 140 }
141 141
142 err = gcry_cipher_setkey (hd, tv[i].key, keylen); 142 err = gcry_cipher_setkey (hd, tv[i].key, keylen);
143 if (err) 143 if (err)
144 { 144 {
145 fail ("cbc-mac algo %d, gcry_cipher_setkey failed: %s\n", 145 fail ("cbc-mac algo %d, gcry_cipher_setkey failed: %s\n",
146 tv[i].algo, gpg_strerror (err)); 146 tv[i].algo, gpg_strerror (err));
147 gcry_cipher_close (hd); 147 gcry_cipher_close (hd);
148 return; 148 return;
149 } 149 }
150 150
151 err = gcry_cipher_setiv (hd, NULL, 0); 151 err = gcry_cipher_setiv (hd, NULL, 0);
152 if (err) 152 if (err)
153 { 153 {
154 fail ("cbc-mac algo %d, gcry_cipher_setiv failed: %s\n", 154 fail ("cbc-mac algo %d, gcry_cipher_setiv failed: %s\n",
155 tv[i].algo, gpg_strerror (err)); 155 tv[i].algo, gpg_strerror (err));
156 gcry_cipher_close (hd); 156 gcry_cipher_close (hd);
157 return; 157 return;
158 } 158 }
159 159
160 err = gcry_cipher_encrypt (hd, 160 err = gcry_cipher_encrypt (hd,
161 out, blklen, 161 out, blklen,
162 tv[i].plaintext, 162 tv[i].plaintext,
163 tv[i].plaintextlen ? 163 tv[i].plaintextlen ?
164 tv[i].plaintextlen : 164 tv[i].plaintextlen :
165 strlen (tv[i].plaintext)); 165 strlen (tv[i].plaintext));
166 if (err) 166 if (err)
167 { 167 {
168 fail ("cbc-mac algo %d, gcry_cipher_encrypt failed: %s\n", 168 fail ("cbc-mac algo %d, gcry_cipher_encrypt failed: %s\n",
169 tv[i].algo, gpg_strerror (err)); 169 tv[i].algo, gpg_strerror (err));
170 gcry_cipher_close (hd); 170 gcry_cipher_close (hd);
171 return; 171 return;
172 } 172 }
173 173
174#if 0 174#if 0
175 { 175 {
176 int j; 176 int j;
177 for (j = 0; j < gcry_cipher_get_algo_blklen (tv[i].algo); j++) 177 for (j = 0; j < gcry_cipher_get_algo_blklen (tv[i].algo); j++)
178 printf ("\\x%02x", out[j] & 0xFF); 178 printf ("\\x%02x", out[j] & 0xFF);
179 printf ("\n"); 179 printf ("\n");
180 } 180 }
181#endif 181#endif
182 182
183 if (memcmp (tv[i].mac, out, blklen)) 183 if (memcmp (tv[i].mac, out, blklen))
184 fail ("cbc-mac algo %d, encrypt mismatch entry %d\n", tv[i].algo, i); 184 fail ("cbc-mac algo %d, encrypt mismatch entry %d\n", tv[i].algo, i);
185 185
186 gcry_cipher_close (hd); 186 gcry_cipher_close (hd);
187 } 187 }
188} 188}
189 189
190static void 190static void
191check_aes128_cbc_cts_cipher (void) 191check_aes128_cbc_cts_cipher (void)
192{ 192{
193 char key[128 / 8] = "chicken teriyaki"; 193 char key[128 / 8] = "chicken teriyaki";
194 char plaintext[] = 194 char plaintext[] =
195 "I would like the General Gau's Chicken, please, and wonton soup."; 195 "I would like the General Gau's Chicken, please, and wonton soup.";
196 struct tv 196 struct tv
197 { 197 {
198 char out[MAX_DATA_LEN]; 198 char out[MAX_DATA_LEN];
199 int inlen; 199 int inlen;
200 } tv[] = 200 } tv[] =
201 { 201 {
202 { "\xc6\x35\x35\x68\xf2\xbf\x8c\xb4\xd8\xa5\x80\x36\x2d\xa7\xff\x7f" 202 { "\xc6\x35\x35\x68\xf2\xbf\x8c\xb4\xd8\xa5\x80\x36\x2d\xa7\xff\x7f"
203 "\x97", 203 "\x97",
204 17 }, 204 17 },
205 { "\xfc\x00\x78\x3e\x0e\xfd\xb2\xc1\xd4\x45\xd4\xc8\xef\xf7\xed\x22" 205 { "\xfc\x00\x78\x3e\x0e\xfd\xb2\xc1\xd4\x45\xd4\xc8\xef\xf7\xed\x22"
206 "\x97\x68\x72\x68\xd6\xec\xcc\xc0\xc0\x7b\x25\xe2\x5e\xcf\xe5", 206 "\x97\x68\x72\x68\xd6\xec\xcc\xc0\xc0\x7b\x25\xe2\x5e\xcf\xe5",
207 31 }, 207 31 },
208 { "\x39\x31\x25\x23\xa7\x86\x62\xd5\xbe\x7f\xcb\xcc\x98\xeb\xf5\xa8" 208 { "\x39\x31\x25\x23\xa7\x86\x62\xd5\xbe\x7f\xcb\xcc\x98\xeb\xf5\xa8"
209 "\x97\x68\x72\x68\xd6\xec\xcc\xc0\xc0\x7b\x25\xe2\x5e\xcf\xe5\x84", 209 "\x97\x68\x72\x68\xd6\xec\xcc\xc0\xc0\x7b\x25\xe2\x5e\xcf\xe5\x84",
210 32 }, 210 32 },
211 { "\x97\x68\x72\x68\xd6\xec\xcc\xc0\xc0\x7b\x25\xe2\x5e\xcf\xe5\x84" 211 { "\x97\x68\x72\x68\xd6\xec\xcc\xc0\xc0\x7b\x25\xe2\x5e\xcf\xe5\x84"
212 "\xb3\xff\xfd\x94\x0c\x16\xa1\x8c\x1b\x55\x49\xd2\xf8\x38\x02\x9e" 212 "\xb3\xff\xfd\x94\x0c\x16\xa1\x8c\x1b\x55\x49\xd2\xf8\x38\x02\x9e"
213 "\x39\x31\x25\x23\xa7\x86\x62\xd5\xbe\x7f\xcb\xcc\x98\xeb\xf5", 213 "\x39\x31\x25\x23\xa7\x86\x62\xd5\xbe\x7f\xcb\xcc\x98\xeb\xf5",
214 47 }, 214 47 },
215 { "\x97\x68\x72\x68\xd6\xec\xcc\xc0\xc0\x7b\x25\xe2\x5e\xcf\xe5\x84" 215 { "\x97\x68\x72\x68\xd6\xec\xcc\xc0\xc0\x7b\x25\xe2\x5e\xcf\xe5\x84"
216 "\x9d\xad\x8b\xbb\x96\xc4\xcd\xc0\x3b\xc1\x03\xe1\xa1\x94\xbb\xd8" 216 "\x9d\xad\x8b\xbb\x96\xc4\xcd\xc0\x3b\xc1\x03\xe1\xa1\x94\xbb\xd8"
217 "\x39\x31\x25\x23\xa7\x86\x62\xd5\xbe\x7f\xcb\xcc\x98\xeb\xf5\xa8", 217 "\x39\x31\x25\x23\xa7\x86\x62\xd5\xbe\x7f\xcb\xcc\x98\xeb\xf5\xa8",
218 48 }, 218 48 },
219 { "\x97\x68\x72\x68\xd6\xec\xcc\xc0\xc0\x7b\x25\xe2\x5e\xcf\xe5\x84" 219 { "\x97\x68\x72\x68\xd6\xec\xcc\xc0\xc0\x7b\x25\xe2\x5e\xcf\xe5\x84"
220 "\x39\x31\x25\x23\xa7\x86\x62\xd5\xbe\x7f\xcb\xcc\x98\xeb\xf5\xa8" 220 "\x39\x31\x25\x23\xa7\x86\x62\xd5\xbe\x7f\xcb\xcc\x98\xeb\xf5\xa8"
221 "\x48\x07\xef\xe8\x36\xee\x89\xa5\x26\x73\x0d\xbc\x2f\x7b\xc8\x40" 221 "\x48\x07\xef\xe8\x36\xee\x89\xa5\x26\x73\x0d\xbc\x2f\x7b\xc8\x40"
222 "\x9d\xad\x8b\xbb\x96\xc4\xcd\xc0\x3b\xc1\x03\xe1\xa1\x94\xbb\xd8", 222 "\x9d\xad\x8b\xbb\x96\xc4\xcd\xc0\x3b\xc1\x03\xe1\xa1\x94\xbb\xd8",
223 64 }, 223 64 },
224 }; 224 };
225 gcry_cipher_hd_t hd; 225 gcry_cipher_hd_t hd;
226 char out[MAX_DATA_LEN]; 226 char out[MAX_DATA_LEN];
227 int i; 227 int i;
228 gcry_error_t err = 0; 228 gcry_error_t err = 0;
229 229
230 err = gcry_cipher_open (&hd, 230 err = gcry_cipher_open (&hd,
231 GCRY_CIPHER_AES, 231 GCRY_CIPHER_AES,
232 GCRY_CIPHER_MODE_CBC, GCRY_CIPHER_CBC_CTS); 232 GCRY_CIPHER_MODE_CBC, GCRY_CIPHER_CBC_CTS);
233 if (err) 233 if (err)
234 { 234 {
235 fail ("aes-cbc-cts, grcy_open_cipher failed: %s\n", gpg_strerror (err)); 235 fail ("aes-cbc-cts, grcy_open_cipher failed: %s\n", gpg_strerror (err));
236 return; 236 return;
237 } 237 }
238 238
239 err = gcry_cipher_setkey (hd, key, 128 / 8); 239 err = gcry_cipher_setkey (hd, key, 128 / 8);
240 if (err) 240 if (err)
241 { 241 {
242 fail ("aes-cbc-cts, gcry_cipher_setkey failed: %s\n", 242 fail ("aes-cbc-cts, gcry_cipher_setkey failed: %s\n",
243 gpg_strerror (err)); 243 gpg_strerror (err));
244 gcry_cipher_close (hd); 244 gcry_cipher_close (hd);
245 return; 245 return;
246 } 246 }
247 247
248 for (i = 0; i < sizeof (tv) / sizeof (tv[0]); i++) 248 for (i = 0; i < sizeof (tv) / sizeof (tv[0]); i++)
249 { 249 {
250 err = gcry_cipher_setiv (hd, NULL, 0); 250 err = gcry_cipher_setiv (hd, NULL, 0);
251 if (err) 251 if (err)
252 { 252 {
253 fail ("aes-cbc-cts, gcry_cipher_setiv failed: %s\n", 253 fail ("aes-cbc-cts, gcry_cipher_setiv failed: %s\n",
254 gpg_strerror (err)); 254 gpg_strerror (err));
255 gcry_cipher_close (hd); 255 gcry_cipher_close (hd);
256 return; 256 return;
257 } 257 }
258 258
259 err = gcry_cipher_encrypt (hd, out, MAX_DATA_LEN, 259 err = gcry_cipher_encrypt (hd, out, MAX_DATA_LEN,
260 plaintext, tv[i].inlen); 260 plaintext, tv[i].inlen);
261 if (err) 261 if (err)
262 { 262 {
263 fail ("aes-cbc-cts, gcry_cipher_encrypt failed: %s\n", 263 fail ("aes-cbc-cts, gcry_cipher_encrypt failed: %s\n",
264 gpg_strerror (err)); 264 gpg_strerror (err));
265 gcry_cipher_close (hd); 265 gcry_cipher_close (hd);
266 return; 266 return;
267 } 267 }
268 268
269 if (memcmp (tv[i].out, out, tv[i].inlen)) 269 if (memcmp (tv[i].out, out, tv[i].inlen))
270 fail ("aes-cbc-cts, encrypt mismatch entry %d\n", i); 270 fail ("aes-cbc-cts, encrypt mismatch entry %d\n", i);
271 271
272 err = gcry_cipher_setiv (hd, NULL, 0); 272 err = gcry_cipher_setiv (hd, NULL, 0);
273 if (err) 273 if (err)
274 { 274 {
275 fail ("aes-cbc-cts, gcry_cipher_setiv failed: %s\n", 275 fail ("aes-cbc-cts, gcry_cipher_setiv failed: %s\n",
276 gpg_strerror (err)); 276 gpg_strerror (err));
277 gcry_cipher_close (hd); 277 gcry_cipher_close (hd);
278 return; 278 return;
279 } 279 }
280 err = gcry_cipher_decrypt (hd, out, tv[i].inlen, NULL, 0); 280 err = gcry_cipher_decrypt (hd, out, tv[i].inlen, NULL, 0);
281 if (err) 281 if (err)
282 { 282 {
283 fail ("aes-cbc-cts, gcry_cipher_decrypt failed: %s\n", 283 fail ("aes-cbc-cts, gcry_cipher_decrypt failed: %s\n",
284 gpg_strerror (err)); 284 gpg_strerror (err));
285 gcry_cipher_close (hd); 285 gcry_cipher_close (hd);
286 return; 286 return;
287 } 287 }
288 288
289 if (memcmp (plaintext, out, tv[i].inlen)) 289 if (memcmp (plaintext, out, tv[i].inlen))
290 fail ("aes-cbc-cts, decrypt mismatch entry %d\n", i); 290 fail ("aes-cbc-cts, decrypt mismatch entry %d\n", i);
291 } 291 }
292 292
293 gcry_cipher_close (hd); 293 gcry_cipher_close (hd);
294} 294}
295 295
296static void 296static void
297check_ctr_cipher (void) 297check_ctr_cipher (void)
298{ 298{
299 struct tv 299 struct tv
300 { 300 {
301 int algo; 301 int algo;
302 char key[MAX_DATA_LEN]; 302 char key[MAX_DATA_LEN];
303 char ctr[MAX_DATA_LEN]; 303 char ctr[MAX_DATA_LEN];
304 struct data 304 struct data
305 { 305 {
306 char plaintext[MAX_DATA_LEN]; 306 char plaintext[MAX_DATA_LEN];
307 int inlen; 307 int inlen;
308 char out[MAX_DATA_LEN]; 308 char out[MAX_DATA_LEN];
309 } 309 }
310 data[MAX_DATA_LEN]; 310 data[MAX_DATA_LEN];
311 } tv[] = 311 } tv[] =
312 { 312 {
313 /* http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf */ 313 /* http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf */
314 { GCRY_CIPHER_AES, 314 { GCRY_CIPHER_AES,
315 "\x2b\x7e\x15\x16\x28\xae\xd2\xa6\xab\xf7\x15\x88\x09\xcf\x4f\x3c", 315 "\x2b\x7e\x15\x16\x28\xae\xd2\xa6\xab\xf7\x15\x88\x09\xcf\x4f\x3c",
316 "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff", 316 "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
317 { { "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96\xe9\x3d\x7e\x11\x73\x93\x17\x2a", 317 { { "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96\xe9\x3d\x7e\x11\x73\x93\x17\x2a",
318 16, 318 16,
319 "\x87\x4d\x61\x91\xb6\x20\xe3\x26\x1b\xef\x68\x64\x99\x0d\xb6\xce" }, 319 "\x87\x4d\x61\x91\xb6\x20\xe3\x26\x1b\xef\x68\x64\x99\x0d\xb6\xce" },
320 { "\xae\x2d\x8a\x57\x1e\x03\xac\x9c\x9e\xb7\x6f\xac\x45\xaf\x8e\x51", 320 { "\xae\x2d\x8a\x57\x1e\x03\xac\x9c\x9e\xb7\x6f\xac\x45\xaf\x8e\x51",
321 16, 321 16,
322 "\x98\x06\xf6\x6b\x79\x70\xfd\xff\x86\x17\x18\x7b\xb9\xff\xfd\xff" }, 322 "\x98\x06\xf6\x6b\x79\x70\xfd\xff\x86\x17\x18\x7b\xb9\xff\xfd\xff" },
323 { "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11\xe5\xfb\xc1\x19\x1a\x0a\x52\xef", 323 { "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11\xe5\xfb\xc1\x19\x1a\x0a\x52\xef",
324 16, 324 16,
325 "\x5a\xe4\xdf\x3e\xdb\xd5\xd3\x5e\x5b\x4f\x09\x02\x0d\xb0\x3e\xab" }, 325 "\x5a\xe4\xdf\x3e\xdb\xd5\xd3\x5e\x5b\x4f\x09\x02\x0d\xb0\x3e\xab" },
326 { "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17\xad\x2b\x41\x7b\xe6\x6c\x37\x10", 326 { "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17\xad\x2b\x41\x7b\xe6\x6c\x37\x10",
327 16, 327 16,
328 "\x1e\x03\x1d\xda\x2f\xbe\x03\xd1\x79\x21\x70\xa0\xf3\x00\x9c\xee" }, 328 "\x1e\x03\x1d\xda\x2f\xbe\x03\xd1\x79\x21\x70\xa0\xf3\x00\x9c\xee" },
329 } 329 }
330 }, 330 },
331 { GCRY_CIPHER_AES192, 331 { GCRY_CIPHER_AES192,
332 "\x8e\x73\xb0\xf7\xda\x0e\x64\x52\xc8\x10\xf3\x2b" 332 "\x8e\x73\xb0\xf7\xda\x0e\x64\x52\xc8\x10\xf3\x2b"
333 "\x80\x90\x79\xe5\x62\xf8\xea\xd2\x52\x2c\x6b\x7b", 333 "\x80\x90\x79\xe5\x62\xf8\xea\xd2\x52\x2c\x6b\x7b",
334 "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff", 334 "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
335 { { "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96\xe9\x3d\x7e\x11\x73\x93\x17\x2a", 335 { { "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96\xe9\x3d\x7e\x11\x73\x93\x17\x2a",
336 16, 336 16,
337 "\x1a\xbc\x93\x24\x17\x52\x1c\xa2\x4f\x2b\x04\x59\xfe\x7e\x6e\x0b" }, 337 "\x1a\xbc\x93\x24\x17\x52\x1c\xa2\x4f\x2b\x04\x59\xfe\x7e\x6e\x0b" },
338 { "\xae\x2d\x8a\x57\x1e\x03\xac\x9c\x9e\xb7\x6f\xac\x45\xaf\x8e\x51", 338 { "\xae\x2d\x8a\x57\x1e\x03\xac\x9c\x9e\xb7\x6f\xac\x45\xaf\x8e\x51",
339 16, 339 16,
340 "\x09\x03\x39\xec\x0a\xa6\xfa\xef\xd5\xcc\xc2\xc6\xf4\xce\x8e\x94" }, 340 "\x09\x03\x39\xec\x0a\xa6\xfa\xef\xd5\xcc\xc2\xc6\xf4\xce\x8e\x94" },
341 { "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11\xe5\xfb\xc1\x19\x1a\x0a\x52\xef", 341 { "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11\xe5\xfb\xc1\x19\x1a\x0a\x52\xef",
342 16, 342 16,
343 "\x1e\x36\xb2\x6b\xd1\xeb\xc6\x70\xd1\xbd\x1d\x66\x56\x20\xab\xf7" }, 343 "\x1e\x36\xb2\x6b\xd1\xeb\xc6\x70\xd1\xbd\x1d\x66\x56\x20\xab\xf7" },
344 { "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17\xad\x2b\x41\x7b\xe6\x6c\x37\x10", 344 { "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17\xad\x2b\x41\x7b\xe6\x6c\x37\x10",
345 16, 345 16,
346 "\x4f\x78\xa7\xf6\xd2\x98\x09\x58\x5a\x97\xda\xec\x58\xc6\xb0\x50" }, 346 "\x4f\x78\xa7\xf6\xd2\x98\x09\x58\x5a\x97\xda\xec\x58\xc6\xb0\x50" },
347 } 347 }
348 }, 348 },
349 { GCRY_CIPHER_AES256, 349 { GCRY_CIPHER_AES256,
350 "\x60\x3d\xeb\x10\x15\xca\x71\xbe\x2b\x73\xae\xf0\x85\x7d\x77\x81" 350 "\x60\x3d\xeb\x10\x15\xca\x71\xbe\x2b\x73\xae\xf0\x85\x7d\x77\x81"
351 "\x1f\x35\x2c\x07\x3b\x61\x08\xd7\x2d\x98\x10\xa3\x09\x14\xdf\xf4", 351 "\x1f\x35\x2c\x07\x3b\x61\x08\xd7\x2d\x98\x10\xa3\x09\x14\xdf\xf4",
352 "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff", 352 "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
353 { { "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96\xe9\x3d\x7e\x11\x73\x93\x17\x2a", 353 { { "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96\xe9\x3d\x7e\x11\x73\x93\x17\x2a",
354 16, 354 16,
355 "\x60\x1e\xc3\x13\x77\x57\x89\xa5\xb7\xa7\xf5\x04\xbb\xf3\xd2\x28" }, 355 "\x60\x1e\xc3\x13\x77\x57\x89\xa5\xb7\xa7\xf5\x04\xbb\xf3\xd2\x28" },
356 { "\xae\x2d\x8a\x57\x1e\x03\xac\x9c\x9e\xb7\x6f\xac\x45\xaf\x8e\x51", 356 { "\xae\x2d\x8a\x57\x1e\x03\xac\x9c\x9e\xb7\x6f\xac\x45\xaf\x8e\x51",
357 16, 357 16,
358 "\xf4\x43\xe3\xca\x4d\x62\xb5\x9a\xca\x84\xe9\x90\xca\xca\xf5\xc5" }, 358 "\xf4\x43\xe3\xca\x4d\x62\xb5\x9a\xca\x84\xe9\x90\xca\xca\xf5\xc5" },
359 { "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11\xe5\xfb\xc1\x19\x1a\x0a\x52\xef", 359 { "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11\xe5\xfb\xc1\x19\x1a\x0a\x52\xef",
360 16, 360 16,
361 "\x2b\x09\x30\xda\xa2\x3d\xe9\x4c\xe8\x70\x17\xba\x2d\x84\x98\x8d" }, 361 "\x2b\x09\x30\xda\xa2\x3d\xe9\x4c\xe8\x70\x17\xba\x2d\x84\x98\x8d" },
362 { "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17\xad\x2b\x41\x7b\xe6\x6c\x37\x10", 362 { "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17\xad\x2b\x41\x7b\xe6\x6c\x37\x10",
363 16, 363 16,
364 "\xdf\xc9\xc5\x8d\xb6\x7a\xad\xa6\x13\xc2\xdd\x08\x45\x79\x41\xa6" } 364 "\xdf\xc9\xc5\x8d\xb6\x7a\xad\xa6\x13\xc2\xdd\x08\x45\x79\x41\xa6" }
365 } 365 }
366 } 366 }
367 }; 367 };
368 gcry_cipher_hd_t hde, hdd; 368 gcry_cipher_hd_t hde, hdd;
369 char out[MAX_DATA_LEN]; 369 char out[MAX_DATA_LEN];
370 int i, j, keylen, blklen; 370 int i, j, keylen, blklen;
371 gcry_error_t err = 0; 371 gcry_error_t err = 0;
372 372
373 for (i = 0; i < sizeof (tv) / sizeof (tv[0]); i++) 373 for (i = 0; i < sizeof (tv) / sizeof (tv[0]); i++)
374 { 374 {
375 err = gcry_cipher_open (&hde, tv[i].algo, GCRY_CIPHER_MODE_CTR, 0); 375 err = gcry_cipher_open (&hde, tv[i].algo, GCRY_CIPHER_MODE_CTR, 0);
376 if (!err) 376 if (!err)
377 err = gcry_cipher_open (&hdd, tv[i].algo, GCRY_CIPHER_MODE_CTR, 0); 377 err = gcry_cipher_open (&hdd, tv[i].algo, GCRY_CIPHER_MODE_CTR, 0);
378 if (err) 378 if (err)
379 { 379 {
380 fail ("aes-ctr, grcy_open_cipher failed: %s\n", gpg_strerror (err)); 380 fail ("aes-ctr, grcy_open_cipher failed: %s\n", gpg_strerror (err));
381 return; 381 return;
382 } 382 }
383 383
384 keylen = gcry_cipher_get_algo_keylen(tv[i].algo); 384 keylen = gcry_cipher_get_algo_keylen(tv[i].algo);
385 if (!keylen) 385 if (!keylen)
386 { 386 {
387 fail ("aes-ctr, gcry_cipher_get_algo_keylen failed\n"); 387 fail ("aes-ctr, gcry_cipher_get_algo_keylen failed\n");
388 return; 388 return;
389 } 389 }
390 390
391 err = gcry_cipher_setkey (hde, tv[i].key, keylen); 391 err = gcry_cipher_setkey (hde, tv[i].key, keylen);
392 if (!err) 392 if (!err)
393 err = gcry_cipher_setkey (hdd, tv[i].key, keylen); 393 err = gcry_cipher_setkey (hdd, tv[i].key, keylen);
394 if (err) 394 if (err)
395 { 395 {
396 fail ("aes-ctr, gcry_cipher_setkey failed: %s\n", 396 fail ("aes-ctr, gcry_cipher_setkey failed: %s\n",
397 gpg_strerror (err)); 397 gpg_strerror (err));
398 gcry_cipher_close (hde); 398 gcry_cipher_close (hde);
399 gcry_cipher_close (hdd); 399 gcry_cipher_close (hdd);
400 return; 400 return;
401 } 401 }
402 402
403 blklen = gcry_cipher_get_algo_blklen(tv[i].algo); 403 blklen = gcry_cipher_get_algo_blklen(tv[i].algo);
404 if (!blklen) 404 if (!blklen)
405 { 405 {
406 fail ("aes-ctr, gcry_cipher_get_algo_blklen failed\n"); 406 fail ("aes-ctr, gcry_cipher_get_algo_blklen failed\n");
407 return; 407 return;
408 } 408 }
409 409
410 err = gcry_cipher_setctr (hde, tv[i].ctr, blklen); 410 err = gcry_cipher_setctr (hde, tv[i].ctr, blklen);
411 if (!err) 411 if (!err)
412 err = gcry_cipher_setctr (hdd, tv[i].ctr, blklen); 412 err = gcry_cipher_setctr (hdd, tv[i].ctr, blklen);
413 if (err) 413 if (err)
414 { 414 {
415 fail ("aes-ctr, gcry_cipher_setctr failed: %s\n", 415 fail ("aes-ctr, gcry_cipher_setctr failed: %s\n",
416 gpg_strerror (err)); 416 gpg_strerror (err));
417 gcry_cipher_close (hde); 417 gcry_cipher_close (hde);
418 gcry_cipher_close (hdd); 418 gcry_cipher_close (hdd);
419 return; 419 return;
420 } 420 }
421 421
422 for (j = 0; tv[i].data[j].inlen; j++) 422 for (j = 0; tv[i].data[j].inlen; j++)
423 { 423 {
424 err = gcry_cipher_encrypt (hde, out, MAX_DATA_LEN, 424 err = gcry_cipher_encrypt (hde, out, MAX_DATA_LEN,
425 tv[i].data[j].plaintext, 425 tv[i].data[j].plaintext,
426 tv[i].data[j].inlen == -1 ? 426 tv[i].data[j].inlen == -1 ?
427 strlen (tv[i].data[j].plaintext) : 427 strlen (tv[i].data[j].plaintext) :
428 tv[i].data[j].inlen); 428 tv[i].data[j].inlen);
429 if (err) 429 if (err)
430 { 430 {
431 fail ("aes-ctr, gcry_cipher_encrypt (%d, %d) failed: %s\n", 431 fail ("aes-ctr, gcry_cipher_encrypt (%d, %d) failed: %s\n",
432 i, j, gpg_strerror (err)); 432 i, j, gpg_strerror (err));
433 gcry_cipher_close (hde); 433 gcry_cipher_close (hde);
434 gcry_cipher_close (hdd); 434 gcry_cipher_close (hdd);
435 return; 435 return;
436 } 436 }
437 437
438 if (memcmp (tv[i].data[j].out, out, tv[i].data[j].inlen)) 438 if (memcmp (tv[i].data[j].out, out, tv[i].data[j].inlen))
439 fail ("aes-ctr, encrypt mismatch entry %d:%d\n", i, j); 439 fail ("aes-ctr, encrypt mismatch entry %d:%d\n", i, j);
440 440
441 err = gcry_cipher_decrypt (hdd, out, tv[i].data[j].inlen, NULL, 0); 441 err = gcry_cipher_decrypt (hdd, out, tv[i].data[j].inlen, NULL, 0);
442 if (err) 442 if (err)
443 { 443 {
444 fail ("aes-ctr, gcry_cipher_decrypt (%d, %d) failed: %s\n", 444 fail ("aes-ctr, gcry_cipher_decrypt (%d, %d) failed: %s\n",
445 i, j, gpg_strerror (err)); 445 i, j, gpg_strerror (err));
446 gcry_cipher_close (hde); 446 gcry_cipher_close (hde);
447 gcry_cipher_close (hdd); 447 gcry_cipher_close (hdd);
448 return; 448 return;
449 } 449 }
450 450
451 if (memcmp (tv[i].data[j].plaintext, out, tv[i].data[j].inlen)) 451 if (memcmp (tv[i].data[j].plaintext, out, tv[i].data[j].inlen))
452 fail ("aes-ctr, decrypt mismatch entry %d:%d\n", i, j); 452 fail ("aes-ctr, decrypt mismatch entry %d:%d\n", i, j);
453 } 453 }
454 454
455 gcry_cipher_close (hde); 455 gcry_cipher_close (hde);
456 gcry_cipher_close (hdd); 456 gcry_cipher_close (hdd);
457 } 457 }
458} 458}
459 459
460static void 460static void
461check_one_cipher (int algo, int mode, int flags) 461check_one_cipher (int algo, int mode, int flags)
462{ 462{
463 gcry_cipher_hd_t hd; 463 gcry_cipher_hd_t hd;
464 char key[32], plain[16], in[16], out[16]; 464 char key[32], plain[16], in[16], out[16];
465 int keylen; 465 int keylen;
466 gcry_error_t err = 0; 466 gcry_error_t err = 0;
467 467
468 memcpy (key, "0123456789abcdef.,;/[]{}-=ABCDEF", 32); 468 memcpy (key, "0123456789abcdef.,;/[]{}-=ABCDEF", 32);
469 memcpy (plain, "foobar42FOOBAR17", 16); 469 memcpy (plain, "foobar42FOOBAR17", 16);
470 470
471 keylen = gcry_cipher_get_algo_keylen (algo); 471 keylen = gcry_cipher_get_algo_keylen (algo);
472 if (!keylen) 472 if (!keylen)
473 { 473 {
474 fail ("algo %d, mode %d, gcry_cipher_get_algo_keylen failed\n", 474 fail ("algo %d, mode %d, gcry_cipher_get_algo_keylen failed\n",
475 algo, mode); 475 algo, mode);
476 return; 476 return;
477 } 477 }
478 478
479 if (keylen < 40 / 8 || keylen > 32) 479 if (keylen < 40 / 8 || keylen > 32)
480 { 480 {
481 fail ("algo %d, mode %d, keylength problem (%d)\n", algo, mode, keylen); 481 fail ("algo %d, mode %d, keylength problem (%d)\n", algo, mode, keylen);
482 return; 482 return;
483 } 483 }
484 484
485 err = gcry_cipher_open (&hd, algo, mode, flags); 485 err = gcry_cipher_open (&hd, algo, mode, flags);
486 if (err) 486 if (err)
487 { 487 {
488 fail ("algo %d, mode %d, grcy_open_cipher failed: %s\n", 488 fail ("algo %d, mode %d, grcy_open_cipher failed: %s\n",
489 algo, mode, gpg_strerror (err)); 489 algo, mode, gpg_strerror (err));
490 return; 490 return;
491 } 491 }
492 492
493 err = gcry_cipher_setkey (hd, key, keylen); 493 err = gcry_cipher_setkey (hd, key, keylen);
494 if (err) 494 if (err)
495 { 495 {
496 fail ("algo %d, mode %d, gcry_cipher_setkey failed: %s\n", 496 fail ("algo %d, mode %d, gcry_cipher_setkey failed: %s\n",
497 algo, mode, gpg_strerror (err)); 497 algo, mode, gpg_strerror (err));
498 gcry_cipher_close (hd); 498 gcry_cipher_close (hd);
499 return; 499 return;
500 } 500 }
501 501
502 err = gcry_cipher_encrypt (hd, out, 16, plain, 16); 502 err = gcry_cipher_encrypt (hd, out, 16, plain, 16);
503 if (err) 503 if (err)
504 { 504 {
505 fail ("algo %d, mode %d, gcry_cipher_encrypt failed: %s\n", 505 fail ("algo %d, mode %d, gcry_cipher_encrypt failed: %s\n",
506 algo, mode, gpg_strerror (err)); 506 algo, mode, gpg_strerror (err));
507 gcry_cipher_close (hd); 507 gcry_cipher_close (hd);
508 return; 508 return;
509 } 509 }
510 510
511 gcry_cipher_reset (hd); 511 gcry_cipher_reset (hd);
512 512
513 err = gcry_cipher_decrypt (hd, in, 16, out, 16); 513 err = gcry_cipher_decrypt (hd, in, 16, out, 16);
514 if (err) 514 if (err)
515 { 515 {
516 fail ("algo %d, mode %d, gcry_cipher_decrypt failed: %s\n", 516 fail ("algo %d, mode %d, gcry_cipher_decrypt failed: %s\n",
517 algo, mode, gpg_strerror (err)); 517 algo, mode, gpg_strerror (err));
518 gcry_cipher_close (hd); 518 gcry_cipher_close (hd);
519 return; 519 return;
520 } 520 }
521 521
522 gcry_cipher_close (hd); 522 gcry_cipher_close (hd);
523 523
524 if (memcmp (plain, in, 16)) 524 if (memcmp (plain, in, 16))
525 fail ("algo %d, mode %d, encrypt-decrypt mismatch\n", algo, mode); 525 fail ("algo %d, mode %d, encrypt-decrypt mismatch\n", algo, mode);
526} 526}
527 527
528 528
529static void 529static void
530check_ciphers (void) 530check_ciphers (void)
531{ 531{
532 static int algos[] = { 532 static int algos[] = {
533 GCRY_CIPHER_3DES, 533 GCRY_CIPHER_3DES,
534 GCRY_CIPHER_CAST5, 534 GCRY_CIPHER_CAST5,
535 GCRY_CIPHER_BLOWFISH, 535 GCRY_CIPHER_BLOWFISH,
536 GCRY_CIPHER_AES, 536 GCRY_CIPHER_AES,
537 GCRY_CIPHER_AES192, 537 GCRY_CIPHER_AES192,
538 GCRY_CIPHER_AES256, 538 GCRY_CIPHER_AES256,
539 GCRY_CIPHER_TWOFISH, 539 GCRY_CIPHER_TWOFISH,
540 GCRY_CIPHER_TWOFISH128, 540 GCRY_CIPHER_TWOFISH128,
541 GCRY_CIPHER_DES, 541 GCRY_CIPHER_DES,
542 GCRY_CIPHER_SERPENT128, 542 GCRY_CIPHER_SERPENT128,
543 GCRY_CIPHER_SERPENT192, 543 GCRY_CIPHER_SERPENT192,
544 GCRY_CIPHER_SERPENT256, 544 GCRY_CIPHER_SERPENT256,
545 0 545 0
546 }; 546 };
547 static int algos2[] = { 547 static int algos2[] = {
548 GCRY_CIPHER_ARCFOUR, 548 GCRY_CIPHER_ARCFOUR,
549 0 549 0
550 }; 550 };
551 int i; 551 int i;
552 552
553 for (i = 0; algos[i]; i++) 553 for (i = 0; algos[i]; i++)
554 { 554 {
555 if (verbose) 555 if (verbose)
556 fprintf (stderr, "checking `%s' [%i]\n", 556 fprintf (stderr, "checking `%s' [%i]\n",
557 gcry_cipher_algo_name (algos[i]), 557 gcry_cipher_algo_name (algos[i]),
558 gcry_cipher_map_name (gcry_cipher_algo_name (algos[i]))); 558 gcry_cipher_map_name (gcry_cipher_algo_name (algos[i])));
559 559
560 check_one_cipher (algos[i], GCRY_CIPHER_MODE_ECB, 0); 560 check_one_cipher (algos[i], GCRY_CIPHER_MODE_ECB, 0);
561 check_one_cipher (algos[i], GCRY_CIPHER_MODE_CFB, 0); 561 check_one_cipher (algos[i], GCRY_CIPHER_MODE_CFB, 0);
562 check_one_cipher (algos[i], GCRY_CIPHER_MODE_CBC, 0); 562 check_one_cipher (algos[i], GCRY_CIPHER_MODE_CBC, 0);
563 check_one_cipher (algos[i], GCRY_CIPHER_MODE_CBC, GCRY_CIPHER_CBC_CTS); 563 check_one_cipher (algos[i], GCRY_CIPHER_MODE_CBC, GCRY_CIPHER_CBC_CTS);
564 check_one_cipher (algos[i], GCRY_CIPHER_MODE_CTR, 0); 564 check_one_cipher (algos[i], GCRY_CIPHER_MODE_CTR, 0);
565 } 565 }
566 566
567 for (i = 0; algos2[i]; i++) 567 for (i = 0; algos2[i]; i++)
568 { 568 {
569 if (verbose) 569 if (verbose)
570 fprintf (stderr, "checking `%s'\n", 570 fprintf (stderr, "checking `%s'\n",
571 gcry_cipher_algo_name (algos2[i])); 571 gcry_cipher_algo_name (algos2[i]));
572 572
573 check_one_cipher (algos2[i], GCRY_CIPHER_MODE_STREAM, 0); 573 check_one_cipher (algos2[i], GCRY_CIPHER_MODE_STREAM, 0);
574 } 574 }
575 /* we have now run all cipher's selftests */ 575 /* we have now run all cipher's selftests */
576 576
577 /* TODO: add some extra encryption to test the higher level functions */ 577 /* TODO: add some extra encryption to test the higher level functions */
578} 578}
579 579
580 580
581 581
582static void 582static void
583check_one_md (int algo, char *data, int len, char *expect) 583check_one_md (int algo, char *data, int len, char *expect)
584{ 584{
585 gcry_md_hd_t hd, hd2; 585 gcry_md_hd_t hd, hd2;
586 unsigned char *p; 586 unsigned char *p;
587 int mdlen; 587 int mdlen;
588 int i; 588 int i;
589 gcry_error_t err = 0; 589 gcry_error_t err = 0;
590 590
591 err = gcry_md_open (&hd, algo, 0); 591 err = gcry_md_open (&hd, algo, 0);
592 if (err) 592 if (err)
593 { 593 {
594 fail ("algo %d, grcy_md_open failed: %s\n", algo, gpg_strerror (err)); 594 fail ("algo %d, grcy_md_open failed: %s\n", algo, gpg_strerror (err));
595 return; 595 return;
596 } 596 }
597 597
598 mdlen = gcry_md_get_algo_dlen (algo); 598 mdlen = gcry_md_get_algo_dlen (algo);
599 if (mdlen < 1 || mdlen > 500) 599 if (mdlen < 1 || mdlen > 500)
600 { 600 {
601 fail ("algo %d, grcy_md_get_algo_dlen failed: %d\n", algo, mdlen); 601 fail ("algo %d, grcy_md_get_algo_dlen failed: %d\n", algo, mdlen);
602 return; 602 return;
603 } 603 }
604 604
605 if (*data == '!' && !data[1]) 605 if (*data == '!' && !data[1])
606 { /* hash one million times a "a" */ 606 { /* hash one million times a "a" */
607 char aaa[1000]; 607 char aaa[1000];
608 608
609 memset (aaa, 'a', 1000); 609 memset (aaa, 'a', 1000);
610 for (i = 0; i < 1000; i++) 610 for (i = 0; i < 1000; i++)
611 gcry_md_write (hd, aaa, 1000); 611 gcry_md_write (hd, aaa, 1000);
612 } 612 }
613 else 613 else
614 gcry_md_write (hd, data, len); 614 gcry_md_write (hd, data, len);
615 615
616 err = gcry_md_copy (&hd2, hd); 616 err = gcry_md_copy (&hd2, hd);
617 if (err) 617 if (err)
618 { 618 {
619 fail ("algo %d, gcry_md_copy failed: %s\n", algo, gpg_strerror (err)); 619 fail ("algo %d, gcry_md_copy failed: %s\n", algo, gpg_strerror (err));
620 } 620 }
621 621
622 gcry_md_close (hd); 622 gcry_md_close (hd);
623 623
624 p = gcry_md_read (hd2, algo); 624 p = gcry_md_read (hd2, algo);
625 625
626 if (memcmp (p, expect, mdlen)) 626 if (memcmp (p, expect, mdlen))
627 { 627 {
628 printf ("computed: "); 628 printf ("computed: ");
629 for (i = 0; i < mdlen; i++) 629 for (i = 0; i < mdlen; i++)
630 printf ("%02x ", p[i] & 0xFF); 630 printf ("%02x ", p[i] & 0xFF);
631 printf ("\nexpected: "); 631 printf ("\nexpected: ");
632 for (i = 0; i < mdlen; i++) 632 for (i = 0; i < mdlen; i++)
633 printf ("%02x ", expect[i] & 0xFF); 633 printf ("%02x ", expect[i] & 0xFF);
634 printf ("\n"); 634 printf ("\n");
635 635
636 fail ("algo %d, digest mismatch\n", algo); 636 fail ("algo %d, digest mismatch\n", algo);
637 } 637 }
638 638
639 gcry_md_close (hd2); 639 gcry_md_close (hd2);
640} 640}
641 641
642static void 642static void
643check_digests (void) 643check_digests (void)
644{ 644{
645 static struct algos 645 static struct algos
646 { 646 {
647 int md; 647 int md;
648 char *data; 648 char *data;
649 char *expect; 649 char *expect;
650 } algos[] = 650 } algos[] =
651 { 651 {
652 { GCRY_MD_MD4, "", 652 { GCRY_MD_MD4, "",
653 "\x31\xD6\xCF\xE0\xD1\x6A\xE9\x31\xB7\x3C\x59\xD7\xE0\xC0\x89\xC0" }, 653 "\x31\xD6\xCF\xE0\xD1\x6A\xE9\x31\xB7\x3C\x59\xD7\xE0\xC0\x89\xC0" },
654 { GCRY_MD_MD4, "a", 654 { GCRY_MD_MD4, "a",
655 "\xbd\xe5\x2c\xb3\x1d\xe3\x3e\x46\x24\x5e\x05\xfb\xdb\xd6\xfb\x24" }, 655 "\xbd\xe5\x2c\xb3\x1d\xe3\x3e\x46\x24\x5e\x05\xfb\xdb\xd6\xfb\x24" },
656 { GCRY_MD_MD4, "message digest", 656 { GCRY_MD_MD4, "message digest",
657 "\xd9\x13\x0a\x81\x64\x54\x9f\xe8\x18\x87\x48\x06\xe1\xc7\x01\x4b" }, 657 "\xd9\x13\x0a\x81\x64\x54\x9f\xe8\x18\x87\x48\x06\xe1\xc7\x01\x4b" },
658 { GCRY_MD_MD5, "", 658 { GCRY_MD_MD5, "",
659 "\xD4\x1D\x8C\xD9\x8F\x00\xB2\x04\xE9\x80\x09\x98\xEC\xF8\x42\x7E" }, 659 "\xD4\x1D\x8C\xD9\x8F\x00\xB2\x04\xE9\x80\x09\x98\xEC\xF8\x42\x7E" },
660 { GCRY_MD_MD5, "a", 660 { GCRY_MD_MD5, "a",
661 "\x0C\xC1\x75\xB9\xC0\xF1\xB6\xA8\x31\xC3\x99\xE2\x69\x77\x26\x61" }, 661 "\x0C\xC1\x75\xB9\xC0\xF1\xB6\xA8\x31\xC3\x99\xE2\x69\x77\x26\x61" },
662 { GCRY_MD_MD5, "abc", 662 { GCRY_MD_MD5, "abc",
663 "\x90\x01\x50\x98\x3C\xD2\x4F\xB0\xD6\x96\x3F\x7D\x28\xE1\x7F\x72" }, 663 "\x90\x01\x50\x98\x3C\xD2\x4F\xB0\xD6\x96\x3F\x7D\x28\xE1\x7F\x72" },
664 { GCRY_MD_MD5, "message digest", 664 { GCRY_MD_MD5, "message digest",
665 "\xF9\x6B\x69\x7D\x7C\xB7\x93\x8D\x52\x5A\x2F\x31\xAA\xF1\x61\xD0" }, 665 "\xF9\x6B\x69\x7D\x7C\xB7\x93\x8D\x52\x5A\x2F\x31\xAA\xF1\x61\xD0" },
666 { GCRY_MD_SHA1, "abc", 666 { GCRY_MD_SHA1, "abc",
667 "\xA9\x99\x3E\x36\x47\x06\x81\x6A\xBA\x3E" 667 "\xA9\x99\x3E\x36\x47\x06\x81\x6A\xBA\x3E"
668 "\x25\x71\x78\x50\xC2\x6C\x9C\xD0\xD8\x9D" }, 668 "\x25\x71\x78\x50\xC2\x6C\x9C\xD0\xD8\x9D" },
669 { GCRY_MD_SHA1, 669 { GCRY_MD_SHA1,
670 "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", 670 "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
671 "\x84\x98\x3E\x44\x1C\x3B\xD2\x6E\xBA\xAE" 671 "\x84\x98\x3E\x44\x1C\x3B\xD2\x6E\xBA\xAE"
672 "\x4A\xA1\xF9\x51\x29\xE5\xE5\x46\x70\xF1" }, 672 "\x4A\xA1\xF9\x51\x29\xE5\xE5\x46\x70\xF1" },
673 { GCRY_MD_SHA1, "!" /* kludge for "a"*1000000 */ , 673 { GCRY_MD_SHA1, "!" /* kludge for "a"*1000000 */ ,
674 "\x34\xAA\x97\x3C\xD4\xC4\xDA\xA4\xF6\x1E" 674 "\x34\xAA\x97\x3C\xD4\xC4\xDA\xA4\xF6\x1E"
675 "\xEB\x2B\xDB\xAD\x27\x31\x65\x34\x01\x6F" }, 675 "\xEB\x2B\xDB\xAD\x27\x31\x65\x34\x01\x6F" },
676 { GCRY_MD_SHA256, "abc", 676 { GCRY_MD_SHA256, "abc",
677 "\xba\x78\x16\xbf\x8f\x01\xcf\xea\x41\x41\x40\xde\x5d\xae\x22\x23" 677 "\xba\x78\x16\xbf\x8f\x01\xcf\xea\x41\x41\x40\xde\x5d\xae\x22\x23"
678 "\xb0\x03\x61\xa3\x96\x17\x7a\x9c\xb4\x10\xff\x61\xf2\x00\x15\xad" }, 678 "\xb0\x03\x61\xa3\x96\x17\x7a\x9c\xb4\x10\xff\x61\xf2\x00\x15\xad" },
679 { GCRY_MD_SHA256, 679 { GCRY_MD_SHA256,
680 "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", 680 "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
681 "\x24\x8d\x6a\x61\xd2\x06\x38\xb8\xe5\xc0\x26\x93\x0c\x3e\x60\x39" 681 "\x24\x8d\x6a\x61\xd2\x06\x38\xb8\xe5\xc0\x26\x93\x0c\x3e\x60\x39"
682 "\xa3\x3c\xe4\x59\x64\xff\x21\x67\xf6\xec\xed\xd4\x19\xdb\x06\xc1" }, 682 "\xa3\x3c\xe4\x59\x64\xff\x21\x67\xf6\xec\xed\xd4\x19\xdb\x06\xc1" },
683 { GCRY_MD_SHA256, "!", 683 { GCRY_MD_SHA256, "!",
684 "\xcd\xc7\x6e\x5c\x99\x14\xfb\x92\x81\xa1\xc7\xe2\x84\xd7\x3e\x67" 684 "\xcd\xc7\x6e\x5c\x99\x14\xfb\x92\x81\xa1\xc7\xe2\x84\xd7\x3e\x67"
685 "\xf1\x80\x9a\x48\xa4\x97\x20\x0e\x04\x6d\x39\xcc\xc7\x11\x2c\xd0" }, 685 "\xf1\x80\x9a\x48\xa4\x97\x20\x0e\x04\x6d\x39\xcc\xc7\x11\x2c\xd0" },
686 { GCRY_MD_SHA384, "abc", 686 { GCRY_MD_SHA384, "abc",
687 "\xcb\x00\x75\x3f\x45\xa3\x5e\x8b\xb5\xa0\x3d\x69\x9a\xc6\x50\x07" 687 "\xcb\x00\x75\x3f\x45\xa3\x5e\x8b\xb5\xa0\x3d\x69\x9a\xc6\x50\x07"
688 "\x27\x2c\x32\xab\x0e\xde\xd1\x63\x1a\x8b\x60\x5a\x43\xff\x5b\xed" 688 "\x27\x2c\x32\xab\x0e\xde\xd1\x63\x1a\x8b\x60\x5a\x43\xff\x5b\xed"
689 "\x80\x86\x07\x2b\xa1\xe7\xcc\x23\x58\xba\xec\xa1\x34\xc8\x25\xa7" }, 689 "\x80\x86\x07\x2b\xa1\xe7\xcc\x23\x58\xba\xec\xa1\x34\xc8\x25\xa7" },
690 { GCRY_MD_SHA512, "abc", 690 { GCRY_MD_SHA512, "abc",
691 "\xDD\xAF\x35\xA1\x93\x61\x7A\xBA\xCC\x41\x73\x49\xAE\x20\x41\x31" 691 "\xDD\xAF\x35\xA1\x93\x61\x7A\xBA\xCC\x41\x73\x49\xAE\x20\x41\x31"
692 "\x12\xE6\xFA\x4E\x89\xA9\x7E\xA2\x0A\x9E\xEE\xE6\x4B\x55\xD3\x9A" 692 "\x12\xE6\xFA\x4E\x89\xA9\x7E\xA2\x0A\x9E\xEE\xE6\x4B\x55\xD3\x9A"
693 "\x21\x92\x99\x2A\x27\x4F\xC1\xA8\x36\xBA\x3C\x23\xA3\xFE\xEB\xBD" 693 "\x21\x92\x99\x2A\x27\x4F\xC1\xA8\x36\xBA\x3C\x23\xA3\xFE\xEB\xBD"
694 "\x45\x4D\x44\x23\x64\x3C\xE8\x0E\x2A\x9A\xC9\x4F\xA5\x4C\xA4\x9F" }, 694 "\x45\x4D\x44\x23\x64\x3C\xE8\x0E\x2A\x9A\xC9\x4F\xA5\x4C\xA4\x9F" },
695 { GCRY_MD_RMD160, "", 695 { GCRY_MD_RMD160, "",
696 "\x9c\x11\x85\xa5\xc5\xe9\xfc\x54\x61\x28" 696 "\x9c\x11\x85\xa5\xc5\xe9\xfc\x54\x61\x28"
697 "\x08\x97\x7e\xe8\xf5\x48\xb2\x25\x8d\x31" }, 697 "\x08\x97\x7e\xe8\xf5\x48\xb2\x25\x8d\x31" },
698 { GCRY_MD_RMD160, "a", 698 { GCRY_MD_RMD160, "a",
699 "\x0b\xdc\x9d\x2d\x25\x6b\x3e\xe9\xda\xae" 699 "\x0b\xdc\x9d\x2d\x25\x6b\x3e\xe9\xda\xae"
700 "\x34\x7b\xe6\xf4\xdc\x83\x5a\x46\x7f\xfe" }, 700 "\x34\x7b\xe6\xf4\xdc\x83\x5a\x46\x7f\xfe" },
701 { GCRY_MD_RMD160, "abc", 701 { GCRY_MD_RMD160, "abc",
702 "\x8e\xb2\x08\xf7\xe0\x5d\x98\x7a\x9b\x04" 702 "\x8e\xb2\x08\xf7\xe0\x5d\x98\x7a\x9b\x04"
703 "\x4a\x8e\x98\xc6\xb0\x87\xf1\x5a\x0b\xfc" }, 703 "\x4a\x8e\x98\xc6\xb0\x87\xf1\x5a\x0b\xfc" },
704 { GCRY_MD_RMD160, "message digest", 704 { GCRY_MD_RMD160, "message digest",
705 "\x5d\x06\x89\xef\x49\xd2\xfa\xe5\x72\xb8" 705 "\x5d\x06\x89\xef\x49\xd2\xfa\xe5\x72\xb8"
706 "\x81\xb1\x23\xa8\x5f\xfa\x21\x59\x5f\x36" }, 706 "\x81\xb1\x23\xa8\x5f\xfa\x21\x59\x5f\x36" },
707 { GCRY_MD_CRC32, "", "\x00\x00\x00\x00" }, 707 { GCRY_MD_CRC32, "", "\x00\x00\x00\x00" },
708 { GCRY_MD_CRC32, "foo", "\x8c\x73\x65\x21" }, 708 { GCRY_MD_CRC32, "foo", "\x8c\x73\x65\x21" },
709 { GCRY_MD_CRC32_RFC1510, "", "\x00\x00\x00\x00" }, 709 { GCRY_MD_CRC32_RFC1510, "", "\x00\x00\x00\x00" },
710 { GCRY_MD_CRC32_RFC1510, "foo", "\x73\x32\xbc\x33" }, 710 { GCRY_MD_CRC32_RFC1510, "foo", "\x73\x32\xbc\x33" },
711 { GCRY_MD_CRC32_RFC1510, "test0123456789", "\xb8\x3e\x88\xd6" }, 711 { GCRY_MD_CRC32_RFC1510, "test0123456789", "\xb8\x3e\x88\xd6" },
712 { GCRY_MD_CRC32_RFC1510, "MASSACHVSETTS INSTITVTE OF TECHNOLOGY", 712 { GCRY_MD_CRC32_RFC1510, "MASSACHVSETTS INSTITVTE OF TECHNOLOGY",
713 "\xe3\x41\x80\xf7" }, 713 "\xe3\x41\x80\xf7" },
714#if 0 714#if 0
715 { GCRY_MD_CRC32_RFC1510, "\x80\x00", "\x3b\x83\x98\x4b" }, 715 { GCRY_MD_CRC32_RFC1510, "\x80\x00", "\x3b\x83\x98\x4b" },
716 { GCRY_MD_CRC32_RFC1510, "\x00\x08", "\x0e\xdb\x88\x32" }, 716 { GCRY_MD_CRC32_RFC1510, "\x00\x08", "\x0e\xdb\x88\x32" },
717 { GCRY_MD_CRC32_RFC1510, "\x00\x80", "\xed\xb8\x83\x20" }, 717 { GCRY_MD_CRC32_RFC1510, "\x00\x80", "\xed\xb8\x83\x20" },
718#endif 718#endif
719 { GCRY_MD_CRC32_RFC1510, "\x80", "\xed\xb8\x83\x20" }, 719 { GCRY_MD_CRC32_RFC1510, "\x80", "\xed\xb8\x83\x20" },
720#if 0 720#if 0
721 { GCRY_MD_CRC32_RFC1510, "\x80\x00\x00\x00", "\xed\x59\xb6\x3b" }, 721 { GCRY_MD_CRC32_RFC1510, "\x80\x00\x00\x00", "\xed\x59\xb6\x3b" },
722 { GCRY_MD_CRC32_RFC1510, "\x00\x00\x00\x01", "\x77\x07\x30\x96" }, 722 { GCRY_MD_CRC32_RFC1510, "\x00\x00\x00\x01", "\x77\x07\x30\x96" },
723#endif 723#endif
724 { GCRY_MD_CRC24_RFC2440, "", "\xb7\x04\xce" }, 724 { GCRY_MD_CRC24_RFC2440, "", "\xb7\x04\xce" },
725 { GCRY_MD_CRC24_RFC2440, "foo", "\x4f\xc2\x55" }, 725 { GCRY_MD_CRC24_RFC2440, "foo", "\x4f\xc2\x55" },
726 { GCRY_MD_TIGER, "", 726 { GCRY_MD_TIGER, "",
727 "\x24\xF0\x13\x0C\x63\xAC\x93\x32\x16\x16\x6E\x76" 727 "\x24\xF0\x13\x0C\x63\xAC\x93\x32\x16\x16\x6E\x76"
728 "\xB1\xBB\x92\x5F\xF3\x73\xDE\x2D\x49\x58\x4E\x7A" }, 728 "\xB1\xBB\x92\x5F\xF3\x73\xDE\x2D\x49\x58\x4E\x7A" },
729 { GCRY_MD_TIGER, "abc", 729 { GCRY_MD_TIGER, "abc",
730 "\xF2\x58\xC1\xE8\x84\x14\xAB\x2A\x52\x7A\xB5\x41" 730 "\xF2\x58\xC1\xE8\x84\x14\xAB\x2A\x52\x7A\xB5\x41"
731 "\xFF\xC5\xB8\xBF\x93\x5F\x7B\x95\x1C\x13\x29\x51" }, 731 "\xFF\xC5\xB8\xBF\x93\x5F\x7B\x95\x1C\x13\x29\x51" },
732 { GCRY_MD_TIGER, "Tiger", 732 { GCRY_MD_TIGER, "Tiger",
733 "\x9F\x00\xF5\x99\x07\x23\x00\xDD\x27\x6A\xBB\x38" 733 "\x9F\x00\xF5\x99\x07\x23\x00\xDD\x27\x6A\xBB\x38"
734 "\xC8\xEB\x6D\xEC\x37\x79\x0C\x11\x6F\x9D\x2B\xDF" }, 734 "\xC8\xEB\x6D\xEC\x37\x79\x0C\x11\x6F\x9D\x2B\xDF" },
735 { GCRY_MD_TIGER, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefg" 735 { GCRY_MD_TIGER, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefg"
736 "hijklmnopqrstuvwxyz0123456789+-", 736 "hijklmnopqrstuvwxyz0123456789+-",
737 "\x87\xFB\x2A\x90\x83\x85\x1C\xF7\x47\x0D\x2C\xF8" 737 "\x87\xFB\x2A\x90\x83\x85\x1C\xF7\x47\x0D\x2C\xF8"
738 "\x10\xE6\xDF\x9E\xB5\x86\x44\x50\x34\xA5\xA3\x86" }, 738 "\x10\xE6\xDF\x9E\xB5\x86\x44\x50\x34\xA5\xA3\x86" },
739 { GCRY_MD_TIGER, "ABCDEFGHIJKLMNOPQRSTUVWXYZ=abcdef" 739 { GCRY_MD_TIGER, "ABCDEFGHIJKLMNOPQRSTUVWXYZ=abcdef"
740 "ghijklmnopqrstuvwxyz+0123456789", 740 "ghijklmnopqrstuvwxyz+0123456789",
741 "\x46\x7D\xB8\x08\x63\xEB\xCE\x48\x8D\xF1\xCD\x12" 741 "\x46\x7D\xB8\x08\x63\xEB\xCE\x48\x8D\xF1\xCD\x12"
742 "\x61\x65\x5D\xE9\x57\x89\x65\x65\x97\x5F\x91\x97" }, 742 "\x61\x65\x5D\xE9\x57\x89\x65\x65\x97\x5F\x91\x97" },
743#if 0 743#if 0
744 { GCRY_MD_TIGER, "Tiger - A Fast New Hash Function, " 744 { GCRY_MD_TIGER, "Tiger - A Fast New Hash Function, "
745 "by Ross Anderson and Eli Biham", 745 "by Ross Anderson and Eli Biham",
746 "0C410A042968868A1671DA5A3FD29A725EC1E457D3CDB303" }, 746 "0C410A042968868A1671DA5A3FD29A725EC1E457D3CDB303" },
747 { GCRY_MD_TIGER, "Tiger - A Fast New Hash Function, " 747 { GCRY_MD_TIGER, "Tiger - A Fast New Hash Function, "
748 "by Ross Anderson and Eli Biham, proceedings of Fa" 748 "by Ross Anderson and Eli Biham, proceedings of Fa"
749 "st Software Encryption 3, Cambridge.", 749 "st Software Encryption 3, Cambridge.",
750 "EBF591D5AFA655CE7F22894FF87F54AC89C811B6B0DA3193" }, 750 "EBF591D5AFA655CE7F22894FF87F54AC89C811B6B0DA3193" },
751 { GCRY_MD_TIGER, "Tiger - A Fast New Hash Function, " 751 { GCRY_MD_TIGER, "Tiger - A Fast New Hash Function, "
752 "by Ross Anderson and Eli Biham, proceedings of Fa" 752 "by Ross Anderson and Eli Biham, proceedings of Fa"
753 "st Software Encryption 3, Cambridge, 1996.", 753 "st Software Encryption 3, Cambridge, 1996.",
754 "3D9AEB03D1BD1A6357B2774DFD6D5B24DD68151D503974FC" }, 754 "3D9AEB03D1BD1A6357B2774DFD6D5B24DD68151D503974FC" },
755 { GCRY_MD_TIGER, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefgh" 755 { GCRY_MD_TIGER, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefgh"
756 "ijklmnopqrstuvwxyz0123456789+-ABCDEFGHIJKLMNOPQRS" 756 "ijklmnopqrstuvwxyz0123456789+-ABCDEFGHIJKLMNOPQRS"
757 "TUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-", 757 "TUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-",
758 "00B83EB4E53440C5 76AC6AAEE0A74858 25FD15E70A59FFE4" }, 758 "00B83EB4E53440C5 76AC6AAEE0A74858 25FD15E70A59FFE4" },
759#endif 759#endif
760 { 0 }, 760 { 0 },
761 }; 761 };
762 int i; 762 int i;
763 763
764 for (i = 0; algos[i].md; i++) 764 for (i = 0; algos[i].md; i++)
765 { 765 {
766 if (verbose) 766 if (verbose)
767 fprintf (stderr, "checking `%s'\n", gcry_md_algo_name (algos[i].md)); 767 fprintf (stderr, "checking `%s'\n", gcry_md_algo_name (algos[i].md));
768 768
769 check_one_md (algos[i].md, algos[i].data, strlen (algos[i].data), 769 check_one_md (algos[i].md, algos[i].data, strlen (algos[i].data),
770 algos[i].expect); 770 algos[i].expect);
771 } 771 }
772 772
773 /* TODO: test HMAC mode */ 773 /* TODO: test HMAC mode */
774} 774}
775 775
776/* Check that the signature SIG matches the hash HASH. PKEY is the 776/* Check that the signature SIG matches the hash HASH. PKEY is the
777 public key used for the verification. BADHASH is a hasvalue which 777 public key used for the verification. BADHASH is a hasvalue which
778 should; result in a bad signature status. */ 778 should; result in a bad signature status. */
779static void 779static void
780verify_one_signature (gcry_sexp_t pkey, gcry_sexp_t hash, 780verify_one_signature (gcry_sexp_t pkey, gcry_sexp_t hash,
781 gcry_sexp_t badhash, gcry_sexp_t sig) 781 gcry_sexp_t badhash, gcry_sexp_t sig)
782{ 782{
783 gcry_error_t rc; 783 gcry_error_t rc;
784 784
785 rc = gcry_pk_verify (sig, hash, pkey); 785 rc = gcry_pk_verify (sig, hash, pkey);
786 if (rc) 786 if (rc)
787 fail ("gcry_pk_verify failed: %s\n", gpg_strerror (rc)); 787 fail ("gcry_pk_verify failed: %s\n", gpg_strerror (rc));
788 rc = gcry_pk_verify (sig, badhash, pkey); 788 rc = gcry_pk_verify (sig, badhash, pkey);
789 if (gcry_err_code (rc) != GPG_ERR_BAD_SIGNATURE) 789 if (gcry_err_code (rc) != GPG_ERR_BAD_SIGNATURE)
790 fail ("gcry_pk_verify failed to detect a bad signature: %s\n", 790 fail ("gcry_pk_verify failed to detect a bad signature: %s\n",
791 gpg_strerror (rc)); 791 gpg_strerror (rc));
792} 792}
793 793
794 794
795/* Test the public key sign function using the private ket SKEY. PKEY 795/* Test the public key sign function using the private ket SKEY. PKEY
796 is used for verification. */ 796 is used for verification. */
797static void 797static void
798check_pubkey_sign (int n, gcry_sexp_t skey, gcry_sexp_t pkey) 798check_pubkey_sign (int n, gcry_sexp_t skey, gcry_sexp_t pkey)
799{ 799{
800 gcry_error_t rc; 800 gcry_error_t rc;
801 gcry_sexp_t sig, badhash, hash; 801 gcry_sexp_t sig, badhash, hash;
802 int dataidx; 802 int dataidx;
803 static const char baddata[] = 803 static const char baddata[] =
804 "(data\n (flags pkcs1)\n" 804 "(data\n (flags pkcs1)\n"
805 " (hash sha1 #11223344556677889900AABBCCDDEEFF10203041#))\n"; 805 " (hash sha1 #11223344556677889900AABBCCDDEEFF10203041#))\n";
806 static struct 806 static struct
807 { 807 {
808 const char *data; 808 const char *data;
809 int expected_rc; 809 int expected_rc;
810 } datas[] = 810 } datas[] =
811 { 811 {
812 { "(data\n (flags pkcs1)\n" 812 { "(data\n (flags pkcs1)\n"
813 " (hash sha1 #11223344556677889900AABBCCDDEEFF10203040#))\n", 813 " (hash sha1 #11223344556677889900AABBCCDDEEFF10203040#))\n",
814 0 }, 814 0 },
815 { "(data\n (flags )\n" 815 { "(data\n (flags )\n"
816 " (hash sha1 #11223344556677889900AABBCCDDEEFF10203040#))\n", 816 " (hash sha1 #11223344556677889900AABBCCDDEEFF10203040#))\n",
817 GPG_ERR_CONFLICT }, 817 GPG_ERR_CONFLICT },
818 { "(data\n (flags pkcs1)\n" 818 { "(data\n (flags pkcs1)\n"
819 " (hash foo #11223344556677889900AABBCCDDEEFF10203040#))\n", 819 " (hash foo #11223344556677889900AABBCCDDEEFF10203040#))\n",
820 GPG_ERR_DIGEST_ALGO }, 820 GPG_ERR_DIGEST_ALGO },
821 { "(data\n (flags )\n" " (value #11223344556677889900AA#))\n", 821 { "(data\n (flags )\n" " (value #11223344556677889900AA#))\n",
822 0 }, 822 0 },
823 { "(data\n (flags raw)\n" " (value #11223344556677889900AA#))\n", 823 { "(data\n (flags raw)\n" " (value #11223344556677889900AA#))\n",
824 0 }, 824 0 },
825 { "(data\n (flags pkcs1)\n" 825 { "(data\n (flags pkcs1)\n"
826 " (value #11223344556677889900AA#))\n", 826 " (value #11223344556677889900AA#))\n",
827 GPG_ERR_CONFLICT }, 827 GPG_ERR_CONFLICT },
828 { "(data\n (flags raw foo)\n" 828 { "(data\n (flags raw foo)\n"
829 " (value #11223344556677889900AA#))\n", 829 " (value #11223344556677889900AA#))\n",
830 GPG_ERR_INV_FLAG }, 830 GPG_ERR_INV_FLAG },
831 { NULL } 831 { NULL }
832 }; 832 };
833 833
834 rc = gcry_sexp_sscan (&badhash, NULL, baddata, strlen (baddata)); 834 rc = gcry_sexp_sscan (&badhash, NULL, baddata, strlen (baddata));
835 if (rc) 835 if (rc)
836 die ("converting data failed: %s\n", gpg_strerror (rc)); 836 die ("converting data failed: %s\n", gpg_strerror (rc));
837 837
838 for (dataidx = 0; datas[dataidx].data; dataidx++) 838 for (dataidx = 0; datas[dataidx].data; dataidx++)
839 { 839 {
840 if (verbose) 840 if (verbose)
841 fprintf (stderr, "signature test %d\n", dataidx); 841 fprintf (stderr, "signature test %d\n", dataidx);
842 842
843 rc = gcry_sexp_sscan (&hash, NULL, datas[dataidx].data, 843 rc = gcry_sexp_sscan (&hash, NULL, datas[dataidx].data,
844 strlen (datas[dataidx].data)); 844 strlen (datas[dataidx].data));
845 if (rc) 845 if (rc)
846 die ("converting data failed: %s\n", gpg_strerror (rc)); 846 die ("converting data failed: %s\n", gpg_strerror (rc));
847 847
848 rc = gcry_pk_sign (&sig, hash, skey); 848 rc = gcry_pk_sign (&sig, hash, skey);
849 if (gcry_err_code (rc) != datas[dataidx].expected_rc) 849 if (gcry_err_code (rc) != datas[dataidx].expected_rc)
850 fail ("gcry_pk_sign failed: %s\n", gpg_strerror (rc)); 850 fail ("gcry_pk_sign failed: %s\n", gpg_strerror (rc));
851 851
852 if (!rc) 852 if (!rc)
853 verify_one_signature (pkey, hash, badhash, sig); 853 verify_one_signature (pkey, hash, badhash, sig);
854 854
855 gcry_sexp_release (sig); 855 gcry_sexp_release (sig);
856 sig = NULL; 856 sig = NULL;
857 gcry_sexp_release (hash); 857 gcry_sexp_release (hash);
858 hash = NULL; 858 hash = NULL;
859 } 859 }
860 860
861 gcry_sexp_release (badhash); 861 gcry_sexp_release (badhash);
862} 862}
863 863
864static void 864static void
865check_pubkey_grip (int n, const unsigned char *grip, 865check_pubkey_grip (int n, const unsigned char *grip,
866 gcry_sexp_t skey, gcry_sexp_t pkey) 866 gcry_sexp_t skey, gcry_sexp_t pkey)
867{ 867{
868 unsigned char sgrip[20], pgrip[20]; 868 unsigned char sgrip[20], pgrip[20];
869 869
870 if (!gcry_pk_get_keygrip (skey, sgrip)) 870 if (!gcry_pk_get_keygrip (skey, sgrip))
871 die ("get keygrip for private RSA key failed\n"); 871 die ("get keygrip for private RSA key failed\n");
872 if (!gcry_pk_get_keygrip (pkey, pgrip)) 872 if (!gcry_pk_get_keygrip (pkey, pgrip))
873 die ("[%i] get keygrip for public RSA key failed\n", n); 873 die ("[%i] get keygrip for public RSA key failed\n", n);
874 if (memcmp (sgrip, pgrip, 20)) 874 if (memcmp (sgrip, pgrip, 20))
875 fail ("[%i] keygrips don't match\n", n); 875 fail ("[%i] keygrips don't match\n", n);
876 if (memcmp (sgrip, grip, 20)) 876 if (memcmp (sgrip, grip, 20))
877 fail ("wrong keygrip for RSA key\n"); 877 fail ("wrong keygrip for RSA key\n");
878} 878}
879 879
880static void 880static void
881do_check_one_pubkey (int n, gcry_sexp_t skey, gcry_sexp_t pkey, 881do_check_one_pubkey (int n, gcry_sexp_t skey, gcry_sexp_t pkey,
882 const unsigned char *grip, int flags) 882 const unsigned char *grip, int flags)
883{ 883{
884 if (flags & FLAG_SIGN) 884 if (flags & FLAG_SIGN)
885 check_pubkey_sign (n, skey, pkey); 885 check_pubkey_sign (n, skey, pkey);
886 if (grip && (flags & FLAG_GRIP)) 886 if (grip && (flags & FLAG_GRIP))
887 check_pubkey_grip (n, grip, skey, pkey); 887 check_pubkey_grip (n, grip, skey, pkey);
888} 888}
889 889
890static void 890static void
891check_one_pubkey (int n, test_spec_pubkey_t spec) 891check_one_pubkey (int n, test_spec_pubkey_t spec)
892{ 892{
893 gcry_error_t err = GPG_ERR_NO_ERROR; 893 gcry_error_t err = GPG_ERR_NO_ERROR;
894 gcry_sexp_t skey, pkey; 894 gcry_sexp_t skey, pkey;
895 895
896 err = gcry_sexp_sscan (&skey, NULL, spec.key.secret, 896 err = gcry_sexp_sscan (&skey, NULL, spec.key.secret,
897 strlen (spec.key.secret)); 897 strlen (spec.key.secret));
898 if (!err) 898 if (!err)
899 err = gcry_sexp_sscan (&pkey, NULL, spec.key.public, 899 err = gcry_sexp_sscan (&pkey, NULL, spec.key.public,
900 strlen (spec.key.public)); 900 strlen (spec.key.public));
901 if (err) 901 if (err)
902 die ("converting sample key failed: %s\n", gpg_strerror (err)); 902 die ("converting sample key failed: %s\n", gpg_strerror (err));
903 903
904 do_check_one_pubkey (n, skey, pkey, spec.key.grip, spec.flags); 904 do_check_one_pubkey (n, skey, pkey, spec.key.grip, spec.flags);
905 905
906 gcry_sexp_release (skey); 906 gcry_sexp_release (skey);
907 gcry_sexp_release (pkey); 907 gcry_sexp_release (pkey);
908} 908}
909 909
910static void 910static void
911get_keys_new (gcry_sexp_t *pkey, gcry_sexp_t *skey) 911get_keys_new (gcry_sexp_t *pkey, gcry_sexp_t *skey)
912{ 912{
913 gcry_sexp_t key_spec, key, pub_key, sec_key; 913 gcry_sexp_t key_spec, key, pub_key, sec_key;
914 int rc; 914 int rc;
915 915
916 rc = gcry_sexp_new (&key_spec, 916 rc = gcry_sexp_new (&key_spec,
917 "(genkey (rsa (nbits 4:1024)))", 0, 1); 917 "(genkey (rsa (nbits 4:1024)))", 0, 1);
918 if (rc) 918 if (rc)
919 die ("error creating S-expression: %s\n", gpg_strerror (rc)); 919 die ("error creating S-expression: %s\n", gpg_strerror (rc));
920 rc = gcry_pk_genkey (&key, key_spec); 920 rc = gcry_pk_genkey (&key, key_spec);
921 gcry_sexp_release (key_spec); 921 gcry_sexp_release (key_spec);
922 if (rc) 922 if (rc)
923 die ("error generating RSA key: %s\n", gpg_strerror (rc)); 923 die ("error generating RSA key: %s\n", gpg_strerror (rc));
924 924
925 pub_key = gcry_sexp_find_token (key, "public-key", 0); 925 pub_key = gcry_sexp_find_token (key, "public-key", 0);
926 if (! pub_key) 926 if (! pub_key)
927 die ("public part missing in key\n"); 927 die ("public part missing in key\n");
928 928
929 sec_key = gcry_sexp_find_token (key, "private-key", 0); 929 sec_key = gcry_sexp_find_token (key, "private-key", 0);
930 if (! sec_key) 930 if (! sec_key)
931 die ("private part missing in key\n"); 931 die ("private part missing in key\n");
932 932
933 gcry_sexp_release (key); 933 gcry_sexp_release (key);
934 *pkey = pub_key; 934 *pkey = pub_key;
935 *skey = sec_key; 935 *skey = sec_key;
936} 936}
937 937
938static void 938static void
939check_one_pubkey_new (int n) 939check_one_pubkey_new (int n)
940{ 940{
941 gcry_sexp_t skey, pkey; 941 gcry_sexp_t skey, pkey;
942 942
943 get_keys_new (&pkey, &skey); 943 get_keys_new (&pkey, &skey);
944 do_check_one_pubkey (n, skey, pkey, NULL, FLAG_SIGN | FLAG_CRYPT); 944 do_check_one_pubkey (n, skey, pkey, NULL, FLAG_SIGN | FLAG_CRYPT);
945} 945}
946 946
947/* Run all tests for the public key fucntions. */ 947/* Run all tests for the public key fucntions. */
948static void 948static void
949check_pubkey (void) 949check_pubkey (void)
950{ 950{
951 test_spec_pubkey_t pubkeys[] = 951 test_spec_pubkey_t pubkeys[] =
952 { 952 {
953 { 953 {
954 GCRY_PK_RSA, FLAG_CRYPT | FLAG_SIGN, 954 GCRY_PK_RSA, FLAG_CRYPT | FLAG_SIGN,
955 955
956 { "(private-key\n" 956 { "(private-key\n"
957 " (rsa\n" 957 " (rsa\n"
958 " (n #00e0ce96f90b6c9e02f3922beada93fe50a875eac6bcc18bb9a9cf2e84965caa" 958 " (n #00e0ce96f90b6c9e02f3922beada93fe50a875eac6bcc18bb9a9cf2e84965caa"
959 " 2d1ff95a7f542465c6c0c19d276e4526ce048868a7a914fd343cc3a87dd74291" 959 " 2d1ff95a7f542465c6c0c19d276e4526ce048868a7a914fd343cc3a87dd74291"
960 " ffc565506d5bbb25cbac6a0e2dd1f8bcaab0d4a29c2f37c950f363484bf269f7" 960 " ffc565506d5bbb25cbac6a0e2dd1f8bcaab0d4a29c2f37c950f363484bf269f7"
961 " 891440464baf79827e03a36e70b814938eebdc63e964247be75dc58b014b7ea251#)\n" 961 " 891440464baf79827e03a36e70b814938eebdc63e964247be75dc58b014b7ea251#)\n"
962 " (e #010001#)\n" 962 " (e #010001#)\n"
963 " (d #046129F2489D71579BE0A75FE029BD6CDB574EBF57EA8A5B0FDA942CAB943B11" 963 " (d #046129F2489D71579BE0A75FE029BD6CDB574EBF57EA8A5B0FDA942CAB943B11"
964 " 7D7BB95E5D28875E0F9FC5FCC06A72F6D502464DABDED78EF6B716177B83D5BD" 964 " 7D7BB95E5D28875E0F9FC5FCC06A72F6D502464DABDED78EF6B716177B83D5BD"
965 " C543DC5D3FED932E59F5897E92E6F58A0F33424106A3B6FA2CBF877510E4AC21" 965 " C543DC5D3FED932E59F5897E92E6F58A0F33424106A3B6FA2CBF877510E4AC21"
966 " C3EE47851E97D12996222AC3566D4CCB0B83D164074ABF7DE655FC2446DA1781#)\n" 966 " C3EE47851E97D12996222AC3566D4CCB0B83D164074ABF7DE655FC2446DA1781#)\n"
967 " (p #00e861b700e17e8afe6837e7512e35b6ca11d0ae47d8b85161c67baf64377213" 967 " (p #00e861b700e17e8afe6837e7512e35b6ca11d0ae47d8b85161c67baf64377213"
968 " fe52d772f2035b3ca830af41d8a4120e1c1c70d12cc22f00d28d31dd48a8d424f1#)\n" 968 " fe52d772f2035b3ca830af41d8a4120e1c1c70d12cc22f00d28d31dd48a8d424f1#)\n"
969 " (q #00f7a7ca5367c661f8e62df34f0d05c10c88e5492348dd7bddc942c9a8f369f9" 969 " (q #00f7a7ca5367c661f8e62df34f0d05c10c88e5492348dd7bddc942c9a8f369f9"
970 " 35a07785d2db805215ed786e4285df1658eed3ce84f469b81b50d358407b4ad361#)\n" 970 " 35a07785d2db805215ed786e4285df1658eed3ce84f469b81b50d358407b4ad361#)\n"
971 " (u #304559a9ead56d2309d203811a641bb1a09626bc8eb36fffa23c968ec5bd891e" 971 " (u #304559a9ead56d2309d203811a641bb1a09626bc8eb36fffa23c968ec5bd891e"
972 " ebbafc73ae666e01ba7c8990bae06cc2bbe10b75e69fcacb353a6473079d8e9b#)))\n", 972 " ebbafc73ae666e01ba7c8990bae06cc2bbe10b75e69fcacb353a6473079d8e9b#)))\n",
973 973
974 "(public-key\n" 974 "(public-key\n"
975 " (rsa\n" 975 " (rsa\n"
976 " (n #00e0ce96f90b6c9e02f3922beada93fe50a875eac6bcc18bb9a9cf2e84965caa" 976 " (n #00e0ce96f90b6c9e02f3922beada93fe50a875eac6bcc18bb9a9cf2e84965caa"
977 " 2d1ff95a7f542465c6c0c19d276e4526ce048868a7a914fd343cc3a87dd74291" 977 " 2d1ff95a7f542465c6c0c19d276e4526ce048868a7a914fd343cc3a87dd74291"
978 " ffc565506d5bbb25cbac6a0e2dd1f8bcaab0d4a29c2f37c950f363484bf269f7" 978 " ffc565506d5bbb25cbac6a0e2dd1f8bcaab0d4a29c2f37c950f363484bf269f7"
979 " 891440464baf79827e03a36e70b814938eebdc63e964247be75dc58b014b7ea251#)\n" 979 " 891440464baf79827e03a36e70b814938eebdc63e964247be75dc58b014b7ea251#)\n"
980 " (e #010001#)))\n", 980 " (e #010001#)))\n",
981 981
982 (const unsigned char*)"\x32\x10\x0c\x27\x17\x3e\xf6\xe9\xc4\xe9" 982 (const unsigned char*)"\x32\x10\x0c\x27\x17\x3e\xf6\xe9\xc4\xe9"
983 "\xa2\x5d\x3d\x69\xf8\x6d\x37\xa4\xf9\x39"} 983 "\xa2\x5d\x3d\x69\xf8\x6d\x37\xa4\xf9\x39"}
984 }, 984 },
985 { 985 {
986 GCRY_PK_DSA, FLAG_SIGN, 986 GCRY_PK_DSA, FLAG_SIGN,
987 987
988 { "(private-key\n" 988 { "(private-key\n"
989 " (DSA\n" 989 " (DSA\n"
990 " (p #00AD7C0025BA1A15F775F3F2D673718391D00456978D347B33D7B49E7F32EDAB" 990 " (p #00AD7C0025BA1A15F775F3F2D673718391D00456978D347B33D7B49E7F32EDAB"
991 " 96273899DD8B2BB46CD6ECA263FAF04A28903503D59062A8865D2AE8ADFB5191" 991 " 96273899DD8B2BB46CD6ECA263FAF04A28903503D59062A8865D2AE8ADFB5191"
992 " CF36FFB562D0E2F5809801A1F675DAE59698A9E01EFE8D7DCFCA084F4C6F5A44" 992 " CF36FFB562D0E2F5809801A1F675DAE59698A9E01EFE8D7DCFCA084F4C6F5A44"
993 " 44D499A06FFAEA5E8EF5E01F2FD20A7B7EF3F6968AFBA1FB8D91F1559D52D8777B#)\n" 993 " 44D499A06FFAEA5E8EF5E01F2FD20A7B7EF3F6968AFBA1FB8D91F1559D52D8777B#)\n"
994 " (q #00EB7B5751D25EBBB7BD59D920315FD840E19AEBF9#)\n" 994 " (q #00EB7B5751D25EBBB7BD59D920315FD840E19AEBF9#)\n"
995 " (g #1574363387FDFD1DDF38F4FBE135BB20C7EE4772FB94C337AF86EA8E49666503" 995 " (g #1574363387FDFD1DDF38F4FBE135BB20C7EE4772FB94C337AF86EA8E49666503"
996 " AE04B6BE81A2F8DD095311E0217ACA698A11E6C5D33CCDAE71498ED35D13991E" 996 " AE04B6BE81A2F8DD095311E0217ACA698A11E6C5D33CCDAE71498ED35D13991E"
997 " B02F09AB40BD8F4C5ED8C75DA779D0AE104BC34C960B002377068AB4B5A1F984" 997 " B02F09AB40BD8F4C5ED8C75DA779D0AE104BC34C960B002377068AB4B5A1F984"
998 " 3FBA91F537F1B7CAC4D8DD6D89B0D863AF7025D549F9C765D2FC07EE208F8D15#)\n" 998 " 3FBA91F537F1B7CAC4D8DD6D89B0D863AF7025D549F9C765D2FC07EE208F8D15#)\n"
999 " (y #64B11EF8871BE4AB572AA810D5D3CA11A6CDBC637A8014602C72960DB135BF46" 999 " (y #64B11EF8871BE4AB572AA810D5D3CA11A6CDBC637A8014602C72960DB135BF46"
1000 " A1816A724C34F87330FC9E187C5D66897A04535CC2AC9164A7150ABFA8179827" 1000 " A1816A724C34F87330FC9E187C5D66897A04535CC2AC9164A7150ABFA8179827"
1001 " 6E45831AB811EEE848EBB24D9F5F2883B6E5DDC4C659DEF944DCFD80BF4D0A20" 1001 " 6E45831AB811EEE848EBB24D9F5F2883B6E5DDC4C659DEF944DCFD80BF4D0A20"
1002 " 42CAA7DC289F0C5A9D155F02D3D551DB741A81695B74D4C8F477F9C7838EB0FB#)\n" 1002 " 42CAA7DC289F0C5A9D155F02D3D551DB741A81695B74D4C8F477F9C7838EB0FB#)\n"
1003 " (x #11D54E4ADBD3034160F2CED4B7CD292A4EBF3EC0#)))\n", 1003 " (x #11D54E4ADBD3034160F2CED4B7CD292A4EBF3EC0#)))\n",
1004 1004
1005 "(public-key\n" 1005 "(public-key\n"
1006 " (DSA\n" 1006 " (DSA\n"
1007 " (p #00AD7C0025BA1A15F775F3F2D673718391D00456978D347B33D7B49E7F32EDAB" 1007 " (p #00AD7C0025BA1A15F775F3F2D673718391D00456978D347B33D7B49E7F32EDAB"
1008 " 96273899DD8B2BB46CD6ECA263FAF04A28903503D59062A8865D2AE8ADFB5191" 1008 " 96273899DD8B2BB46CD6ECA263FAF04A28903503D59062A8865D2AE8ADFB5191"
1009 " CF36FFB562D0E2F5809801A1F675DAE59698A9E01EFE8D7DCFCA084F4C6F5A44" 1009 " CF36FFB562D0E2F5809801A1F675DAE59698A9E01EFE8D7DCFCA084F4C6F5A44"
1010 " 44D499A06FFAEA5E8EF5E01F2FD20A7B7EF3F6968AFBA1FB8D91F1559D52D8777B#)\n" 1010 " 44D499A06FFAEA5E8EF5E01F2FD20A7B7EF3F6968AFBA1FB8D91F1559D52D8777B#)\n"
1011 " (q #00EB7B5751D25EBBB7BD59D920315FD840E19AEBF9#)\n" 1011 " (q #00EB7B5751D25EBBB7BD59D920315FD840E19AEBF9#)\n"
1012 " (g #1574363387FDFD1DDF38F4FBE135BB20C7EE4772FB94C337AF86EA8E49666503" 1012 " (g #1574363387FDFD1DDF38F4FBE135BB20C7EE4772FB94C337AF86EA8E49666503"
1013 " AE04B6BE81A2F8DD095311E0217ACA698A11E6C5D33CCDAE71498ED35D13991E" 1013 " AE04B6BE81A2F8DD095311E0217ACA698A11E6C5D33CCDAE71498ED35D13991E"
1014 " B02F09AB40BD8F4C5ED8C75DA779D0AE104BC34C960B002377068AB4B5A1F984" 1014 " B02F09AB40BD8F4C5ED8C75DA779D0AE104BC34C960B002377068AB4B5A1F984"
1015 " 3FBA91F537F1B7CAC4D8DD6D89B0D863AF7025D549F9C765D2FC07EE208F8D15#)\n" 1015 " 3FBA91F537F1B7CAC4D8DD6D89B0D863AF7025D549F9C765D2FC07EE208F8D15#)\n"
1016 " (y #64B11EF8871BE4AB572AA810D5D3CA11A6CDBC637A8014602C72960DB135BF46" 1016 " (y #64B11EF8871BE4AB572AA810D5D3CA11A6CDBC637A8014602C72960DB135BF46"
1017 " A1816A724C34F87330FC9E187C5D66897A04535CC2AC9164A7150ABFA8179827" 1017 " A1816A724C34F87330FC9E187C5D66897A04535CC2AC9164A7150ABFA8179827"
1018 " 6E45831AB811EEE848EBB24D9F5F2883B6E5DDC4C659DEF944DCFD80BF4D0A20" 1018 " 6E45831AB811EEE848EBB24D9F5F2883B6E5DDC4C659DEF944DCFD80BF4D0A20"
1019 " 42CAA7DC289F0C5A9D155F02D3D551DB741A81695B74D4C8F477F9C7838EB0FB#)))\n", 1019 " 42CAA7DC289F0C5A9D155F02D3D551DB741A81695B74D4C8F477F9C7838EB0FB#)))\n",
1020 1020
1021 (const unsigned char*)"\xc6\x39\x83\x1a\x43\xe5\x05\x5d\xc6\xd8" 1021 (const unsigned char*)"\xc6\x39\x83\x1a\x43\xe5\x05\x5d\xc6\xd8"
1022 "\x4a\xa6\xf9\xeb\x23\xbf\xa9\x12\x2d\x5b" } 1022 "\x4a\xa6\xf9\xeb\x23\xbf\xa9\x12\x2d\x5b" }
1023 }, 1023 },
1024 { 1024 {
1025 GCRY_PK_ELG, FLAG_SIGN | FLAG_CRYPT, 1025 GCRY_PK_ELG, FLAG_SIGN | FLAG_CRYPT,
1026 1026
1027 { "(private-key\n" 1027 { "(private-key\n"
1028 " (ELG\n" 1028 " (ELG\n"
1029 " (p #00B93B93386375F06C2D38560F3B9C6D6D7B7506B20C1773F73F8DE56E6CD65D" 1029 " (p #00B93B93386375F06C2D38560F3B9C6D6D7B7506B20C1773F73F8DE56E6CD65D"
1030 " F48DFAAA1E93F57A2789B168362A0F787320499F0B2461D3A4268757A7B27517" 1030 " F48DFAAA1E93F57A2789B168362A0F787320499F0B2461D3A4268757A7B27517"
1031 " B7D203654A0CD484DEC6AF60C85FEB84AAC382EAF2047061FE5DAB81A20A0797" 1031 " B7D203654A0CD484DEC6AF60C85FEB84AAC382EAF2047061FE5DAB81A20A0797"
1032 " 6E87359889BAE3B3600ED718BE61D4FC993CC8098A703DD0DC942E965E8F18D2A7#)\n" 1032 " 6E87359889BAE3B3600ED718BE61D4FC993CC8098A703DD0DC942E965E8F18D2A7#)\n"
1033 " (g #05#)\n" 1033 " (g #05#)\n"
1034 " (y #72DAB3E83C9F7DD9A931FDECDC6522C0D36A6F0A0FEC955C5AC3C09175BBFF2B" 1034 " (y #72DAB3E83C9F7DD9A931FDECDC6522C0D36A6F0A0FEC955C5AC3C09175BBFF2B"
1035 " E588DB593DC2E420201BEB3AC17536918417C497AC0F8657855380C1FCF11C5B" 1035 " E588DB593DC2E420201BEB3AC17536918417C497AC0F8657855380C1FCF11C5B"
1036 " D20DB4BEE9BDF916648DE6D6E419FA446C513AAB81C30CB7B34D6007637BE675" 1036 " D20DB4BEE9BDF916648DE6D6E419FA446C513AAB81C30CB7B34D6007637BE675"
1037 " 56CE6473E9F9EE9B9FADD275D001563336F2186F424DEC6199A0F758F6A00FF4#)\n" 1037 " 56CE6473E9F9EE9B9FADD275D001563336F2186F424DEC6199A0F758F6A00FF4#)\n"
1038 " (x #03C28900087B38DABF4A0AB98ACEA39BB674D6557096C01D72E31C16BDD32214#)))\n", 1038 " (x #03C28900087B38DABF4A0AB98ACEA39BB674D6557096C01D72E31C16BDD32214#)))\n",
1039 1039
1040 "(public-key\n" 1040 "(public-key\n"
1041 " (ELG\n" 1041 " (ELG\n"
1042 " (p #00B93B93386375F06C2D38560F3B9C6D6D7B7506B20C1773F73F8DE56E6CD65D" 1042 " (p #00B93B93386375F06C2D38560F3B9C6D6D7B7506B20C1773F73F8DE56E6CD65D"
1043 " F48DFAAA1E93F57A2789B168362A0F787320499F0B2461D3A4268757A7B27517" 1043 " F48DFAAA1E93F57A2789B168362A0F787320499F0B2461D3A4268757A7B27517"
1044 " B7D203654A0CD484DEC6AF60C85FEB84AAC382EAF2047061FE5DAB81A20A0797" 1044 " B7D203654A0CD484DEC6AF60C85FEB84AAC382EAF2047061FE5DAB81A20A0797"
1045 " 6E87359889BAE3B3600ED718BE61D4FC993CC8098A703DD0DC942E965E8F18D2A7#)\n" 1045 " 6E87359889BAE3B3600ED718BE61D4FC993CC8098A703DD0DC942E965E8F18D2A7#)\n"
1046 " (g #05#)\n" 1046 " (g #05#)\n"
1047 " (y #72DAB3E83C9F7DD9A931FDECDC6522C0D36A6F0A0FEC955C5AC3C09175BBFF2B" 1047 " (y #72DAB3E83C9F7DD9A931FDECDC6522C0D36A6F0A0FEC955C5AC3C09175BBFF2B"
1048 " E588DB593DC2E420201BEB3AC17536918417C497AC0F8657855380C1FCF11C5B" 1048 " E588DB593DC2E420201BEB3AC17536918417C497AC0F8657855380C1FCF11C5B"
1049 " D20DB4BEE9BDF916648DE6D6E419FA446C513AAB81C30CB7B34D6007637BE675" 1049 " D20DB4BEE9BDF916648DE6D6E419FA446C513AAB81C30CB7B34D6007637BE675"
1050 " 56CE6473E9F9EE9B9FADD275D001563336F2186F424DEC6199A0F758F6A00FF4#)))\n", 1050 " 56CE6473E9F9EE9B9FADD275D001563336F2186F424DEC6199A0F758F6A00FF4#)))\n",
1051 1051
1052 (const unsigned char*)"\xa7\x99\x61\xeb\x88\x83\xd2\xf4\x05\xc8" 1052 (const unsigned char*)"\xa7\x99\x61\xeb\x88\x83\xd2\xf4\x05\xc8"
1053 "\x4f\xba\x06\xf8\x78\x09\xbc\x1e\x20\xe5" } 1053 "\x4f\xba\x06\xf8\x78\x09\xbc\x1e\x20\xe5" }
1054 }, 1054 },
1055 }; 1055 };
1056 int i; 1056 int i;
1057 1057
1058 for (i = 0; i < sizeof (pubkeys) / sizeof (*pubkeys); i++) 1058 for (i = 0; i < sizeof (pubkeys) / sizeof (*pubkeys); i++)
1059 if (pubkeys[i].id) 1059 if (pubkeys[i].id)
1060 check_one_pubkey (i, pubkeys[i]); 1060 check_one_pubkey (i, pubkeys[i]);
1061 1061
1062 check_one_pubkey_new (i); 1062 check_one_pubkey_new (i);
1063} 1063}
1064 1064
1065int 1065int
1066main (int argc, char **argv) 1066main (int argc, char **argv)
1067{ 1067{
1068 int debug = 0; 1068 int debug = 0;
1069 1069
1070 if (argc > 1 && !strcmp (argv[1], "--verbose")) 1070 if (argc > 1 && !strcmp (argv[1], "--verbose"))
1071 verbose = 1; 1071 verbose = 1;
1072 else if (argc > 1 && !strcmp (argv[1], "--debug")) 1072 else if (argc > 1 && !strcmp (argv[1], "--debug"))
1073 verbose = debug = 1; 1073 verbose = debug = 1;
1074 1074
1075 if (!gcry_check_version (GCRYPT_VERSION)) 1075 if (!gcry_check_version (GCRYPT_VERSION))
1076 die ("version mismatch\n"); 1076 die ("version mismatch\n");
1077 1077
1078 gcry_set_progress_handler (progress_handler, NULL); 1078 gcry_set_progress_handler (progress_handler, NULL);
1079 1079
1080 gcry_control (GCRYCTL_DISABLE_SECMEM, 0); 1080 gcry_control (GCRYCTL_DISABLE_SECMEM, 0);
1081 gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); 1081 gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
1082 if (debug) 1082 if (debug)
1083 gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1u, 0); 1083 gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1u, 0);
1084 check_ciphers (); 1084 check_ciphers ();
1085 check_aes128_cbc_cts_cipher (); 1085 check_aes128_cbc_cts_cipher ();
1086 check_cbc_mac_cipher (); 1086 check_cbc_mac_cipher ();
1087 check_ctr_cipher (); 1087 check_ctr_cipher ();
1088 check_digests (); 1088 check_digests ();
1089 check_pubkey (); 1089 check_pubkey ();
1090 1090
1091 return error_count ? 1 : 0; 1091 return error_count ? 1 : 0;
1092} 1092}
diff --git a/linden/indra/libgcrypt/libgcrypt-1.2.2/tests/benchmark.c b/linden/indra/libgcrypt/libgcrypt-1.2.2/tests/benchmark.c
index 5f3fcff..2af06ab 100755..100644
--- a/linden/indra/libgcrypt/libgcrypt-1.2.2/tests/benchmark.c
+++ b/linden/indra/libgcrypt/libgcrypt-1.2.2/tests/benchmark.c
@@ -1,440 +1,440 @@
1/* benchmark.c - for libgcrypt 1/* benchmark.c - for libgcrypt
2 * Copyright (C) 2002, 2004 Free Software Foundation, Inc. 2 * Copyright (C) 2002, 2004 Free Software Foundation, Inc.
3 * 3 *
4 * This file is part of Libgcrypt. 4 * This file is part of Libgcrypt.
5 * 5 *
6 * Libgcrypt is free software; you can redistribute it and/or modify 6 * Libgcrypt is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser general Public License as 7 * it under the terms of the GNU Lesser general Public License as
8 * published by the Free Software Foundation; either version 2.1 of 8 * published by the Free Software Foundation; either version 2.1 of
9 * the License, or (at your option) any later version. 9 * the License, or (at your option) any later version.
10 * 10 *
11 * Libgcrypt is distributed in the hope that it will be useful, 11 * Libgcrypt is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details. 14 * GNU Lesser General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU Lesser General Public 16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this program; if not, write to the Free Software 17 * License along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
19 */ 19 */
20 20
21#ifdef HAVE_CONFIG_H 21#ifdef HAVE_CONFIG_H
22#include <config.h> 22#include <config.h>
23#endif 23#endif
24#include <stdio.h> 24#include <stdio.h>
25#include <stdlib.h> 25#include <stdlib.h>
26#include <time.h> 26#include <time.h>
27#ifndef _WIN32 27#ifndef _WIN32
28#include <sys/times.h> 28#include <sys/times.h>
29#endif 29#endif
30#include <gcrypt.h> 30#include <gcrypt.h>
31 31
32#define PGM "benchmark" 32#define PGM "benchmark"
33#define BUG() do {fprintf ( stderr, "Ooops at %s:%d\n", __FILE__ , __LINE__ );\ 33#define BUG() do {fprintf ( stderr, "Ooops at %s:%d\n", __FILE__ , __LINE__ );\
34 exit(2);} while(0) 34 exit(2);} while(0)
35 35
36 36
37/* Helper for the start and stop timer. */ 37/* Helper for the start and stop timer. */
38static clock_t started_at, stopped_at; 38static clock_t started_at, stopped_at;
39 39
40 40
41static void 41static void
42start_timer (void) 42start_timer (void)
43{ 43{
44#ifdef _WIN32 44#ifdef _WIN32
45 started_at = stopped_at = clock (); 45 started_at = stopped_at = clock ();
46#else 46#else
47 struct tms tmp; 47 struct tms tmp;
48 48
49 times (&tmp); 49 times (&tmp);
50 started_at = stopped_at = tmp.tms_utime; 50 started_at = stopped_at = tmp.tms_utime;
51#endif 51#endif
52} 52}
53 53
54static void 54static void
55stop_timer (void) 55stop_timer (void)
56{ 56{
57#ifdef _WIN32 57#ifdef _WIN32
58 stopped_at = clock (); 58 stopped_at = clock ();
59#else 59#else
60 struct tms tmp; 60 struct tms tmp;
61 61
62 times (&tmp); 62 times (&tmp);
63 stopped_at = tmp.tms_utime; 63 stopped_at = tmp.tms_utime;
64#endif 64#endif
65} 65}
66 66
67static const char * 67static const char *
68elapsed_time (void) 68elapsed_time (void)
69{ 69{
70 static char buf[50]; 70 static char buf[50];
71 71
72 sprintf (buf, "%5.0fms", 72 sprintf (buf, "%5.0fms",
73 (((double) (stopped_at - started_at))/CLOCKS_PER_SEC)*10000000); 73 (((double) (stopped_at - started_at))/CLOCKS_PER_SEC)*10000000);
74 return buf; 74 return buf;
75} 75}
76 76
77 77
78static void 78static void
79random_bench (void) 79random_bench (void)
80{ 80{
81 char buf[128]; 81 char buf[128];
82 int i; 82 int i;
83 83
84 printf ("%-10s", "random"); 84 printf ("%-10s", "random");
85 85
86 start_timer (); 86 start_timer ();
87 for (i=0; i < 100; i++) 87 for (i=0; i < 100; i++)
88 gcry_randomize (buf, sizeof buf, GCRY_STRONG_RANDOM); 88 gcry_randomize (buf, sizeof buf, GCRY_STRONG_RANDOM);
89 stop_timer (); 89 stop_timer ();
90 printf (" %s", elapsed_time ()); 90 printf (" %s", elapsed_time ());
91 91
92 start_timer (); 92 start_timer ();
93 for (i=0; i < 100; i++) 93 for (i=0; i < 100; i++)
94 gcry_randomize (buf, 8, GCRY_STRONG_RANDOM); 94 gcry_randomize (buf, 8, GCRY_STRONG_RANDOM);
95 stop_timer (); 95 stop_timer ();
96 printf (" %s", elapsed_time ()); 96 printf (" %s", elapsed_time ());
97 97
98 putchar ('\n'); 98 putchar ('\n');
99} 99}
100 100
101 101
102 102
103static void 103static void
104md_bench ( const char *algoname ) 104md_bench ( const char *algoname )
105{ 105{
106 int algo; 106 int algo;
107 gcry_md_hd_t hd; 107 gcry_md_hd_t hd;
108 int i; 108 int i;
109 char buf[1000]; 109 char buf[1000];
110 gcry_error_t err = GPG_ERR_NO_ERROR; 110 gcry_error_t err = GPG_ERR_NO_ERROR;
111 111
112 if (!algoname) 112 if (!algoname)
113 { 113 {
114 for (i=1; i < 400; i++) 114 for (i=1; i < 400; i++)
115 if ( !gcry_md_test_algo (i) ) 115 if ( !gcry_md_test_algo (i) )
116 md_bench (gcry_md_algo_name (i)); 116 md_bench (gcry_md_algo_name (i));
117 return; 117 return;
118 } 118 }
119 119
120 algo = gcry_md_map_name (algoname); 120 algo = gcry_md_map_name (algoname);
121 if (!algo) 121 if (!algo)
122 { 122 {
123 fprintf (stderr, PGM ": invalid hash algorithm `%s'\n", algoname); 123 fprintf (stderr, PGM ": invalid hash algorithm `%s'\n", algoname);
124 exit (1); 124 exit (1);
125 } 125 }
126 126
127 err = gcry_md_open (&hd, algo, 0); 127 err = gcry_md_open (&hd, algo, 0);
128 if (err) 128 if (err)
129 { 129 {
130 fprintf (stderr, PGM ": error opening hash algorithm `%s'\n", algoname); 130 fprintf (stderr, PGM ": error opening hash algorithm `%s'\n", algoname);
131 exit (1); 131 exit (1);
132 } 132 }
133 133
134 for (i=0; i < sizeof buf; i++) 134 for (i=0; i < sizeof buf; i++)
135 buf[i] = i; 135 buf[i] = i;
136 136
137 printf ("%-12s", gcry_md_algo_name (algo)); 137 printf ("%-12s", gcry_md_algo_name (algo));
138 138
139 start_timer (); 139 start_timer ();
140 for (i=0; i < 1000; i++) 140 for (i=0; i < 1000; i++)
141 gcry_md_write (hd, buf, sizeof buf); 141 gcry_md_write (hd, buf, sizeof buf);
142 gcry_md_final (hd); 142 gcry_md_final (hd);
143 stop_timer (); 143 stop_timer ();
144 printf (" %s", elapsed_time ()); 144 printf (" %s", elapsed_time ());
145 145
146 gcry_md_reset (hd); 146 gcry_md_reset (hd);
147 start_timer (); 147 start_timer ();
148 for (i=0; i < 10000; i++) 148 for (i=0; i < 10000; i++)
149 gcry_md_write (hd, buf, sizeof buf/10); 149 gcry_md_write (hd, buf, sizeof buf/10);
150 gcry_md_final (hd); 150 gcry_md_final (hd);
151 stop_timer (); 151 stop_timer ();
152 printf (" %s", elapsed_time ()); 152 printf (" %s", elapsed_time ());
153 153
154 gcry_md_reset (hd); 154 gcry_md_reset (hd);
155 start_timer (); 155 start_timer ();
156 for (i=0; i < 1000000; i++) 156 for (i=0; i < 1000000; i++)
157 gcry_md_write (hd, "", 1); 157 gcry_md_write (hd, "", 1);
158 gcry_md_final (hd); 158 gcry_md_final (hd);
159 stop_timer (); 159 stop_timer ();
160 printf (" %s", elapsed_time ()); 160 printf (" %s", elapsed_time ());
161 161
162 gcry_md_close (hd); 162 gcry_md_close (hd);
163 putchar ('\n'); 163 putchar ('\n');
164} 164}
165 165
166static void 166static void
167cipher_bench ( const char *algoname ) 167cipher_bench ( const char *algoname )
168{ 168{
169 static int header_printed; 169 static int header_printed;
170 int algo; 170 int algo;
171 gcry_cipher_hd_t hd; 171 gcry_cipher_hd_t hd;
172 int i; 172 int i;
173 int keylen, blklen; 173 int keylen, blklen;
174 char key[128]; 174 char key[128];
175 char outbuf[1000], buf[1000]; 175 char outbuf[1000], buf[1000];
176 size_t buflen; 176 size_t buflen;
177 static struct { int mode; const char *name; int blocked; } modes[] = { 177 static struct { int mode; const char *name; int blocked; } modes[] = {
178 { GCRY_CIPHER_MODE_ECB, "ECB", 1 }, 178 { GCRY_CIPHER_MODE_ECB, "ECB", 1 },
179 { GCRY_CIPHER_MODE_CBC, "CBC", 1 }, 179 { GCRY_CIPHER_MODE_CBC, "CBC", 1 },
180 { GCRY_CIPHER_MODE_CFB, "CFB", 0 }, 180 { GCRY_CIPHER_MODE_CFB, "CFB", 0 },
181 { GCRY_CIPHER_MODE_CTR, "CTR", 0 }, 181 { GCRY_CIPHER_MODE_CTR, "CTR", 0 },
182 { GCRY_CIPHER_MODE_STREAM, "STREAM", 0 }, 182 { GCRY_CIPHER_MODE_STREAM, "STREAM", 0 },
183 {0} 183 {0}
184 }; 184 };
185 int modeidx; 185 int modeidx;
186 gcry_error_t err = GPG_ERR_NO_ERROR; 186 gcry_error_t err = GPG_ERR_NO_ERROR;
187 187
188 188
189 if (!algoname) 189 if (!algoname)
190 { 190 {
191 for (i=1; i < 400; i++) 191 for (i=1; i < 400; i++)
192 if ( !gcry_cipher_test_algo (i) ) 192 if ( !gcry_cipher_test_algo (i) )
193 cipher_bench (gcry_cipher_algo_name (i)); 193 cipher_bench (gcry_cipher_algo_name (i));
194 return; 194 return;
195 } 195 }
196 196
197 197
198 if (!header_printed) 198 if (!header_printed)
199 { 199 {
200 printf ("%-10s", ""); 200 printf ("%-10s", "");
201 for (modeidx=0; modes[modeidx].mode; modeidx++) 201 for (modeidx=0; modes[modeidx].mode; modeidx++)
202 printf (" %-15s", modes[modeidx].name ); 202 printf (" %-15s", modes[modeidx].name );
203 putchar ('\n'); 203 putchar ('\n');
204 printf ("%-10s", ""); 204 printf ("%-10s", "");
205 for (modeidx=0; modes[modeidx].mode; modeidx++) 205 for (modeidx=0; modes[modeidx].mode; modeidx++)
206 printf (" ---------------" ); 206 printf (" ---------------" );
207 putchar ('\n'); 207 putchar ('\n');
208 header_printed = 1; 208 header_printed = 1;
209 } 209 }
210 210
211 algo = gcry_cipher_map_name (algoname); 211 algo = gcry_cipher_map_name (algoname);
212 if (!algo) 212 if (!algo)
213 { 213 {
214 fprintf (stderr, PGM ": invalid cipher algorithm `%s'\n", algoname); 214 fprintf (stderr, PGM ": invalid cipher algorithm `%s'\n", algoname);
215 exit (1); 215 exit (1);
216 } 216 }
217 217
218 keylen = gcry_cipher_get_algo_keylen (algo); 218 keylen = gcry_cipher_get_algo_keylen (algo);
219 if (!keylen) 219 if (!keylen)
220 { 220 {
221 fprintf (stderr, PGM ": failed to get key length for algorithm `%s'\n", 221 fprintf (stderr, PGM ": failed to get key length for algorithm `%s'\n",
222 algoname); 222 algoname);
223 exit (1); 223 exit (1);
224 } 224 }
225 if ( keylen > sizeof key ) 225 if ( keylen > sizeof key )
226 { 226 {
227 fprintf (stderr, PGM ": algo %d, keylength problem (%d)\n", 227 fprintf (stderr, PGM ": algo %d, keylength problem (%d)\n",
228 algo, keylen ); 228 algo, keylen );
229 exit (1); 229 exit (1);
230 } 230 }
231 for (i=0; i < keylen; i++) 231 for (i=0; i < keylen; i++)
232 key[i] = i + (clock () & 0xff); 232 key[i] = i + (clock () & 0xff);
233 233
234 blklen = gcry_cipher_get_algo_blklen (algo); 234 blklen = gcry_cipher_get_algo_blklen (algo);
235 if (!blklen) 235 if (!blklen)
236 { 236 {
237 fprintf (stderr, PGM ": failed to get block length for algorithm `%s'\n", 237 fprintf (stderr, PGM ": failed to get block length for algorithm `%s'\n",
238 algoname); 238 algoname);
239 exit (1); 239 exit (1);
240 } 240 }
241 241
242 printf ("%-10s", gcry_cipher_algo_name (algo)); 242 printf ("%-10s", gcry_cipher_algo_name (algo));
243 fflush (stdout); 243 fflush (stdout);
244 244
245 for (modeidx=0; modes[modeidx].mode; modeidx++) 245 for (modeidx=0; modes[modeidx].mode; modeidx++)
246 { 246 {
247 if ((blklen > 1 && modes[modeidx].mode == GCRY_CIPHER_MODE_STREAM) 247 if ((blklen > 1 && modes[modeidx].mode == GCRY_CIPHER_MODE_STREAM)
248 | (blklen == 1 && modes[modeidx].mode != GCRY_CIPHER_MODE_STREAM)) 248 | (blklen == 1 && modes[modeidx].mode != GCRY_CIPHER_MODE_STREAM))
249 { 249 {
250 printf (" " ); 250 printf (" " );
251 continue; 251 continue;
252 } 252 }
253 253
254 for (i=0; i < sizeof buf; i++) 254 for (i=0; i < sizeof buf; i++)
255 buf[i] = i; 255 buf[i] = i;
256 256
257 err = gcry_cipher_open (&hd, algo, modes[modeidx].mode, 0); 257 err = gcry_cipher_open (&hd, algo, modes[modeidx].mode, 0);
258 if (err) 258 if (err)
259 { 259 {
260 fprintf (stderr, PGM ": error opening cipher `%s'\n", algoname); 260 fprintf (stderr, PGM ": error opening cipher `%s'\n", algoname);
261 exit (1); 261 exit (1);
262 } 262 }
263 263
264 err = gcry_cipher_setkey (hd, key, keylen); 264 err = gcry_cipher_setkey (hd, key, keylen);
265 if (err) 265 if (err)
266 { 266 {
267 fprintf (stderr, "gcry_cipher_setkey failed: %s\n", 267 fprintf (stderr, "gcry_cipher_setkey failed: %s\n",
268 gpg_strerror (err)); 268 gpg_strerror (err));
269 gcry_cipher_close (hd); 269 gcry_cipher_close (hd);
270 exit (1); 270 exit (1);
271 } 271 }
272 272
273 buflen = sizeof buf; 273 buflen = sizeof buf;
274 if (modes[modeidx].blocked) 274 if (modes[modeidx].blocked)
275 buflen = (buflen / blklen) * blklen; 275 buflen = (buflen / blklen) * blklen;
276 276
277 start_timer (); 277 start_timer ();
278 for (i=err=0; !err && i < 1000; i++) 278 for (i=err=0; !err && i < 1000; i++)
279 err = gcry_cipher_encrypt ( hd, outbuf, buflen, buf, buflen); 279 err = gcry_cipher_encrypt ( hd, outbuf, buflen, buf, buflen);
280 stop_timer (); 280 stop_timer ();
281 printf (" %s", elapsed_time ()); 281 printf (" %s", elapsed_time ());
282 fflush (stdout); 282 fflush (stdout);
283 gcry_cipher_close (hd); 283 gcry_cipher_close (hd);
284 if (err) 284 if (err)
285 { 285 {
286 fprintf (stderr, "gcry_cipher_encrypt failed: %s\n", 286 fprintf (stderr, "gcry_cipher_encrypt failed: %s\n",
287 gpg_strerror (err) ); 287 gpg_strerror (err) );
288 exit (1); 288 exit (1);
289 } 289 }
290 290
291 err = gcry_cipher_open (&hd, algo, modes[modeidx].mode, 0); 291 err = gcry_cipher_open (&hd, algo, modes[modeidx].mode, 0);
292 if (err) 292 if (err)
293 { 293 {
294 fprintf (stderr, PGM ": error opening cipher `%s'/n", algoname); 294 fprintf (stderr, PGM ": error opening cipher `%s'/n", algoname);
295 exit (1); 295 exit (1);
296 } 296 }
297 297
298 err = gcry_cipher_setkey (hd, key, keylen); 298 err = gcry_cipher_setkey (hd, key, keylen);
299 if (err) 299 if (err)
300 { 300 {
301 fprintf (stderr, "gcry_cipher_setkey failed: %s\n", 301 fprintf (stderr, "gcry_cipher_setkey failed: %s\n",
302 gpg_strerror (err)); 302 gpg_strerror (err));
303 gcry_cipher_close (hd); 303 gcry_cipher_close (hd);
304 exit (1); 304 exit (1);
305 } 305 }
306 306
307 start_timer (); 307 start_timer ();
308 for (i=err=0; !err && i < 1000; i++) 308 for (i=err=0; !err && i < 1000; i++)
309 err = gcry_cipher_decrypt ( hd, outbuf, buflen, buf, buflen); 309 err = gcry_cipher_decrypt ( hd, outbuf, buflen, buf, buflen);
310 stop_timer (); 310 stop_timer ();
311 printf (" %s", elapsed_time ()); 311 printf (" %s", elapsed_time ());
312 fflush (stdout); 312 fflush (stdout);
313 gcry_cipher_close (hd); 313 gcry_cipher_close (hd);
314 if (err) 314 if (err)
315 { 315 {
316 fprintf (stderr, "gcry_cipher_decrypt failed: %s\n", 316 fprintf (stderr, "gcry_cipher_decrypt failed: %s\n",
317 gpg_strerror (err) ); 317 gpg_strerror (err) );
318 exit (1); 318 exit (1);
319 } 319 }
320 } 320 }
321 321
322 putchar ('\n'); 322 putchar ('\n');
323} 323}
324 324
325 325
326static void 326static void
327do_powm ( const char *n_str, const char *e_str, const char *m_str) 327do_powm ( const char *n_str, const char *e_str, const char *m_str)
328{ 328{
329 gcry_mpi_t e, n, msg, cip; 329 gcry_mpi_t e, n, msg, cip;
330 gcry_error_t err; 330 gcry_error_t err;
331 int i; 331 int i;
332 332
333 err = gcry_mpi_scan (&n, GCRYMPI_FMT_HEX, n_str, 0, 0); 333 err = gcry_mpi_scan (&n, GCRYMPI_FMT_HEX, n_str, 0, 0);
334 if (err) BUG (); 334 if (err) BUG ();
335 err = gcry_mpi_scan (&e, GCRYMPI_FMT_HEX, e_str, 0, 0); 335 err = gcry_mpi_scan (&e, GCRYMPI_FMT_HEX, e_str, 0, 0);
336 if (err) BUG (); 336 if (err) BUG ();
337 err = gcry_mpi_scan (&msg, GCRYMPI_FMT_HEX, m_str, 0, 0); 337 err = gcry_mpi_scan (&msg, GCRYMPI_FMT_HEX, m_str, 0, 0);
338 if (err) BUG (); 338 if (err) BUG ();
339 339
340 cip = gcry_mpi_new (0); 340 cip = gcry_mpi_new (0);
341 341
342 start_timer (); 342 start_timer ();
343 for (i=0; i < 1000; i++) 343 for (i=0; i < 1000; i++)
344 gcry_mpi_powm (cip, msg, e, n); 344 gcry_mpi_powm (cip, msg, e, n);
345 stop_timer (); 345 stop_timer ();
346 printf (" %s", elapsed_time ()); fflush (stdout); 346 printf (" %s", elapsed_time ()); fflush (stdout);
347/* { */ 347/* { */
348/* char *buf; */ 348/* char *buf; */
349 349
350/* if (gcry_mpi_aprint (GCRYMPI_FMT_HEX, (void**)&buf, NULL, cip)) */ 350/* if (gcry_mpi_aprint (GCRYMPI_FMT_HEX, (void**)&buf, NULL, cip)) */
351/* BUG (); */ 351/* BUG (); */
352/* printf ("result: %s\n", buf); */ 352/* printf ("result: %s\n", buf); */
353/* gcry_free (buf); */ 353/* gcry_free (buf); */
354/* } */ 354/* } */
355 gcry_mpi_release (cip); 355 gcry_mpi_release (cip);
356 gcry_mpi_release (msg); 356 gcry_mpi_release (msg);
357 gcry_mpi_release (n); 357 gcry_mpi_release (n);
358 gcry_mpi_release (e); 358 gcry_mpi_release (e);
359} 359}
360 360
361 361
362static void 362static void
363mpi_bench (void) 363mpi_bench (void)
364{ 364{
365 printf ("%-10s", "powm"); fflush (stdout); 365 printf ("%-10s", "powm"); fflush (stdout);
366 366
367 do_powm ( 367 do_powm (
368"20A94417D4D5EF2B2DA99165C7DC87DADB3979B72961AF90D09D59BA24CB9A10166FDCCC9C659F2B9626EC23F3FA425F564A072BA941B03FA81767CC289E4", 368"20A94417D4D5EF2B2DA99165C7DC87DADB3979B72961AF90D09D59BA24CB9A10166FDCCC9C659F2B9626EC23F3FA425F564A072BA941B03FA81767CC289E4",
369 "29", 369 "29",
370"B870187A323F1ECD5B8A0B4249507335A1C4CE8394F38FD76B08C78A42C58F6EA136ACF90DFE8603697B1694A3D81114D6117AC1811979C51C4DD013D52F8" 370"B870187A323F1ECD5B8A0B4249507335A1C4CE8394F38FD76B08C78A42C58F6EA136ACF90DFE8603697B1694A3D81114D6117AC1811979C51C4DD013D52F8"
371 ); 371 );
372 do_powm ( 372 do_powm (
373 "20A94417D4D5EF2B2DA99165C7DC87DADB3979B72961AF90D09D59BA24CB9A10166FDCCC9C659F2B9626EC23F3FA425F564A072BA941B03FA81767CC289E41071F0246879A442658FBD18C1771571E7073EEEB2160BA0CBFB3404D627069A6CFBD53867AD2D9D40231648000787B5C84176B4336144644AE71A403CA40716", 373 "20A94417D4D5EF2B2DA99165C7DC87DADB3979B72961AF90D09D59BA24CB9A10166FDCCC9C659F2B9626EC23F3FA425F564A072BA941B03FA81767CC289E41071F0246879A442658FBD18C1771571E7073EEEB2160BA0CBFB3404D627069A6CFBD53867AD2D9D40231648000787B5C84176B4336144644AE71A403CA40716",
374 "29", 374 "29",
375 "B870187A323F1ECD5B8A0B4249507335A1C4CE8394F38FD76B08C78A42C58F6EA136ACF90DFE8603697B1694A3D81114D6117AC1811979C51C4DD013D52F8FC4EE4BB446B83E48ABED7DB81CBF5E81DE4759E8D68AC985846D999F96B0D8A80E5C69D272C766AB8A23B40D50A4FA889FBC2BD2624222D8EB297F4BAEF8593847" 375 "B870187A323F1ECD5B8A0B4249507335A1C4CE8394F38FD76B08C78A42C58F6EA136ACF90DFE8603697B1694A3D81114D6117AC1811979C51C4DD013D52F8FC4EE4BB446B83E48ABED7DB81CBF5E81DE4759E8D68AC985846D999F96B0D8A80E5C69D272C766AB8A23B40D50A4FA889FBC2BD2624222D8EB297F4BAEF8593847"
376 ); 376 );
377 do_powm ( 377 do_powm (
378 "20A94417D4D5EF2B2DA99165C7DC87DADB3979B72961AF90D09D59BA24CB9A10166FDCCC9C659F2B9626EC23F3FA425F564A072BA941B03FA81767CC289E41071F0246879A442658FBD18C1771571E7073EEEB2160BA0CBFB3404D627069A6CFBD53867AD2D9D40231648000787B5C84176B4336144644AE71A403CA4071620A94417D4D5EF2B2DA99165C7DC87DADB3979B72961AF90D09D59BA24CB9A10166FDCCC9C659F2B9626EC23F3FA425F564A072BA941B03FA81767CC289E41071F0246879A442658FBD18C1771571E7073EEEB2160BA0CBFB3404D627069A6CFBD53867AD2D9D40231648000787B5C84176B4336144644AE71A403CA40716", 378 "20A94417D4D5EF2B2DA99165C7DC87DADB3979B72961AF90D09D59BA24CB9A10166FDCCC9C659F2B9626EC23F3FA425F564A072BA941B03FA81767CC289E41071F0246879A442658FBD18C1771571E7073EEEB2160BA0CBFB3404D627069A6CFBD53867AD2D9D40231648000787B5C84176B4336144644AE71A403CA4071620A94417D4D5EF2B2DA99165C7DC87DADB3979B72961AF90D09D59BA24CB9A10166FDCCC9C659F2B9626EC23F3FA425F564A072BA941B03FA81767CC289E41071F0246879A442658FBD18C1771571E7073EEEB2160BA0CBFB3404D627069A6CFBD53867AD2D9D40231648000787B5C84176B4336144644AE71A403CA40716",
379 "29", 379 "29",
380 "B870187A323F1ECD5B8A0B4249507335A1C4CE8394F38FD76B08C78A42C58F6EA136ACF90DFE8603697B1694A3D81114D6117AC1811979C51C4DD013D52F8FC4EE4BB446B83E48ABED7DB81CBF5E81DE4759E8D68AC985846D999F96B0D8A80E5C69D272C766AB8A23B40D50A4FA889FBC2BD2624222D8EB297F4BAEF8593847B870187A323F1ECD5B8A0B4249507335A1C4CE8394F38FD76B08C78A42C58F6EA136ACF90DFE8603697B1694A3D81114D6117AC1811979C51C4DD013D52F8FC4EE4BB446B83E48ABED7DB81CBF5E81DE4759E8D68AC985846D999F96B0D8A80E5C69D272C766AB8A23B40D50A4FA889FBC2BD2624222D8EB297F4BAEF8593847" 380 "B870187A323F1ECD5B8A0B4249507335A1C4CE8394F38FD76B08C78A42C58F6EA136ACF90DFE8603697B1694A3D81114D6117AC1811979C51C4DD013D52F8FC4EE4BB446B83E48ABED7DB81CBF5E81DE4759E8D68AC985846D999F96B0D8A80E5C69D272C766AB8A23B40D50A4FA889FBC2BD2624222D8EB297F4BAEF8593847B870187A323F1ECD5B8A0B4249507335A1C4CE8394F38FD76B08C78A42C58F6EA136ACF90DFE8603697B1694A3D81114D6117AC1811979C51C4DD013D52F8FC4EE4BB446B83E48ABED7DB81CBF5E81DE4759E8D68AC985846D999F96B0D8A80E5C69D272C766AB8A23B40D50A4FA889FBC2BD2624222D8EB297F4BAEF8593847"
381 ); 381 );
382 382
383 putchar ('\n'); 383 putchar ('\n');
384 384
385 385
386} 386}
387 387
388 388
389int 389int
390main( int argc, char **argv ) 390main( int argc, char **argv )
391{ 391{
392 if (argc) 392 if (argc)
393 { argc--; argv++; } 393 { argc--; argv++; }
394 394
395 if ( !argc ) 395 if ( !argc )
396 { 396 {
397 md_bench (NULL); 397 md_bench (NULL);
398 putchar ('\n'); 398 putchar ('\n');
399 cipher_bench (NULL); 399 cipher_bench (NULL);
400 putchar ('\n'); 400 putchar ('\n');
401 mpi_bench (); 401 mpi_bench ();
402 putchar ('\n'); 402 putchar ('\n');
403 random_bench (); 403 random_bench ();
404 } 404 }
405 else if ( !strcmp (*argv, "--help")) 405 else if ( !strcmp (*argv, "--help"))
406 fputs ("usage: benchmark [md|cipher|random|mpi [algonames]]\n", stdout); 406 fputs ("usage: benchmark [md|cipher|random|mpi [algonames]]\n", stdout);
407 else if ( !strcmp (*argv, "random")) 407 else if ( !strcmp (*argv, "random"))
408 { 408 {
409 random_bench (); 409 random_bench ();
410 } 410 }
411 else if ( !strcmp (*argv, "md")) 411 else if ( !strcmp (*argv, "md"))
412 { 412 {
413 if (argc == 1) 413 if (argc == 1)
414 md_bench (NULL); 414 md_bench (NULL);
415 else 415 else
416 for (argc--, argv++; argc; argc--, argv++) 416 for (argc--, argv++; argc; argc--, argv++)
417 md_bench ( *argv ); 417 md_bench ( *argv );
418 } 418 }
419 else if ( !strcmp (*argv, "cipher")) 419 else if ( !strcmp (*argv, "cipher"))
420 { 420 {
421 if (argc == 1) 421 if (argc == 1)
422 cipher_bench (NULL); 422 cipher_bench (NULL);
423 else 423 else
424 for (argc--, argv++; argc; argc--, argv++) 424 for (argc--, argv++; argc; argc--, argv++)
425 cipher_bench ( *argv ); 425 cipher_bench ( *argv );
426 } 426 }
427 else if ( !strcmp (*argv, "mpi")) 427 else if ( !strcmp (*argv, "mpi"))
428 { 428 {
429 mpi_bench (); 429 mpi_bench ();
430 } 430 }
431 else 431 else
432 { 432 {
433 fprintf (stderr, PGM ": bad arguments\n"); 433 fprintf (stderr, PGM ": bad arguments\n");
434 return 1; 434 return 1;
435 } 435 }
436 436
437 return 0; 437 return 0;
438} 438}
439 439
440 440
diff --git a/linden/indra/libgcrypt/libgcrypt-1.2.2/tests/keygen.c b/linden/indra/libgcrypt/libgcrypt-1.2.2/tests/keygen.c
index 9dd755c..6cc8d4c 100755..100644
--- a/linden/indra/libgcrypt/libgcrypt-1.2.2/tests/keygen.c
+++ b/linden/indra/libgcrypt/libgcrypt-1.2.2/tests/keygen.c
@@ -1,241 +1,241 @@
1/* keygen.c - key generation regression tests 1/* keygen.c - key generation regression tests
2 * Copyright (C) 2003 Free Software Foundation, Inc. 2 * Copyright (C) 2003 Free Software Foundation, Inc.
3 * 3 *
4 * This file is part of Libgcrypt. 4 * This file is part of Libgcrypt.
5 * 5 *
6 * Libgcrypt is free software; you can redistribute it and/or modify 6 * Libgcrypt is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as 7 * it under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation; either version 2.1 of 8 * published by the Free Software Foundation; either version 2.1 of
9 * the License, or (at your option) any later version. 9 * the License, or (at your option) any later version.
10 * 10 *
11 * Libgcrypt is distributed in the hope that it will be useful, 11 * Libgcrypt is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details. 14 * GNU Lesser General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU Lesser General Public 16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this program; if not, write to the Free Software 17 * License along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
19 */ 19 */
20 20
21#include <stdio.h> 21#include <stdio.h>
22#include <stdlib.h> 22#include <stdlib.h>
23#include <string.h> 23#include <string.h>
24#include <stdarg.h> 24#include <stdarg.h>
25#include "../src/gcrypt.h" 25#include "../src/gcrypt.h"
26 26
27 27
28 28
29static int verbose; 29static int verbose;
30static int error_count; 30static int error_count;
31 31
32static void 32static void
33fail ( const char *format, ... ) 33fail ( const char *format, ... )
34{ 34{
35 va_list arg_ptr ; 35 va_list arg_ptr ;
36 36
37 va_start( arg_ptr, format ) ; 37 va_start( arg_ptr, format ) ;
38 vfprintf (stderr, format, arg_ptr ); 38 vfprintf (stderr, format, arg_ptr );
39 va_end(arg_ptr); 39 va_end(arg_ptr);
40 error_count++; 40 error_count++;
41} 41}
42 42
43static void 43static void
44die ( const char *format, ... ) 44die ( const char *format, ... )
45{ 45{
46 va_list arg_ptr ; 46 va_list arg_ptr ;
47 47
48 va_start( arg_ptr, format ) ; 48 va_start( arg_ptr, format ) ;
49 vfprintf (stderr, format, arg_ptr ); 49 vfprintf (stderr, format, arg_ptr );
50 va_end(arg_ptr); 50 va_end(arg_ptr);
51 exit (1); 51 exit (1);
52} 52}
53 53
54 54
55static void 55static void
56print_mpi (const char *text, gcry_mpi_t a) 56print_mpi (const char *text, gcry_mpi_t a)
57{ 57{
58 char *buf; 58 char *buf;
59 void *bufaddr = &buf; 59 void *bufaddr = &buf;
60 gcry_error_t rc; 60 gcry_error_t rc;
61 61
62 rc = gcry_mpi_aprint (GCRYMPI_FMT_HEX, bufaddr, NULL, a); 62 rc = gcry_mpi_aprint (GCRYMPI_FMT_HEX, bufaddr, NULL, a);
63 if (rc) 63 if (rc)
64 fprintf (stderr, "%s=[error printing number: %s]\n", 64 fprintf (stderr, "%s=[error printing number: %s]\n",
65 text, gpg_strerror (rc)); 65 text, gpg_strerror (rc));
66 else 66 else
67 { 67 {
68 fprintf (stderr, "%s=0x%s\n", text, buf); 68 fprintf (stderr, "%s=0x%s\n", text, buf);
69 gcry_free (buf); 69 gcry_free (buf);
70 } 70 }
71} 71}
72 72
73 73
74static void 74static void
75check_generated_rsa_key (gcry_sexp_t key, unsigned long expected_e) 75check_generated_rsa_key (gcry_sexp_t key, unsigned long expected_e)
76{ 76{
77 gcry_sexp_t skey, pkey, list; 77 gcry_sexp_t skey, pkey, list;
78 78
79 pkey = gcry_sexp_find_token (key, "public-key", 0); 79 pkey = gcry_sexp_find_token (key, "public-key", 0);
80 if (!pkey) 80 if (!pkey)
81 fail ("public part missing in return value\n"); 81 fail ("public part missing in return value\n");
82 else 82 else
83 { 83 {
84 gcry_mpi_t e = NULL; 84 gcry_mpi_t e = NULL;
85 85
86 list = gcry_sexp_find_token (pkey, "e", 0); 86 list = gcry_sexp_find_token (pkey, "e", 0);
87 if (!list || !(e=gcry_sexp_nth_mpi (list, 1, 0)) ) 87 if (!list || !(e=gcry_sexp_nth_mpi (list, 1, 0)) )
88 fail ("public exponent not found\n"); 88 fail ("public exponent not found\n");
89 else if (!expected_e) 89 else if (!expected_e)
90 { 90 {
91 if (verbose) 91 if (verbose)
92 print_mpi ("e", e); 92 print_mpi ("e", e);
93 } 93 }
94 else if ( gcry_mpi_cmp_ui (e, expected_e)) 94 else if ( gcry_mpi_cmp_ui (e, expected_e))
95 { 95 {
96 print_mpi ("e", e); 96 print_mpi ("e", e);
97 fail ("public exponent is not %lu\n", expected_e); 97 fail ("public exponent is not %lu\n", expected_e);
98 } 98 }
99 gcry_sexp_release (list); 99 gcry_sexp_release (list);
100 gcry_mpi_release (e); 100 gcry_mpi_release (e);
101 gcry_sexp_release (pkey); 101 gcry_sexp_release (pkey);
102 } 102 }
103 103
104 skey = gcry_sexp_find_token (key, "private-key", 0); 104 skey = gcry_sexp_find_token (key, "private-key", 0);
105 if (!skey) 105 if (!skey)
106 fail ("private part missing in return value\n"); 106 fail ("private part missing in return value\n");
107 else 107 else
108 { 108 {
109 int rc = gcry_pk_testkey (skey); 109 int rc = gcry_pk_testkey (skey);
110 if (rc) 110 if (rc)
111 fail ("gcry_pk_testkey failed: %s\n", gpg_strerror (rc)); 111 fail ("gcry_pk_testkey failed: %s\n", gpg_strerror (rc));
112 gcry_sexp_release (skey); 112 gcry_sexp_release (skey);
113 } 113 }
114 114
115 } 115 }
116 116
117static void 117static void
118check_rsa_keys (void) 118check_rsa_keys (void)
119{ 119{
120 gcry_sexp_t keyparm, key; 120 gcry_sexp_t keyparm, key;
121 int rc; 121 int rc;
122 122
123 if (verbose) 123 if (verbose)
124 fprintf (stderr, "creating 1024 bit RSA key using old interface\n"); 124 fprintf (stderr, "creating 1024 bit RSA key using old interface\n");
125 rc = gcry_sexp_new (&keyparm, 125 rc = gcry_sexp_new (&keyparm,
126 "(genkey\n" 126 "(genkey\n"
127 " (rsa\n" 127 " (rsa\n"
128 " (nbits 4:1024)\n" 128 " (nbits 4:1024)\n"
129 " ))", 0, 1); 129 " ))", 0, 1);
130 if (rc) 130 if (rc)
131 die ("error creating S-expression: %s\n", gpg_strerror (rc)); 131 die ("error creating S-expression: %s\n", gpg_strerror (rc));
132 rc = gcry_pk_genkey (&key, keyparm); 132 rc = gcry_pk_genkey (&key, keyparm);
133 gcry_sexp_release (keyparm); 133 gcry_sexp_release (keyparm);
134 if (rc) 134 if (rc)
135 die ("error generating RSA key: %s\n", gpg_strerror (rc)); 135 die ("error generating RSA key: %s\n", gpg_strerror (rc));
136 136
137 check_generated_rsa_key (key, 65537); 137 check_generated_rsa_key (key, 65537);
138 gcry_sexp_release (key); 138 gcry_sexp_release (key);
139 139
140 if (verbose) 140 if (verbose)
141 fprintf (stderr, "creating 512 bit RSA key with e=257\n"); 141 fprintf (stderr, "creating 512 bit RSA key with e=257\n");
142 rc = gcry_sexp_new (&keyparm, 142 rc = gcry_sexp_new (&keyparm,
143 "(genkey\n" 143 "(genkey\n"
144 " (rsa\n" 144 " (rsa\n"
145 " (nbits 3:512)\n" 145 " (nbits 3:512)\n"
146 " (rsa-use-e 3:257)\n" 146 " (rsa-use-e 3:257)\n"
147 " ))", 0, 1); 147 " ))", 0, 1);
148 if (rc) 148 if (rc)
149 die ("error creating S-expression: %s\n", gpg_strerror (rc)); 149 die ("error creating S-expression: %s\n", gpg_strerror (rc));
150 rc = gcry_pk_genkey (&key, keyparm); 150 rc = gcry_pk_genkey (&key, keyparm);
151 gcry_sexp_release (keyparm); 151 gcry_sexp_release (keyparm);
152 if (rc) 152 if (rc)
153 die ("error generating RSA key: %s\n", gpg_strerror (rc)); 153 die ("error generating RSA key: %s\n", gpg_strerror (rc));
154 154
155 check_generated_rsa_key (key, 257); 155 check_generated_rsa_key (key, 257);
156 gcry_sexp_release (key); 156 gcry_sexp_release (key);
157 157
158 if (verbose) 158 if (verbose)
159 fprintf (stderr, "creating 512 bit RSA key with default e\n"); 159 fprintf (stderr, "creating 512 bit RSA key with default e\n");
160 rc = gcry_sexp_new (&keyparm, 160 rc = gcry_sexp_new (&keyparm,
161 "(genkey\n" 161 "(genkey\n"
162 " (rsa\n" 162 " (rsa\n"
163 " (nbits 3:512)\n" 163 " (nbits 3:512)\n"
164 " (rsa-use-e 1:0)\n" 164 " (rsa-use-e 1:0)\n"
165 " ))", 0, 1); 165 " ))", 0, 1);
166 if (rc) 166 if (rc)
167 die ("error creating S-expression: %s\n", gpg_strerror (rc)); 167 die ("error creating S-expression: %s\n", gpg_strerror (rc));
168 rc = gcry_pk_genkey (&key, keyparm); 168 rc = gcry_pk_genkey (&key, keyparm);
169 gcry_sexp_release (keyparm); 169 gcry_sexp_release (keyparm);
170 if (rc) 170 if (rc)
171 die ("error generating RSA key: %s\n", gpg_strerror (rc)); 171 die ("error generating RSA key: %s\n", gpg_strerror (rc));
172 172
173 check_generated_rsa_key (key, 0); /* We don't expect a constant exponent. */ 173 check_generated_rsa_key (key, 0); /* We don't expect a constant exponent. */
174 gcry_sexp_release (key); 174 gcry_sexp_release (key);
175 175
176} 176}
177 177
178 178
179static void 179static void
180check_nonce (void) 180check_nonce (void)
181{ 181{
182 char a[32], b[32]; 182 char a[32], b[32];
183 int i,j; 183 int i,j;
184 int oops=0; 184 int oops=0;
185 185
186 if (verbose) 186 if (verbose)
187 fprintf (stderr, "checking gcry_create_nonce\n"); 187 fprintf (stderr, "checking gcry_create_nonce\n");
188 188
189 gcry_create_nonce (a, sizeof a); 189 gcry_create_nonce (a, sizeof a);
190 for (i=0; i < 10; i++) 190 for (i=0; i < 10; i++)
191 { 191 {
192 gcry_create_nonce (b, sizeof b); 192 gcry_create_nonce (b, sizeof b);
193 if (!memcmp (a, b, sizeof a)) 193 if (!memcmp (a, b, sizeof a))
194 die ("identical nounce found\n"); 194 die ("identical nounce found\n");
195 } 195 }
196 for (i=0; i < 10; i++) 196 for (i=0; i < 10; i++)
197 { 197 {
198 gcry_create_nonce (a, sizeof a); 198 gcry_create_nonce (a, sizeof a);
199 if (!memcmp (a, b, sizeof a)) 199 if (!memcmp (a, b, sizeof a))
200 die ("identical nounce found\n"); 200 die ("identical nounce found\n");
201 } 201 }
202 202
203 again: 203 again:
204 for (i=1,j=0; i < sizeof a; i++) 204 for (i=1,j=0; i < sizeof a; i++)
205 if (a[0] == a[i]) 205 if (a[0] == a[i])
206 j++; 206 j++;
207 if (j+1 == sizeof (a)) 207 if (j+1 == sizeof (a))
208 { 208 {
209 if (oops) 209 if (oops)
210 die ("impossible nonce found\n"); 210 die ("impossible nonce found\n");
211 oops++; 211 oops++;
212 gcry_create_nonce (a, sizeof a); 212 gcry_create_nonce (a, sizeof a);
213 goto again; 213 goto again;
214 } 214 }
215} 215}
216 216
217int 217int
218main (int argc, char **argv) 218main (int argc, char **argv)
219{ 219{
220 int debug = 0; 220 int debug = 0;
221 221
222 if (argc > 1 && !strcmp (argv[1], "--verbose")) 222 if (argc > 1 && !strcmp (argv[1], "--verbose"))
223 verbose = 1; 223 verbose = 1;
224 else if (argc > 1 && !strcmp (argv[1], "--debug")) 224 else if (argc > 1 && !strcmp (argv[1], "--debug"))
225 verbose = debug = 1; 225 verbose = debug = 1;
226 226
227 if (!gcry_check_version (GCRYPT_VERSION)) 227 if (!gcry_check_version (GCRYPT_VERSION))
228 die ("version mismatch\n"); 228 die ("version mismatch\n");
229 gcry_control (GCRYCTL_DISABLE_SECMEM, 0); 229 gcry_control (GCRYCTL_DISABLE_SECMEM, 0);
230 gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); 230 gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
231 if (debug) 231 if (debug)
232 gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1u , 0); 232 gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1u , 0);
233 /* No valuable keys are create, so we can speed up our RNG. */ 233 /* No valuable keys are create, so we can speed up our RNG. */
234 gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); 234 gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0);
235 235
236 check_rsa_keys (); 236 check_rsa_keys ();
237 check_nonce (); 237 check_nonce ();
238 238
239 return error_count? 1:0; 239 return error_count? 1:0;
240} 240}
241 241
diff --git a/linden/indra/libgcrypt/libgcrypt-1.2.2/tests/prime.c b/linden/indra/libgcrypt/libgcrypt-1.2.2/tests/prime.c
index 95e71db..625c153 100755..100644
--- a/linden/indra/libgcrypt/libgcrypt-1.2.2/tests/prime.c
+++ b/linden/indra/libgcrypt/libgcrypt-1.2.2/tests/prime.c
@@ -1,119 +1,119 @@
1/* prime.c - part of the Libgcrypt test suite. 1/* prime.c - part of the Libgcrypt test suite.
2 Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. 2 Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or 4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License as 5 modify it under the terms of the GNU General Public License as
6 published by the Free Software Foundation; either version 2 of the 6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version. 7 License, or (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, but 9 This program is distributed in the hope that it will be useful, but
10 WITHOUT ANY WARRANTY; without even the implied warranty of 10 WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details. 12 General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software 15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
17 USA. */ 17 USA. */
18 18
19#include <assert.h> 19#include <assert.h>
20#include <stdio.h> 20#include <stdio.h>
21#include <string.h> 21#include <string.h>
22#include <stdlib.h> 22#include <stdlib.h>
23 23
24#include "../src/gcrypt.h" 24#include "../src/gcrypt.h"
25 25
26static int verbose; 26static int verbose;
27 27
28static void 28static void
29die (const char *format, ...) 29die (const char *format, ...)
30{ 30{
31 va_list arg_ptr; 31 va_list arg_ptr;
32 32
33 va_start (arg_ptr, format); 33 va_start (arg_ptr, format);
34 vfprintf (stderr, format, arg_ptr); 34 vfprintf (stderr, format, arg_ptr);
35 va_end (arg_ptr); 35 va_end (arg_ptr);
36 exit (1); 36 exit (1);
37} 37}
38 38
39static void 39static void
40check_primes (void) 40check_primes (void)
41{ 41{
42 gcry_error_t err = GPG_ERR_NO_ERROR; 42 gcry_error_t err = GPG_ERR_NO_ERROR;
43 gcry_mpi_t *factors = NULL; 43 gcry_mpi_t *factors = NULL;
44 gcry_mpi_t prime = NULL; 44 gcry_mpi_t prime = NULL;
45 gcry_mpi_t g; 45 gcry_mpi_t g;
46 unsigned int i = 0; 46 unsigned int i = 0;
47 struct prime_spec 47 struct prime_spec
48 { 48 {
49 unsigned int prime_bits; 49 unsigned int prime_bits;
50 unsigned int factor_bits; 50 unsigned int factor_bits;
51 unsigned int flags; 51 unsigned int flags;
52 } prime_specs[] = 52 } prime_specs[] =
53 { 53 {
54 { 1024, 100, GCRY_PRIME_FLAG_SPECIAL_FACTOR }, 54 { 1024, 100, GCRY_PRIME_FLAG_SPECIAL_FACTOR },
55 { 128, 0, 0 }, 55 { 128, 0, 0 },
56 { 0 }, 56 { 0 },
57 }; 57 };
58 58
59 for (i = 0; prime_specs[i].prime_bits; i++) 59 for (i = 0; prime_specs[i].prime_bits; i++)
60 { 60 {
61 err = gcry_prime_generate (&prime, 61 err = gcry_prime_generate (&prime,
62 prime_specs[i].prime_bits, 62 prime_specs[i].prime_bits,
63 prime_specs[i].factor_bits, 63 prime_specs[i].factor_bits,
64 &factors, 64 &factors,
65 NULL, NULL, 65 NULL, NULL,
66 GCRY_WEAK_RANDOM, 66 GCRY_WEAK_RANDOM,
67 prime_specs[i].flags); 67 prime_specs[i].flags);
68 assert (! err); 68 assert (! err);
69 if (verbose) 69 if (verbose)
70 { 70 {
71 fprintf (stderr, "test %d: p = ", i); 71 fprintf (stderr, "test %d: p = ", i);
72 gcry_mpi_dump (prime); 72 gcry_mpi_dump (prime);
73 putc ('\n', stderr); 73 putc ('\n', stderr);
74 } 74 }
75 75
76 err = gcry_prime_check (prime, 0); 76 err = gcry_prime_check (prime, 0);
77 assert (! err); 77 assert (! err);
78 78
79 err = gcry_prime_group_generator (&g, prime, factors, NULL); 79 err = gcry_prime_group_generator (&g, prime, factors, NULL);
80 assert (!err); 80 assert (!err);
81 gcry_prime_release_factors (factors); factors = NULL; 81 gcry_prime_release_factors (factors); factors = NULL;
82 82
83 if (verbose) 83 if (verbose)
84 { 84 {
85 fprintf (stderr, " %d: g = ", i); 85 fprintf (stderr, " %d: g = ", i);
86 gcry_mpi_dump (g); 86 gcry_mpi_dump (g);
87 putc ('\n', stderr); 87 putc ('\n', stderr);
88 } 88 }
89 gcry_mpi_release (g); 89 gcry_mpi_release (g);
90 90
91 91
92 gcry_mpi_add_ui (prime, prime, 1); 92 gcry_mpi_add_ui (prime, prime, 1);
93 err = gcry_prime_check (prime, 0); 93 err = gcry_prime_check (prime, 0);
94 assert (err); 94 assert (err);
95 } 95 }
96} 96}
97 97
98int 98int
99main (int argc, char **argv) 99main (int argc, char **argv)
100{ 100{
101 int debug = 0; 101 int debug = 0;
102 102
103 if ((argc > 1) && (! strcmp (argv[1], "--verbose"))) 103 if ((argc > 1) && (! strcmp (argv[1], "--verbose")))
104 verbose = 1; 104 verbose = 1;
105 else if ((argc > 1) && (! strcmp (argv[1], "--debug"))) 105 else if ((argc > 1) && (! strcmp (argv[1], "--debug")))
106 verbose = debug = 1; 106 verbose = debug = 1;
107 107
108 gcry_control (GCRYCTL_DISABLE_SECMEM, 0); 108 gcry_control (GCRYCTL_DISABLE_SECMEM, 0);
109 if (! gcry_check_version (GCRYPT_VERSION)) 109 if (! gcry_check_version (GCRYPT_VERSION))
110 die ("version mismatch\n"); 110 die ("version mismatch\n");
111 111
112 gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); 112 gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
113 if (debug) 113 if (debug)
114 gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1u, 0); 114 gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1u, 0);
115 115
116 check_primes (); 116 check_primes ();
117 117
118 return 0; 118 return 0;
119} 119}
diff --git a/linden/indra/libgcrypt/libgcrypt-1.2.2/tests/pubkey.c b/linden/indra/libgcrypt/libgcrypt-1.2.2/tests/pubkey.c
index 9633c37..8753732 100755..100644
--- a/linden/indra/libgcrypt/libgcrypt-1.2.2/tests/pubkey.c
+++ b/linden/indra/libgcrypt/libgcrypt-1.2.2/tests/pubkey.c
@@ -1,252 +1,252 @@
1/* pubkey.c - Public key encryption/decryption tests 1/* pubkey.c - Public key encryption/decryption tests
2 * Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. 2 * Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
3 * 3 *
4 * This file is part of Libgcrypt. 4 * This file is part of Libgcrypt.
5 * 5 *
6 * Libgcrypt is free software; you can redistribute it and/or modify 6 * Libgcrypt is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as 7 * it under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation; either version 2.1 of 8 * published by the Free Software Foundation; either version 2.1 of
9 * the License, or (at your option) any later version. 9 * the License, or (at your option) any later version.
10 * 10 *
11 * Libgcrypt is distributed in the hope that it will be useful, 11 * Libgcrypt is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details. 14 * GNU Lesser General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU Lesser General Public 16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this program; if not, write to the Free Software 17 * License along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
19 */ 19 */
20 20
21#include <stdarg.h> 21#include <stdarg.h>
22#include <stdio.h> 22#include <stdio.h>
23#include <stdlib.h> 23#include <stdlib.h>
24#include <string.h> 24#include <string.h>
25 25
26 26
27#include "../src/gcrypt.h" 27#include "../src/gcrypt.h"
28 28
29/* Sample RSA keys, taken from basic.c. */ 29/* Sample RSA keys, taken from basic.c. */
30 30
31static const char sample_private_key_1[] = 31static const char sample_private_key_1[] =
32"(private-key\n" 32"(private-key\n"
33" (openpgp-rsa\n" 33" (openpgp-rsa\n"
34" (n #00e0ce96f90b6c9e02f3922beada93fe50a875eac6bcc18bb9a9cf2e84965caa" 34" (n #00e0ce96f90b6c9e02f3922beada93fe50a875eac6bcc18bb9a9cf2e84965caa"
35 "2d1ff95a7f542465c6c0c19d276e4526ce048868a7a914fd343cc3a87dd74291" 35 "2d1ff95a7f542465c6c0c19d276e4526ce048868a7a914fd343cc3a87dd74291"
36 "ffc565506d5bbb25cbac6a0e2dd1f8bcaab0d4a29c2f37c950f363484bf269f7" 36 "ffc565506d5bbb25cbac6a0e2dd1f8bcaab0d4a29c2f37c950f363484bf269f7"
37 "891440464baf79827e03a36e70b814938eebdc63e964247be75dc58b014b7ea251#)\n" 37 "891440464baf79827e03a36e70b814938eebdc63e964247be75dc58b014b7ea251#)\n"
38" (e #010001#)\n" 38" (e #010001#)\n"
39" (d #046129F2489D71579BE0A75FE029BD6CDB574EBF57EA8A5B0FDA942CAB943B11" 39" (d #046129F2489D71579BE0A75FE029BD6CDB574EBF57EA8A5B0FDA942CAB943B11"
40 "7D7BB95E5D28875E0F9FC5FCC06A72F6D502464DABDED78EF6B716177B83D5BD" 40 "7D7BB95E5D28875E0F9FC5FCC06A72F6D502464DABDED78EF6B716177B83D5BD"
41 "C543DC5D3FED932E59F5897E92E6F58A0F33424106A3B6FA2CBF877510E4AC21" 41 "C543DC5D3FED932E59F5897E92E6F58A0F33424106A3B6FA2CBF877510E4AC21"
42 "C3EE47851E97D12996222AC3566D4CCB0B83D164074ABF7DE655FC2446DA1781#)\n" 42 "C3EE47851E97D12996222AC3566D4CCB0B83D164074ABF7DE655FC2446DA1781#)\n"
43" (p #00e861b700e17e8afe6837e7512e35b6ca11d0ae47d8b85161c67baf64377213" 43" (p #00e861b700e17e8afe6837e7512e35b6ca11d0ae47d8b85161c67baf64377213"
44 "fe52d772f2035b3ca830af41d8a4120e1c1c70d12cc22f00d28d31dd48a8d424f1#)\n" 44 "fe52d772f2035b3ca830af41d8a4120e1c1c70d12cc22f00d28d31dd48a8d424f1#)\n"
45" (q #00f7a7ca5367c661f8e62df34f0d05c10c88e5492348dd7bddc942c9a8f369f9" 45" (q #00f7a7ca5367c661f8e62df34f0d05c10c88e5492348dd7bddc942c9a8f369f9"
46 "35a07785d2db805215ed786e4285df1658eed3ce84f469b81b50d358407b4ad361#)\n" 46 "35a07785d2db805215ed786e4285df1658eed3ce84f469b81b50d358407b4ad361#)\n"
47" (u #304559a9ead56d2309d203811a641bb1a09626bc8eb36fffa23c968ec5bd891e" 47" (u #304559a9ead56d2309d203811a641bb1a09626bc8eb36fffa23c968ec5bd891e"
48 "ebbafc73ae666e01ba7c8990bae06cc2bbe10b75e69fcacb353a6473079d8e9b#)\n" 48 "ebbafc73ae666e01ba7c8990bae06cc2bbe10b75e69fcacb353a6473079d8e9b#)\n"
49" )\n" 49" )\n"
50")\n"; 50")\n";
51 51
52static const char sample_public_key_1[] = 52static const char sample_public_key_1[] =
53"(public-key\n" 53"(public-key\n"
54" (rsa\n" 54" (rsa\n"
55" (n #00e0ce96f90b6c9e02f3922beada93fe50a875eac6bcc18bb9a9cf2e84965caa" 55" (n #00e0ce96f90b6c9e02f3922beada93fe50a875eac6bcc18bb9a9cf2e84965caa"
56 "2d1ff95a7f542465c6c0c19d276e4526ce048868a7a914fd343cc3a87dd74291" 56 "2d1ff95a7f542465c6c0c19d276e4526ce048868a7a914fd343cc3a87dd74291"
57 "ffc565506d5bbb25cbac6a0e2dd1f8bcaab0d4a29c2f37c950f363484bf269f7" 57 "ffc565506d5bbb25cbac6a0e2dd1f8bcaab0d4a29c2f37c950f363484bf269f7"
58 "891440464baf79827e03a36e70b814938eebdc63e964247be75dc58b014b7ea251#)\n" 58 "891440464baf79827e03a36e70b814938eebdc63e964247be75dc58b014b7ea251#)\n"
59" (e #010001#)\n" 59" (e #010001#)\n"
60" )\n" 60" )\n"
61")\n"; 61")\n";
62 62
63#define RANDOM_DATA_NBITS 800 63#define RANDOM_DATA_NBITS 800
64 64
65static int verbose; 65static int verbose;
66 66
67static void 67static void
68die (const char *format, ...) 68die (const char *format, ...)
69{ 69{
70 va_list arg_ptr ; 70 va_list arg_ptr ;
71 71
72 va_start( arg_ptr, format ) ; 72 va_start( arg_ptr, format ) ;
73 vfprintf (stderr, format, arg_ptr ); 73 vfprintf (stderr, format, arg_ptr );
74 va_end(arg_ptr); 74 va_end(arg_ptr);
75 exit (1); 75 exit (1);
76} 76}
77 77
78static void 78static void
79check_keys_crypt (gcry_sexp_t pkey, gcry_sexp_t skey, 79check_keys_crypt (gcry_sexp_t pkey, gcry_sexp_t skey,
80 gcry_sexp_t plain0) 80 gcry_sexp_t plain0)
81{ 81{
82 gcry_sexp_t plain1, cipher, l; 82 gcry_sexp_t plain1, cipher, l;
83 gcry_mpi_t x0, x1; 83 gcry_mpi_t x0, x1;
84 int rc; 84 int rc;
85 int have_flags; 85 int have_flags;
86 86
87 /* Extract data from plaintext. */ 87 /* Extract data from plaintext. */
88 l = gcry_sexp_find_token (plain0, "value", 0); 88 l = gcry_sexp_find_token (plain0, "value", 0);
89 x0 = gcry_sexp_nth_mpi (l, 1, GCRYMPI_FMT_USG); 89 x0 = gcry_sexp_nth_mpi (l, 1, GCRYMPI_FMT_USG);
90 90
91 /* Encrypt data. */ 91 /* Encrypt data. */
92 rc = gcry_pk_encrypt (&cipher, plain0, pkey); 92 rc = gcry_pk_encrypt (&cipher, plain0, pkey);
93 if (rc) 93 if (rc)
94 die ("encryption failed: %s\n", gcry_strerror (rc)); 94 die ("encryption failed: %s\n", gcry_strerror (rc));
95 95
96 l = gcry_sexp_find_token (cipher, "flags", 0); 96 l = gcry_sexp_find_token (cipher, "flags", 0);
97 have_flags = !!l; 97 have_flags = !!l;
98 gcry_sexp_release (l); 98 gcry_sexp_release (l);
99 99
100 /* Decrypt data. */ 100 /* Decrypt data. */
101 rc = gcry_pk_decrypt (&plain1, cipher, skey); 101 rc = gcry_pk_decrypt (&plain1, cipher, skey);
102 gcry_sexp_release (cipher); 102 gcry_sexp_release (cipher);
103 if (rc) 103 if (rc)
104 die ("decryption failed: %s\n", gcry_strerror (rc)); 104 die ("decryption failed: %s\n", gcry_strerror (rc));
105 105
106 /* Extract decrypted data. Note that for compatibility reasons, the 106 /* Extract decrypted data. Note that for compatibility reasons, the
107 output of gcry_pk_decrypt depends on whether a flags lists (even 107 output of gcry_pk_decrypt depends on whether a flags lists (even
108 if empty) occurs in its input data. Because we passed the output 108 if empty) occurs in its input data. Because we passed the output
109 of encrypt directly to decrypt, such a flag value won't be there 109 of encrypt directly to decrypt, such a flag value won't be there
110 as of today. We check it anyway. */ 110 as of today. We check it anyway. */
111 l = gcry_sexp_find_token (plain1, "value", 0); 111 l = gcry_sexp_find_token (plain1, "value", 0);
112 if (l) 112 if (l)
113 { 113 {
114 if (!have_flags) 114 if (!have_flags)
115 die ("compatibility mode of pk_decrypt broken\n"); 115 die ("compatibility mode of pk_decrypt broken\n");
116 gcry_sexp_release (plain1); 116 gcry_sexp_release (plain1);
117 x1 = gcry_sexp_nth_mpi (l, 1, GCRYMPI_FMT_USG); 117 x1 = gcry_sexp_nth_mpi (l, 1, GCRYMPI_FMT_USG);
118 gcry_sexp_release (l); 118 gcry_sexp_release (l);
119 } 119 }
120 else 120 else
121 { 121 {
122 if (have_flags) 122 if (have_flags)
123 die ("compatibility mode of pk_decrypt broken\n"); 123 die ("compatibility mode of pk_decrypt broken\n");
124 x1 = gcry_sexp_nth_mpi (plain1, 0, GCRYMPI_FMT_USG); 124 x1 = gcry_sexp_nth_mpi (plain1, 0, GCRYMPI_FMT_USG);
125 gcry_sexp_release (plain1); 125 gcry_sexp_release (plain1);
126 } 126 }
127 127
128 /* Compare. */ 128 /* Compare. */
129 if (gcry_mpi_cmp (x0, x1)) 129 if (gcry_mpi_cmp (x0, x1))
130 die ("data corrupted\n"); 130 die ("data corrupted\n");
131} 131}
132 132
133static void 133static void
134check_keys (gcry_sexp_t pkey, gcry_sexp_t skey) 134check_keys (gcry_sexp_t pkey, gcry_sexp_t skey)
135{ 135{
136 gcry_sexp_t plain; 136 gcry_sexp_t plain;
137 gcry_mpi_t x; 137 gcry_mpi_t x;
138 int rc; 138 int rc;
139 139
140 /* Create plain text. */ 140 /* Create plain text. */
141 x = gcry_mpi_new (RANDOM_DATA_NBITS); 141 x = gcry_mpi_new (RANDOM_DATA_NBITS);
142 gcry_mpi_randomize (x, RANDOM_DATA_NBITS, GCRY_WEAK_RANDOM); 142 gcry_mpi_randomize (x, RANDOM_DATA_NBITS, GCRY_WEAK_RANDOM);
143 143
144 rc = gcry_sexp_build (&plain, NULL, "(data (flags raw) (value %m))", x); 144 rc = gcry_sexp_build (&plain, NULL, "(data (flags raw) (value %m))", x);
145 if (rc) 145 if (rc)
146 die ("converting data for encryption failed: %s\n", 146 die ("converting data for encryption failed: %s\n",
147 gcry_strerror (rc)); 147 gcry_strerror (rc));
148 148
149 check_keys_crypt (pkey, skey, plain); 149 check_keys_crypt (pkey, skey, plain);
150 gcry_sexp_release (plain); 150 gcry_sexp_release (plain);
151 gcry_mpi_release (x); 151 gcry_mpi_release (x);
152 152
153 /* Create plain text. */ 153 /* Create plain text. */
154 x = gcry_mpi_new (RANDOM_DATA_NBITS); 154 x = gcry_mpi_new (RANDOM_DATA_NBITS);
155 gcry_mpi_randomize (x, RANDOM_DATA_NBITS, GCRY_WEAK_RANDOM); 155 gcry_mpi_randomize (x, RANDOM_DATA_NBITS, GCRY_WEAK_RANDOM);
156 156
157 rc = gcry_sexp_build (&plain, NULL, "(data (flags raw no-blinding) (value %m))", x); 157 rc = gcry_sexp_build (&plain, NULL, "(data (flags raw no-blinding) (value %m))", x);
158 if (rc) 158 if (rc)
159 die ("converting data for encryption failed: %s\n", 159 die ("converting data for encryption failed: %s\n",
160 gcry_strerror (rc)); 160 gcry_strerror (rc));
161 161
162 check_keys_crypt (pkey, skey, plain); 162 check_keys_crypt (pkey, skey, plain);
163 gcry_sexp_release (plain); 163 gcry_sexp_release (plain);
164} 164}
165 165
166static void 166static void
167get_keys_sample (gcry_sexp_t *pkey, gcry_sexp_t *skey) 167get_keys_sample (gcry_sexp_t *pkey, gcry_sexp_t *skey)
168{ 168{
169 gcry_sexp_t pub_key, sec_key; 169 gcry_sexp_t pub_key, sec_key;
170 int rc; 170 int rc;
171 171
172 rc = gcry_sexp_sscan (&pub_key, NULL, sample_public_key_1, 172 rc = gcry_sexp_sscan (&pub_key, NULL, sample_public_key_1,
173 strlen (sample_public_key_1)); 173 strlen (sample_public_key_1));
174 if (! rc) 174 if (! rc)
175 rc = gcry_sexp_sscan (&sec_key, NULL, sample_private_key_1, 175 rc = gcry_sexp_sscan (&sec_key, NULL, sample_private_key_1,
176 strlen (sample_private_key_1)); 176 strlen (sample_private_key_1));
177 if (rc) 177 if (rc)
178 die ("converting sample keys failed: %s\n", gcry_strerror (rc)); 178 die ("converting sample keys failed: %s\n", gcry_strerror (rc));
179 179
180 *pkey = pub_key; 180 *pkey = pub_key;
181 *skey = sec_key; 181 *skey = sec_key;
182} 182}
183 183
184static void 184static void
185get_keys_new (gcry_sexp_t *pkey, gcry_sexp_t *skey) 185get_keys_new (gcry_sexp_t *pkey, gcry_sexp_t *skey)
186{ 186{
187 gcry_sexp_t key_spec, key, pub_key, sec_key; 187 gcry_sexp_t key_spec, key, pub_key, sec_key;
188 int rc; 188 int rc;
189 189
190 rc = gcry_sexp_new (&key_spec, 190 rc = gcry_sexp_new (&key_spec,
191 "(genkey (rsa (nbits 4:1024)))", 0, 1); 191 "(genkey (rsa (nbits 4:1024)))", 0, 1);
192 if (rc) 192 if (rc)
193 die ("error creating S-expression: %s\n", gcry_strerror (rc)); 193 die ("error creating S-expression: %s\n", gcry_strerror (rc));
194 rc = gcry_pk_genkey (&key, key_spec); 194 rc = gcry_pk_genkey (&key, key_spec);
195 gcry_sexp_release (key_spec); 195 gcry_sexp_release (key_spec);
196 if (rc) 196 if (rc)
197 die ("error generating RSA key: %s\n", gcry_strerror (rc)); 197 die ("error generating RSA key: %s\n", gcry_strerror (rc));
198 198
199 pub_key = gcry_sexp_find_token (key, "public-key", 0); 199 pub_key = gcry_sexp_find_token (key, "public-key", 0);
200 if (! pub_key) 200 if (! pub_key)
201 die ("public part missing in key\n"); 201 die ("public part missing in key\n");
202 202
203 sec_key = gcry_sexp_find_token (key, "private-key", 0); 203 sec_key = gcry_sexp_find_token (key, "private-key", 0);
204 if (! sec_key) 204 if (! sec_key)
205 die ("private part missing in key\n"); 205 die ("private part missing in key\n");
206 206
207 gcry_sexp_release (key); 207 gcry_sexp_release (key);
208 *pkey = pub_key; 208 *pkey = pub_key;
209 *skey = sec_key; 209 *skey = sec_key;
210} 210}
211 211
212static void 212static void
213check_run (void) 213check_run (void)
214{ 214{
215 gcry_sexp_t pkey, skey; 215 gcry_sexp_t pkey, skey;
216 216
217 /* Check sample keys. */ 217 /* Check sample keys. */
218 get_keys_sample (&pkey, &skey); 218 get_keys_sample (&pkey, &skey);
219 check_keys (pkey, skey); 219 check_keys (pkey, skey);
220 gcry_sexp_release (pkey); 220 gcry_sexp_release (pkey);
221 gcry_sexp_release (skey); 221 gcry_sexp_release (skey);
222 222
223 /* Check newly generated keys. */ 223 /* Check newly generated keys. */
224 get_keys_new (&pkey, &skey); 224 get_keys_new (&pkey, &skey);
225 check_keys (pkey, skey); 225 check_keys (pkey, skey);
226 gcry_sexp_release (pkey); 226 gcry_sexp_release (pkey);
227 gcry_sexp_release (skey); 227 gcry_sexp_release (skey);
228} 228}
229 229
230int 230int
231main (int argc, char **argv) 231main (int argc, char **argv)
232{ 232{
233 int debug = 0; 233 int debug = 0;
234 int i = 10; 234 int i = 10;
235 235
236 if (argc > 1 && !strcmp (argv[1], "--verbose")) 236 if (argc > 1 && !strcmp (argv[1], "--verbose"))
237 verbose = 1; 237 verbose = 1;
238 else if (argc > 1 && !strcmp (argv[1], "--debug")) 238 else if (argc > 1 && !strcmp (argv[1], "--debug"))
239 verbose = debug = 1; 239 verbose = debug = 1;
240 240
241 gcry_control (GCRYCTL_DISABLE_SECMEM, 0); 241 gcry_control (GCRYCTL_DISABLE_SECMEM, 0);
242 if (!gcry_check_version (GCRYPT_VERSION)) 242 if (!gcry_check_version (GCRYPT_VERSION))
243 die ("version mismatch\n"); 243 die ("version mismatch\n");
244 gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); 244 gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
245 if (debug) 245 if (debug)
246 gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1u , 0); 246 gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1u , 0);
247 247
248 for (; i > 0; i--) 248 for (; i > 0; i--)
249 check_run (); 249 check_run ();
250 250
251 return 0; 251 return 0;
252} 252}
diff --git a/linden/indra/libgcrypt/libgcrypt-1.2.2/tests/random.c b/linden/indra/libgcrypt/libgcrypt-1.2.2/tests/random.c
index 9d3198c..5b5c541 100755..100644
--- a/linden/indra/libgcrypt/libgcrypt-1.2.2/tests/random.c
+++ b/linden/indra/libgcrypt/libgcrypt-1.2.2/tests/random.c
@@ -1,252 +1,252 @@
1/* random.c - part of the Libgcrypt test suite. 1/* random.c - part of the Libgcrypt test suite.
2 Copyright (C) 2005 Free Software Foundation, Inc. 2 Copyright (C) 2005 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or 4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License as 5 modify it under the terms of the GNU General Public License as
6 published by the Free Software Foundation; either version 2 of the 6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version. 7 License, or (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, but 9 This program is distributed in the hope that it will be useful, but
10 WITHOUT ANY WARRANTY; without even the implied warranty of 10 WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details. 12 General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software 15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
17 USA. */ 17 USA. */
18 18
19#include <assert.h> 19#include <assert.h>
20#include <stdio.h> 20#include <stdio.h>
21#include <string.h> 21#include <string.h>
22#include <stdlib.h> 22#include <stdlib.h>
23#include <errno.h> 23#include <errno.h>
24#include <signal.h> 24#include <signal.h>
25#include <unistd.h> 25#include <unistd.h>
26#include <sys/wait.h> 26#include <sys/wait.h>
27 27
28#include "../src/gcrypt.h" 28#include "../src/gcrypt.h"
29 29
30static int verbose; 30static int verbose;
31 31
32static void 32static void
33die (const char *format, ...) 33die (const char *format, ...)
34{ 34{
35 va_list arg_ptr; 35 va_list arg_ptr;
36 36
37 va_start (arg_ptr, format); 37 va_start (arg_ptr, format);
38 vfprintf (stderr, format, arg_ptr); 38 vfprintf (stderr, format, arg_ptr);
39 va_end (arg_ptr); 39 va_end (arg_ptr);
40 exit (1); 40 exit (1);
41} 41}
42 42
43 43
44static void 44static void
45print_hex (const char *text, const void *buf, size_t n) 45print_hex (const char *text, const void *buf, size_t n)
46{ 46{
47 const unsigned char *p = buf; 47 const unsigned char *p = buf;
48 48
49 fputs (text, stdout); 49 fputs (text, stdout);
50 for (; n; n--, p++) 50 for (; n; n--, p++)
51 printf ("%02X", *p); 51 printf ("%02X", *p);
52 putchar ('\n'); 52 putchar ('\n');
53} 53}
54 54
55 55
56static int 56static int
57writen (int fd, const void *buf, size_t nbytes) 57writen (int fd, const void *buf, size_t nbytes)
58{ 58{
59 size_t nleft = nbytes; 59 size_t nleft = nbytes;
60 int nwritten; 60 int nwritten;
61 61
62 while (nleft > 0) 62 while (nleft > 0)
63 { 63 {
64 nwritten = write (fd, buf, nleft); 64 nwritten = write (fd, buf, nleft);
65 if (nwritten < 0) 65 if (nwritten < 0)
66 { 66 {
67 if (errno == EINTR) 67 if (errno == EINTR)
68 nwritten = 0; 68 nwritten = 0;
69 else 69 else
70 return -1; 70 return -1;
71 } 71 }
72 nleft -= nwritten; 72 nleft -= nwritten;
73 buf = (const char*)buf + nwritten; 73 buf = (const char*)buf + nwritten;
74 } 74 }
75 75
76 return 0; 76 return 0;
77} 77}
78 78
79static int 79static int
80readn (int fd, void *buf, size_t buflen, size_t *ret_nread) 80readn (int fd, void *buf, size_t buflen, size_t *ret_nread)
81{ 81{
82 size_t nleft = buflen; 82 size_t nleft = buflen;
83 int nread; 83 int nread;
84 char *p; 84 char *p;
85 85
86 p = buf; 86 p = buf;
87 while ( nleft > 0 ) 87 while ( nleft > 0 )
88 { 88 {
89 nread = read ( fd, buf, nleft ); 89 nread = read ( fd, buf, nleft );
90 if (nread < 0) 90 if (nread < 0)
91 { 91 {
92 if (nread == EINTR) 92 if (nread == EINTR)
93 nread = 0; 93 nread = 0;
94 else 94 else
95 return -1; 95 return -1;
96 } 96 }
97 else if (!nread) 97 else if (!nread)
98 break; /* EOF */ 98 break; /* EOF */
99 nleft -= nread; 99 nleft -= nread;
100 buf = (char*)buf + nread; 100 buf = (char*)buf + nread;
101 } 101 }
102 if (ret_nread) 102 if (ret_nread)
103 *ret_nread = buflen - nleft; 103 *ret_nread = buflen - nleft;
104 return 0; 104 return 0;
105} 105}
106 106
107 107
108 108
109/* Check that forking won't return the same random. */ 109/* Check that forking won't return the same random. */
110static void 110static void
111check_forking (void) 111check_forking (void)
112{ 112{
113 pid_t pid; 113 pid_t pid;
114 int rp[2]; 114 int rp[2];
115 int i, status; 115 int i, status;
116 size_t nread; 116 size_t nread;
117 char tmp1[16], tmp1c[16], tmp1p[16]; 117 char tmp1[16], tmp1c[16], tmp1p[16];
118 118
119 /* We better make sure that the RNG has been initialzied. */ 119 /* We better make sure that the RNG has been initialzied. */
120 gcry_randomize (tmp1, sizeof tmp1, GCRY_STRONG_RANDOM); 120 gcry_randomize (tmp1, sizeof tmp1, GCRY_STRONG_RANDOM);
121 if (verbose) 121 if (verbose)
122 print_hex ("initial random: ", tmp1, sizeof tmp1); 122 print_hex ("initial random: ", tmp1, sizeof tmp1);
123 123
124 if (pipe (rp) == -1) 124 if (pipe (rp) == -1)
125 die ("pipe failed: %s\n", strerror (errno)); 125 die ("pipe failed: %s\n", strerror (errno));
126 126
127 pid = fork (); 127 pid = fork ();
128 if (pid == (pid_t)(-1)) 128 if (pid == (pid_t)(-1))
129 die ("fork failed: %s\n", strerror (errno)); 129 die ("fork failed: %s\n", strerror (errno));
130 if (!pid) 130 if (!pid)
131 { 131 {
132 gcry_randomize (tmp1c, sizeof tmp1c, GCRY_STRONG_RANDOM); 132 gcry_randomize (tmp1c, sizeof tmp1c, GCRY_STRONG_RANDOM);
133 if (writen (rp[1], tmp1c, sizeof tmp1c)) 133 if (writen (rp[1], tmp1c, sizeof tmp1c))
134 die ("write failed: %s\n", strerror (errno)); 134 die ("write failed: %s\n", strerror (errno));
135 if (verbose) 135 if (verbose)
136 { 136 {
137 print_hex (" child random: ", tmp1c, sizeof tmp1c); 137 print_hex (" child random: ", tmp1c, sizeof tmp1c);
138 fflush (stdout); 138 fflush (stdout);
139 } 139 }
140 _exit (0); 140 _exit (0);
141 } 141 }
142 gcry_randomize (tmp1p, sizeof tmp1p, GCRY_STRONG_RANDOM); 142 gcry_randomize (tmp1p, sizeof tmp1p, GCRY_STRONG_RANDOM);
143 if (verbose) 143 if (verbose)
144 print_hex (" parent random: ", tmp1p, sizeof tmp1p); 144 print_hex (" parent random: ", tmp1p, sizeof tmp1p);
145 145
146 close (rp[1]); 146 close (rp[1]);
147 if (readn (rp[0], tmp1c, sizeof tmp1c, &nread)) 147 if (readn (rp[0], tmp1c, sizeof tmp1c, &nread))
148 die ("read failed: %s\n", strerror (errno)); 148 die ("read failed: %s\n", strerror (errno));
149 if (nread != sizeof tmp1c) 149 if (nread != sizeof tmp1c)
150 die ("read too short\n"); 150 die ("read too short\n");
151 151
152 while ( (i=waitpid (pid, &status, 0)) == -1 && errno == EINTR) 152 while ( (i=waitpid (pid, &status, 0)) == -1 && errno == EINTR)
153 ; 153 ;
154 if (i != (pid_t)(-1) 154 if (i != (pid_t)(-1)
155 && WIFEXITED (status) && !WEXITSTATUS (status)) 155 && WIFEXITED (status) && !WEXITSTATUS (status))
156 ; 156 ;
157 else 157 else
158 die ("child failed\n"); 158 die ("child failed\n");
159 159
160 if (!memcmp (tmp1p, tmp1c, sizeof tmp1c)) 160 if (!memcmp (tmp1p, tmp1c, sizeof tmp1c))
161 die ("parent and child got the same random number\n"); 161 die ("parent and child got the same random number\n");
162} 162}
163 163
164 164
165 165
166/* Check that forking won't return the same nonce. */ 166/* Check that forking won't return the same nonce. */
167static void 167static void
168check_nonce_forking (void) 168check_nonce_forking (void)
169{ 169{
170 pid_t pid; 170 pid_t pid;
171 int rp[2]; 171 int rp[2];
172 int i, status; 172 int i, status;
173 size_t nread; 173 size_t nread;
174 char nonce1[10], nonce1c[10], nonce1p[10]; 174 char nonce1[10], nonce1c[10], nonce1p[10];
175 175
176 /* We won't get the same nonce back if we never initialized the 176 /* We won't get the same nonce back if we never initialized the
177 nonce subsystem, thus we get one nonce here and forget about 177 nonce subsystem, thus we get one nonce here and forget about
178 it. */ 178 it. */
179 gcry_create_nonce (nonce1, sizeof nonce1); 179 gcry_create_nonce (nonce1, sizeof nonce1);
180 if (verbose) 180 if (verbose)
181 print_hex ("initial nonce: ", nonce1, sizeof nonce1); 181 print_hex ("initial nonce: ", nonce1, sizeof nonce1);
182 182
183 if (pipe (rp) == -1) 183 if (pipe (rp) == -1)
184 die ("pipe failed: %s\n", strerror (errno)); 184 die ("pipe failed: %s\n", strerror (errno));
185 185
186 pid = fork (); 186 pid = fork ();
187 if (pid == (pid_t)(-1)) 187 if (pid == (pid_t)(-1))
188 die ("fork failed: %s\n", strerror (errno)); 188 die ("fork failed: %s\n", strerror (errno));
189 if (!pid) 189 if (!pid)
190 { 190 {
191 gcry_create_nonce (nonce1c, sizeof nonce1c); 191 gcry_create_nonce (nonce1c, sizeof nonce1c);
192 if (writen (rp[1], nonce1c, sizeof nonce1c)) 192 if (writen (rp[1], nonce1c, sizeof nonce1c))
193 die ("write failed: %s\n", strerror (errno)); 193 die ("write failed: %s\n", strerror (errno));
194 if (verbose) 194 if (verbose)
195 { 195 {
196 print_hex (" child nonce: ", nonce1c, sizeof nonce1c); 196 print_hex (" child nonce: ", nonce1c, sizeof nonce1c);
197 fflush (stdout); 197 fflush (stdout);
198 } 198 }
199 _exit (0); 199 _exit (0);
200 } 200 }
201 gcry_create_nonce (nonce1p, sizeof nonce1p); 201 gcry_create_nonce (nonce1p, sizeof nonce1p);
202 if (verbose) 202 if (verbose)
203 print_hex (" parent nonce: ", nonce1p, sizeof nonce1p); 203 print_hex (" parent nonce: ", nonce1p, sizeof nonce1p);
204 204
205 close (rp[1]); 205 close (rp[1]);
206 if (readn (rp[0], nonce1c, sizeof nonce1c, &nread)) 206 if (readn (rp[0], nonce1c, sizeof nonce1c, &nread))
207 die ("read failed: %s\n", strerror (errno)); 207 die ("read failed: %s\n", strerror (errno));
208 if (nread != sizeof nonce1c) 208 if (nread != sizeof nonce1c)
209 die ("read too short\n"); 209 die ("read too short\n");
210 210
211 while ( (i=waitpid (pid, &status, 0)) == -1 && errno == EINTR) 211 while ( (i=waitpid (pid, &status, 0)) == -1 && errno == EINTR)
212 ; 212 ;
213 if (i != (pid_t)(-1) 213 if (i != (pid_t)(-1)
214 && WIFEXITED (status) && !WEXITSTATUS (status)) 214 && WIFEXITED (status) && !WEXITSTATUS (status))
215 ; 215 ;
216 else 216 else
217 die ("child failed\n"); 217 die ("child failed\n");
218 218
219 if (!memcmp (nonce1p, nonce1c, sizeof nonce1c)) 219 if (!memcmp (nonce1p, nonce1c, sizeof nonce1c))
220 die ("parent and child got the same nonce\n"); 220 die ("parent and child got the same nonce\n");
221} 221}
222 222
223 223
224 224
225 225
226 226
227 227
228int 228int
229main (int argc, char **argv) 229main (int argc, char **argv)
230{ 230{
231 int debug = 0; 231 int debug = 0;
232 232
233 if ((argc > 1) && (! strcmp (argv[1], "--verbose"))) 233 if ((argc > 1) && (! strcmp (argv[1], "--verbose")))
234 verbose = 1; 234 verbose = 1;
235 else if ((argc > 1) && (! strcmp (argv[1], "--debug"))) 235 else if ((argc > 1) && (! strcmp (argv[1], "--debug")))
236 verbose = debug = 1; 236 verbose = debug = 1;
237 237
238 signal (SIGPIPE, SIG_IGN); 238 signal (SIGPIPE, SIG_IGN);
239 239
240 gcry_control (GCRYCTL_DISABLE_SECMEM, 0); 240 gcry_control (GCRYCTL_DISABLE_SECMEM, 0);
241 if (!gcry_check_version (GCRYPT_VERSION)) 241 if (!gcry_check_version (GCRYPT_VERSION))
242 die ("version mismatch\n"); 242 die ("version mismatch\n");
243 243
244 gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); 244 gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
245 if (debug) 245 if (debug)
246 gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1u, 0); 246 gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1u, 0);
247 247
248 check_forking (); 248 check_forking ();
249 check_nonce_forking (); 249 check_nonce_forking ();
250 250
251 return 0; 251 return 0;
252} 252}
diff --git a/linden/indra/libgcrypt/libgcrypt-1.2.2/tests/register.c b/linden/indra/libgcrypt/libgcrypt-1.2.2/tests/register.c
index 5da956f..a667c2d 100755..100644
--- a/linden/indra/libgcrypt/libgcrypt-1.2.2/tests/register.c
+++ b/linden/indra/libgcrypt/libgcrypt-1.2.2/tests/register.c
@@ -1,159 +1,159 @@
1/* register.c - Test for registering of additional cipher modules. 1/* register.c - Test for registering of additional cipher modules.
2 * Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. 2 * Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
3 * 3 *
4 * This file is part of Libgcrypt. 4 * This file is part of Libgcrypt.
5 * 5 *
6 * Libgcrypt is free software; you can redistribute it and/or modify 6 * Libgcrypt is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as 7 * it under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation; either version 2.1 of 8 * published by the Free Software Foundation; either version 2.1 of
9 * the License, or (at your option) any later version. 9 * the License, or (at your option) any later version.
10 * 10 *
11 * Libgcrypt is distributed in the hope that it will be useful, 11 * Libgcrypt is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details. 14 * GNU Lesser General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU Lesser General Public 16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this program; if not, write to the Free Software 17 * License along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
19 */ 19 */
20 20
21#include <stdarg.h> 21#include <stdarg.h>
22#include <stdio.h> 22#include <stdio.h>
23#include <stdlib.h> 23#include <stdlib.h>
24#include <string.h> 24#include <string.h>
25#include <assert.h> 25#include <assert.h>
26 26
27#include "../src/gcrypt.h" 27#include "../src/gcrypt.h"
28 28
29static int verbose; 29static int verbose;
30 30
31static void 31static void
32die (const char *format, ...) 32die (const char *format, ...)
33{ 33{
34 va_list arg_ptr ; 34 va_list arg_ptr ;
35 35
36 va_start( arg_ptr, format ) ; 36 va_start( arg_ptr, format ) ;
37 vfprintf (stderr, format, arg_ptr ); 37 vfprintf (stderr, format, arg_ptr );
38 va_end(arg_ptr); 38 va_end(arg_ptr);
39 exit (1); 39 exit (1);
40} 40}
41 41
42gcry_err_code_t 42gcry_err_code_t
43foo_setkey (void *c, const unsigned char *key, unsigned keylen) 43foo_setkey (void *c, const unsigned char *key, unsigned keylen)
44{ 44{
45 return 0; 45 return 0;
46} 46}
47 47
48#define FOO_BLOCKSIZE 16 48#define FOO_BLOCKSIZE 16
49 49
50void 50void
51foo_encrypt (void *c, unsigned char *outbuf, const unsigned char *inbuf) 51foo_encrypt (void *c, unsigned char *outbuf, const unsigned char *inbuf)
52{ 52{
53 int i; 53 int i;
54 54
55 for (i = 0; i < FOO_BLOCKSIZE; i++) 55 for (i = 0; i < FOO_BLOCKSIZE; i++)
56 outbuf[i] = inbuf[i] ^ 0x42; 56 outbuf[i] = inbuf[i] ^ 0x42;
57} 57}
58 58
59void 59void
60foo_decrypt (void *c, unsigned char *outbuf, const unsigned char *inbuf) 60foo_decrypt (void *c, unsigned char *outbuf, const unsigned char *inbuf)
61{ 61{
62 int i; 62 int i;
63 63
64 for (i = 0; i < FOO_BLOCKSIZE; i++) 64 for (i = 0; i < FOO_BLOCKSIZE; i++)
65 outbuf[i] = inbuf[i] ^ 0x42; 65 outbuf[i] = inbuf[i] ^ 0x42;
66} 66}
67 67
68gcry_cipher_spec_t cipher_spec_foo = 68gcry_cipher_spec_t cipher_spec_foo =
69 { 69 {
70 "FOO", NULL, NULL, 16, 0, 0, 70 "FOO", NULL, NULL, 16, 0, 0,
71 foo_setkey, foo_encrypt, foo_decrypt, 71 foo_setkey, foo_encrypt, foo_decrypt,
72 NULL, NULL, 72 NULL, NULL,
73 }; 73 };
74 74
75int 75int
76check_list (int algorithm) 76check_list (int algorithm)
77{ 77{
78 gcry_error_t err = GPG_ERR_NO_ERROR; 78 gcry_error_t err = GPG_ERR_NO_ERROR;
79 int *list, list_length; 79 int *list, list_length;
80 int i, ret = 0; 80 int i, ret = 0;
81 81
82 err = gcry_cipher_list (NULL, &list_length); 82 err = gcry_cipher_list (NULL, &list_length);
83 assert (! err); 83 assert (! err);
84 list = malloc (sizeof (int) * list_length); 84 list = malloc (sizeof (int) * list_length);
85 assert (list); 85 assert (list);
86 err = gcry_cipher_list (list, &list_length); 86 err = gcry_cipher_list (list, &list_length);
87 87
88 for (i = 0; i < list_length && (! ret); i++) 88 for (i = 0; i < list_length && (! ret); i++)
89 if (list[i] == algorithm) 89 if (list[i] == algorithm)
90 ret = 1; 90 ret = 1;
91 91
92 return ret; 92 return ret;
93} 93}
94 94
95void 95void
96check_run (void) 96check_run (void)
97{ 97{
98 int err, algorithm; 98 int err, algorithm;
99 gcry_cipher_hd_t h; 99 gcry_cipher_hd_t h;
100 char plain[16] = "Heil Discordia!"; 100 char plain[16] = "Heil Discordia!";
101 char encrypted[16], decrypted[16]; 101 char encrypted[16], decrypted[16];
102 gcry_module_t module; 102 gcry_module_t module;
103 int ret; 103 int ret;
104 104
105 err = gcry_cipher_register (&cipher_spec_foo, &algorithm, &module); 105 err = gcry_cipher_register (&cipher_spec_foo, &algorithm, &module);
106 assert (! err); 106 assert (! err);
107 107
108 err = gcry_cipher_open (&h, algorithm, GCRY_CIPHER_MODE_CBC, 0); 108 err = gcry_cipher_open (&h, algorithm, GCRY_CIPHER_MODE_CBC, 0);
109 assert (! err); 109 assert (! err);
110 110
111 err = gcry_cipher_encrypt (h, 111 err = gcry_cipher_encrypt (h,
112 (unsigned char *) encrypted, sizeof (encrypted), 112 (unsigned char *) encrypted, sizeof (encrypted),
113 (unsigned char *) plain, sizeof (plain)); 113 (unsigned char *) plain, sizeof (plain));
114 assert (! err); 114 assert (! err);
115 assert (memcmp ((void *) plain, (void *) encrypted, sizeof (plain))); 115 assert (memcmp ((void *) plain, (void *) encrypted, sizeof (plain)));
116 116
117 err = gcry_cipher_reset (h); 117 err = gcry_cipher_reset (h);
118 assert (! err); 118 assert (! err);
119 119
120 err = gcry_cipher_decrypt (h, 120 err = gcry_cipher_decrypt (h,
121 (unsigned char *) decrypted, sizeof (decrypted), 121 (unsigned char *) decrypted, sizeof (decrypted),
122 (unsigned char *) encrypted, sizeof (encrypted)); 122 (unsigned char *) encrypted, sizeof (encrypted));
123 assert (! err); 123 assert (! err);
124 assert (! memcmp ((void *) plain, (void *) decrypted, sizeof (plain))); 124 assert (! memcmp ((void *) plain, (void *) decrypted, sizeof (plain)));
125 125
126 ret = check_list (algorithm); 126 ret = check_list (algorithm);
127 assert (ret); 127 assert (ret);
128 128
129 gcry_cipher_close (h); 129 gcry_cipher_close (h);
130 130
131 gcry_cipher_unregister (module); 131 gcry_cipher_unregister (module);
132 132
133 ret = check_list (algorithm); 133 ret = check_list (algorithm);
134 assert (! ret); 134 assert (! ret);
135} 135}
136 136
137int 137int
138main (int argc, char **argv) 138main (int argc, char **argv)
139{ 139{
140 int debug = 0; 140 int debug = 0;
141 int i = 1; 141 int i = 1;
142 142
143 if (argc > 1 && !strcmp (argv[1], "--verbose")) 143 if (argc > 1 && !strcmp (argv[1], "--verbose"))
144 verbose = 1; 144 verbose = 1;
145 else if (argc > 1 && !strcmp (argv[1], "--debug")) 145 else if (argc > 1 && !strcmp (argv[1], "--debug"))
146 verbose = debug = 1; 146 verbose = debug = 1;
147 147
148 gcry_control (GCRYCTL_DISABLE_SECMEM, 0); 148 gcry_control (GCRYCTL_DISABLE_SECMEM, 0);
149 if (!gcry_check_version (GCRYPT_VERSION)) 149 if (!gcry_check_version (GCRYPT_VERSION))
150 die ("version mismatch\n"); 150 die ("version mismatch\n");
151 gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); 151 gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
152 if (debug) 152 if (debug)
153 gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1u , 0); 153 gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1u , 0);
154 154
155 for (; i > 0; i--) 155 for (; i > 0; i--)
156 check_run (); 156 check_run ();
157 157
158 return 0; 158 return 0;
159} 159}
diff --git a/linden/indra/libgcrypt/libgcrypt-1.2.2/tests/testapi.c b/linden/indra/libgcrypt/libgcrypt-1.2.2/tests/testapi.c
index d9e809a..e14ae7b 100755..100644
--- a/linden/indra/libgcrypt/libgcrypt-1.2.2/tests/testapi.c
+++ b/linden/indra/libgcrypt/libgcrypt-1.2.2/tests/testapi.c
@@ -1,112 +1,112 @@
1/* testapi.c - for libgcrypt 1/* testapi.c - for libgcrypt
2 * Copyright (C) 2000, 2002 Free Software Foundation, Inc. 2 * Copyright (C) 2000, 2002 Free Software Foundation, Inc.
3 * 3 *
4 * This file is part of Libgcrypt. 4 * This file is part of Libgcrypt.
5 * 5 *
6 * Libgcrypt is free software; you can redistribute it and/or modify 6 * Libgcrypt is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser general Public License as 7 * it under the terms of the GNU Lesser general Public License as
8 * published by the Free Software Foundation; either version 2.1 of 8 * published by the Free Software Foundation; either version 2.1 of
9 * the License, or (at your option) any later version. 9 * the License, or (at your option) any later version.
10 * 10 *
11 * Libgcrypt is distributed in the hope that it will be useful, 11 * Libgcrypt is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details. 14 * GNU Lesser General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU Lesser General Public 16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this program; if not, write to the Free Software 17 * License along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
19 */ 19 */
20 20
21#include <stdio.h> 21#include <stdio.h>
22#include <stdlib.h> 22#include <stdlib.h>
23#include <gcrypt.h> 23#include <gcrypt.h>
24 24
25 25
26#define BUG() do {fprintf ( stderr, "Ooops at %s:%d\n", __FILE__ , __LINE__ );\ 26#define BUG() do {fprintf ( stderr, "Ooops at %s:%d\n", __FILE__ , __LINE__ );\
27 exit(2);} while(0) 27 exit(2);} while(0)
28 28
29/* an ElGamal public key */ 29/* an ElGamal public key */
30struct { 30struct {
31 const char *p,*g,*y; 31 const char *p,*g,*y;
32} elg_testkey1 = { 32} elg_testkey1 = {
33 "0x9D559F31A6D30492C383213844AEBB7772963A85D3239F3611AAB93A2A985F64FB735B9259EC326BF5720F909980D609D37C288C9223B0350FBE493C3B5AF54CA23031E952E92F8A3DBEDBC5A684993D452CD54F85B85160166FCD25BD7AB6AE9B1EB4FCC9D300DAFF081C4CBA6694906D3E3FF18196A5CCF7F0A6182962166B", 33 "0x9D559F31A6D30492C383213844AEBB7772963A85D3239F3611AAB93A2A985F64FB735B9259EC326BF5720F909980D609D37C288C9223B0350FBE493C3B5AF54CA23031E952E92F8A3DBEDBC5A684993D452CD54F85B85160166FCD25BD7AB6AE9B1EB4FCC9D300DAFF081C4CBA6694906D3E3FF18196A5CCF7F0A6182962166B",
34 "0x5", 34 "0x5",
35 "0x9640024BB2A277205813FF685048AA27E2B192B667163E7C59E381E27003D044C700C531CE8FD4AA781B463BC9FFE74956AF09A38A098322B1CF72FC896F009E3A6BFF053D3B1D1E1994BF9CC07FA12963D782F027B51511DDE8C5F43421FBC12734A9C070F158C729A370BEE5FC51A772219438EDA8202C35FA3F5D8CD1997B" 35 "0x9640024BB2A277205813FF685048AA27E2B192B667163E7C59E381E27003D044C700C531CE8FD4AA781B463BC9FFE74956AF09A38A098322B1CF72FC896F009E3A6BFF053D3B1D1E1994BF9CC07FA12963D782F027B51511DDE8C5F43421FBC12734A9C070F158C729A370BEE5FC51A772219438EDA8202C35FA3F5D8CD1997B"
36}; 36};
37 37
38void 38void
39test_sexp ( int argc, char **argv ) 39test_sexp ( int argc, char **argv )
40{ 40{
41 int rc, nbits; 41 int rc, nbits;
42 gcry_sexp_t sexp; 42 gcry_sexp_t sexp;
43 gcry_mpi_t key[3]; 43 gcry_mpi_t key[3];
44 size_t n; 44 size_t n;
45 char *buf; 45 char *buf;
46 46
47 if ( gcry_mpi_scan( &key[0], GCRYMPI_FMT_HEX, elg_testkey1.p, NULL ) ) 47 if ( gcry_mpi_scan( &key[0], GCRYMPI_FMT_HEX, elg_testkey1.p, NULL ) )
48 BUG(); 48 BUG();
49 if ( gcry_mpi_scan( &key[1], GCRYMPI_FMT_HEX, elg_testkey1.g, NULL ) ) 49 if ( gcry_mpi_scan( &key[1], GCRYMPI_FMT_HEX, elg_testkey1.g, NULL ) )
50 BUG(); 50 BUG();
51 if ( gcry_mpi_scan( &key[2], GCRYMPI_FMT_HEX, elg_testkey1.y, NULL ) ) 51 if ( gcry_mpi_scan( &key[2], GCRYMPI_FMT_HEX, elg_testkey1.y, NULL ) )
52 BUG(); 52 BUG();
53 53
54 /* get nbits from a key */ 54 /* get nbits from a key */
55 rc = gcry_sexp_build ( &sexp, NULL, 55 rc = gcry_sexp_build ( &sexp, NULL,
56 "(public-key(elg(p%m)(g%m)(y%m)))", 56 "(public-key(elg(p%m)(g%m)(y%m)))",
57 key[0], key[1], key[2] ); 57 key[0], key[1], key[2] );
58 fputs ( "DUMP of PK:\n", stderr ); 58 fputs ( "DUMP of PK:\n", stderr );
59 gcry_sexp_dump ( sexp ); 59 gcry_sexp_dump ( sexp );
60 { gcry_sexp_t x; 60 { gcry_sexp_t x;
61 x = gcry_sexp_cdr ( sexp ); 61 x = gcry_sexp_cdr ( sexp );
62 fputs ( "DUMP of CDR:\n", stderr ); 62 fputs ( "DUMP of CDR:\n", stderr );
63 gcry_sexp_dump ( x ); 63 gcry_sexp_dump ( x );
64 gcry_sexp_release ( x ); 64 gcry_sexp_release ( x );
65 } 65 }
66 nbits = gcry_pk_get_nbits( sexp ); 66 nbits = gcry_pk_get_nbits( sexp );
67 printf ( "elg_testkey1 - nbits=%d\n", nbits ); 67 printf ( "elg_testkey1 - nbits=%d\n", nbits );
68 n = gcry_sexp_sprint ( sexp, 0, NULL, 0 ); 68 n = gcry_sexp_sprint ( sexp, 0, NULL, 0 );
69 buf = gcry_xmalloc ( n ); 69 buf = gcry_xmalloc ( n );
70 n = gcry_sexp_sprint ( sexp, 0, buf, n ); 70 n = gcry_sexp_sprint ( sexp, 0, buf, n );
71 printf ( "sprint length=%u\n", (unsigned int)n ); 71 printf ( "sprint length=%u\n", (unsigned int)n );
72 gcry_free ( buf ); 72 gcry_free ( buf );
73 gcry_sexp_release( sexp ); 73 gcry_sexp_release( sexp );
74} 74}
75 75
76 76
77void 77void
78test_genkey ( int argc, char **argv ) 78test_genkey ( int argc, char **argv )
79{ 79{
80 int rc, nbits = 1024; 80 int rc, nbits = 1024;
81 gcry_sexp_t s_parms, s_key; 81 gcry_sexp_t s_parms, s_key;
82 82
83 gcry_control( GCRYCTL_INIT_SECMEM, 16384, 0 ); 83 gcry_control( GCRYCTL_INIT_SECMEM, 16384, 0 );
84 rc = gcry_sexp_build ( &s_parms, NULL, "(genkey(dsa(nbits %d)))", nbits ); 84 rc = gcry_sexp_build ( &s_parms, NULL, "(genkey(dsa(nbits %d)))", nbits );
85 rc = gcry_pk_genkey( &s_key, s_parms ); 85 rc = gcry_pk_genkey( &s_key, s_parms );
86 if ( rc ) { 86 if ( rc ) {
87 fprintf ( stderr, "genkey failed: %s\n", gpg_strerror (rc) ); 87 fprintf ( stderr, "genkey failed: %s\n", gpg_strerror (rc) );
88 return; 88 return;
89 } 89 }
90 gcry_sexp_release( s_parms ); 90 gcry_sexp_release( s_parms );
91 gcry_sexp_dump ( s_key ); 91 gcry_sexp_dump ( s_key );
92 gcry_sexp_release( s_key ); 92 gcry_sexp_release( s_key );
93} 93}
94 94
95int 95int
96main( int argc, char **argv ) 96main( int argc, char **argv )
97{ 97{
98 if ( argc < 2 ) 98 if ( argc < 2 )
99 printf("%s\n", gcry_check_version ( NULL ) ); 99 printf("%s\n", gcry_check_version ( NULL ) );
100 else if ( !strcmp ( argv[1], "version") ) 100 else if ( !strcmp ( argv[1], "version") )
101 printf("%s\n", gcry_check_version ( argc > 2 ? argv[2] : NULL ) ); 101 printf("%s\n", gcry_check_version ( argc > 2 ? argv[2] : NULL ) );
102 else if ( !strcmp ( argv[1], "sexp" ) ) 102 else if ( !strcmp ( argv[1], "sexp" ) )
103 test_sexp ( argc-2, argv+2 ); 103 test_sexp ( argc-2, argv+2 );
104 else if ( !strcmp ( argv[1], "genkey" ) ) 104 else if ( !strcmp ( argv[1], "genkey" ) )
105 test_genkey ( argc-2, argv+2 ); 105 test_genkey ( argc-2, argv+2 );
106 else { 106 else {
107 fprintf (stderr, "usage: testapi mode-string [mode-args]\n"); 107 fprintf (stderr, "usage: testapi mode-string [mode-args]\n");
108 return 1; 108 return 1;
109 } 109 }
110 110
111 return 0; 111 return 0;
112} 112}
diff --git a/linden/indra/libgcrypt/libgcrypt-1.2.2/tests/tsexp.c b/linden/indra/libgcrypt/libgcrypt-1.2.2/tests/tsexp.c
index 551ab68..54c9e81 100755..100644
--- a/linden/indra/libgcrypt/libgcrypt-1.2.2/tests/tsexp.c
+++ b/linden/indra/libgcrypt/libgcrypt-1.2.2/tests/tsexp.c
@@ -1,396 +1,396 @@
1/* tsexp.c - S-expression regression tests 1/* tsexp.c - S-expression regression tests
2 * Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. 2 * Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
3 * 3 *
4 * This file is part of Libgcrypt. 4 * This file is part of Libgcrypt.
5 * 5 *
6 * Libgcrypt is free software; you can redistribute it and/or modify 6 * Libgcrypt is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as 7 * it under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation; either version 2.1 of 8 * published by the Free Software Foundation; either version 2.1 of
9 * the License, or (at your option) any later version. 9 * the License, or (at your option) any later version.
10 * 10 *
11 * Libgcrypt is distributed in the hope that it will be useful, 11 * Libgcrypt is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details. 14 * GNU Lesser General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU Lesser General Public 16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this program; if not, write to the Free Software 17 * License along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
19 */ 19 */
20 20
21#include <stdio.h> 21#include <stdio.h>
22#include <stdlib.h> 22#include <stdlib.h>
23#include <string.h> 23#include <string.h>
24#include <stdarg.h> 24#include <stdarg.h>
25#include "../src/gcrypt.h" 25#include "../src/gcrypt.h"
26 26
27#define PGMNAME "tsexp" 27#define PGMNAME "tsexp"
28 28
29static int verbose; 29static int verbose;
30static int error_count; 30static int error_count;
31 31
32static void 32static void
33info (const char *format, ...) 33info (const char *format, ...)
34{ 34{
35 va_list arg_ptr; 35 va_list arg_ptr;
36 36
37 if (verbose) 37 if (verbose)
38 { 38 {
39 va_start( arg_ptr, format ) ; 39 va_start( arg_ptr, format ) ;
40 vfprintf (stderr, format, arg_ptr ); 40 vfprintf (stderr, format, arg_ptr );
41 va_end(arg_ptr); 41 va_end(arg_ptr);
42 } 42 }
43} 43}
44 44
45static void 45static void
46fail ( const char *format, ... ) 46fail ( const char *format, ... )
47{ 47{
48 va_list arg_ptr ; 48 va_list arg_ptr ;
49 49
50 fputs (PGMNAME ": ", stderr); 50 fputs (PGMNAME ": ", stderr);
51 va_start( arg_ptr, format ) ; 51 va_start( arg_ptr, format ) ;
52 vfprintf (stderr, format, arg_ptr ); 52 vfprintf (stderr, format, arg_ptr );
53 va_end(arg_ptr); 53 va_end(arg_ptr);
54 error_count++; 54 error_count++;
55} 55}
56 56
57 57
58/* fixme: we need better tests */ 58/* fixme: we need better tests */
59static void 59static void
60basic (void) 60basic (void)
61{ 61{
62 int pass; 62 int pass;
63 gcry_sexp_t sexp; 63 gcry_sexp_t sexp;
64 int idx; 64 int idx;
65 char *secure_buffer; 65 char *secure_buffer;
66 size_t secure_buffer_len; 66 size_t secure_buffer_len;
67 const char *string; 67 const char *string;
68 static struct { 68 static struct {
69 const char *token; 69 const char *token;
70 const char *parm; 70 const char *parm;
71 } values[] = { 71 } values[] = {
72 { "public-key", NULL }, 72 { "public-key", NULL },
73 { "dsa", NULL }, 73 { "dsa", NULL },
74 { "dsa", "p" }, 74 { "dsa", "p" },
75 { "dsa", "y" }, 75 { "dsa", "y" },
76 { "dsa", "q" }, 76 { "dsa", "q" },
77 { "dsa", "g" }, 77 { "dsa", "g" },
78 { NULL } 78 { NULL }
79 }; 79 };
80 80
81 info ("doing some pretty pointless tests\n"); 81 info ("doing some pretty pointless tests\n");
82 82
83 secure_buffer_len = 99; 83 secure_buffer_len = 99;
84 secure_buffer = gcry_xmalloc_secure (secure_buffer_len); 84 secure_buffer = gcry_xmalloc_secure (secure_buffer_len);
85 memset (secure_buffer, 'G', secure_buffer_len); 85 memset (secure_buffer, 'G', secure_buffer_len);
86 86
87 for (pass=0;;pass++) 87 for (pass=0;;pass++)
88 { 88 {
89 switch (pass) 89 switch (pass)
90 { 90 {
91 case 0: 91 case 0:
92 string = ("(public-key (dsa (p #41424344#) (y this_is_y) " 92 string = ("(public-key (dsa (p #41424344#) (y this_is_y) "
93 "(q #61626364656667#) (g %m)))"); 93 "(q #61626364656667#) (g %m)))");
94 94
95 if ( gcry_sexp_build (&sexp, NULL, string, 95 if ( gcry_sexp_build (&sexp, NULL, string,
96 gcry_mpi_set_ui (NULL, 42)) ) 96 gcry_mpi_set_ui (NULL, 42)) )
97 { 97 {
98 fail (" scanning `%s' failed\n", string); 98 fail (" scanning `%s' failed\n", string);
99 return; 99 return;
100 } 100 }
101 break; 101 break;
102 102
103 case 1: 103 case 1:
104 string = ("(public-key (dsa (p #41424344#) (y this_is_y) " 104 string = ("(public-key (dsa (p #41424344#) (y this_is_y) "
105 "(q %b) (g %m)))"); 105 "(q %b) (g %m)))");
106 106
107 if ( gcry_sexp_build (&sexp, NULL, string, 107 if ( gcry_sexp_build (&sexp, NULL, string,
108 15, "foo\0\x01\0x02789012345", 108 15, "foo\0\x01\0x02789012345",
109 gcry_mpi_set_ui (NULL, 42)) ) 109 gcry_mpi_set_ui (NULL, 42)) )
110 { 110 {
111 fail (" scanning `%s' failed\n", string); 111 fail (" scanning `%s' failed\n", string);
112 return; 112 return;
113 } 113 }
114 break; 114 break;
115 115
116 case 2: 116 case 2:
117 string = ("(public-key (dsa (p #41424344#) (y silly_y_value) " 117 string = ("(public-key (dsa (p #41424344#) (y silly_y_value) "
118 "(q %b) (g %m)))"); 118 "(q %b) (g %m)))");
119 119
120 if ( gcry_sexp_build (&sexp, NULL, string, 120 if ( gcry_sexp_build (&sexp, NULL, string,
121 secure_buffer_len, secure_buffer, 121 secure_buffer_len, secure_buffer,
122 gcry_mpi_set_ui (NULL, 17)) ) 122 gcry_mpi_set_ui (NULL, 17)) )
123 { 123 {
124 fail (" scanning `%s' failed\n", string); 124 fail (" scanning `%s' failed\n", string);
125 return; 125 return;
126 } 126 }
127 if (!gcry_is_secure (sexp)) 127 if (!gcry_is_secure (sexp))
128 fail ("gcry_sexp_build did not switch to secure memory\n"); 128 fail ("gcry_sexp_build did not switch to secure memory\n");
129 break; 129 break;
130 130
131 default: 131 default:
132 return; /* Ready. */ 132 return; /* Ready. */
133 } 133 }
134 134
135 135
136 /* now find something */ 136 /* now find something */
137 for (idx=0; values[idx].token; idx++) 137 for (idx=0; values[idx].token; idx++)
138 { 138 {
139 const char *token = values[idx].token; 139 const char *token = values[idx].token;
140 const char *parm = values[idx].parm; 140 const char *parm = values[idx].parm;
141 gcry_sexp_t s1, s2; 141 gcry_sexp_t s1, s2;
142 gcry_mpi_t a; 142 gcry_mpi_t a;
143 const char *p; 143 const char *p;
144 size_t n; 144 size_t n;
145 145
146 s1 = gcry_sexp_find_token (sexp, token, strlen(token) ); 146 s1 = gcry_sexp_find_token (sexp, token, strlen(token) );
147 if (!s1) 147 if (!s1)
148 { 148 {
149 fail ("didn't found `%s'\n", token); 149 fail ("didn't found `%s'\n", token);
150 continue; 150 continue;
151 } 151 }
152 152
153 p = gcry_sexp_nth_data (s1, 0, &n); 153 p = gcry_sexp_nth_data (s1, 0, &n);
154 if (!p) 154 if (!p)
155 { 155 {
156 fail ("no car for `%s'\n", token); 156 fail ("no car for `%s'\n", token);
157 continue; 157 continue;
158 } 158 }
159 info ("car=`%.*s'\n", (int)n, p); 159 info ("car=`%.*s'\n", (int)n, p);
160 160
161 s2 = gcry_sexp_cdr (s1); 161 s2 = gcry_sexp_cdr (s1);
162 if (!s2) 162 if (!s2)
163 { 163 {
164 fail ("no cdr for `%s'\n", token); 164 fail ("no cdr for `%s'\n", token);
165 continue; 165 continue;
166 } 166 }
167 167
168 p = gcry_sexp_nth_data (s2, 0, &n); 168 p = gcry_sexp_nth_data (s2, 0, &n);
169 if (p) 169 if (p)
170 { 170 {
171 fail ("data at car of `%s'\n", token); 171 fail ("data at car of `%s'\n", token);
172 continue; 172 continue;
173 } 173 }
174 174
175 if (parm) 175 if (parm)
176 { 176 {
177 s2 = gcry_sexp_find_token (s1, parm, strlen (parm)); 177 s2 = gcry_sexp_find_token (s1, parm, strlen (parm));
178 if (!s2) 178 if (!s2)
179 { 179 {
180 fail ("didn't found `%s'\n", parm); 180 fail ("didn't found `%s'\n", parm);
181 continue; 181 continue;
182 } 182 }
183 p = gcry_sexp_nth_data (s2, 0, &n); 183 p = gcry_sexp_nth_data (s2, 0, &n);
184 if (!p) 184 if (!p)
185 { 185 {
186 fail("no car for `%s'\n", parm ); 186 fail("no car for `%s'\n", parm );
187 continue; 187 continue;
188 } 188 }
189 info ("car=`%.*s'\n", (int)n, p); 189 info ("car=`%.*s'\n", (int)n, p);
190 p = gcry_sexp_nth_data (s2, 1, &n); 190 p = gcry_sexp_nth_data (s2, 1, &n);
191 if (!p) 191 if (!p)
192 { 192 {
193 fail("no cdr for `%s'\n", parm ); 193 fail("no cdr for `%s'\n", parm );
194 continue; 194 continue;
195 } 195 }
196 info ("cdr=`%.*s'\n", (int)n, p); 196 info ("cdr=`%.*s'\n", (int)n, p);
197 197
198 a = gcry_sexp_nth_mpi (s2, 0, GCRYMPI_FMT_USG); 198 a = gcry_sexp_nth_mpi (s2, 0, GCRYMPI_FMT_USG);
199 if (!a) 199 if (!a)
200 { 200 {
201 fail("failed to cdr the mpi for `%s'\n", parm); 201 fail("failed to cdr the mpi for `%s'\n", parm);
202 continue; 202 continue;
203 } 203 }
204 } 204 }
205 } 205 }
206 206
207 gcry_sexp_release (sexp); 207 gcry_sexp_release (sexp);
208 sexp = NULL; 208 sexp = NULL;
209 } 209 }
210 gcry_free (secure_buffer); 210 gcry_free (secure_buffer);
211} 211}
212 212
213 213
214static void 214static void
215canon_len (void) 215canon_len (void)
216{ 216{
217 static struct { 217 static struct {
218 size_t textlen; /* length of the buffer */ 218 size_t textlen; /* length of the buffer */
219 size_t expected;/* expected length or 0 on error and then ... */ 219 size_t expected;/* expected length or 0 on error and then ... */
220 size_t erroff; /* ... and at this offset */ 220 size_t erroff; /* ... and at this offset */
221 gcry_error_t errcode; /* ... with this error code */ 221 gcry_error_t errcode; /* ... with this error code */
222 char *text; 222 char *text;
223 } values[] = { 223 } values[] = {
224 { 14, 13, 0, GPG_ERR_NO_ERROR, "(9:abcdefghi) " }, 224 { 14, 13, 0, GPG_ERR_NO_ERROR, "(9:abcdefghi) " },
225 { 16, 15, 0, GPG_ERR_NO_ERROR, "(10:abcdefghix)" }, 225 { 16, 15, 0, GPG_ERR_NO_ERROR, "(10:abcdefghix)" },
226 { 14, 0,14, GPG_ERR_SEXP_STRING_TOO_LONG, "(10:abcdefghi)" }, 226 { 14, 0,14, GPG_ERR_SEXP_STRING_TOO_LONG, "(10:abcdefghi)" },
227 { 15, 0, 1, GPG_ERR_SEXP_ZERO_PREFIX, "(010:abcdefghi)" }, 227 { 15, 0, 1, GPG_ERR_SEXP_ZERO_PREFIX, "(010:abcdefghi)" },
228 { 2, 0, 0, GPG_ERR_SEXP_NOT_CANONICAL, "1:"}, 228 { 2, 0, 0, GPG_ERR_SEXP_NOT_CANONICAL, "1:"},
229 { 4, 0, 4, GPG_ERR_SEXP_STRING_TOO_LONG, "(1:)"}, 229 { 4, 0, 4, GPG_ERR_SEXP_STRING_TOO_LONG, "(1:)"},
230 { 5, 5, 0, GPG_ERR_NO_ERROR, "(1:x)"}, 230 { 5, 5, 0, GPG_ERR_NO_ERROR, "(1:x)"},
231 { 2, 2, 0, GPG_ERR_NO_ERROR, "()"}, 231 { 2, 2, 0, GPG_ERR_NO_ERROR, "()"},
232 { 4, 2, 0, GPG_ERR_NO_ERROR, "()()"}, 232 { 4, 2, 0, GPG_ERR_NO_ERROR, "()()"},
233 { 4, 4, 0, GPG_ERR_NO_ERROR, "(())"}, 233 { 4, 4, 0, GPG_ERR_NO_ERROR, "(())"},
234 { 3, 0, 3, GPG_ERR_SEXP_STRING_TOO_LONG, "(()"}, 234 { 3, 0, 3, GPG_ERR_SEXP_STRING_TOO_LONG, "(()"},
235 { 3, 0, 1, GPG_ERR_SEXP_BAD_CHARACTER, "( )"}, 235 { 3, 0, 1, GPG_ERR_SEXP_BAD_CHARACTER, "( )"},
236 { 9, 9, 0, GPG_ERR_NO_ERROR, "(3:abc())"}, 236 { 9, 9, 0, GPG_ERR_NO_ERROR, "(3:abc())"},
237 { 10, 0, 6, GPG_ERR_SEXP_BAD_CHARACTER, "(3:abc ())"}, 237 { 10, 0, 6, GPG_ERR_SEXP_BAD_CHARACTER, "(3:abc ())"},
238 /* fixme: we need much more cases */ 238 /* fixme: we need much more cases */
239 { 0 }, 239 { 0 },
240 }; 240 };
241 int idx; 241 int idx;
242 gcry_error_t errcode; 242 gcry_error_t errcode;
243 size_t n, erroff; 243 size_t n, erroff;
244 244
245 info ("checking canoncial length test function\n"); 245 info ("checking canoncial length test function\n");
246 for (idx=0; values[idx].text; idx++) 246 for (idx=0; values[idx].text; idx++)
247 { 247 {
248 n = gcry_sexp_canon_len ((const unsigned char*)values[idx].text, 248 n = gcry_sexp_canon_len ((const unsigned char*)values[idx].text,
249 values[idx].textlen, 249 values[idx].textlen,
250 &erroff, &errcode); 250 &erroff, &errcode);
251 251
252 if (n && n == values[idx].expected) 252 if (n && n == values[idx].expected)
253 ; /* success */ 253 ; /* success */
254 else if (!n && !values[idx].expected) 254 else if (!n && !values[idx].expected)
255 { /* we expected an error - check that this is the right one */ 255 { /* we expected an error - check that this is the right one */
256 if (values[idx].erroff != erroff) 256 if (values[idx].erroff != erroff)
257 fail ("canonical length test %d - wrong error offset %u\n", 257 fail ("canonical length test %d - wrong error offset %u\n",
258 idx, (unsigned int)erroff); 258 idx, (unsigned int)erroff);
259 if (gcry_err_code (errcode) != values[idx].errcode) 259 if (gcry_err_code (errcode) != values[idx].errcode)
260 fail ("canonical length test %d - wrong error code %d\n", 260 fail ("canonical length test %d - wrong error code %d\n",
261 idx, errcode); 261 idx, errcode);
262 } 262 }
263 else 263 else
264 fail ("canonical length test %d failed - n=%u, off=%u, err=%d\n", 264 fail ("canonical length test %d failed - n=%u, off=%u, err=%d\n",
265 idx, (unsigned int)n, (unsigned int)erroff, errcode); 265 idx, (unsigned int)n, (unsigned int)erroff, errcode);
266 } 266 }
267} 267}
268 268
269 269
270static void 270static void
271back_and_forth_one (int testno, const char *buffer, size_t length) 271back_and_forth_one (int testno, const char *buffer, size_t length)
272{ 272{
273 gcry_error_t rc; 273 gcry_error_t rc;
274 gcry_sexp_t se, se1; 274 gcry_sexp_t se, se1;
275 size_t n, n1; 275 size_t n, n1;
276 char *p1; 276 char *p1;
277 277
278 rc = gcry_sexp_new (&se, buffer, length, 1); 278 rc = gcry_sexp_new (&se, buffer, length, 1);
279 if (rc) 279 if (rc)
280 { 280 {
281 fail ("baf %d: gcry_sexp_new failed: %s\n", testno, gpg_strerror (rc)); 281 fail ("baf %d: gcry_sexp_new failed: %s\n", testno, gpg_strerror (rc));
282 return; 282 return;
283 } 283 }
284 n1 = gcry_sexp_sprint (se, GCRYSEXP_FMT_CANON, NULL, 0); 284 n1 = gcry_sexp_sprint (se, GCRYSEXP_FMT_CANON, NULL, 0);
285 if (!n1) 285 if (!n1)
286 { 286 {
287 fail ("baf %d: get required length for canon failed\n", testno); 287 fail ("baf %d: get required length for canon failed\n", testno);
288 return; 288 return;
289 } 289 }
290 p1 = gcry_xmalloc (n1); 290 p1 = gcry_xmalloc (n1);
291 n = gcry_sexp_sprint (se, GCRYSEXP_FMT_CANON, p1, n1); 291 n = gcry_sexp_sprint (se, GCRYSEXP_FMT_CANON, p1, n1);
292 if (n1 != n+1) /* sprints adds an extra 0 but dies not return it */ 292 if (n1 != n+1) /* sprints adds an extra 0 but dies not return it */
293 { 293 {
294 fail ("baf %d: length mismatch for canon\n", testno); 294 fail ("baf %d: length mismatch for canon\n", testno);
295 return; 295 return;
296 } 296 }
297 rc = gcry_sexp_create (&se1, p1, n, 0, gcry_free); 297 rc = gcry_sexp_create (&se1, p1, n, 0, gcry_free);
298 if (rc) 298 if (rc)
299 { 299 {
300 fail ("baf %d: gcry_sexp_create failed: %s\n", 300 fail ("baf %d: gcry_sexp_create failed: %s\n",
301 testno, gpg_strerror (rc)); 301 testno, gpg_strerror (rc));
302 return; 302 return;
303 } 303 }
304 gcry_sexp_release (se1); 304 gcry_sexp_release (se1);
305 305
306 /* FIXME: we need a lot more tests */ 306 /* FIXME: we need a lot more tests */
307 307
308 gcry_sexp_release (se); 308 gcry_sexp_release (se);
309} 309}
310 310
311 311
312 312
313static void 313static void
314back_and_forth (void) 314back_and_forth (void)
315{ 315{
316 static struct { char *buf; int len; } tests[] = { 316 static struct { char *buf; int len; } tests[] = {
317 { "(7:g34:fgh1::2:())", 0 }, 317 { "(7:g34:fgh1::2:())", 0 },
318 { "(7:g34:fgh1::2:())", 18 }, 318 { "(7:g34:fgh1::2:())", 18 },
319 { NULL, 0 } 319 { NULL, 0 }
320 }; 320 };
321 int idx; 321 int idx;
322 322
323 for (idx=0; tests[idx].buf; idx++) 323 for (idx=0; tests[idx].buf; idx++)
324 back_and_forth_one (idx, tests[idx].buf, tests[idx].len); 324 back_and_forth_one (idx, tests[idx].buf, tests[idx].len);
325} 325}
326 326
327 327
328static void 328static void
329check_sscan (void) 329check_sscan (void)
330{ 330{
331 static struct { 331 static struct {
332 const char *text; 332 const char *text;
333 gcry_error_t expected_err; 333 gcry_error_t expected_err;
334 } values[] = { 334 } values[] = {
335 /* Bug reported by Olivier L'Heureux 2003-10-07 */ 335 /* Bug reported by Olivier L'Heureux 2003-10-07 */
336 { "(7:sig-val(3:dsa" 336 { "(7:sig-val(3:dsa"
337 "(1:r20:\x7e\xff\xd5\xba\xc9\xc9\xa4\x9b\xd4\x26\x8b\x64" 337 "(1:r20:\x7e\xff\xd5\xba\xc9\xc9\xa4\x9b\xd4\x26\x8b\x64"
338 "\x06\x7a\xcf\x42\x7b\x6c\x51\xfb)" 338 "\x06\x7a\xcf\x42\x7b\x6c\x51\xfb)"
339 "(1:s21:\x01\x8c\x6c\x6f\x37\x1a\x8d\xfd\x5a\xb3\x2a\x3d" 339 "(1:s21:\x01\x8c\x6c\x6f\x37\x1a\x8d\xfd\x5a\xb3\x2a\x3d"
340 "\xc5\xae\x23\xed\x32\x62\x30\x62\x3e)))", 340 "\xc5\xae\x23\xed\x32\x62\x30\x62\x3e)))",
341 GPG_ERR_NO_ERROR }, 341 GPG_ERR_NO_ERROR },
342 { "(7:sig-val(3:dsa" 342 { "(7:sig-val(3:dsa"
343 "(1:r20:\x7e\xff\xd5\xba\xc9\xc9\xa4\x9b\xd4\x26\x8b\x64" 343 "(1:r20:\x7e\xff\xd5\xba\xc9\xc9\xa4\x9b\xd4\x26\x8b\x64"
344 "\x06\x7a\xcf\x42\x7b\x6c\x51\xfb)" 344 "\x06\x7a\xcf\x42\x7b\x6c\x51\xfb)"
345 "(1:s21:\x01\x8c\x6c\x6f\x37\x1a\x8d\xfd\x5a\xb3\x2a\x3d" 345 "(1:s21:\x01\x8c\x6c\x6f\x37\x1a\x8d\xfd\x5a\xb3\x2a\x3d"
346 "\xc5\xae\x23\xed\x32\x62\x30\x62\x3e))", 346 "\xc5\xae\x23\xed\x32\x62\x30\x62\x3e))",
347 GPG_ERR_SEXP_UNMATCHED_PAREN }, 347 GPG_ERR_SEXP_UNMATCHED_PAREN },
348 { "(7:sig-val(3:dsa" 348 { "(7:sig-val(3:dsa"
349 "(1:r20:\x7e\xff\xd5\xba\xc9\xc9\xa4\x9b\xd4\x26\x8b\x64" 349 "(1:r20:\x7e\xff\xd5\xba\xc9\xc9\xa4\x9b\xd4\x26\x8b\x64"
350 "\x06\x7a\xcf\x42\x7b\x6c\x51\xfb)" 350 "\x06\x7a\xcf\x42\x7b\x6c\x51\xfb)"
351 "(1:s21:\x01\x8c\x6c\x6f\x37\x1a\x8d\xfd\x5a\xb3\x2a\x3d" 351 "(1:s21:\x01\x8c\x6c\x6f\x37\x1a\x8d\xfd\x5a\xb3\x2a\x3d"
352 "\xc5\xae\x23\xed\x32\x62\x30\x62\x3e))))", 352 "\xc5\xae\x23\xed\x32\x62\x30\x62\x3e))))",
353 GPG_ERR_SEXP_UNMATCHED_PAREN }, 353 GPG_ERR_SEXP_UNMATCHED_PAREN },
354 { NULL, 0 } 354 { NULL, 0 }
355 }; 355 };
356 int idx; 356 int idx;
357 gcry_error_t err; 357 gcry_error_t err;
358 gcry_sexp_t s; 358 gcry_sexp_t s;
359 359
360 info ("checking gcry_sexp_sscan\n"); 360 info ("checking gcry_sexp_sscan\n");
361 for (idx=0; values[idx].text; idx++) 361 for (idx=0; values[idx].text; idx++)
362 { 362 {
363 err = gcry_sexp_sscan (&s, NULL, 363 err = gcry_sexp_sscan (&s, NULL,
364 values[idx].text, 364 values[idx].text,
365 strlen (values[idx].text)); 365 strlen (values[idx].text));
366 if (gpg_err_code (err) != values[idx].expected_err) 366 if (gpg_err_code (err) != values[idx].expected_err)
367 fail ("gcry_sexp_sscan test %d failed: %s\n", idx, gpg_strerror (err)); 367 fail ("gcry_sexp_sscan test %d failed: %s\n", idx, gpg_strerror (err));
368 gcry_sexp_release (s); 368 gcry_sexp_release (s);
369 } 369 }
370} 370}
371 371
372 372
373 373
374 374
375int 375int
376main (int argc, char **argv) 376main (int argc, char **argv)
377{ 377{
378 if (argc > 1 && !strcmp (argv[1], "-v")) 378 if (argc > 1 && !strcmp (argv[1], "-v"))
379 verbose = 1; 379 verbose = 1;
380 380
381 gcry_control (GCRYCTL_DISABLE_SECMEM_WARN); 381 gcry_control (GCRYCTL_DISABLE_SECMEM_WARN);
382 gcry_control (GCRYCTL_INIT_SECMEM, 16384, 0); 382 gcry_control (GCRYCTL_INIT_SECMEM, 16384, 0);
383 383
384 basic (); 384 basic ();
385 canon_len (); 385 canon_len ();
386 back_and_forth (); 386 back_and_forth ();
387 check_sscan (); 387 check_sscan ();
388 388
389 return error_count? 1:0; 389 return error_count? 1:0;
390} 390}
391 391
392 392
393 393
394 394
395 395
396 396