-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathElgamalAttack.h
33 lines (26 loc) · 950 Bytes
/
ElgamalAttack.h
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
/*
* Abstract base class for two-phase attacks on ElGamal
*/
typedef struct {
mpz_t key;
mpz_t value;
} MpzTableEntry;
typedef struct {
size_t length;
MpzTableEntry *entries;
} MpzTable;
int mpzTableEntryCompare (const void *a, const void *b);
int mpzTableEntryReverseCompare (const void *a, const void *b);
class ElgamalAttack {
protected:
unsigned int bits1, bits2;
ElgamalCryptosystem *e;
public:
virtual ~ElgamalAttack () {}
// return false if the table build failed, e.g. not enough memory
virtual bool buildTable (gmp_randstate_t rstate) = 0;
virtual bool crackMessage (mpz_t result, const ElgamalCipherText ct, gmp_randstate_t rstate);
virtual size_t crackMessage (MpzList *results, const ElgamalCipherText ct,
gmp_randstate_t rstate, size_t maxResults=0);
virtual const char* getAttackName () const = 0;
};