mirror of
https://github.com/brmlab/timingattack.git
synced 2025-06-08 09:04:00 +02:00
CrackerCore is now capable to store stats.
This commit is contained in:
parent
820bacc34e
commit
8b250c2645
3 changed files with 5 additions and 3 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
target
|
|
@ -5,13 +5,13 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class CrackerCore {
|
public class CrackerCore {
|
||||||
public static int[] select(List<long[]> stats) {
|
public int[] select(List<long[]> stats, byte[] hmac) {
|
||||||
// each item of the stats must have length exactly Byte.MAX_VALUE
|
|
||||||
double[] means = Stats.mean(stats);
|
double[] means = Stats.mean(stats);
|
||||||
|
|
||||||
ArrayList<Integer> idx = new ArrayList<Integer>();
|
ArrayList<Integer> idx = new ArrayList<Integer>();
|
||||||
|
|
||||||
// TODO: implement your code here **************************
|
// TODO: implement your code here **************************
|
||||||
|
// you can store your stats
|
||||||
for (int i = 0; i< means.length; i++) {
|
for (int i = 0; i< means.length; i++) {
|
||||||
// for each byte test the condition
|
// for each byte test the condition
|
||||||
idx.add(i);
|
idx.add(i);
|
||||||
|
|
|
@ -27,6 +27,7 @@ public class HmacCracker implements Runnable {
|
||||||
byte[] hmac;
|
byte[] hmac;
|
||||||
int maxIterations;
|
int maxIterations;
|
||||||
int totalIterations = 0;
|
int totalIterations = 0;
|
||||||
|
CrackerCore core = new CrackerCore();
|
||||||
|
|
||||||
public HmacCracker(OutputStream outputStream, InputStream inputStream, int iMax, byte[] signature, char[] msg) {
|
public HmacCracker(OutputStream outputStream, InputStream inputStream, int iMax, byte[] signature, char[] msg) {
|
||||||
this.outputStream = outputStream;
|
this.outputStream = outputStream;
|
||||||
|
@ -124,7 +125,7 @@ public class HmacCracker implements Runnable {
|
||||||
statsPool.add(Arrays.copyOf(stats, stats.length));
|
statsPool.add(Arrays.copyOf(stats, stats.length));
|
||||||
maxIt--;
|
maxIt--;
|
||||||
}
|
}
|
||||||
int[] bestM = CrackerCore.select(statsPool);
|
int[] bestM = core.select(statsPool, hmac);
|
||||||
if (bestM == null) {
|
if (bestM == null) {
|
||||||
bin = bin*2;
|
bin = bin*2;
|
||||||
System.out.print("#"); // we need to collect more stats
|
System.out.print("#"); // we need to collect more stats
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue