-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAPITest_full.c
91 lines (67 loc) · 1.92 KB
/
APITest_full.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
#include "APISimulator.h"
int main(int argc, char *arg[]) {
uint32_t vote;
uint8_t infoContest=0x3f;
int tamQR, numVotos, numTest=1;
int chal = 1;
for (numVotos = 10; numVotos <= 100; numVotos+=100) {
printf("Votos = %d\n",numVotos);
for (int i = 0; i < numTest; i ++) {
if (i%100==0) {
printf("Teste = %d\n",i);
}
Setup();
onStart (infoContest);
for(int j = 0; j < numVotos; j ++) {
printf("VOTO %d\n\n",numberTotalvoters());
getrandom(&vote, sizeof(vote), 0);
vote&=0x8FFFFFFF;
onVoterActive(vote, 0);
getrandom(&vote, sizeof(vote), 0);
vote&=0x8FFFFFFF;
onVoterActive(vote, 1);
getrandom(&vote, sizeof(vote), 0);
vote&=0x8FFFFFFF;
onVoterActive(vote, 2);
getrandom(&vote, sizeof(vote), 0);
vote&=0x8FFFFFFF;
onVoterActive(vote, 3);
getrandom(&vote, sizeof(vote), 0);
vote&=0x8FFFFFFF;
onVoterActive(vote, 4);
getrandom(&vote, sizeof(vote), 0);
vote&=0x8FFFFFFF;
onVoterActive(vote, 5);
//check tracking code
tamQR = createQRTrackingCode();
printf("\n%d\n",tamQR);
for(int idx = 0; idx < tamQR; idx++) {
printf("%02x ", QRCodeTrackingCode[idx]);
}
printf("\n");
if (j == 7 && chal == 1){
onChallenge (FALSE);
printf("\n%d %d %d\n", sizeQRCodeSpoil[0],sizeQRCodeSpoil[1],sizeQRCodeSpoil[2]);
for(int idx = 0; idx < sizeQRCodeSpoil[0]; idx++) {
printf("%02x ", QRCodeSpoilTrackingCode[idx]);
}
printf("\n\n");
for(int idx = 0; idx < sizeQRCodeSpoil[1]; idx++) {
printf("%02x ", QRCodeSpoilNonce[idx]);
}
printf("\n\n");
for(int idx = 0; idx < sizeQRCodeSpoil[2]; idx++) {
printf("%02x ", QRCodeSpoilVotes[idx]);
}
printf("\n\n");
verifyVote(QRCodeTrackingCode,QRCodeSpoilTrackingCode,QRCodeSpoilNonce,QRCodeSpoilVotes);
chal = 0;
} else {
onChallenge (TRUE);
}
}
onFinish();
}
}
return 0;
}