forked from Keysight/Jlsca
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main-noninc.jl
44 lines (34 loc) · 1.09 KB
/
main-noninc.jl
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
using Sca
using Trs
using Align
# our vanilla main function
function go()
if length(ARGS) < 1
@printf("no input trace\n")
return
end
if nworkers() > 1
@printf("This module does not use parallelization!")
end
filename = ARGS[1]
direction::Direction = (length(ARGS) > 1 && ARGS[2] == "BACKWARD" ? BACKWARD : FORWARD)
params = getParameters(filename, direction)
if params == nothing
params = AesSboxAttack()
end
params.analysis.leakageFunctions = [hw]
numberOfAverages = length(params.keyByteOffsets)
numberOfCandidates = getNumberOfCandidates(params)
trs = InspectorTrace(filename)
# # example alignment pass
# maxShift = 20000
# referenceOffset = 5000
# reference = trs[1][2][referenceOffset:referenceOffset+5000]
# corvalMin = 0.4
# alignstate = CorrelationAlignFFT(reference, referenceOffset, maxShift)
# addSamplePass(trs, x -> ((shift,corval) = correlationAlign(x, alignstate); corval > corvalMin ? circshift(x, shift) : Vector{eltype(x)}(0)))
numberOfTraces = length(trs)
ret = sca(trs, params, 1, numberOfTraces)
return ret
end
@time go()