Debian Codegraph @

lib/ce-wpa/memory.c

raw symbols SCIP
1 /*
2 * Based on John the Ripper and modified to integrate with aircrack
3 *
4 * John the Ripper copyright and license.
5 *
6 * John the Ripper password cracker,
7 * Copyright (c) 1996-2013 by Solar Designer.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * As a special exception to the GNU General Public License terms,
20 * permission is hereby granted to link the code of this program, with or
21 * without modification, with any version of the OpenSSL library and/or any
22 * version of unRAR, and to distribute such linked combinations. You must
23 * obey the GNU GPL in all respects for all of the code used other than
24 * OpenSSL and unRAR. If you modify this program, you may extend this
25 * exception to your version of the program, but you are not obligated to
26 * do so. (In other words, you may release your derived work under pure
27 * GNU GPL version 2 or later as published by the FSF.)
28 *
29 * (This exception from the GNU GPL is not required for the core tree of
30 * John the Ripper, but arguably it is required for -jumbo.)
31 *
32 * Relaxed terms for certain components.
33 *
34 * In addition or alternatively to the license above, many components are
35 * available to you under more relaxed terms (most commonly under cut-down
36 * BSD license) as specified in the corresponding source files.
37 *
38 * For more information on John the Ripper licensing please visit:
39 *
40 * http://www.openwall.com/john/doc/LICENSE.shtml
41 *
42 * This file is part of John the Ripper password cracker,
43 * Copyright (c) 1996-98,2010,2012 by Solar Designer
44 *
45 * Redistribution and use in source and binary forms, with or without
46 * modification, are permitted.
47 *
48 * There's ABSOLUTELY NO WARRANTY, express or implied.
49 */
50
51 #define _POSIX_C_SOURCEcxx . . $ `lib/ce-wpa/memory.c:51:9`! 200112L
52
53 #ifdef HAVE_CONFIG_Hcxx . . $ `<built-in>:411:9`!
54 #include "config.h"cxx . . $ `<file>/config.h`/
55 #endif
56
57 #include <stdio.h>
58 #include <stdlib.h>
59 #include <string.h>
60 #include <errno.h>
61 #include <ctype.h> /* for isprint() */
62 #if HAVE_MEMALIGN && HAVE_MALLOC_Hcxx . . $ `config.h:152:9`!
63 #include <malloc.h>
64 #endif
65
66 #include "aircrack-ng/ce-wpa/arch.h"cxx . . $ `<file>/include/aircrack-ng/ce-wpa/arch.h`/
67 #include "aircrack-ng/ce-wpa/misc.h"cxx . . $ `<file>/include/aircrack-ng/ce-wpa/misc.h`/
68 #include "aircrack-ng/ce-wpa/memory.h"cxx . . $ `<file>/include/aircrack-ng/ce-wpa/memory.h`/
69 #include "aircrack-ng/ce-wpa/jcommon.h"cxx . . $ `<file>/include/aircrack-ng/ce-wpa/jcommon.h`/
70 #include "aircrack-ng/ce-wpa/johnswap.h"cxx . . $ `<file>/include/aircrack-ng/ce-wpa/johnswap.h`/
71
72 unsigned int mem_saving_levelcxx . . $ mem_saving_level. = 0;
73
74 // Add 'cleanup' methods for the mem_alloc_tiny. VERY little cost, but
75 // allows us to check for mem leaks easier.
76 struct rm_listcxx . . $ rm_list#
77 {
78 void * memcxx . . $ rm_list#mem.;
79 struct rm_listcxx . . $ rm_list# * nextcxx . . $ rm_list#next.;
80 };
81 static struct rm_listcxx . . $ rm_list# * mem_alloc_tiny_memorycxx . . $ mem_alloc_tiny_memory.;
82
83 static void add_memory_linkcxx . . $ add_memory_link(5d22bdacc48458e8).(void * v)
84 {
85 struct rm_listcxx . . $ rm_list# * p = (struct rm_listcxx . . $ rm_list# *) mem_alloccxx . . $ `include/aircrack-ng/ce-wpa/memory.h:136:9`!(sizeof(struct rm_list));
86 if (p)
87 {
88 p->nextcxx . . $ rm_list#next. = mem_alloc_tiny_memorycxx . . $ mem_alloc_tiny_memory.;
89 p->memcxx . . $ rm_list#mem. = v;
90 mem_alloc_tiny_memorycxx . . $ mem_alloc_tiny_memory. = p;
91 }
92 }
93 // call at program exit.
94 void cleanup_tiny_memorycxx . . $ cleanup_tiny_memory(49f6e7a06ebc5aa8).(void)
95 {
96 struct rm_listcxx . . $ rm_list# *p = mem_alloc_tiny_memorycxx . . $ mem_alloc_tiny_memory., *p2;
97 for (;;)
98 {
99 if (!p) return;
100 freecxx . . $ free(5d22bdacc48458e8).(p->memcxx . . $ rm_list#mem.);
101 p2 = p->nextcxx . . $ rm_list#next.;
102 freecxx . . $ free(5d22bdacc48458e8).(p);
103 p = p2;
104 }
105 }
106
107 void * mem_alloc_funccxx . . $ mem_alloc_func(bfcfa4d6b7f7ef64).(size_tcxx . . $ size_t# size)
108 {
109 void * res;
110
111 if (!size) return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
112 res = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(size);
113 if (!res)
114 {
115 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!,
116 "mem_alloc(): %s trying to allocate " Zucxx . . $ `include/aircrack-ng/ce-wpa/misc.h:75:9`! " bytes\n",
117 strerrorcxx . . $ strerror(ff224f080444ee45).(ENOMEMcxx . . $ `<external>/8987895939074593727/errno-base.h:16:9`!),
118 size);
119 perrorcxx . . $ perror(85c52e162fed56f9).("mem_alloc");
120 }
121
122 return res;
123 }
124
125 void * mem_calloc_funccxx . . $ mem_calloc_func(63a7bf2941bfcd7a).(size_tcxx . . $ size_t# count, size_tcxx . . $ size_t# size)
126 {
127 void * res;
128
129 if (!count || !size) return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
130 res = calloccxx . . $ calloc(63a7bf2941bfcd7a).(count, size);
131 if (!res)
132 {
133 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!,
134 "mem_calloc(): %s trying to allocate " Zucxx . . $ `include/aircrack-ng/ce-wpa/misc.h:75:9`! " bytes\n",
135 strerrorcxx . . $ strerror(ff224f080444ee45).(ENOMEMcxx . . $ `<external>/8987895939074593727/errno-base.h:16:9`!),
136 count * size);
137 perrorcxx . . $ perror(85c52e162fed56f9).("mem_calloc");
138 }
139
140 return res;
141 }
142
143 /*
144 * if -DDEBUG we turn mem_alloc_tiny() to essentially be just a malloc()
145 * with additional alignment. The reason for this is it's way easier to
146 * trace bugs that way.
147 * Also, with -DDEBUG we always return exactly the requested
148 * alignment, in order to trigger bugs!
149 */
150 #ifdef DEBUG
151 #undef MEM_ALLOC_SIZE
152 #define MEM_ALLOC_SIZE 0
153 #endif
154 void * mem_alloc_tiny_funccxx . . $ mem_alloc_tiny_func(63a7bf2941bfcd7a).(size_tcxx . . $ size_t# size, size_tcxx . . $ size_t# align)
155 {
156 static char * buffer = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
157 static size_tcxx . . $ size_t# bufree = 0;
158 size_tcxx . . $ size_t# mask;
159 char * p;
160
161 #ifdef DEBUG
162 /*
163 * We may be called with size zero, for example from ldr_load_pw_line()
164 * that calls mem_alloc_copy() with format->params.salt_size as size.
165 * This causes problems with -DDEBUG without this fix because we never
166 * get out of the while loop when MEM_ALLOC_SIZE is zero too. The
167 * previous fix for this was returning NULL but that lead to other
168 * problems that I did not bother digging into. This fix should be
169 * 100% safe.
170 */
171 if (size == 0) size = 1;
172 #endif
173
174 #if ARCH_ALLOWS_UNALIGNEDcxx . . $ `include/aircrack-ng/ce-wpa/arch.h:118:9`!
175 if (mem_saving_levelcxx . . $ mem_saving_level. > 2 && align < MEM_ALIGN_SIMDcxx . . $ `include/aircrack-ng/ce-wpa/memory.h:99:9`!) align = MEM_ALIGN_NONEcxx . . $ `include/aircrack-ng/ce-wpa/memory.h:78:9`!;
176 #endif
177
178 mask = align - 1;
179
180 do
181 {
182 if (buffer)
183 {
184 size_tcxx . . $ size_t# need = size + mask - (((size_tcxx . . $ size_t#) buffer + mask) & mask);
185 if (bufree >= need)
186 {
187 p = buffer;
188 p += mask;
189 p -= (size_tcxx . . $ size_t#) p & mask;
190 bufree -= need;
191 buffer = p + size;
192 #if defined(DEBUG)
193 /* Ensure alignment is no better than requested */
194 if (((size_t) p & ((mask << 1) + 1)) == 0) p += align;
195 #endif
196 return p;
197 }
198 }
199
200 if (size + mask > MEM_ALLOC_SIZEcxx . . $ `include/aircrack-ng/ce-wpa/memory.h:108:9`! || bufree > MEM_ALLOC_MAX_WASTEcxx . . $ `include/aircrack-ng/ce-wpa/memory.h:117:9`!) break;
201 buffer = (char *) mem_alloccxx . . $ `include/aircrack-ng/ce-wpa/memory.h:136:9`!(MEM_ALLOC_SIZEcxx . . $ `include/aircrack-ng/ce-wpa/memory.h:108:9`!);
202 add_memory_linkcxx . . $ add_memory_link(5d22bdacc48458e8).((void *) buffer);
203 bufree = MEM_ALLOC_SIZEcxx . . $ `include/aircrack-ng/ce-wpa/memory.h:108:9`!;
204 } while (1);
205
206 p = (char *) mem_alloccxx . . $ `include/aircrack-ng/ce-wpa/memory.h:136:9`!(size + mask);
207 if (p == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) abortcxx . . $ abort(8df32a62017fbbf6).();
208 add_memory_linkcxx . . $ add_memory_link(5d22bdacc48458e8).((void *) p);
209 p += mask;
210 p -= (size_tcxx . . $ size_t#) p & mask;
211 #if defined(DEBUG)
212 /* Ensure alignment is no better than requested */
213 if (((size_t) p & ((mask << 1) + 1)) == 0) p += align;
214 #endif
215 return p;
216 }
217
218 void * mem_calloc_tiny_funccxx . . $ mem_calloc_tiny_func(63a7bf2941bfcd7a).(size_tcxx . . $ size_t# size, size_tcxx . . $ size_t# align)
219 {
220 char * cp = (char *) mem_alloc_tinycxx . . $ `include/aircrack-ng/ce-wpa/memory.h:138:9`!(size, align);
221 memsetcxx . . $ memset(d1de1e4fb215f1c6).(cp, 0, size);
222 return cp;
223 }
224
225 void * mem_alloc_copy_funccxx . . $ mem_alloc_copy_func(dfa4a9ebc9436eff).(void * src, size_tcxx . . $ size_t# size, size_tcxx . . $ size_t# align)
226 {
227 return memcpycxx . . $ memcpy(cc817cb175f282d).(mem_alloc_tinycxx . . $ `include/aircrack-ng/ce-wpa/memory.h:138:9`!(size, align), src, size);
228 }
229
230 void * mem_alloc_align_funccxx . . $ mem_alloc_align_func(63a7bf2941bfcd7a).(size_tcxx . . $ size_t# size, size_tcxx . . $ size_t# align)
231 {
232 void * ptr = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
233 #if HAVE_POSIX_MEMALIGNcxx . . $ `config.h:176:9`!
234 if (posix_memaligncxx . . $ posix_memalign(e974a8a87fa206f3).(&ptr, align, size)) pexitcxx . . $ `include/aircrack-ng/ce-wpa/misc.h:132:9`!("posix_memalign");
235 #elif HAVE_ALIGNED_ALLOC
236 /* According to the Linux man page, "size should be a multiple of
237 alignment", whatever they mean with "should"... This does not
238 make any sense whatsoever but we round it up to comply. */
239 size = ((size + (align - 1)) / align) * align;
240 if (!(ptr = aligned_alloc(align, size))) pexit("aligned_alloc");
241 #elif HAVE_MEMALIGN
242 /* Let's just pray this implementation can actually free it */
243 #if defined(__sparc__) || defined(__sparc) || defined(sparc) \
244 || defined(__sparcv9)
245 if (!(ptr = memalign(align, size)))
246 #else
247 if (!(ptr = memalign(&ptr, align, size)))
248 #endif
249 perror("memalign");
250 #elif HAVE___MINGW_ALIGNED_MALLOC
251 if (!(ptr = __mingw_aligned_malloc(size, align)))
252 perror("__mingw_aligned_malloc");
253 #elif HAVE__ALIGNED_MALLOC
254 if (!(ptr = _aligned_malloc(size, align))) perror("aligned_malloc");
255
256 #elif AC_BUILT
257 #error No suitable aligned alloc found, please report to john-dev mailing list (state your OS details).
258
259 /* we need an aligned alloc function for legacy builds */
260 #elif _ISOC11_SOURCE
261 size = ((size + (align - 1)) / align) * align;
262 if (!(ptr = aligned_alloc(align, size))) perror("aligned_alloc");
263 #else
264 if (posix_memalign(&ptr, align, size)) perror("posix_memalign");
265 #endif
266 return ptr;
267 }
268
269 void * mem_calloc_align_funccxx . . $ mem_calloc_align_func(7483b66c05176f66).(size_tcxx . . $ size_t# count, size_tcxx . . $ size_t# size, size_tcxx . . $ size_t# align)
270 {
271 void * ptr = mem_alloc_align_funccxx . . $ mem_alloc_align_func(63a7bf2941bfcd7a).(size * count, align);
272
273 memsetcxx . . $ memset(d1de1e4fb215f1c6).(ptr, 0, size * count);
274 return ptr;
275 }
276
277 char * str_alloc_copy_funccxx . . $ str_alloc_copy_func(7a9722d75b371431).(char * src)
278 {
279 size_tcxx . . $ size_t# size;
280
281 if (!src) return "";
282 if (!*src) return "";
283
284 size = strlencxx . . $ strlen(751346f8406fd082).(src) + 1;
285 return (char *) memcpycxx . . $ memcpy(cc817cb175f282d).(mem_alloc_tinycxx . . $ `include/aircrack-ng/ce-wpa/memory.h:138:9`!(size, MEM_ALIGN_NONEcxx . . $ `include/aircrack-ng/ce-wpa/memory.h:78:9`!), src, size);
286 }
287
288 void dump_textcxx . . $ dump_text(d0320739773070f2).(void * in, int len)
289 {
290 unsigned char * p = (unsigned char *) in;
291
292 while (len--)
293 {
294 fputccxx . . $ fputc(b1cd03d6c470d1bd).(isprintcxx . . $ `<external>/17904084882347303253/ctype.h:195:10`!(*p) ? *p : '.', stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!);
295 p++;
296 }
297 fputccxx . . $ fputc(b1cd03d6c470d1bd).('\n', stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!);
298 }
299
300 void dump_stuff_noeolcxx . . $ dump_stuff_noeol(67abb4dd43ac34c5).(void * x, unsigned int size)
301 {
302 unsigned int i;
303 for (i = 0; i < size; i++)
304 {
305 printfcxx . . $ printf(581fddd72a8db8fc).("%.2x", ((unsigned char *) x)[i]);
306 if ((i % 4) == 3) printfcxx . . $ printf(581fddd72a8db8fc).(" ");
307 }
308 }
309 void dump_stuffcxx . . $ dump_stuff(67abb4dd43ac34c5).(void * x, unsigned int size)
310 {
311 dump_stuff_noeolcxx . . $ dump_stuff_noeol(67abb4dd43ac34c5).(x, size);
312 printfcxx . . $ printf(581fddd72a8db8fc).("\n");
313 }
314 void dump_stuff_msgcxx . . $ dump_stuff_msg(5ea3737145543082).(const void * msg, void * x, unsigned int size)
315 {
316 printfcxx . . $ printf(581fddd72a8db8fc).("%s : ", (char *) msg);
317 dump_stuffcxx . . $ dump_stuff(67abb4dd43ac34c5).(x, size);
318 }
319 void dump_stuff_msg_seplinecxx . . $ dump_stuff_msg_sepline(5ea3737145543082).(const void * msg, void * x, unsigned int size)
320 {
321 printfcxx . . $ printf(581fddd72a8db8fc).("%s :\n", (char *) msg);
322 dump_stuffcxx . . $ dump_stuff(67abb4dd43ac34c5).(x, size);
323 }
324
325 void dump_stuff_be_noeolcxx . . $ dump_stuff_be_noeol(67abb4dd43ac34c5).(void * x, unsigned int size)
326 {
327 unsigned int i;
328 for (i = 0; i < size; i++)
329 {
330 printfcxx . . $ printf(581fddd72a8db8fc).("%.2x", ((unsigned char *) x)[i ^ 3]);
331 if ((i % 4) == 3) printfcxx . . $ printf(581fddd72a8db8fc).(" ");
332 }
333 }
334 void dump_stuff_becxx . . $ dump_stuff_be(67abb4dd43ac34c5).(void * x, unsigned int size)
335 {
336 dump_stuff_be_noeolcxx . . $ dump_stuff_be_noeol(67abb4dd43ac34c5).(x, size);
337 printfcxx . . $ printf(581fddd72a8db8fc).("\n");
338 }
339 void dump_stuff_be_msgcxx . . $ dump_stuff_be_msg(5ea3737145543082).(const void * msg, void * x, unsigned int size)
340 {
341 printfcxx . . $ printf(581fddd72a8db8fc).("%s : ", (char *) msg);
342 dump_stuff_becxx . . $ dump_stuff_be(67abb4dd43ac34c5).(x, size);
343 }
344 void dump_stuff_be_msg_seplinecxx . . $ dump_stuff_be_msg_sepline(5ea3737145543082).(const void * msg, void * x, unsigned int size)
345 {
346 printfcxx . . $ printf(581fddd72a8db8fc).("%s :\n", (char *) msg);
347 dump_stuff_becxx . . $ dump_stuff_be(67abb4dd43ac34c5).(x, size);
348 }
349
350 void alter_endianitycxx . . $ alter_endianity(67abb4dd43ac34c5).(void * _x, unsigned int size)
351 {
352 ARCH_WORD_32cxx . . $ ARCH_WORD_32# * x = (ARCH_WORD_32cxx . . $ ARCH_WORD_32# *) _x;
353
354 // size is in octets
355 size >>= 2;
356
357 #if !ARCH_ALLOWS_UNALIGNEDcxx . . $ `include/aircrack-ng/ce-wpa/arch.h:118:9`!
358 if (is_aligned(x, sizeof(ARCH_WORD_32)))
359 {
360 #endif
361 while (size--)
362 {
363 *x = JOHNSWAPcxx . . $ `include/aircrack-ng/ce-wpa/johnswap.h:77:9`!(*x);
364 x++;
365 }
366 #if !ARCH_ALLOWS_UNALIGNEDcxx . . $ `include/aircrack-ng/ce-wpa/arch.h:118:9`!
367 }
368 else
369 {
370 unsigned char *cpX, c;
371
372 cpX = (unsigned char *) x;
373 while (size--)
374 {
375 c = *cpX;
376 *cpX = cpX[3];
377 cpX[3] = c;
378 c = cpX[1];
379 cpX[1] = cpX[2];
380 cpX[2] = c;
381 cpX += 4;
382 }
383 }
384 #endif
385 }
386
387 #if defined(SIMD_COEF_32cxx . . $ `include/aircrack-ng/ce-wpa/memory.h:71:9`!) || defined(NT_X86_64cxx . . $ `include/aircrack-ng/ce-wpa/arch.h:423:9`!) || defined(SIMD_PARA_MD5) \
388 || defined(SIMD_PARA_MD4) || defined(SIMD_PARA_SHA1cxx . . $ `include/aircrack-ng/ce-wpa/arch.h:353:9`!)
389 #ifndef SIMD_COEF_32cxx . . $ `include/aircrack-ng/ce-wpa/memory.h:71:9`!
390 #define SIMD_COEF_32 4
391 #endif
392 #ifndef SIMD_COEF_64cxx . . $ `include/aircrack-ng/ce-wpa/memory.h:72:9`!
393 #define SIMD_COEF_64 2
394 #endif
395 #ifndef SIMD_COEF_32cxx . . $ `include/aircrack-ng/ce-wpa/memory.h:71:9`!
396 #define SIMD_COEF_32 4
397 #endif
398
399 // These work for standard SIMD_COEF_32 buffers, AND for SSEi MMX_PARA multiple
400 // SIMD_COEF_32 blocks, where index will be mod(X * SIMD_COEF_32) and not simply
401 // mod(SIMD_COEF_32)
402 #define SHAGETPOScxx . . $ `lib/ce-wpa/memory.c:402:9`!(i, index) \
403 ((index & (SIMD_COEF_32cxx . . $ `include/aircrack-ng/ce-wpa/memory.h:71:9`! - 1)) * 4 \
404 + ((i) & (0xffffffff - 3)) * SIMD_COEF_32cxx . . $ `include/aircrack-ng/ce-wpa/memory.h:71:9`! \
405 + (3 - ((i) &3)) \
406 + (unsigned int) index / SIMD_COEF_32cxx . . $ `include/aircrack-ng/ce-wpa/memory.h:71:9`! * SHA_BUF_SIZcxx . . $ `include/aircrack-ng/ce-wpa/arch.h:421:9`! * 4 \
407 * SIMD_COEF_32cxx . . $ `include/aircrack-ng/ce-wpa/memory.h:71:9`!) // for endianity conversion
408 #define SHAGETOUTPOScxx . . $ `lib/ce-wpa/memory.c:408:9`!(i, index) \
409 ((index & (SIMD_COEF_32cxx . . $ `include/aircrack-ng/ce-wpa/memory.h:71:9`! - 1)) * 4 \
410 + ((i) & (0xffffffff - 3)) * SIMD_COEF_32cxx . . $ `include/aircrack-ng/ce-wpa/memory.h:71:9`! \
411 + (3 - ((i) &3)) \
412 + (unsigned int) index / SIMD_COEF_32cxx . . $ `include/aircrack-ng/ce-wpa/memory.h:71:9`! * 20 \
413 * SIMD_COEF_32cxx . . $ `include/aircrack-ng/ce-wpa/memory.h:71:9`!) // for endianity conversion
414 // for MD4/MD5 or any 64 byte LE SSE interleaved hash
415 #define GETPOScxx . . $ `lib/ce-wpa/memory.c:415:9`!(i, index) \
416 ((index & (SIMD_COEF_32cxx . . $ `include/aircrack-ng/ce-wpa/memory.h:71:9`! - 1)) * 4 \
417 + ((i) & (0xffffffff - 3)) * SIMD_COEF_32cxx . . $ `include/aircrack-ng/ce-wpa/memory.h:71:9`! \
418 + ((i) &3) \
419 + (unsigned int) index / SIMD_COEF_32cxx . . $ `include/aircrack-ng/ce-wpa/memory.h:71:9`! * 64 * SIMD_COEF_32cxx . . $ `include/aircrack-ng/ce-wpa/memory.h:71:9`!)
420 #define GETOUTPOScxx . . $ `lib/ce-wpa/memory.c:420:9`!(i, index) \
421 ((index & (SIMD_COEF_32cxx . . $ `include/aircrack-ng/ce-wpa/memory.h:71:9`! - 1)) * 4 \
422 + ((i) & (0xffffffff - 3)) * SIMD_COEF_32cxx . . $ `include/aircrack-ng/ce-wpa/memory.h:71:9`! \
423 + ((i) &3) \
424 + (unsigned int) index / SIMD_COEF_32cxx . . $ `include/aircrack-ng/ce-wpa/memory.h:71:9`! * 16 * SIMD_COEF_32cxx . . $ `include/aircrack-ng/ce-wpa/memory.h:71:9`!)
425 // for SHA384/SHA512 128 byte BE interleaved hash (arrays of 16 8 byte ints)
426 #define SHA64GETPOScxx . . $ `lib/ce-wpa/memory.c:426:9`!(i, index) \
427 ((index & (SIMD_COEF_64cxx . . $ `include/aircrack-ng/ce-wpa/memory.h:72:9`! - 1)) * 8 \
428 + ((i) & (0xffffffff - 7)) * SIMD_COEF_64cxx . . $ `include/aircrack-ng/ce-wpa/memory.h:72:9`! \
429 + (7 - ((i) &7)) \
430 + (unsigned int) index / SIMD_COEF_64cxx . . $ `include/aircrack-ng/ce-wpa/memory.h:72:9`! * SHA_BUF_SIZcxx . . $ `include/aircrack-ng/ce-wpa/arch.h:421:9`! * 8 * SIMD_COEF_64cxx . . $ `include/aircrack-ng/ce-wpa/memory.h:72:9`!)
431 #define SHA64GETOUTPOScxx . . $ `lib/ce-wpa/memory.c:431:9`!(i, index) \
432 ((index & (SIMD_COEF_64cxx . . $ `include/aircrack-ng/ce-wpa/memory.h:72:9`! - 1)) * 8 \
433 + ((i) & (0xffffffff - 7)) * SIMD_COEF_64cxx . . $ `include/aircrack-ng/ce-wpa/memory.h:72:9`! \
434 + (7 - ((i) &7)) \
435 + (unsigned int) index / SIMD_COEF_64cxx . . $ `include/aircrack-ng/ce-wpa/memory.h:72:9`! * 64 * SIMD_COEF_64cxx . . $ `include/aircrack-ng/ce-wpa/memory.h:72:9`!)
436
437 // for SHA384/SHA512 128 byte FLAT interleaved hash (arrays of 16 8 byte ints),
438 // but we do not BE interleave.
439 #define SHA64GETPOSnecxx . . $ `lib/ce-wpa/memory.c:439:9`!(i, index) \
440 ((index & (SIMD_COEF_64cxx . . $ `include/aircrack-ng/ce-wpa/memory.h:72:9`! - 1)) * 8 \
441 + ((i) & (0xffffffff - 7)) * SIMD_COEF_64cxx . . $ `include/aircrack-ng/ce-wpa/memory.h:72:9`! \
442 + ((i) &7) \
443 + (unsigned int) index / SIMD_COEF_64cxx . . $ `include/aircrack-ng/ce-wpa/memory.h:72:9`! * SHA_BUF_SIZcxx . . $ `include/aircrack-ng/ce-wpa/arch.h:421:9`! * 8 * SIMD_COEF_64cxx . . $ `include/aircrack-ng/ce-wpa/memory.h:72:9`!)
444
445 void dump_stuff_mmx_noeolcxx . . $ dump_stuff_mmx_noeol(c68aebd18e69fbb8).(void * buf, unsigned int size, unsigned int index)
446 {
447 unsigned int i;
448 for (i = 0; i < size; i++)
449 {
450 printfcxx . . $ printf(581fddd72a8db8fc).("%.2x", ((unsigned char *) buf)[GETPOScxx . . $ `lib/ce-wpa/memory.c:415:9`!(i, index)]);
451 if ((i % 4) == 3) printfcxx . . $ printf(581fddd72a8db8fc).(" ");
452 }
453 }
454 void dump_stuff_mmxcxx . . $ dump_stuff_mmx(c68aebd18e69fbb8).(void * buf, unsigned int size, unsigned int index)
455 {
456 dump_stuff_mmx_noeolcxx . . $ dump_stuff_mmx_noeol(c68aebd18e69fbb8).(buf, size, index);
457 printfcxx . . $ printf(581fddd72a8db8fc).("\n");
458 }
459 void dump_stuff_mmx_msgcxx . . $ dump_stuff_mmx_msg(105d03968d6c4a4b).(const void * msg,
460 void * buf,
461 unsigned int size,
462 unsigned int index)
463 {
464 printfcxx . . $ printf(581fddd72a8db8fc).("%s : ", (char *) msg);
465 dump_stuff_mmxcxx . . $ dump_stuff_mmx(c68aebd18e69fbb8).(buf, size, index);
466 }
467 void dump_stuff_mmx_msg_seplinecxx . . $ dump_stuff_mmx_msg_sepline(105d03968d6c4a4b).(const void * msg,
468 void * buf,
469 unsigned int size,
470 unsigned int index)
471 {
472 printfcxx . . $ printf(581fddd72a8db8fc).("%s :\n", (char *) msg);
473 dump_stuff_mmxcxx . . $ dump_stuff_mmx(c68aebd18e69fbb8).(buf, size, index);
474 }
475 void dump_out_mmx_noeolcxx . . $ dump_out_mmx_noeol(c68aebd18e69fbb8).(void * buf, unsigned int size, unsigned int index)
476 {
477 unsigned int i;
478 for (i = 0; i < size; i++)
479 {
480 printfcxx . . $ printf(581fddd72a8db8fc).("%.2x", ((unsigned char *) buf)[GETOUTPOScxx . . $ `lib/ce-wpa/memory.c:420:9`!(i, index)]);
481 if ((i % 4) == 3) printfcxx . . $ printf(581fddd72a8db8fc).(" ");
482 }
483 }
484 void dump_out_mmxcxx . . $ dump_out_mmx(c68aebd18e69fbb8).(void * buf, unsigned int size, unsigned int index)
485 {
486 dump_out_mmx_noeolcxx . . $ dump_out_mmx_noeol(c68aebd18e69fbb8).(buf, size, index);
487 printfcxx . . $ printf(581fddd72a8db8fc).("\n");
488 }
489 void dump_out_mmx_msgcxx . . $ dump_out_mmx_msg(105d03968d6c4a4b).(const void * msg,
490 void * buf,
491 unsigned int size,
492 unsigned int index)
493 {
494 printfcxx . . $ printf(581fddd72a8db8fc).("%s : ", (char *) msg);
495 dump_out_mmxcxx . . $ dump_out_mmx(c68aebd18e69fbb8).(buf, size, index);
496 }
497 void dump_out_mmx_msg_seplinecxx . . $ dump_out_mmx_msg_sepline(105d03968d6c4a4b).(const void * msg,
498 void * buf,
499 unsigned int size,
500 unsigned int index)
501 {
502 printfcxx . . $ printf(581fddd72a8db8fc).("%s :\n", (char *) msg);
503 dump_out_mmxcxx . . $ dump_out_mmx(c68aebd18e69fbb8).(buf, size, index);
504 }
505
506 #if defined(SIMD_PARA_MD5)
507 #define GETPOSMPARA(i, index) \
508 ((index & (SIMD_COEF_32 - 1)) * 4 \
509 + (((i) & (0xffffffff - 3)) % 64) * SIMD_COEF_32 \
510 + (i / 64) * SIMD_COEF_32 * SIMD_PARA_MD5 * 64 \
511 + ((i) &3) \
512 + (unsigned int) index / SIMD_COEF_32 * 64 * SIMD_COEF_32)
513 // multiple para blocks
514 void dump_stuff_mpara_mmx_noeol(void * buf,
515 unsigned int size,
516 unsigned int index)
517 {
518 unsigned int i;
519 for (i = 0; i < size; i++)
520 {
521 printf("%.2x", ((unsigned char *) buf)[GETPOSMPARA(i, index)]);
522 if ((i % 4) == 3) printf(" ");
523 }
524 }
525 void dump_stuff_mpara_mmx(void * buf, unsigned int size, unsigned int index)
526 {
527 dump_stuff_mpara_mmx_noeol(buf, size, index);
528 printf("\n");
529 }
530 // obuf has to be at lease size long. This function will unwind the SSE-para
531 // buffers into a flat.
532 void getbuf_stuff_mpara_mmx(unsigned char * oBuf,
533 void * buf,
534 unsigned int size,
535 unsigned int index)
536 {
537 unsigned int i;
538 for (i = 0; i < size; i++)
539 *oBuf++ = ((unsigned char *) buf)[GETPOSMPARA(i, index)];
540 }
541 void dump_stuff_mpara_mmx_msg(const void * msg,
542 void * buf,
543 unsigned int size,
544 unsigned int index)
545 {
546 printf("%s : ", (char *) msg);
547 dump_stuff_mpara_mmx(buf, size, index);
548 }
549 void dump_stuff_mpara_mmx_msg_sepline(const void * msg,
550 void * buf,
551 unsigned int size,
552 unsigned int index)
553 {
554 printf("%s :\n", (char *) msg);
555 dump_stuff_mpara_mmx(buf, size, index);
556 }
557 #endif
558
559 void dump_stuff_shammxcxx . . $ dump_stuff_shammx(c68aebd18e69fbb8).(void * buf, unsigned int size, unsigned int index)
560 {
561 unsigned int i;
562 for (i = 0; i < size; i++)
563 {
564 printfcxx . . $ printf(581fddd72a8db8fc).("%.2x", ((unsigned char *) buf)[SHAGETPOScxx . . $ `lib/ce-wpa/memory.c:402:9`!(i, index)]);
565 if ((i % 4) == 3) printfcxx . . $ printf(581fddd72a8db8fc).(" ");
566 }
567 printfcxx . . $ printf(581fddd72a8db8fc).("\n");
568 }
569 void dump_stuff_shammx_msgcxx . . $ dump_stuff_shammx_msg(105d03968d6c4a4b).(const void * msg,
570 void * buf,
571 unsigned int size,
572 unsigned int index)
573 {
574 printfcxx . . $ printf(581fddd72a8db8fc).("%s : ", (char *) msg);
575 dump_stuff_shammxcxx . . $ dump_stuff_shammx(c68aebd18e69fbb8).(buf, size, index);
576 }
577 void dump_out_shammxcxx . . $ dump_out_shammx(c68aebd18e69fbb8).(void * buf, unsigned int size, unsigned int index)
578 {
579 unsigned int i;
580 for (i = 0; i < size; i++)
581 {
582 printfcxx . . $ printf(581fddd72a8db8fc).("%.2x", ((unsigned char *) buf)[SHAGETOUTPOScxx . . $ `lib/ce-wpa/memory.c:408:9`!(i, index)]);
583 if ((i % 4) == 3) printfcxx . . $ printf(581fddd72a8db8fc).(" ");
584 }
585 printfcxx . . $ printf(581fddd72a8db8fc).("\n");
586 }
587 void dump_out_shammx_msgcxx . . $ dump_out_shammx_msg(105d03968d6c4a4b).(const void * msg,
588 void * buf,
589 unsigned int size,
590 unsigned int index)
591 {
592 printfcxx . . $ printf(581fddd72a8db8fc).("%s : ", (char *) msg);
593 dump_out_shammxcxx . . $ dump_out_shammx(c68aebd18e69fbb8).(buf, size, index);
594 }
595
596 void dump_stuff_shammx64cxx . . $ dump_stuff_shammx64(c68aebd18e69fbb8).(void * buf, unsigned int size, unsigned int index)
597 {
598 unsigned int i;
599 for (i = 0; i < size; i++)
600 {
601 printfcxx . . $ printf(581fddd72a8db8fc).("%.2x", ((unsigned char *) buf)[SHA64GETPOScxx . . $ `lib/ce-wpa/memory.c:426:9`!(i, index)]);
602 if ((i % 4) == 3) printfcxx . . $ printf(581fddd72a8db8fc).(" ");
603 }
604 printfcxx . . $ printf(581fddd72a8db8fc).("\n");
605 }
606 void dump_stuff_shammx64_msgcxx . . $ dump_stuff_shammx64_msg(105d03968d6c4a4b).(const void * msg,
607 void * buf,
608 unsigned int size,
609 unsigned int index)
610 {
611 printfcxx . . $ printf(581fddd72a8db8fc).("%s : ", (char *) msg);
612 dump_stuff_shammx64cxx . . $ dump_stuff_shammx64(c68aebd18e69fbb8).(buf, size, index);
613 }
614 void dump_stuff_mmx64cxx . . $ dump_stuff_mmx64(c68aebd18e69fbb8).(void * buf, unsigned int size, unsigned int index)
615 {
616 unsigned int i;
617 for (i = 0; i < size; i++)
618 {
619 printfcxx . . $ printf(581fddd72a8db8fc).("%.2x", ((unsigned char *) buf)[SHA64GETPOSnecxx . . $ `lib/ce-wpa/memory.c:439:9`!(i, index)]);
620 if ((i % 4) == 3) printfcxx . . $ printf(581fddd72a8db8fc).(" ");
621 }
622 printfcxx . . $ printf(581fddd72a8db8fc).("\n");
623 }
624 void dump_stuff_mmx64_msgcxx . . $ dump_stuff_mmx64_msg(105d03968d6c4a4b).(const void * msg,
625 void * buf,
626 unsigned int size,
627 unsigned int index)
628 {
629 printfcxx . . $ printf(581fddd72a8db8fc).("%s : ", (char *) msg);
630 dump_stuff_mmx64cxx . . $ dump_stuff_mmx64(c68aebd18e69fbb8).(buf, size, index);
631 }
632
633 void dump_out_shammx64cxx . . $ dump_out_shammx64(c68aebd18e69fbb8).(void * buf, unsigned int size, unsigned int index)
634 {
635 unsigned int i;
636 for (i = 0; i < size; i++)
637 {
638 printfcxx . . $ printf(581fddd72a8db8fc).("%.2x", ((unsigned char *) buf)[SHA64GETOUTPOScxx . . $ `lib/ce-wpa/memory.c:431:9`!(i, index)]);
639 if ((i % 4) == 3) printfcxx . . $ printf(581fddd72a8db8fc).(" ");
640 }
641 printfcxx . . $ printf(581fddd72a8db8fc).("\n");
642 }
643 void dump_out_shammx64_msgcxx . . $ dump_out_shammx64_msg(105d03968d6c4a4b).(const void * msg,
644 void * buf,
645 unsigned int size,
646 unsigned int index)
647 {
648 printfcxx . . $ printf(581fddd72a8db8fc).("%s : ", (char *) msg);
649 dump_out_shammx64cxx . . $ dump_out_shammx64(c68aebd18e69fbb8).(buf, size, index);
650 }
651 #endif
652
653 void alter_endianity_wcxx . . $ alter_endianity_w(67abb4dd43ac34c5).(void * _x, unsigned int count)
654 {
655 int i = -1;
656 ARCH_WORD_32cxx . . $ ARCH_WORD_32# * x = (ARCH_WORD_32cxx . . $ ARCH_WORD_32# *) _x;
657 #if ARCH_ALLOWS_UNALIGNEDcxx . . $ `include/aircrack-ng/ce-wpa/arch.h:118:9`!
658 while (++i < (int) count)
659 {
660 x[i] = JOHNSWAPcxx . . $ `include/aircrack-ng/ce-wpa/johnswap.h:77:9`!(x[i]);
661 }
662 #else
663 unsigned char *cpX, c;
664 if (is_aligned(x, sizeof(ARCH_WORD_32)))
665 {
666 // we are in alignment.
667 while (++i < (int) count)
668 {
669 x[i] = JOHNSWAP(x[i]);
670 }
671 return;
672 }
673 // non-aligned data :(
674 cpX = (unsigned char *) x;
675 while (++i < (int) count)
676 {
677 c = *cpX;
678 *cpX = cpX[3];
679 cpX[3] = c;
680 c = cpX[1];
681 cpX[1] = cpX[2];
682 cpX[2] = c;
683 cpX += 4;
684 }
685 #endif
686 }
687
688 void alter_endianity_w64cxx . . $ alter_endianity_w64(67abb4dd43ac34c5).(void * _x, unsigned int count)
689 {
690 int i = -1;
691 ARCH_WORD_64cxx . . $ ARCH_WORD_64# * x = (ARCH_WORD_64cxx . . $ ARCH_WORD_64# *) _x;
692 #if ARCH_ALLOWS_UNALIGNEDcxx . . $ `include/aircrack-ng/ce-wpa/arch.h:118:9`!
693 while (++i < (int) count)
694 {
695 x[i] = JOHNSWAP64cxx . . $ `include/aircrack-ng/ce-wpa/johnswap.h:78:9`!(x[i]);
696 }
697 #else
698 unsigned char *cpX, c;
699 if (is_aligned(x, sizeof(ARCH_WORD_64)))
700 {
701 // we are in alignment.
702 while (++i < (int) count)
703 {
704 x[i] = JOHNSWAP64(x[i]);
705 }
706 return;
707 }
708 // non-aligned data :(
709 cpX = (unsigned char *) x;
710 while (++i < (int) count)
711 {
712 c = *cpX;
713 *cpX = cpX[7];
714 cpX[7] = c;
715 c = cpX[1];
716 cpX[1] = cpX[6];
717 cpX[6] = c;
718 c = cpX[2];
719 cpX[2] = cpX[5];
720 cpX[5] = c;
721 c = cpX[3];
722 cpX[3] = cpX[4];
723 cpX[4] = c;
724 cpX += 8;
725 }
726 #endif
727 }