1 /*
2  * Comparator Configuration for remote devices.
3  *
4  * This software is Copyright (c) 2016-2017 Denis Burykin
5  * [denis_burykin yahoo com], [denis-burykin2014 yandex ru]
6  * and it is hereby released to the general public under the following terms:
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted.
9  *
10  */
11 #ifndef _CMP_CONFIG_H_
12 #define _CMP_CONFIG_H_
13 
14 #include "../../formats.h"
15 
16 #define PKT_TYPE_CMP_CONFIG		0x03
17 
18 // Warning: global cmp_config
19 
20 struct cmp_config {
21 	int id; // db_salt->sequential_id
22 	//unsigned char *salt;
23 	void *salt_ptr; // salt to send to device, of length salt_len
24 	int salt_len;
25 	unsigned int tunable_costs[FMT_TUNABLE_COSTS];
26 	int num_hashes;
27 	int num_hashes_max; // save on malloc/free
28 	struct db_password **pw;
29 };
30 
31 extern struct cmp_config cmp_config;
32 
33 // Comparator Configuration in CPU memory.
34 // Contains pointers to 'struct db_password' which contain
35 // hashes ("binaries").
36 // pointers are sorted by hash binary values (ascending order)
37 //
38 // Used for:
39 // - creation of cmp_config packets for remote devices
40 // - getting results with get_password() function.
41 //
42 // TODO: probably we can have sorted db_passwords's in db_salt?
43 
44 void cmp_config_new(struct db_salt *salt, void *salt_ptr, int salt_len);
45 
46 // Same as above, num_hashes=0
47 void cmp_config_nocompar_new(struct db_salt *salt, void *salt_ptr, int salt_len);
48 
49 // Creates CMP_CONFIG packet for on-device comparator
50 struct pkt *pkt_cmp_config_new(struct cmp_config *cmp_config);
51 
52 #endif
53