forked from jtesta/rainbowcrackalack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_index_to_plaintext_ntlm9.c
91 lines (68 loc) · 2.63 KB
/
test_index_to_plaintext_ntlm9.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
* Rainbow Crackalack: test_index_to_plaintext.c
* Copyright (C) 2018-2019 Joe Testa <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms version 3 of the GNU General Public License as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <inttypes.h>
#include <stdio.h>
#include <string.h>
#include "opencl_setup.h"
#include "cpu_rt_functions.h"
#include "misc.h"
#include "shared.h"
#include "test_shared.h"
#include "test_index_to_plaintext_ntlm9.h"
struct i2p_ntlm9_test {
cl_ulong index;
char expected_plaintext[MAX_PLAINTEXT_LEN];
};
struct i2p_ntlm9_test i2p_ntlm9_tests[] = {
{381435424925352145, "YO$tJH3AC"}
};
int gpu_test_index_to_plaintext_ntlm9(cl_device_id device, cl_context context, cl_kernel kernel, cl_ulong index, char *expected_plaintext) {
CLMAKETESTVARS();
int test_passed = 0;
cl_mem index_buffer = NULL, plaintext_buffer = NULL;
unsigned char *plaintext = NULL;
queue = CLCREATEQUEUE(context, device);
plaintext = calloc(MAX_PLAINTEXT_LEN, sizeof(unsigned char));
if (plaintext == NULL) {
fprintf(stderr, "Failed to create I/O buffers.\n");
exit(-1);
}
CLCREATEARG(0, index_buffer, CL_RO, index, sizeof(cl_ulong));
CLCREATEARG_ARRAY(1, plaintext_buffer, CL_WO, plaintext, MAX_PLAINTEXT_LEN);
CLRUNKERNEL(queue, kernel, &global_work_size);
CLFLUSH(queue);
CLWAIT(queue);
CLREADBUFFER(plaintext_buffer, MAX_PLAINTEXT_LEN, plaintext);
if (strcmp(expected_plaintext, (char *)plaintext) == 0)
test_passed = 1;
else {
printf("\n\nGPU error:\n\tIndex: %"PRIu64"\n\tExpected: [%"PRIu64"][%s]\n\tCalculated: [%s]\n\n", index, strlen(expected_plaintext), expected_plaintext, plaintext);
}
CLFREEBUFFER(index_buffer);
CLFREEBUFFER(plaintext_buffer);
CLRELEASEQUEUE(queue);
FREE(plaintext);
return test_passed;
}
int test_index_to_plaintext_ntlm9(cl_device_id device, cl_context context, cl_kernel kernel) {
int tests_passed = 1;
unsigned int i = 0;
for (i = 0; i < (sizeof(i2p_ntlm9_tests) / sizeof(struct i2p_ntlm9_test)); i++) {
tests_passed &= gpu_test_index_to_plaintext_ntlm9(device, context, kernel, i2p_ntlm9_tests[i].index, i2p_ntlm9_tests[i].expected_plaintext);
}
return tests_passed;
}