-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathElgamalAttack.cc
55 lines (47 loc) · 1.71 KB
/
ElgamalAttack.cc
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
/*
* =====================================================================================
*
* Filename: ElgamalAttack.cc
*
* Description: Implementation of abstract base class for attacks.
*
* Version: 1.0
* Created: 10/05/2008 10:35:22 AM
* Revision: none
* Compiler: gcc
*
* Author: Bryce Allen (bda), bryce@bda.ath.cx
* Company:
*
* =====================================================================================
*/
#include <gmp.h>
#include "include/types.h"
#include "include/elgamal.h"
#include "MpzList.h"
#include "ElgamalAttack.h"
int mpzTableEntryCompare (const void *a, const void *b) {
return mpz_cmp (((MpzTableEntry *)a)->key, ((MpzTableEntry *)b)->key);
}
int mpzTableEntryReverseCompare (const void *a, const void *b) {
return mpz_cmp (((MpzTableEntry *)b)->key, ((MpzTableEntry *)a)->key);
}
bool ElgamalAttack::crackMessage (mpz_t result, ElgamalCipherText ct, gmp_randstate_t rstate) {
MpzList results (1);
return (crackMessage (&results, ct, rstate, 1) > 0);
}
// TODO: make abstract
size_t ElgamalAttack::crackMessage (MpzList *results, const ElgamalCipherText ct,
gmp_randstate_t rstate, size_t maxResults) {
return 0;
}
/*
char * ElgamalAttack::tableFileName () {
// TABLEDIR + cryptosystem + '_{bits}', allowing 3 digits for the bits
char *fileName = (char *) malloc (strlen(TABLEDIR) + strlen(label) + 1 + 4);
strncpy (fileName, TABLEDIR, strlen (TABLEDIR));
strncpy (fileName + strlen(TABLEDIR), label, strlen(label));
*(fileName + strlen(TABLEDIR) + strlen(label)) = '_';
snprintf (fileName + strlen(TABLEDIR) + strlen(label) + 1, 4, "%d", bits1);
}
*/